Fixed task sorting
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
konrad 2019-04-28 21:39:57 +02:00
parent 59bfacc771
commit 2810618101
Signed by: konrad
GPG Key ID: F40E70337AB24C9B

View File

@ -150,9 +150,7 @@
},
parseTasks() {
this.setDates()
// The following three are split up in different functions to be able to call them independently
this.prepareTasks()
this.sortTasks()
},
prepareTasks() {
this.theTasks = this.tasks
@ -165,15 +163,7 @@
.map(t => {
return this.addGantAttributes(t)
})
},
addGantAttributes(t) {
t.endDate === null ? this.endDate : t.endDate
t.durationDays = Math.floor((t.endDate - t.startDate) / 1000 / 60 / 60 / 24) + 1
t.offsetDays = Math.floor((t.startDate - this.startDate) / 1000 / 60 / 60 / 24) + 1
return t
},
sortTasks() {
this.theTasks.sort(function(a,b) {
.sort(function(a,b) {
if (a.startDate < b.startDate)
return -1
if (a.startDate > b.startDate)
@ -181,6 +171,12 @@
return 0
})
},
addGantAttributes(t) {
t.endDate === null ? this.endDate : t.endDate
t.durationDays = Math.floor((t.endDate - t.startDate) / 1000 / 60 / 60 / 24) + 1
t.offsetDays = Math.floor((t.startDate - this.startDate) / 1000 / 60 / 60 / 24) + 1
return t
},
resizeTask(newRect) {
let didntHaveDates = this.taskDragged.startDate === null ? true : false
@ -206,7 +202,6 @@
}
}
this.theTasks.push(this.addGantAttributes(r))
this.sortTasks()
}
message.success({message: 'The task was successfully updated.'}, this)