Skip to content
Snippets Groups Projects
Commit d2fbfa9f authored by jackie / Andrea Ida Malkah Klaura's avatar jackie / Andrea Ida Malkah Klaura
Browse files

FIX: refetch timeslots when calendar view changes

parent 2e9d2285
No related branches found
No related tags found
No related merge requests found
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
default-view="agendaWeek" default-view="agendaWeek"
:events="calendarSlots" :events="calendarSlots"
:config="calendarConfig" :config="calendarConfig"
@view-render="renderView"
/> />
</b-modal> </b-modal>
</div> </div>
...@@ -40,7 +41,7 @@ export default { ...@@ -40,7 +41,7 @@ export default {
calendarSlots: [], calendarSlots: [],
// this is the whole configuration for our schedule calendar, including // this is the whole configuration for our schedule calendar, including
// rendering functions and all // simple event handlers that do not need the whole components scope
calendarConfig: { calendarConfig: {
height: 600, height: 600,
firstDay: 1, firstDay: 1,
...@@ -99,23 +100,34 @@ export default { ...@@ -99,23 +100,34 @@ export default {
} }
}, },
// this is called when the user changes the calendar view, so we just
// refetch the timeslots with the updated visible date range
renderView (view) {
this.$log.debug(view.start.format() + ' ' + view.end.format())
if (this.loaded.shows) {
this.$log.debug('refetching')
this.loadTimeslots(view.start.format(), view.end.format())
}
},
loadTimeslots (start, end) { loadTimeslots (start, end) {
this.loaded.timeslots = false this.loaded.timeslots = false
this.calendarSlots = []
let uri = process.env.VUE_APP_API_STEERING + 'timeslots?start=' + start + '&end=' + end let uri = process.env.VUE_APP_API_STEERING + 'timeslots?start=' + start + '&end=' + end
axios.get(uri, { axios.get(uri, {
withCredentials: true, withCredentials: true,
headers: { 'Authorization': 'Bearer ' + this.$parent.$parent.user.access_token } headers: { 'Authorization': 'Bearer ' + this.$parent.$parent.user.access_token }
}).then(response => { }).then(response => {
let slots = response.data this.timeslots = response.data
for (let i in slots) { for (let i in this.timeslots) {
let highlighting = 'otherShow' let highlighting = 'otherShow'
if (slots[i].show === this.show.id) { if (this.timeslots[i].show === this.show.id) {
highlighting = 'currentShow' highlighting = 'currentShow'
} }
this.calendarSlots.push({ this.calendarSlots.push({
start: slots[i].start, start: this.timeslots[i].start,
end: slots[i].end, end: this.timeslots[i].end,
title: this.getShowTitleById(slots[i].show), title: this.getShowTitleById(this.timeslots[i].show),
className: highlighting className: highlighting
}) })
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment