From b6fa148aacc1dfbcc920b23dbc08a748cadae6e3 Mon Sep 17 00:00:00 2001 From: wahyu Date: Fri, 13 Oct 2023 16:51:55 +0700 Subject: [PATCH 1/2] fix today marker --- edit-mode/function/expenseResource.js | 31 ---------------- edit-mode/function/function.js | 52 ++++++++++++++++----------- edit-mode/function/ganttSettings.js | 21 +++++++++++ 3 files changed, 52 insertions(+), 52 deletions(-) diff --git a/edit-mode/function/expenseResource.js b/edit-mode/function/expenseResource.js index d27ad63..602ca20 100644 --- a/edit-mode/function/expenseResource.js +++ b/edit-mode/function/expenseResource.js @@ -75,37 +75,6 @@ $(document).ready(function () { }); } - function searchReport(id) { - var payload = { - "columns": [ - { - "name": "assign_material_id", - "logic_operator": "=", - "value": id, - "operator": "AND" - } - ], - // "joins": [{ "name": "m_proyek", "column_join": "proyek_id", "column_results": ["kode_sortname", "nama"] }], - } - $.ajax({ - data: JSON.stringify(payload), - url: `${base_url}report-activity-material/search`, - type: "POST", - success: function (data) { - data.data.forEach(element => { - let activityId = element.activity_id; - let task = gantt.getTask(activityId); - task.actual_start = null; - task.actual_end = null; - }); - actionHappen = true; - }, - error: function (data) { - // gantt.alert("Failed to get the data."); - } - }); - } - $("#modal-expense").on("click", "#show-form-expense", function () { $(this).hide(); $("#hide-form-expense").show(); diff --git a/edit-mode/function/function.js b/edit-mode/function/function.js index bc3426d..717c306 100644 --- a/edit-mode/function/function.js +++ b/edit-mode/function/function.js @@ -14,6 +14,37 @@ function getUrlParameter(sParam) { return false; }; + function searchReport(id) { + var payload = { + "columns": [ + { + "name": "assign_material_id", + "logic_operator": "=", + "value": id, + "operator": "AND" + } + ], + // "joins": [{ "name": "m_proyek", "column_join": "proyek_id", "column_results": ["kode_sortname", "nama"] }], + } + $.ajax({ + data: JSON.stringify(payload), + url: `${base_url}report-activity-material/search`, + type: "POST", + success: function (data) { + data.data.forEach(element => { + let activityId = element.activity_id; + let task = gantt.getTask(activityId); + task.actual_start = null; + task.actual_end = null; + }); + actionHappen = true; + }, + error: function (data) { + // gantt.alert("Failed to get the data."); + } + }); + } + const formatNumber = (angka) => { var number_string = angka.replace(/[^,\d]/g, '').toString(), split = number_string.split(','), @@ -733,27 +764,6 @@ function batchUpdate(){ }); } -function updateSchedule() { - $("body").addClass("loading"); - return gantt.ajax.get({ - headers: { - "Content-Type": "application/json", - "Authorization": `Bearer ${token}` - }, - url: base_url + "activity/update-schedule/" + ganttId - }).then(function (response) { - $("body").removeClass("loading"); - refresData(); - }).catch(function (error) { - $("body").removeClass("loading") - gantt.alert({ - title: "Peringatan", - type: "alert-error", - text: "Update activity gagal" - }); - }); -} - $(window).on('beforeunload', function(event) { let batchEntity = localStorage.getItem('batchEntity'); sendStorage(); diff --git a/edit-mode/function/ganttSettings.js b/edit-mode/function/ganttSettings.js index e941046..86cc8e9 100644 --- a/edit-mode/function/ganttSettings.js +++ b/edit-mode/function/ganttSettings.js @@ -447,6 +447,27 @@ function setSynchronize() { }); } +function updateSchedule() { + $("body").addClass("loading"); + return gantt.ajax.get({ + headers: { + "Content-Type": "application/json", + "Authorization": `Bearer ${token}` + }, + url: base_url + "activity/update-schedule/" + ganttId + }).then(function (response) { + $("body").removeClass("loading"); + window.location.reload(); + }).catch(function (error) { + $("body").removeClass("loading") + gantt.alert({ + title: "Peringatan", + type: "alert-error", + text: "Update activity gagal" + }); + }); +} + async function setSynchronizeAPI() { const res = await axiosInstance .get(ACTIVITY_SYNCHRONIZE_REPORT_URL, HEADER) From 059f8b912dc98c7ffe820b7d7a03cc7480b1f02b Mon Sep 17 00:00:00 2001 From: wahyu Date: Mon, 16 Oct 2023 08:13:31 +0700 Subject: [PATCH 2/2] adjust actual date after deleting report --- edit-mode/function/function.js | 23 ++++++++++++++++------- edit-mode/function/reportActivity.js | 1 + 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/edit-mode/function/function.js b/edit-mode/function/function.js index 717c306..c91369b 100644 --- a/edit-mode/function/function.js +++ b/edit-mode/function/function.js @@ -14,7 +14,7 @@ function getUrlParameter(sParam) { return false; }; - function searchReport(id) { + function searchReport(id, updateActual = true) { var payload = { "columns": [ { @@ -31,12 +31,21 @@ function getUrlParameter(sParam) { url: `${base_url}report-activity-material/search`, type: "POST", success: function (data) { - data.data.forEach(element => { - let activityId = element.activity_id; - let task = gantt.getTask(activityId); - task.actual_start = null; - task.actual_end = null; - }); + if (updateActual) { + data.data.forEach(element => { + let activityId = element.activity_id; + let task = gantt.getTask(activityId); + task.actual_start = null; + task.actual_end = null; + }); + } else { + if (data.data.length == 1) { + let activityId = data.data[0].activity_id; + let task = gantt.getTask(activityId); + task.actual_start = null; + task.actual_end = null; + } + } actionHappen = true; }, error: function (data) { diff --git a/edit-mode/function/reportActivity.js b/edit-mode/function/reportActivity.js index 29cc50b..e9d58aa 100644 --- a/edit-mode/function/reportActivity.js +++ b/edit-mode/function/reportActivity.js @@ -654,6 +654,7 @@ $(document).ready(function () { } function deleteRaMaterial(id) { + searchReport(assignMaterialId, false); $.ajax({ url: `${base_url}report-activity-material/delete/${id}`, type: "DELETE",