All was correct before add functions to gantt, I have a problem with chcange value task(dates), after resizable or dragable task have before value
How is good practice create this function?
antt.on('beforetaskdrag', (task) => {
if(task && task.taskRecord && task.taskRecord.startDate && task.taskRecord.endDate && task.taskRecord.type=='T' && task.taskRecord.state<=3) {
// console.log("beforetaskdrag startDate",task.taskRecord.startDate);
// console.log("beforetaskdrag endDate",task.taskRecord.endDate);
//this.taskEditingGantt = task;
//this.operationDatesUpdateBefore = {};
//this.operationDatesUpdateBefore.id = task.taskRecord.id;
//this.operationDatesUpdateBefore.name = task.taskRecord.name;
//this.operationDatesUpdateBefore.startDate = task.taskRecord.startDate;
//this.operationDatesUpdateBefore.endDate = task.taskRecord.endDate;
}
return true;
});
gantt.on('afterTaskDrop', (task) => {
if(task && task.context && task.context.record && task.context.record.type=='T' && task.context.record.state<=3) {
// console.log("afterTaskDrop startDate",task.context.record.startDate);
// console.log("afterTaskDrop endDate",task.context.record.endDate);
//this.operationDatesUpdateAfter = {};
//this.operationDatesUpdateAfter.id = task.context.record.id;
//this.operationDatesUpdateAfter.name = task.context.record.name;
//this.operationDatesUpdateAfter.startDate = task.context.record.startDate;
//this.operationDatesUpdateAfter.endDate = task.context.record.endDate;
//this.openModalOperationDates();
}
return true;
});
gantt.on('taskResizeStart', (task) => {
if(task && task.taskRecord && task.taskRecord.startDate && task.taskRecord.endDate && task.taskRecord.type=='T' && task.taskRecord.state<=3) {
//this.taskEditingGantt = task;
//this.operationDatesUpdateBefore = {};
//this.operationDatesUpdateBefore.id = task.taskRecord.id;
//this.operationDatesUpdateBefore.name = task.taskRecord.name;
//this.operationDatesUpdateBefore.startDate = task.taskRecord.startDate;
//this.operationDatesUpdateBefore.endDate = task.taskRecord.endDate;
}
return true;
});
gantt.on('beforetaskresizefinalize', ({context}) => {
context.async = true;
setTimeout(() => {
context.finalize(true);
return true;
}, 200);
return true;
});
gantt.on('taskResizeEnd', (task) => {
console.log("taskstop",task);
if(task && task.taskRecord && task.taskRecord && task.taskRecord.type=='T' && task.taskRecord.state<=3) {
//this.operationDatesUpdateAfter = {};
//this.operationDatesUpdateAfter.id = task.taskRecord.id;
//this.operationDatesUpdateAfter.name = task.taskRecord.name;
//this.operationDatesUpdateAfter.startDate = task.taskRecord.startDate;
//this.operationDatesUpdateAfter.endDate = task.taskRecord.endDate;
//this.openModalOperationDates();
}
return true;
});