Fix maintaining the current page for the list view when navigating back from another page

This commit is contained in:
kolaente 2020-04-14 23:37:08 +02:00
parent cc02fc82fc
commit 588b87fb96
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
3 changed files with 7 additions and 2 deletions

View file

@ -59,6 +59,7 @@
auth.user.infos.type !== authType.LINK_SHARE &&
this.$route.params.type !== 'gantt' &&
this.$route.params.type !== 'table' &&
this.$route.params.type !== 'list' &&
this.$route.params.type !== ''
) {
router.push({name: 'showList', params: { id: this.$route.params.id }})

View file

@ -143,7 +143,6 @@
},
created() {
this.taskService = new TaskService()
this.initTasks(1)
},
methods: {
// This function initializes the tasks page and loads the first page of tasks

View file

@ -19,6 +19,11 @@ export default {
watch: {
'$route.query': 'loadTasksForPage', // Only listen for query path changes
},
beforeMount() {
// Triggering loading the tasks in beforeMount lets the component maintain the current page, therefore the page
// is not lost after navigating back from a task detail page for example.
this.loadTasksForPage(this.$route.query)
},
created() {
this.taskCollectionService = new TaskCollectionService()
},
@ -67,7 +72,7 @@ export default {
},
loadTasksForPage(e) {
// The page parameter can be undefined, in the case where the user loads a new list from the side bar menu
let page = e.page
let page = Number(e.page)
if (typeof e.page === 'undefined') {
page = 1
}