From 6c10696cb53953dc49799cb2e5d464d009e6d34f Mon Sep 17 00:00:00 2001 From: wangyidong Date: Sat, 13 Jul 2024 12:23:38 +0800 Subject: [PATCH] * [perf story #59018] Bind onBeforeRowDragEnd event for gantt. --- lib/zin/wg/gantt/js/v1.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/zin/wg/gantt/js/v1.js b/lib/zin/wg/gantt/js/v1.js index f87f6de1c0..2ba81fd0d8 100644 --- a/lib/zin/wg/gantt/js/v1.js +++ b/lib/zin/wg/gantt/js/v1.js @@ -601,9 +601,6 @@ function initGantt() loadPage($.createLink('review', 'create', 'projectID=' + projectID)); } - let taskID = 0; - if(ganttType == 'assignedTo') taskID = id; - /* The id of task item is like executionID-taskID. e.g. 1507-37829, 37829 is task id. */ let taskID = ganttType == 'assignedTo' ? id : 0; let position = id.indexOf('-'); @@ -611,6 +608,22 @@ function initGantt() if(!isNaN(taskID) && taskID > 0) zui.Modal.open({url: $.createLink('task', 'view', 'taskID=' + taskID, 'html', true), 'size': 'lg'}); }); + + gantt.attachEvent("onBeforeRowDragEnd", function(id, parent, tindex) + { + let tasks = gantt.getChildren(parent); + let task = gantt.getTask(id); + let link = $.createLink('programplan', 'ajaxResponseGanttMoveEvent'); + + //prevent moving to another position. + if(task.parent != parent || id.indexOf('-') == -1) return false; + + $.post(link, {id: id, tasks: tasks}); + return true; + }); + + /* Link attachEvent onAfterTaskDrag */ + gantt.attachEvent("onBeforeTaskChanged", function(id, mode, task){return validateResources(id)}); } $(function()