Skip to content
Snippets Groups Projects
Commit afaa79f5 authored by permcu's avatar permcu
Browse files

Change date into url hash fragment

parent d91a13b3
No related branches found
No related tags found
2 merge requests!355Implement infinite scrolling and by date navigation for coursebook,!350Resolve "Add simple course book list"
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
</v-list-item-content> </v-list-item-content>
</v-list-item> </v-list-item>
<date-select-footer :value="date" @click="handleDateMove" /> <date-select-footer :value="$route.hash.substring(1)" @click="handleDateMove" />
</template> </template>
<template #loading> <template #loading>
<CoursebookLoader /> <CoursebookLoader />
...@@ -96,12 +96,6 @@ export default { ...@@ -96,12 +96,6 @@ export default {
required: false, required: false,
default: null, default: null,
}, },
// ISODate
date: {
type: String,
required: false,
default: "",
},
}, },
data() { data() {
return { return {
...@@ -117,10 +111,11 @@ export default { ...@@ -117,10 +111,11 @@ export default {
}, },
computed: { computed: {
gqlQueryArgs() { gqlQueryArgs() {
console.log('computing gqlQueryArgs');
const date = this.$route.hash.substring(1)
return { return {
// Assure courseId is a number
own: this.filterType === "all" ? false : true, own: this.filterType === "all" ? false : true,
objId: this.objId ? Number(this.objId) : null, objId: this.objId ? Number(this.objId) : undefined,
objType: this.objType?.toUpperCase(), objType: this.objType?.toUpperCase(),
dateStart: this.dateStart ?? this.date, dateStart: this.dateStart ?? this.date,
dateEnd: dateEnd:
...@@ -147,15 +142,15 @@ export default { ...@@ -147,15 +142,15 @@ export default {
Object.hasOwn(selectedFilters, "objType") Object.hasOwn(selectedFilters, "objType")
) { ) {
this.$router.push({ this.$router.push({
name: "alsijil.coursebook_by_type_and_date", name: "alsijil.coursebook",
params: { params: {
filterType: selectedFilters.filterType filterType: selectedFilters.filterType
? selectedFilters.filterType ? selectedFilters.filterType
: this.filterType, : this.filterType,
objType: selectedFilters.objType, objType: selectedFilters.objType,
objId: selectedFilters.objId, objId: selectedFilters.objId,
date: this.date,
}, },
hash: this.$route.hash,
}); });
} }
}, },
...@@ -204,12 +199,11 @@ export default { ...@@ -204,12 +199,11 @@ export default {
} }
this.$router.push({ this.$router.push({
name: "alsijil.coursebook_by_type_and_date", name: "alsijil.coursebook",
params: { params: {
filterType: this.filterType, filterType: this.filterType,
objType: this.objType, objType: this.objType,
objId: this.objId, objId: this.objId,
date: newDate.toISODate(),
}, },
}); });
...@@ -238,12 +232,21 @@ export default { ...@@ -238,12 +232,21 @@ export default {
return "documentation_" + nearestId.toISODate(); return "documentation_" + nearestId.toISODate();
}, },
gotoDate(date, scroll) {
// show
this.$router.push({ hash: date.toISODate() })
console.log('hash', this.$route.hash);
// assure
// scroll
},
}, },
mounted() { mounted() {
this.dateStart = this.date; // assure date hash
this.dateEnd = DateTime.fromISO(this.dateStart) console.log('mounted with hash', this.$route.hash);
.plus({ weeks: 1 }) if (!this.$route.hash) {
.toISODate(); console.log('initialized hash');
this.$router.push({ hash: DateTime.now().toISODate() })
}
}, },
}; };
</script> </script>
......
...@@ -60,14 +60,14 @@ export default { ...@@ -60,14 +60,14 @@ export default {
component: () => import("./components/coursebook/Coursebook.vue"), component: () => import("./components/coursebook/Coursebook.vue"),
redirect: () => { redirect: () => {
return { return {
name: "alsijil.coursebook_by_type_and_date", name: "alsijil.coursebook",
params: { params: {
date: DateTime.now().toISODate(),
filterType: "my", filterType: "my",
}, },
hash: "#" + DateTime.now().toISODate(),
}; };
}, },
name: "alsijil.coursebook", name: "alsijil.coursebook_landing",
props: true, props: true,
meta: { meta: {
inMenu: true, inMenu: true,
...@@ -79,9 +79,9 @@ export default { ...@@ -79,9 +79,9 @@ export default {
}, },
children: [ children: [
{ {
path: ":date(\\d\\d\\d\\d-\\d\\d-\\d\\d)/:filterType(my|all)/:objType(group|course|teacher)?/:objId(\\d+)?/", path: ":filterType(my|all)/:objType(group|course|teacher)?/:objId(\\d+)?/",
component: () => import("./components/coursebook/Coursebook.vue"), component: () => import("./components/coursebook/Coursebook.vue"),
name: "alsijil.coursebook_by_type_and_date", name: "alsijil.coursebook",
meta: { meta: {
titleKey: "alsijil.coursebook.menu_title", titleKey: "alsijil.coursebook.menu_title",
toolbarTitle: "alsijil.coursebook.menu_title", toolbarTitle: "alsijil.coursebook.menu_title",
......
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