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 @@
/>
</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>
......@@ -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>
......
<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>
......
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