angular-gantt icon indicating copy to clipboard operation
angular-gantt copied to clipboard

Cancel a moove moveBegin & moveEnd

Open ptitdje45 opened this issue 7 years ago • 3 comments

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

ptitdje45 avatar May 30 '17 06:05 ptitdje45

Hi,

Have you found a solution, I am having the same issue.

Thanks in advance. Hatim

heloufir avatar Jun 25 '17 18:06 heloufir

Nop, i just reload data :'(

ptitdje45 avatar Jun 25 '17 19:06 ptitdje45

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.

heloufir avatar Jun 26 '17 20:06 heloufir