Skip to content
Snippets Groups Projects
Commit 5ebad87e authored by Julian's avatar Julian
Browse files

Reformat

parent 4f6b4a28
No related branches found
No related tags found
1 merge request!362Resolve "Add personal note management dialog in course book"
...@@ -21,20 +21,20 @@ ...@@ -21,20 +21,20 @@
<coursebook-day <coursebook-day
v-for="{ date, docs, first, last } in groupDocsByDay(items)" v-for="{ date, docs, first, last } in groupDocsByDay(items)"
v-intersect="{ v-intersect="{
handler: intersectHandler(date, first, last), handler: intersectHandler(date, first, last),
options: { options: {
rootMargin: '-' + topMargin + 'px 0px 0px 0px', rootMargin: '-' + topMargin + 'px 0px 0px 0px',
threshold: [0, 1], threshold: [0, 1],
}, },
}" }"
:date="date" :date="date"
:docs="docs" :docs="docs"
:lastQuery="lastQuery" :lastQuery="lastQuery"
:focus-on-mount="initDate && (initDate.toMillis() === date.toMillis())" :focus-on-mount="initDate && initDate.toMillis() === date.toMillis()"
@init="transition" @init="transition"
:key="'day-' + date" :key="'day-' + date"
ref="days" ref="days"
/> />
<coursebook-loader /> <coursebook-loader />
<date-select-footer <date-select-footer
...@@ -42,13 +42,10 @@ ...@@ -42,13 +42,10 @@
@input="gotoDate" @input="gotoDate"
@prev="gotoPrev" @prev="gotoPrev"
@next="gotoNext" @next="gotoNext"
/> />
</template> </template>
<template #loading> <template #loading>
<coursebook-loader <coursebook-loader :number-of-days="10" :number-of-docs="5" />
:number-of-days="10"
:number-of-docs="5"
/>
</template> </template>
<template #no-data> <template #no-data>
...@@ -190,12 +187,12 @@ export default { ...@@ -190,12 +187,12 @@ export default {
methods: { methods: {
resetDate(toDate) { resetDate(toDate) {
// Assure current date // Assure current date
console.log('Resetting date range', this.$route.hash); console.log("Resetting date range", this.$route.hash);
this.currentDate = toDate || this.$route.hash?.substring(1); this.currentDate = toDate || this.$route.hash?.substring(1);
if (!this.currentDate) { if (!this.currentDate) {
console.log('Set default date'); console.log("Set default date");
this.setDate(DateTime.now().toISODate()); this.setDate(DateTime.now().toISODate());
} }
const date = DateTime.fromISO(this.currentDate); const date = DateTime.fromISO(this.currentDate);
this.initDate = date; this.initDate = date;
...@@ -203,15 +200,15 @@ export default { ...@@ -203,15 +200,15 @@ export default {
this.dateEnd = date.plus({ days: this.dayIncrement }).toISODate(); this.dateEnd = date.plus({ days: this.dayIncrement }).toISODate();
}, },
transition() { transition() {
this.initDate = false this.initDate = false;
this.ready = true this.ready = true;
}, },
groupDocsByDay(docs) { groupDocsByDay(docs) {
// => {dt: {date: dt, docs: doc ...} ...} // => {dt: {date: dt, docs: doc ...} ...}
const docsByDay = docs.reduce((byDay, doc) => { const docsByDay = docs.reduce((byDay, doc) => {
// This works with dummy. Does actual doc have dateStart instead? // This works with dummy. Does actual doc have dateStart instead?
const day = DateTime.fromISO(doc.datetimeStart).startOf("day"); const day = DateTime.fromISO(doc.datetimeStart).startOf("day");
byDay[day] ??= {date: day, docs: []}; byDay[day] ??= { date: day, docs: [] };
byDay[day].docs.push(doc); byDay[day].docs.push(doc);
return byDay; return byDay;
}, {}); }, {});
...@@ -219,7 +216,7 @@ export default { ...@@ -219,7 +216,7 @@ export default {
// sorting is necessary since backend can send docs unordered // sorting is necessary since backend can send docs unordered
return Object.keys(docsByDay) return Object.keys(docsByDay)
.sort() .sort()
.map((key, idx, {length}) => { .map((key, idx, { length }) => {
const day = docsByDay[key]; const day = docsByDay[key];
day.first = idx === 0; day.first = idx === 0;
const lastIdx = length - 1; const lastIdx = length - 1;
...@@ -229,7 +226,7 @@ export default { ...@@ -229,7 +226,7 @@ export default {
}, },
// docsByDay: {dt: [dt doc ...] ...} // docsByDay: {dt: [dt doc ...] ...}
fetchMore(from, to, then) { fetchMore(from, to, then) {
console.log('fetching', from, to); console.log("fetching", from, to);
this.lastQuery.fetchMore({ this.lastQuery.fetchMore({
variables: { variables: {
dateStart: from, dateStart: from,
...@@ -237,10 +234,10 @@ export default { ...@@ -237,10 +234,10 @@ export default {
}, },
// Transform the previous result with new data // Transform the previous result with new data
updateQuery: (previousResult, { fetchMoreResult }) => { updateQuery: (previousResult, { fetchMoreResult }) => {
console.log('Received more'); console.log("Received more");
then(); then();
return { items: previousResult.items.concat(fetchMoreResult.items) }; return { items: previousResult.items.concat(fetchMoreResult.items) };
} },
}); });
}, },
setDate(date) { setDate(date) {
...@@ -248,7 +245,7 @@ export default { ...@@ -248,7 +245,7 @@ export default {
if (!this.hashUpdater) { if (!this.hashUpdater) {
this.hashUpdater = window.requestIdleCallback(() => { this.hashUpdater = window.requestIdleCallback(() => {
if (!(this.$route.hash.substring(1) === this.currentDate)) { if (!(this.$route.hash.substring(1) === this.currentDate)) {
this.$router.replace({ hash: this.currentDate }) this.$router.replace({ hash: this.currentDate });
} }
this.hashUpdater = false; this.hashUpdater = false;
}); });
...@@ -257,7 +254,8 @@ export default { ...@@ -257,7 +254,8 @@ export default {
fixScrollPos(height, top) { fixScrollPos(height, top) {
this.$nextTick(() => { this.$nextTick(() => {
if (height < document.documentElement.scrollHeight) { if (height < document.documentElement.scrollHeight) {
document.documentElement.scrollTop = document.documentElement.scrollHeight - height + top; document.documentElement.scrollTop =
document.documentElement.scrollHeight - height + top;
this.ready = true; this.ready = true;
} else { } else {
// Update top, could have changed in the meantime. // Update top, could have changed in the meantime.
...@@ -270,28 +268,35 @@ export default { ...@@ -270,28 +268,35 @@ export default {
return (entries) => { return (entries) => {
const entry = entries[0]; const entry = entries[0];
if (entry.isIntersecting) { if (entry.isIntersecting) {
if (entry.boundingClientRect.top <= this.topMargin || first) {
if ((entry.boundingClientRect.top <= this.topMargin) || first) { console.log("@ ", date.toISODate());
console.log('@ ', date.toISODate());
this.setDate(date.toISODate()); this.setDate(date.toISODate());
} }
if (once && this.ready && first) { if (once && this.ready && first) {
console.log('load up', date.toISODate()); console.log("load up", date.toISODate());
this.ready = false; this.ready = false;
this.fetchMore(date.minus({ days: this.dayIncrement }).toISODate(), this.fetchMore(
date.minus({ days: 1 }).toISODate(), date.minus({ days: this.dayIncrement }).toISODate(),
() => { date.minus({ days: 1 }).toISODate(),
this.fixScrollPos(document.documentElement.scrollHeight, () => {
document.documentElement.scrollTop); this.fixScrollPos(
}); document.documentElement.scrollHeight,
document.documentElement.scrollTop,
);
},
);
once = false; once = false;
} else if (once && this.ready && last) { } else if (once && this.ready && last) {
console.log('load down', date.toISODate()); console.log("load down", date.toISODate());
this.ready = false; this.ready = false;
this.fetchMore(date.plus({ days: 1 }).toISODate(), this.fetchMore(
date.plus({ days: this.dayIncrement }).toISODate(), date.plus({ days: 1 }).toISODate(),
() => { this.ready = true }); date.plus({ days: this.dayIncrement }).toISODate(),
() => {
this.ready = true;
},
);
once = false; once = false;
} }
} }
...@@ -319,15 +324,19 @@ export default { ...@@ -319,15 +324,19 @@ export default {
.find((date2) => date2 > date); .find((date2) => date2 > date);
}, },
gotoDate(date) { gotoDate(date) {
const present = this.$refs.days const present = this.$refs.days.find(
.find((day) => day.date.toISODate() === date); (day) => day.date.toISODate() === date,
);
if (present) { if (present) {
// React immediatly -> smoother navigation // React immediatly -> smoother navigation
// Also intersect handler does not always react to scrollIntoView // Also intersect handler does not always react to scrollIntoView
this.setDate(date); this.setDate(date);
present.focus("smooth"); present.focus("smooth");
} else if (!this.findPrev(DateTime.fromISO(date)) || !this.findNext(DateTime.fromISO(date))) { } else if (
!this.findPrev(DateTime.fromISO(date)) ||
!this.findNext(DateTime.fromISO(date))
) {
this.resetDate(date); this.resetDate(date);
} }
}, },
......
<template> <template>
<v-list-item <v-list-item :style="{ scrollMarginTop: '145px' }" two-line>
:style="{ scrollMarginTop: '145px' }"
two-line
>
<v-list-item-content> <v-list-item-content>
<v-subheader class="text-h6">{{ <v-subheader class="text-h6">{{
$d(date, "dateWithWeekday") $d(date, "dateWithWeekday")
...@@ -48,21 +45,21 @@ export default { ...@@ -48,21 +45,21 @@ export default {
default: false, default: false,
}, },
}, },
emits: ['init'], emits: ["init"],
methods: { methods: {
focus(how) { focus(how) {
this.$el.scrollIntoView({ this.$el.scrollIntoView({
behavior: how, behavior: how,
block: "start", block: "start",
inline: "nearest" inline: "nearest",
}); });
console.log('focused @', this.date.toISODate()); console.log("focused @", this.date.toISODate());
}, },
}, },
mounted() { mounted() {
if (this.focusOnMount) { if (this.focusOnMount) {
this.$nextTick(this.focus("instant")); this.$nextTick(this.focus("instant"));
this.$emit('init'); this.$emit("init");
} }
}, },
}; };
......
...@@ -24,12 +24,12 @@ export default { ...@@ -24,12 +24,12 @@ export default {
numberOfDays: { numberOfDays: {
type: Number, type: Number,
required: false, required: false,
default: 1 default: 1,
}, },
numberOfDocs: { numberOfDocs: {
type: Number, type: Number,
required: false, required: false,
default: 1 default: 1,
}, },
}, },
}; };
......
<script> <script>
import BackButton from "aleksis.core/components/generic/BackButton.vue";
import CancelButton from "aleksis.core/components/generic/buttons/CancelButton.vue"; import CancelButton from "aleksis.core/components/generic/buttons/CancelButton.vue";
import MobileFullscreenDialog from "aleksis.core/components/generic/dialogs/MobileFullscreenDialog.vue"; import MobileFullscreenDialog from "aleksis.core/components/generic/dialogs/MobileFullscreenDialog.vue";
import documentationPartMixin from "../documentation/documentationPartMixin"; import documentationPartMixin from "../documentation/documentationPartMixin";
...@@ -10,25 +9,24 @@ export default { ...@@ -10,25 +9,24 @@ export default {
name: "ManageStudentsDialog", name: "ManageStudentsDialog",
extends: MobileFullscreenDialog, extends: MobileFullscreenDialog,
components: { components: {
BackButton,
CancelButton, CancelButton,
LessonInformation, LessonInformation,
MobileFullscreenDialog, MobileFullscreenDialog,
SlideIterator, SlideIterator,
}, },
mixins: [ documentationPartMixin ], mixins: [documentationPartMixin],
data() { data() {
return { return {
dialog: false, dialog: false,
search: "", search: "",
selected: [], selected: [],
isExpanded: false, isExpanded: false,
} };
}, },
computed: { computed: {
items() { items() {
return this.documentation.participations; return this.documentation.participations;
} },
}, },
}; };
</script> </script>
...@@ -69,9 +67,11 @@ export default { ...@@ -69,9 +67,11 @@ export default {
v-model="selected" v-model="selected"
:items="items" :items="items"
:search="search" :search="search"
:item-key-getter="item => 'documentation-' + documentation.id + '-student-' + item.id" :item-key-getter="
(item) => 'documentation-' + documentation.id + '-student-' + item.id
"
:is-expanded.sync="isExpanded" :is-expanded.sync="isExpanded"
> >
<template #listItemContent="{ item }"> <template #listItemContent="{ item }">
<v-list-item-title> <v-list-item-title>
{{ item.person.fullName }} {{ item.person.fullName }}
...@@ -86,13 +86,8 @@ export default { ...@@ -86,13 +86,8 @@ export default {
<template #expandedItem="{ item, close }"> <template #expandedItem="{ item, close }">
<v-card-title> <v-card-title>
<v-tooltip bottom> <v-tooltip bottom>
<template v-slot:activator="{ on, attrs }"> <template #activator="{ on, attrs }">
<v-btn <v-btn v-bind="attrs" v-on="on" icon @click="close">
v-bind="attrs"
v-on="on"
icon
@click="close"
>
<v-icon>$prev</v-icon> <v-icon>$prev</v-icon>
</v-btn> </v-btn>
</template> </template>
...@@ -110,11 +105,13 @@ export default { ...@@ -110,11 +105,13 @@ export default {
</template> </template>
<template #actions> <template #actions>
<cancel-button @click="dialog = false" i18n-key="actions.close" v-show="$vuetify.breakpoint.mobile" /> <cancel-button
@click="dialog = false"
i18n-key="actions.close"
v-show="$vuetify.breakpoint.mobile"
/>
</template> </template>
</mobile-fullscreen-dialog> </mobile-fullscreen-dialog>
</template> </template>
<style scoped> <style scoped></style>
</style>
...@@ -19,9 +19,9 @@ from aleksis.core.schema.base import ( ...@@ -19,9 +19,9 @@ from aleksis.core.schema.base import (
PermissionsTypeMixin, PermissionsTypeMixin,
) )
from aleksis.core.util.core_helpers import get_site_preferences from aleksis.core.util.core_helpers import get_site_preferences
from .participation_status import ParticipationStatusType
from ..models import Documentation from ..models import Documentation
from .participation_status import ParticipationStatusType
class DocumentationType(PermissionsTypeMixin, DjangoFilterMixin, DjangoObjectType): class DocumentationType(PermissionsTypeMixin, DjangoFilterMixin, DjangoObjectType):
......
from graphene_django import DjangoObjectType from graphene_django import DjangoObjectType
from aleksis.apps.alsijil.models import ParticipationStatus from aleksis.apps.alsijil.models import ParticipationStatus
from aleksis.core.schema.base import PermissionsTypeMixin, DjangoFilterMixin from aleksis.core.schema.base import DjangoFilterMixin, PermissionsTypeMixin
class ParticipationStatusType(PermissionsTypeMixin, DjangoFilterMixin, DjangoObjectType): class ParticipationStatusType(PermissionsTypeMixin, DjangoFilterMixin, DjangoObjectType):
......
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