diff --git a/edit-mode/function/ganttConfig.js b/edit-mode/function/ganttConfig.js
index 2c53423..b2d1d6d 100644
--- a/edit-mode/function/ganttConfig.js
+++ b/edit-mode/function/ganttConfig.js
@@ -116,6 +116,7 @@ var colHeader = '
';
optionsContent += ' ';
+ optionsContent += ' ';
optionsContent += ' ';
optionsContent += !hasChild ? ' ' : '';
optionsContent += !hasChild ? ' ' : '';
@@ -255,6 +256,9 @@ function clickGridButton(id, action) {
}
});
break;
+ case "set-baseline-activity":
+ setBaselineActivity(id);
+ break;
case "upload":
showDocuments(id);
break;
diff --git a/edit-mode/function/ganttSettings.js b/edit-mode/function/ganttSettings.js
index ca81445..54f494b 100644
--- a/edit-mode/function/ganttSettings.js
+++ b/edit-mode/function/ganttSettings.js
@@ -5,6 +5,9 @@
const VERSION_GANTT_EDIT_URL = `${base_url}version-gantt/edit/${ganttId}`;
const VERSION_GANTT_UPDATE_URL = `${base_url}version-gantt/update/${ganttId}`;
const ACTIVITY_SET_BASELINE_URL = `${base_url}project/set-baseline/${ganttId}`;
+const ACTIVITY_SET_BASELINE_ACTIVITY_URL = (id) => {
+ return `${base_url}project/set-baseline-activity/${id}/${ganttId}`;
+}
const ACTIVITY_SYNCHRONIZE_REPORT_URL = `${base_url}project/synchronize-report/${ganttId}`;
let projectId = getUrlParameter("proyek_id");
var toggleTasks = "Collapse";
@@ -128,7 +131,8 @@ $(document).ready(function () {
});
$("#dashboard-project").on('click', function (event) {
- window.location.href = `https://project.ospro.id/#/dashboard-project/${projectId}/${ganttId}`;
+ // window.location.href = `https://project.ospro.id/#/dashboard-project/${projectId}/${ganttId}`;
+ window.location.href = `http://localhost:3000/#/dashboard-project/${projectId}/${ganttId}`;
});
$("#gantt-baseline").on('click', function (event) {
@@ -358,6 +362,20 @@ function setBaseline() {
});
}
+// Set Baseline Activity
+function setBaselineActivity(activity_id) {
+ var box = gantt.confirm({
+ text: "Set Baseline Activity?",
+ ok: "Yes",
+ cancel: "No",
+ callback: async function (result) {
+ if (result) {
+ await setBaselineActivityAPI(activity_id);
+ }
+ }
+ });
+}
+
async function importUpdate() {
expandTask();
var allTasks = [];
@@ -391,10 +409,26 @@ async function importUpdate() {
});
}
+async function setBaselineActivityAPI(activity_id) {
+ await importUpdate();
+ const res = await axiosInstance
+ .get(ACTIVITY_SET_BASELINE_ACTIVITY_URL(activity_id), HEADER)
+ .then(res => res)
+ .catch((error) => error.response);
+ if (res && res.status === 200) {
+ gantt.message("Set baseline activity success!");
+ window.location.reload();
+ } else {
+ $("body").removeClass("loading");
+ gantt.alert({ type: "error", text: "Failed to set baseline activity" });
+ }
+ gantt.render();
+}
+
async function setBaselineAPI() {
await importUpdate();
const res = await axiosInstance
- .get(ACTIVITY_SET_BASELINE_URL, HEADER)
+ .get(ACTIVITY_SET_BASELINE_URL(activity_id), HEADER)
.then(res => res)
.catch((error) => error.response);
console.log('set baseline res', res);
@@ -406,6 +440,7 @@ async function setBaselineAPI() {
window.location.reload();
}
else {
+ $("body").removeClass("loading");
gantt.alert({ type: "error", text: "Failed to set baseline" });
}
gantt.render();