Fixed resizing being triggered when clicking on update
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
konrad 2019-04-29 16:28:41 +02:00
parent 1f0395b6b2
commit 178e61c81d
Signed by: konrad
GPG Key ID: F40E70337AB24C9B

View File

@ -46,7 +46,7 @@
:class="{'done': t.done}"
>
<span>{{t.text}}</span>
<a @click="editTask(t)">
<a @click="editTask(t)" class="edit-toggle">
<icon icon="pen"/>
</a>
</VueDragResize>
@ -183,39 +183,49 @@
return t
},
resizeTask(newRect) {
let didntHaveDates = this.taskDragged.startDate === null ? true : false
let startDate = new Date(this.startDate)
startDate.setDate(startDate.getDate() + newRect.left / this.dayWidth)
startDate.setUTCHours(0)
startDate.setUTCMinutes(0)
startDate.setUTCSeconds(0)
startDate.setUTCMilliseconds(0)
this.taskDragged.startDate = startDate
let endDate = new Date(startDate)
endDate.setDate(startDate.getDate() + newRect.width / this.dayWidth)
this.taskDragged.startDate = startDate
this.taskDragged.endDate = endDate
// Timeout to definitly catch if the user clicked on taskedit
setTimeout(() => {
this.taskService.update(this.taskDragged)
.then(r => {
// If the task didn't have dates before, we'll update the list
if(didntHaveDates) {
for (const t in this.tasksWithoutDates) {
if (this.tasksWithoutDates[t].id === r.id) {
this.tasksWithoutDates.splice(t, 1)
if(this.isTaskEdit) {
return
}
let didntHaveDates = this.taskDragged.startDate === null ? true : false
let startDate = new Date(this.startDate)
startDate.setDate(startDate.getDate() + newRect.left / this.dayWidth)
startDate.setUTCHours(0)
startDate.setUTCMinutes(0)
startDate.setUTCSeconds(0)
startDate.setUTCMilliseconds(0)
this.taskDragged.startDate = startDate
let endDate = new Date(startDate)
endDate.setDate(startDate.getDate() + newRect.width / this.dayWidth)
this.taskDragged.startDate = startDate
this.taskDragged.endDate = endDate
this.taskService.update(this.taskDragged)
.then(r => {
// If the task didn't have dates before, we'll update the list
if(didntHaveDates) {
for (const t in this.tasksWithoutDates) {
if (this.tasksWithoutDates[t].id === r.id) {
this.tasksWithoutDates.splice(t, 1)
}
}
this.theTasks.push(this.addGantAttributes(r))
}
this.theTasks.push(this.addGantAttributes(r))
}
message.success({message: 'The task was successfully updated.'}, this)
})
.catch(e => {
message.error(e, this)
})
message.success({message: 'The task was successfully updated.'}, this)
})
.catch(e => {
message.error(e, this)
})
}, 100)
},
editTask(task){
editTask(task) {
this.isTaskEdit = true
// eslint-disable-next-line
console.log(task)
},