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

Update date logic

parent 38d62361
No related branches found
No related tags found
No related merge requests found
......@@ -148,10 +148,8 @@ export default {
data() {
return {
gqlQuery: documentationsForCoursebook,
currentDate: "",
visible: [],
knownDates: {},
lastQuery: null,
visible: [],
dateStart: "",
dateEnd: "",
// Placeholder values while query isn't completed yet
......@@ -211,15 +209,11 @@ export default {
console.log('Set default date');
this.$router.replace({ hash: DateTime.now().toISODate() })
}
// Resetting known dates to dateRange around current date
this.knownDates = {};
this.currentDate = this.$route.hash.substring(1);
const dateRange = this.dateRange(DateTime.fromISO(this.$route.hash.substring(1)));
dateRange.forEach((ts) => this.knownDates[ts] = true);
const lastIdx = dateRange.length - 1;
// Returning a dateRange each around first & last date for the initial query
this.dateStart = this.dateRange(dateRange[0])[0].toISODate();
this.dateEnd = this.dateRange(dateRange[lastIdx])[lastIdx].toISODate();
const date = DateTime.fromISO(this.$route.hash.substring(1));
// Reset visible
this.visible = [];
this.dateStart = date.minus({ days: 3 }).toISODate();
this.dateEnd = date.plus({ days: 4 }).toISODate();
},
changeSelection(selection) {
this.$router.push({
......@@ -234,6 +228,7 @@ export default {
hash: this.$route.hash,
});
this.resetDate();
// might skip query until both set = atomic
},
groupDocsByDay(docs) {
// => {dt: [dt doc ...] ...}
......@@ -258,12 +253,6 @@ export default {
});
// sorting is necessary since backend can send docs unordered
},
dateRange(date) {
return Interval
.fromDateTimes(date.minus({ days: 3 }), date.plus({ days: 4 }))
.splitBy({ days: 1 })
.map((ts) => ts.start);
},
// docsByDay: {dt: [dt doc ...] ...}
assureDate(date) {
if (!this.knownDates[date]) {
......
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