angular-gantt
angular-gantt copied to clipboard
Cancel a moove moveBegin & moveEnd
Hi there,
I'm currently trying to cancel a task moove if it is not valid.
api.tasks.on.moveEnd($scope, addEventName('tasks.on.moveEnd', logTaskEvent));
api.tasks.on.moveBegin($scope, addEventName('tasks.on.moveBegin', savePreviousRow));
moveBegin
vm.previousRaw = task.row.model.id;
vm.previousFrom = task.row.from._d;
vm.previousTo = task.row.to._d;
moveEnd vm.res is the data model
for (var j = 0; j < vm.res.length; j++) {
if (vm.res[j].id === task.row.model.id) {
for (var k = 0; k < vm.res[j].tasks.length; k++) {
if (vm.res[j].tasks[k].id === task.model.id) {
copyTask = angular.copy(vm.res[j].tasks[k]);
copyTask.from = vm.previousFrom;
copyTask.to = vm.previousTo;
vm.res[j].tasks.splice(k, 1);
//delete vm.res[j].tasks[k];
}
}
}
}
for (var p = 0; p < vm.res.length; p++) {
if (vm.res[p].id === vm.previousRaw) {
vm.res[p].tasks.push(copyTask);
}
}
It work ( 80% of the time, and sometimes there is a bug about the dates )
- is there any way to do it in a simplier way ?
Cheers, Jérémy
Hi,
Have you found a solution, I am having the same issue.
Thanks in advance. Hatim
Nop, i just reload data :'(
Ok, thanks for your reply.
For my case, I have a global variable containing the data (like there are in the database: insert, updates, delete, affects dynamically this variable) so in the moveBegin function I take the task's ID and loop over the data variable to get the task object (I am not getting it from the task object passed in the moveBegin function parameters) and it resolve my issue.