feat:#40 added semester selection by month

This commit is contained in:
Elmar Kresse
2024-03-17 22:27:37 +01:00
parent 6e33a6b4fc
commit d5ce23ba2c

View File

@@ -26,6 +26,19 @@ async function getCourses() {
return { name: course }; return { name: course };
}); });
}); });
// replace selected course if it is not available in the new courses list
if (
selectedCourse.value.name !== "" &&
!courses.value.some((course) => course.name === selectedCourse.value.name)
) {
selectedCourse.value = { name: "" };
}
// if course is selected, get the modules for the selected course
if (selectedCourse.value.name !== "") {
await getModules();
}
} }
const store = moduleStore(); const store = moduleStore();
@@ -42,10 +55,14 @@ const semesters: ComputedRef<{ name: string; value: string }[]> = computed(
], ],
); );
// return current semester summer form march to august and winter from september to february
const currentSemester: { name: string; value: string } = new Date().getMonth() >= 2 && new Date().getMonth() <= 7 ? semesters.value[1] : semesters.value[0];
const selectedSemester: Ref<{ name: string; value: string }> = ref( const selectedSemester: Ref<{ name: string; value: string }> = ref(
semesters.value[0], currentSemester
); );
//if semesters get changed, refresh the selected semester ref with a watcher //if semesters get changed, refresh the selected semester ref with a watcher
watch( watch(
semesters, semesters,