From 70be6b446613efcb0938e4d814e3d3ad59e2ab02 Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Mon, 10 Jul 2023 11:37:30 +0700 Subject: [PATCH] Fix duratiion calculation and geom --- edit-mode/function/ganttEvent.js | 5 ++++- edit-mode/function/restActivityLink.js | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/edit-mode/function/ganttEvent.js b/edit-mode/function/ganttEvent.js index 128f893..d973882 100644 --- a/edit-mode/function/ganttEvent.js +++ b/edit-mode/function/ganttEvent.js @@ -54,7 +54,10 @@ gantt.attachEvent("onBeforeTaskUpdate", function(id,new_item){ progress = progress/100; new_item['progress'] = progress; new_item['end_date'].setHours(23,59,59); - new_item['duration'] += 1; + new_item['duration'] = gantt.calculateDuration({ + start_date: new_item['start_date'], + end_date: new_item['end_date'] + }) }); gantt.attachEvent("onAfterTaskDrag", function(id, mode, e){ diff --git a/edit-mode/function/restActivityLink.js b/edit-mode/function/restActivityLink.js index e81ca72..15abacc 100644 --- a/edit-mode/function/restActivityLink.js +++ b/edit-mode/function/restActivityLink.js @@ -1,3 +1,4 @@ +let geom = []; gantt.ajax.get({ url: `${base_url}activity/${ganttId}/${proyekId}/get`, headers: { @@ -19,6 +20,13 @@ gantt.ajax.get({ isBaselineSet = false; } } + geom = []; + data.data.forEach(element => { + geom.push({ + "activity_id": element.id, + "geom": element.geom + }) + }); gantt.silent(function () { gantt.parse(data); }); @@ -63,6 +71,13 @@ function refresData(id){ let obj = JSON.parse(response); data['data'] = obj.data.data; data['links'] = obj.data.links; + geom = []; + data.data.forEach(element => { + geom.push({ + "activity_id": element.id, + "geom": element.geom + }) + }); gantt.silent(function () { gantt.parse(data); }); @@ -147,7 +162,7 @@ var dp = gantt.createDataProcessor(function(entity, action, data, id) { } }); } - + data['geom'] = geom.find(obj => obj.activity_id == id)?.geom; return gantt.ajax.put({ headers: { "Content-Type": "application/json",