Browse Source

Merge pull request 'set baseline activity' (#2) from dev-wahyun into master

Reviewed-on: ibnu/generic-ospro-gantt#2
pull/1/head
farhantock 7 months ago
parent
commit
c011260f80
  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">'; 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="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="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 += '<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="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> ' : ''; 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; break;
case "set-baseline-activity":
setBaselineActivity(id);
break;
case "upload": case "upload":
showDocuments(id); showDocuments(id);
break; 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_EDIT_URL = `${base_url}version-gantt/edit/${ganttId}`;
const VERSION_GANTT_UPDATE_URL = `${base_url}version-gantt/update/${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_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}`; const ACTIVITY_SYNCHRONIZE_REPORT_URL = `${base_url}project/synchronize-report/${ganttId}`;
let projectId = getUrlParameter("proyek_id"); let projectId = getUrlParameter("proyek_id");
var toggleTasks = "Collapse"; var toggleTasks = "Collapse";
@ -128,7 +131,8 @@ $(document).ready(function () {
}); });
$("#dashboard-project").on('click', function (event) { $("#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) { $("#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() { async function importUpdate() {
expandTask(); expandTask();
var allTasks = []; 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() { async function setBaselineAPI() {
await importUpdate(); await importUpdate();
const res = await axiosInstance const res = await axiosInstance
.get(ACTIVITY_SET_BASELINE_URL, HEADER) .get(ACTIVITY_SET_BASELINE_URL(activity_id), HEADER)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
console.log('set baseline res', res); console.log('set baseline res', res);
@ -406,6 +440,7 @@ async function setBaselineAPI() {
window.location.reload(); window.location.reload();
} }
else { else {
$("body").removeClass("loading");
gantt.alert({ type: "error", text: "Failed to set baseline" }); gantt.alert({ type: "error", text: "Failed to set baseline" });
} }
gantt.render(); gantt.render();

Loading…
Cancel
Save