Skip to content
Snippets Groups Projects
Commit 11892d1f authored by Julian's avatar Julian
Browse files

Reformat

parent 80358342
No related branches found
No related tags found
2 merge requests!352Draft: Resolve "Add dialog with each lesson's students",!350Resolve "Add simple course book list"
Pipeline #174439 failed
...@@ -37,11 +37,18 @@ ...@@ -37,11 +37,18 @@
/> />
</template> </template>
<template #default="{ items }"> <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-content :id="'documentation_' + day[0].toISODate()">
<v-list-item-title>{{ $d(day[0], "short") }}</v-list-item-title> <v-list-item-title>{{ $d(day[0], "short") }}</v-list-item-title>
<v-list max-width="100%"> <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-modal
:documentation="doc" :documentation="doc"
:affected-query="lastQuery" :affected-query="lastQuery"
...@@ -146,7 +153,9 @@ export default { ...@@ -146,7 +153,9 @@ export default {
objId: this.objId ? Number(this.objId) : null, objId: this.objId ? Number(this.objId) : null,
objType: this.objType?.toUpperCase(), objType: this.objType?.toUpperCase(),
dateStart: this.dateStart ?? this.date, 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() { selectable() {
...@@ -205,9 +214,10 @@ export default { ...@@ -205,9 +214,10 @@ export default {
const dateEndParsed = DateTime.fromISO(this.dateEnd); const dateEndParsed = DateTime.fromISO(this.dateEnd);
const dateParsed = DateTime.fromISO(this.date); const dateParsed = DateTime.fromISO(this.date);
const newDate = direction === "prev" ? const newDate =
dateParsed.minus({ days: 1 }) : direction === "prev"
dateParsed.plus({ days: 1 }); ? dateParsed.minus({ days: 1 })
: dateParsed.plus({ days: 1 });
/* /*
TODO: TODO:
...@@ -234,33 +244,36 @@ export default { ...@@ -234,33 +244,36 @@ export default {
}); });
// Define the function to find the nearest ID // 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 // TODO: This should only be done after loading the new data
const nearestId = this.findNearestId(newDate, direction, ids); const nearestId = this.findNearestId(newDate, direction, ids);
this.$vuetify.goTo("#" + nearestId); this.$vuetify.goTo("#" + nearestId);
}, },
findNearestId(targetDate, direction, ids) { findNearestId(targetDate, direction, ids) {
const sortedIds = (ids const sortedIds = ids
.map((id) => DateTime.fromISO(id.split("_")[1])) .map((id) => DateTime.fromISO(id.split("_")[1]))
.sort( .sort((a, b) => a - b);
(a, b) => a - b,
));
if (direction === "prev") { if (direction === "prev") {
sortedIds.reverse(); sortedIds.reverse();
} }
const nearestId = sortedIds.find(id => const nearestId =
direction === "next" ? id >= targetDate : id <= targetDate sortedIds.find((id) =>
) || sortedIds[sortedIds.length - 1]; direction === "next" ? id >= targetDate : id <= targetDate,
) || sortedIds[sortedIds.length - 1];
return "documentation_" + nearestId.toISODate(); return "documentation_" + nearestId.toISODate();
}, },
}, },
mounted() { mounted() {
this.dateStart = this.date; 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> </script>
...@@ -30,7 +30,7 @@ export default { ...@@ -30,7 +30,7 @@ export default {
return { return {
PREV: "prev", PREV: "prev",
NEXT: "next", NEXT: "next",
} };
}, },
methods: { methods: {
/** /**
...@@ -40,9 +40,15 @@ export default { ...@@ -40,9 +40,15 @@ export default {
this.$emit("click", direction); this.$emit("click", direction);
this.$emit(direction); this.$emit(direction);
if (direction === this.PREV) { 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 { } 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 { ...@@ -58,29 +64,29 @@ export default {
ref="sheet" ref="sheet"
class="rounded-t-xl rounded-b-0" class="rounded-t-xl rounded-b-0"
> >
<v-card> <v-card>
<v-card-title id="content"> <v-card-title id="content">
<div class="d-flex align-center justify-space-between full-width"> <div class="d-flex align-center justify-space-between full-width">
<v-btn icon large class="me-4" @click="handleClick(PREV)"> <v-btn icon large class="me-4" @click="handleClick(PREV)">
<v-icon>$prev</v-icon> <v-icon>$prev</v-icon>
</v-btn> </v-btn>
<date-field <date-field
solo-inverted solo-inverted
flat flat
hide-details hide-details
:value="value" :value="value"
@input="$emit('input', $event)" @input="$emit('input', $event)"
:label="$t('alsijil.coursebook.date_select.label')" :label="$t('alsijil.coursebook.date_select.label')"
:disabled="loading" :disabled="loading"
readonly readonly
/> />
<v-btn icon large class="ms-4" @click="handleClick(NEXT)"> <v-btn icon large class="ms-4" @click="handleClick(NEXT)">
<v-icon>$next</v-icon> <v-icon>$next</v-icon>
</v-btn> </v-btn>
</div> </div>
</v-card-title> </v-card-title>
</v-card> </v-card>
</v-bottom-sheet> </v-bottom-sheet>
</template> </template>
<style scoped> <style scoped>
......
<template> <template>
<div> <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-content>
<v-list-item-title> <v-list-item-title>
<v-skeleton-loader type="heading" /> <v-skeleton-loader type="heading" />
</v-list-item-title> </v-list-item-title>
<v-list max-width="100%"> <v-list max-width="100%">
<v-list-item v-for="_ in 5"> <v-list-item v-for="j in 5" :key="'j-' + j">
<DocumentationLoader /> <DocumentationLoader />
</v-list-item> </v-list-item>
</v-list> </v-list>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment