From b9b28bb1f8c3d46345063aa99c27b27c89e836de Mon Sep 17 00:00:00 2001 From: wahyu Date: Wed, 20 Sep 2023 16:51:47 +0700 Subject: [PATCH] compare rendered data with response --- edit-mode/function/function.js | 26 ++++++++++++++++++++++++++ edit-mode/function/ganttSettings.js | 6 +++++- edit-mode/function/restActivityLink.js | 2 ++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/edit-mode/function/function.js b/edit-mode/function/function.js index 7f07fef..15d5fcd 100644 --- a/edit-mode/function/function.js +++ b/edit-mode/function/function.js @@ -367,6 +367,32 @@ function setGanttOpen() { localStorage.setItem('ganttOpen', JSON.stringify(ganttOpen)); } +function compareData(data){ + expandTask(); + var allTasks = []; + var taskCount = gantt.getTaskCount(); + + for (var i = 0; i < taskCount; i++) { + var task = gantt.getTaskByIndex(i); + allTasks.push(task); + } + allTasks.forEach((task, index) => { + if (task.start_date != data.data[index].start_date) { + gantt.getTask(task.id).start_date = task.start_date; + } + if (task.end_date != data.data[index].end_date) { + gantt.getTask(task.id).end_date = task.end_date; + } + if (task.planned_start != data.data[index].planned_start) { + gantt.getTask(task.id).planned_start = task.planned_start; + } + if (task.planned_end != data.data[index].planned_end) { + gantt.getTask(task.id).planned_end = task.planned_end; + } + gantt.updateTask(task.id); + }); +} + function getGanttOpen() { let ganttOpen = localStorage.getItem('ganttOpen'); if (ganttOpen) { diff --git a/edit-mode/function/ganttSettings.js b/edit-mode/function/ganttSettings.js index 77db70c..a6276fe 100644 --- a/edit-mode/function/ganttSettings.js +++ b/edit-mode/function/ganttSettings.js @@ -350,7 +350,7 @@ function setBaseline() { }); } -async function setBaselineAPI() { +async function importUpdate() { expandTask(); var allTasks = []; var taskCount = gantt.getTaskCount(); @@ -381,6 +381,10 @@ async function setBaselineAPI() { text: "Update import gagal" }); }); +} + +async function setBaselineAPI() { + await importUpdate(); const res = await axiosInstance .get(ACTIVITY_SET_BASELINE_URL, HEADER) .then(res => res) diff --git a/edit-mode/function/restActivityLink.js b/edit-mode/function/restActivityLink.js index f484941..cc5ea22 100644 --- a/edit-mode/function/restActivityLink.js +++ b/edit-mode/function/restActivityLink.js @@ -40,6 +40,7 @@ gantt.ajax.get({ gantt.silent(function () { // updateLinksLag(data); gantt.parse(data); + compareData(data); getGanttOpen(); gantt.parse(data); earliest = getEarliestTaskDate(); @@ -93,6 +94,7 @@ function refresData(id) { gantt.silent(function () { // updateLinksLag(data); gantt.parse(data); + compareData(data); getGanttOpen(); gantt.parse(data); earliest = getEarliestTaskDate();