diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/Coursebook.vue b/aleksis/apps/alsijil/frontend/components/coursebook/Coursebook.vue index 5c4537f502af6415c76cf78f43bc19a73c149d2f..137650eaf1b8fd4e895ea99390521c600d06adef 100644 --- a/aleksis/apps/alsijil/frontend/components/coursebook/Coursebook.vue +++ b/aleksis/apps/alsijil/frontend/components/coursebook/Coursebook.vue @@ -37,11 +37,18 @@ /> </template> <template #default="{ items }"> - <v-list-item v-for="day in groupDocsByDay(items)" two-line> + <v-list-item + v-for="day in groupDocsByDay(items)" + two-line + :key="'day-' + day[0]" + > <v-list-item-content :id="'documentation_' + day[0].toISODate()"> <v-list-item-title>{{ $d(day[0], "short") }}</v-list-item-title> <v-list max-width="100%"> - <v-list-item v-for="doc in day.slice(1)"> + <v-list-item + v-for="doc in day.slice(1)" + :key="'documentation-' + doc.id" + > <documentation-modal :documentation="doc" :affected-query="lastQuery" @@ -146,7 +153,9 @@ export default { objId: this.objId ? Number(this.objId) : null, objType: this.objType?.toUpperCase(), dateStart: this.dateStart ?? this.date, - dateEnd: this.dateEnd ?? DateTime.fromISO(this.date).plus({ weeks: 1 }).toISODate(), + dateEnd: + this.dateEnd ?? + DateTime.fromISO(this.date).plus({ weeks: 1 }).toISODate(), }; }, selectable() { @@ -205,9 +214,10 @@ export default { const dateEndParsed = DateTime.fromISO(this.dateEnd); const dateParsed = DateTime.fromISO(this.date); - const newDate = direction === "prev" ? - dateParsed.minus({ days: 1 }) : - dateParsed.plus({ days: 1 }); + const newDate = + direction === "prev" + ? dateParsed.minus({ days: 1 }) + : dateParsed.plus({ days: 1 }); /* TODO: @@ -234,33 +244,36 @@ export default { }); // Define the function to find the nearest ID - const ids = Array.from(document.querySelectorAll("[id^='documentation_']")).map((el) => el.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, - )); + 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]; + const nearestId = + sortedIds.find((id) => + direction === "next" ? id >= targetDate : id <= targetDate, + ) || sortedIds[sortedIds.length - 1]; return "documentation_" + nearestId.toISODate(); }, }, mounted() { this.dateStart = this.date; - this.dateEnd = DateTime.fromISO(this.dateStart).plus({ weeks: 1 }).toISODate(); + this.dateEnd = DateTime.fromISO(this.dateStart) + .plus({ weeks: 1 }) + .toISODate(); }, }; </script> diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/CoursebookDateSelect.vue b/aleksis/apps/alsijil/frontend/components/coursebook/CoursebookDateSelect.vue index ac54bff3b33861bab60ebad1928291bff66b8ddd..353666ad533d9d133a9d206509632013fe3c9cc5 100644 --- a/aleksis/apps/alsijil/frontend/components/coursebook/CoursebookDateSelect.vue +++ b/aleksis/apps/alsijil/frontend/components/coursebook/CoursebookDateSelect.vue @@ -30,7 +30,7 @@ export default { return { PREV: "prev", NEXT: "next", - } + }; }, methods: { /** @@ -40,9 +40,15 @@ export default { this.$emit("click", direction); this.$emit(direction); if (direction === this.PREV) { - this.$emit("input", DateTime.fromISO(this.value).minus({ days: 1 }).toISODate()); + this.$emit( + "input", + DateTime.fromISO(this.value).minus({ days: 1 }).toISODate(), + ); } else { - this.$emit("input", DateTime.fromISO(this.value).plus({ days: 1 }).toISODate()); + this.$emit( + "input", + DateTime.fromISO(this.value).plus({ days: 1 }).toISODate(), + ); } }, }, @@ -58,29 +64,29 @@ export default { ref="sheet" class="rounded-t-xl rounded-b-0" > - <v-card> - <v-card-title id="content"> - <div class="d-flex align-center justify-space-between full-width"> - <v-btn icon large class="me-4" @click="handleClick(PREV)"> - <v-icon>$prev</v-icon> - </v-btn> - <date-field - solo-inverted - flat - hide-details - :value="value" - @input="$emit('input', $event)" - :label="$t('alsijil.coursebook.date_select.label')" - :disabled="loading" - readonly - /> - <v-btn icon large class="ms-4" @click="handleClick(NEXT)"> - <v-icon>$next</v-icon> - </v-btn> - </div> - </v-card-title> - </v-card> -</v-bottom-sheet> + <v-card> + <v-card-title id="content"> + <div class="d-flex align-center justify-space-between full-width"> + <v-btn icon large class="me-4" @click="handleClick(PREV)"> + <v-icon>$prev</v-icon> + </v-btn> + <date-field + solo-inverted + flat + hide-details + :value="value" + @input="$emit('input', $event)" + :label="$t('alsijil.coursebook.date_select.label')" + :disabled="loading" + readonly + /> + <v-btn icon large class="ms-4" @click="handleClick(NEXT)"> + <v-icon>$next</v-icon> + </v-btn> + </div> + </v-card-title> + </v-card> + </v-bottom-sheet> </template> <style scoped> diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/CoursebookLoader.vue b/aleksis/apps/alsijil/frontend/components/coursebook/CoursebookLoader.vue index ce391e8512f55bb49b0b15ef650fada0156d01a8..a99df0588b779a7643b5ae66617132110c49b67c 100644 --- a/aleksis/apps/alsijil/frontend/components/coursebook/CoursebookLoader.vue +++ b/aleksis/apps/alsijil/frontend/components/coursebook/CoursebookLoader.vue @@ -1,12 +1,12 @@ <template> <div> - <v-list-item v-for="_ in 10"> + <v-list-item v-for="i in 10" :key="'i-' + i"> <v-list-item-content> <v-list-item-title> <v-skeleton-loader type="heading" /> </v-list-item-title> <v-list max-width="100%"> - <v-list-item v-for="_ in 5"> + <v-list-item v-for="j in 5" :key="'j-' + j"> <DocumentationLoader /> </v-list-item> </v-list>