Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/components/CalendarGrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export default {
* hence we can't use beforeRouteUpdate directly.
*/
if (!this.isWidget) {
this.$router.beforeEach((to, from, next) => {
this.$router.beforeEach((to, from) => {
if (to.params.firstDay !== from.params.firstDay) {
const calendarApi = this.$refs.fullCalendar.getApi()
calendarApi.gotoDate(getYYYYMMDDFromFirstdayParam(to.params.firstDay))
Expand All @@ -291,8 +291,6 @@ export default {
const calendarApi = this.$refs.fullCalendar.getApi()
calendarApi.unselect()
}

next()
})

// Trigger the select event programmatically on initial page load to show the new event
Expand Down
33 changes: 10 additions & 23 deletions src/mixins/EditorMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -897,11 +897,10 @@
*
* @param {object} to The route to navigate to
* @param {object} from The route coming from
* @param {Function} next Function to be called when ready to load the next view
*/
async beforeRouteEnter(to, from, next) {
async beforeRouteEnter(to, from) {

Check failure on line 901 in src/mixins/EditorMixin.js

View workflow job for this annotation

GitHub Actions / NPM lint

'from' is defined but never used
if (to.name === 'NewFullView' || to.name === 'NewPopoverView') {
next(async (vm) => {
return async (vm) => {
vm.resetState()

const isAllDay = (to.params.allDay === '1')
Expand All @@ -920,17 +919,15 @@
} finally {
vm.isLoading = false
}
})
}
} else {
next(async (vm) => {
return async (vm) => {
vm.resetState()
const objectId = to.params.object
const recurrenceId = to.params.recurrenceId

if (recurrenceId === 'next') {
const closeToDate = dateFactory()
// TODO: can we replace this by simply returning the new route since we are inside next()
// Probably not though, because it's async
try {
await vm.loadingCalendars()
const recurrenceId = await vm.calendarObjectInstanceStore.resolveClosestRecurrenceIdForCalendarObject({
Expand Down Expand Up @@ -962,7 +959,7 @@
} finally {
vm.isLoading = false
}
})
}
}
},
/**
Expand All @@ -972,17 +969,15 @@
*
* @param {object} to The route to navigate to
* @param {object} from The route coming from
* @param {Function} next Function to be called when ready to load the next view
*/
async beforeRouteUpdate(to, from, next) {
async beforeRouteUpdate(to, from) {
// If we are in the New Event dialog, we want to update the selected time
if (to.name === 'NewFullView' || to.name === 'NewPopoverView') {
// If allDay, dtstart and dtend are the same there is no need to update.
// This is usally the case when navigating through the calendar while the editor is open
if (to.params.allDay === from.params.allDay
&& to.params.dtstart === from.params.dtstart
&& to.params.dtend === from.params.dtend) {
next()
return
}

Expand All @@ -993,14 +988,12 @@

await this.loadingCalendars()
await this.calendarObjectInstanceStore.updateCalendarObjectInstanceForNewEvent({ isAllDay, start, end, timezoneId })
next()
} else {
// If both the objectId and recurrenceId remained the same
// there is no need to update. This is usally the case when navigating
// through the calendar while the editor is open
if (to.params.object === from.params.object
&& to.params.recurrenceId === from.params.recurrenceId) {
next()
return
}

Expand All @@ -1010,8 +1003,7 @@
await this.save()
} catch (error) {
console.debug(error)
next(false)
return
return false
}

this.resetState()
Expand All @@ -1025,8 +1017,7 @@
closeToDate,
})
const params = { ...this.$route.params, recurrenceId }
next({ name: this.$route.name, params })
return
return { name: this.$route.name, params }
}

try {
Expand All @@ -1041,7 +1032,6 @@
this.error = t('calendar', 'It might have been deleted, or there was a typo in the link')
} finally {
this.isLoading = false
next()
}
}
},
Expand All @@ -1050,13 +1040,11 @@
*
* @param {object} to The route to navigate to
* @param {object} from The route coming from
* @param {Function} next Function to be called when ready to load the next view
*/
async beforeRouteLeave(to, from, next) {
async beforeRouteLeave(to, from) {
// requiresActionOnRouteLeave is false when an action like deleting / saving / cancelling was already taken.
// The responsibility of this method is to automatically save the event when the user clicks outside the editor
if (!this.requiresActionOnRouteLeave) {
next()
return
}

Expand All @@ -1065,10 +1053,9 @@
&& (from.name !== 'NewPopoverView' || to.name !== 'EditFullView')) {
await this.save()
}
next()
} catch (error) {
console.debug(error)
next(false)
return false
}
},
}
5 changes: 1 addition & 4 deletions src/services/windowTitleService.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ export default function(router) {
* This listens to router changes and automatically
* updates the title
*/
router.beforeEach((to, from, next) => {
router.beforeEach((to) => {
if (!to.params.firstDay) {
next()
return
}

Expand All @@ -47,8 +46,6 @@ export default function(router) {
const locale = settingsStore.momentLocale

updateTitle(date, view, locale)

next()
})

/**
Expand Down
Loading