diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/Coursebook.vue b/aleksis/apps/alsijil/frontend/components/coursebook/Coursebook.vue index 42bf9ed630d1d6c639f023583d94c7b19ab7cba2..f3ac4bbca1ab20917379463038d1911230bb4dc7 100644 --- a/aleksis/apps/alsijil/frontend/components/coursebook/Coursebook.vue +++ b/aleksis/apps/alsijil/frontend/components/coursebook/Coursebook.vue @@ -258,67 +258,6 @@ export default { }); // sorting is necessary since backend can send docs unordered }, - /** - * @param {"prev"|"next"} direction - */ - handleDateMove(direction) { - const dateStartParsed = DateTime.fromISO(this.dateStart); - const dateEndParsed = DateTime.fromISO(this.dateEnd); - const dateParsed = DateTime.fromISO(this.date); - - const newDate = - direction === "prev" - ? dateParsed.minus({ days: 1 }) - : dateParsed.plus({ days: 1 }); - - /* - TODO: - Everything below this line is also needed for when a date is selected via the calendar. - → probably move this into a different function and create a second event listener for the input event. - */ - - // Load 3 days into the future/past - if (dateStartParsed >= newDate) { - this.dateStart = newDate.minus({ days: 3 }).toISODate(); - } - if (dateEndParsed <= newDate) { - this.dateEnd = newDate.plus({ days: 3 }).toISODate(); - } - - this.$router.push({ - name: "alsijil.coursebook", - params: { - filterType: this.filterType, - objType: this.objType, - objId: this.objId, - }, - }); - - // Define the function to find the nearest ID - const ids = Array.from( - document.querySelectorAll("[id^='documentation_']"), - ).map((el) => el.id); - - // TODO: This should only be done after loading the new data - const nearestId = this.findNearestId(newDate, direction, ids); - this.$vuetify.goTo("#" + nearestId); - }, - findNearestId(targetDate, direction, ids) { - const sortedIds = ids - .map((id) => DateTime.fromISO(id.split("_")[1])) - .sort((a, b) => a - b); - - if (direction === "prev") { - sortedIds.reverse(); - } - - const nearestId = - sortedIds.find((id) => - direction === "next" ? id >= targetDate : id <= targetDate, - ) || sortedIds[sortedIds.length - 1]; - - return "documentation_" + nearestId.toISODate(); - }, dateRange(date) { return Interval .fromDateTimes(date.minus({ days: 3 }), date.plus({ days: 4 }))