Browse Source

add endpoint baseline activity

pull/1/head
wahyun 8 months ago
parent
commit
fa85ac05eb
  1. 4
      edit-mode/function/ganttConfig.js
  2. 39
      edit-mode/function/ganttSettings.js

4
edit-mode/function/ganttConfig.js

@ -116,6 +116,7 @@ var colHeader = '<div class="gantt_grid_head_cell"><i style="margin-right:5px;"
var optionsContent = '<div class="align-left">';
optionsContent += '<i title="Add Activity" class="fa gantt_button_grid gantt_grid_add fa-plus icon-action f-blue-sky" onclick="clickGridButton(' + task.id + ', \'add\')"></i> ';
optionsContent += '<i title="Delete Activity" class="fa gantt_button_grid gantt_grid_delete fa-times icon-action f-red" onclick="clickGridButton(' + task.id + ', \'delete\')"></i> ';
optionsContent += '<i title="Set Baseline Activity" class="fa gantt_button_grid gantt_grid_delete fa-grip-lines icon-action f-blue-sky" onclick="clickGridButton(' + task.id + ', \'set-baseline-activity\')"></i> ';
optionsContent += '<i title="Add Milestone" class="fa gantt_button_grid gantt_grid_add fab fa-jira icon-action f-black" onclick="addMilestone(' + task.id + ')"></i> ';
optionsContent += !hasChild ? '<i title="Upload Document" class="fa gantt_button_grid gantt_grid_delete fa-file icon-action f-orange" onclick="clickGridButton(' + task.id + ', \'upload\')"></i> ' : '';
optionsContent += !hasChild ? '<i title="Show Comments" class="fa gantt_button_grid gantt_grid_delete fa-comment icon-action f-black" onclick="clickGridButton(' + task.id + ', \'comment\')"></i> ' : '';
@ -255,6 +256,9 @@ function clickGridButton(id, action) {
}
});
break;
case "set-baseline-activity":
setBaselineActivity(id);
break;
case "upload":
showDocuments(id);
break;

39
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();

Loading…
Cancel
Save