Fix loading tasks for the first page after navigating to a new list

This commit is contained in:
kolaente 2019-12-17 23:03:55 +01:00
parent 11d9aaae12
commit d041384999
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -132,11 +132,15 @@
this.listService = new ListService() this.listService = new ListService()
this.taskService = new TaskService() this.taskService = new TaskService()
this.taskCollectionService = new TaskCollectionService() this.taskCollectionService = new TaskCollectionService()
this.taskEditTask = null this.initTasks(1)
this.isTaskEdit = false
this.loadTasks(1)
}, },
methods: { methods: {
// This function initializes the tasks page and loads the first page of tasks
initTasks(page) {
this.taskEditTask = null
this.isTaskEdit = false
this.loadTasks(page)
},
addTask() { addTask() {
let task = new TaskModel({text: this.newTaskText, listID: this.$route.params.id}) let task = new TaskModel({text: this.newTaskText, listID: this.$route.params.id})
this.taskService.create(task) this.taskService.create(task)
@ -191,7 +195,12 @@
}) })
}, },
loadTasksForPage(e) { loadTasksForPage(e) {
this.loadTasks(e.page) // 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
if (typeof e.page === 'undefined') {
page = 1
}
this.initTasks(page)
}, },
markAsDone(e) { markAsDone(e) {
let updateFunc = () => { let updateFunc = () => {