Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixnuty bug pri vytvarani zapisneho listu pre predlzujucich studentov #160

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions votrfront/js/PrehladStudiaPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,31 @@ export function PrehladStudiaObdobia() {
});
}

// funguje len pre 5 rocne studium !!!
// ked bude mat bc studium dlzku inu ako 3, alebo magisterske inu ako 2, bugne
function GetOficialnaDlzkaStudia(studium){

// asi najlepsi test
if (studium.sp_doplnujuce_udaje.includes("bakalársky")) return 3;
if (studium.sp_doplnujuce_udaje.includes("magisterský")) return 2;
LordLoles marked this conversation as resolved.
Show resolved Hide resolved

// ak by bol nejaky preklep v skorsej informacii, pride dalsi test
if (studium.sp_doplnujuce_udaje.includes("I. st.")) return 3;
if (studium.sp_doplnujuce_udaje.includes("II. st.")) return 2;

// a posledny
if (studium.sp_skratka.charAt(0) == "m") return 2;
else return 3;
}

export function PridatZapisnyListButton (props) {
var studium = props.studium;
var cache = new CacheRequester();
var zapisne_listy = cache.get('get_zapisne_listy', studium.studium_key);
var pocet_rokov_studovania = parseInt(studium.rok_studia) + 1;
var oficialna_dlzka_studia = GetOficialnaDlzkaStudia(studium);
var rok_studia = pocet_rokov_studovania < oficialna_dlzka_studia ? pocet_rokov_studovania : oficialna_dlzka_studia;

if (!cache.loadedAll) {
return <Loading requests={cache.missing} />;
}
Expand All @@ -85,10 +106,11 @@ export function PridatZapisnyListButton (props) {
return <button type="button" className='btn btn-xs btn-success' disabled={true}>Vytvoriť</button>
} else { // ak studium prebieha a nemame este zapisny list na tento rok
return <button type="button" onClick={() => {
if (confirm(`Vytvoriť zápisný list pre akademický rok ${currentAcademicYear()}?`)) {
sendRpc('create_zapisny_list', [studium.studium_key, currentAcademicYear(), null],(message) =>
if (confirm(`Vytvoriť zápisný list pre ${rok_studia}. ročník a akademický rok ${currentAcademicYear()}?`)) {
sendRpc('create_zapisny_list', [studium.studium_key, currentAcademicYear(), rok_studia],(message) =>
{if (message !== null) {alert(message);}
else {RequestCache.invalidate('get_zapisne_listy');}})}}}
else {RequestCache.invalidate('get_zapisne_listy');}})}
}}
className='btn btn-xs btn-success'>Vytvoriť</button>
}
} else { // ak studium uz skoncilo
Expand Down