|
|
|
@ -39,11 +39,11 @@ var daysObj = [
|
|
|
|
|
value: "6" |
|
|
|
|
} |
|
|
|
|
]; |
|
|
|
|
var days = [0,1,2,3,4,5,6]; // Sunday -> Saturday
|
|
|
|
|
var days = [0, 1, 2, 3, 4, 5, 6]; // Sunday -> Saturday
|
|
|
|
|
|
|
|
|
|
var selectDayOffChoices = null; |
|
|
|
|
|
|
|
|
|
$(document).ready(function() { |
|
|
|
|
$(document).ready(function () { |
|
|
|
|
// init select multiple workdays
|
|
|
|
|
selectDayOffChoices = new Choices('#select_dayoff', { |
|
|
|
|
removeItemButton: true, |
|
|
|
@ -53,13 +53,13 @@ $(document).ready(function() {
|
|
|
|
|
// renderChoiceLimit: 5
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$('#gantt_setting_btn').on('click', async function() { |
|
|
|
|
$('#gantt_setting_btn').on('click', async function () { |
|
|
|
|
const result = await axiosInstance |
|
|
|
|
.get(VERSION_GANTT_EDIT_URL, HEADER) |
|
|
|
|
.then(res => res) |
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
|
|
if(result && result.status==200){ |
|
|
|
|
if (result && result.status == 200) { |
|
|
|
|
if (result.data && result.data.data) { |
|
|
|
|
var config_dayoff = null; |
|
|
|
|
if (result.data.data.config_dayoff !== null) { |
|
|
|
@ -67,20 +67,20 @@ $(document).ready(function() {
|
|
|
|
|
|
|
|
|
|
if (config_dayoff && config_dayoff.length > 0) { |
|
|
|
|
var config_dayoff_arr = config_dayoff.split(','); |
|
|
|
|
for (var i=0; i < config_dayoff_arr.length; i++) { |
|
|
|
|
for (var i = 0; i < config_dayoff_arr.length; i++) { |
|
|
|
|
var day = daysObj.find(o => parseInt(o.value) === parseInt(config_dayoff_arr[i])); |
|
|
|
|
selectDayOffChoices.setChoiceByValue(day.value); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
gantt.alert({type: "error", text: "Failed to get settings. Please check your internet connection."}); |
|
|
|
|
} else { |
|
|
|
|
gantt.alert({ type: "error", text: "Failed to get settings. Please check your internet connection." }); |
|
|
|
|
} |
|
|
|
|
$('#modal_gantt_setting').modal('show'); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$('#btn_save_setting').on('click', async function() { |
|
|
|
|
$('#btn_save_setting').on('click', async function () { |
|
|
|
|
var holidays = []; |
|
|
|
|
var dayoff = $('#select_dayoff').val(); |
|
|
|
|
var costToComplete = $("#costToCompleteBox").val(); |
|
|
|
@ -90,13 +90,13 @@ $(document).ready(function() {
|
|
|
|
|
var workdays = _.difference(days, dayoff); |
|
|
|
|
|
|
|
|
|
// reset the dayoff first
|
|
|
|
|
for (var i=0; i < days.length; i++) { |
|
|
|
|
gantt.unsetWorkTime({day: days[i], hours: false}); |
|
|
|
|
for (var i = 0; i < days.length; i++) { |
|
|
|
|
gantt.unsetWorkTime({ day: days[i], hours: false }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (dayoff.length > 0) { |
|
|
|
|
for (var i=0; i < dayoff.length; i++) { |
|
|
|
|
gantt.setWorkTime({ day:dayoff[i], hours:false }); |
|
|
|
|
for (var i = 0; i < dayoff.length; i++) { |
|
|
|
|
gantt.setWorkTime({ day: dayoff[i], hours: false }); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -116,30 +116,30 @@ $(document).ready(function() {
|
|
|
|
|
refresData(); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
gantt.alert({type: "error", text: "Failed to update setting"}); |
|
|
|
|
gantt.alert({ type: "error", text: "Failed to update setting" }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
gantt.render(); |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$("#gantt_toggle_task_btn").on('click', function(event) { |
|
|
|
|
toggleCollapseTasks(); |
|
|
|
|
}); |
|
|
|
|
$("#gantt_toggle_task_btn").on('click', function (event) { |
|
|
|
|
toggleCollapseTasks(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$("#dashboard-project").on('click', function(event) { |
|
|
|
|
window.location.href = `https://adw.ospro.id/#/dashboard-project/${projectId}/${ganttId}`; |
|
|
|
|
$("#dashboard-project").on('click', function (event) { |
|
|
|
|
window.location.href = `https://adw.ospro.id/#/dashboard-project/${projectId}/${ganttId}`; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$("#gantt-baseline").on('click', function(event) { |
|
|
|
|
$("#gantt-baseline").on('click', function (event) { |
|
|
|
|
setBaseline(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$("#save-activity").on('click', function(event) { |
|
|
|
|
$("#save-activity").on('click', function (event) { |
|
|
|
|
resetActivity(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$("#gantt-synchronize").on('click', function(event) { |
|
|
|
|
$("#gantt-synchronize").on('click', function (event) { |
|
|
|
|
setSynchronize(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
@ -147,7 +147,7 @@ $(document).ready(function() {
|
|
|
|
|
initGanttSettings(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
async function initHolidays(){ |
|
|
|
|
async function initHolidays() { |
|
|
|
|
let payload = { |
|
|
|
|
"columns": [ |
|
|
|
|
{ "name": "version_gantt_id", "logic_operator": "=", "value": ganttId }, |
|
|
|
@ -159,7 +159,7 @@ async function initHolidays(){
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$.ajax({ |
|
|
|
|
data: JSON.stringify(payload), |
|
|
|
|
data: JSON.stringify(payload), |
|
|
|
|
url: `${base_url}holiday/search`, |
|
|
|
|
type: "POST", |
|
|
|
|
success: function (result) { |
|
|
|
@ -169,7 +169,7 @@ async function initHolidays(){
|
|
|
|
|
var b = moment(a).add(val.duration, 'days'); |
|
|
|
|
for (var m = moment(a); m.isBefore(b); m.add(1, 'days')) { |
|
|
|
|
let holiday = new Date(m.format('YYYY-MM-DD')); |
|
|
|
|
console.log("holiday", holiday); |
|
|
|
|
console.log("holiday", holiday); |
|
|
|
|
gantt.setWorkTime({ |
|
|
|
|
date: holiday, |
|
|
|
|
hours: false |
|
|
|
@ -190,39 +190,39 @@ async function initGanttSettings() {
|
|
|
|
|
.then(res => res) |
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
|
|
if (result && result.status==200){ |
|
|
|
|
if (result && result.status == 200) { |
|
|
|
|
var config_dayoff = result.data.data.config_dayoff; |
|
|
|
|
var type_gantt = result.data.data.calculation_type; |
|
|
|
|
reRenderColumns(type_gantt); |
|
|
|
|
reRenderColumns(type_gantt); |
|
|
|
|
var dayoff = []; |
|
|
|
|
if(config_dayoff && config_dayoff.length > 0){ |
|
|
|
|
if (config_dayoff && config_dayoff.length > 0) { |
|
|
|
|
dayoff = config_dayoff.split(','); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// reset the dayoff first
|
|
|
|
|
for (var i=0; i < days.length; i++) { |
|
|
|
|
gantt.unsetWorkTime({day: days[i], hours: false}); |
|
|
|
|
for (var i = 0; i < days.length; i++) { |
|
|
|
|
gantt.unsetWorkTime({ day: days[i], hours: false }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (dayoff.length > 0) { |
|
|
|
|
for (var i=0; i < dayoff.length; i++) { |
|
|
|
|
gantt.setWorkTime({ day:dayoff[i], hours:false }); |
|
|
|
|
for (var i = 0; i < dayoff.length; i++) { |
|
|
|
|
gantt.setWorkTime({ day: dayoff[i], hours: false }); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
for (let index = 1; index <= 7; index++) { |
|
|
|
|
const dateToCheck = new Date(2023, 4, index); // Note: Month is 0-based, so 5 represents June
|
|
|
|
|
if (gantt.isWorkTime({ date: dateToCheck, hours: false })) { |
|
|
|
|
console.log(dateToCheck.toString() + ' is work time.'); |
|
|
|
|
} else { |
|
|
|
|
console.log(dateToCheck.toString() + ' is not work time.'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
for (let index = 1; index <= 7; index++) { |
|
|
|
|
const dateToCheck = new Date(2023, 4, index); // Note: Month is 0-based, so 5 represents June
|
|
|
|
|
if (gantt.isWorkTime({ date: dateToCheck, hours: false })) { |
|
|
|
|
console.log(dateToCheck.toString() + ' is work time.'); |
|
|
|
|
} else { |
|
|
|
|
console.log(dateToCheck.toString() + ' is not work time.'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function expandTask(){ |
|
|
|
|
function expandTask() { |
|
|
|
|
console.log("check expandTask") |
|
|
|
|
gantt.eachTask(function(task){ |
|
|
|
|
gantt.eachTask(function (task) { |
|
|
|
|
task.$open = true; |
|
|
|
|
}); |
|
|
|
|
// updateProperty({task_open:true})
|
|
|
|
@ -236,11 +236,11 @@ function expandTask(){
|
|
|
|
|
function toggleCollapseTasks() { |
|
|
|
|
// collapse task / activity
|
|
|
|
|
console.log('toggleCollapseTasks'); |
|
|
|
|
gantt.eachTask(function(task){ |
|
|
|
|
gantt.eachTask(function (task) { |
|
|
|
|
task.$open = toggleTasks == "Expand"; |
|
|
|
|
}); |
|
|
|
|
if (toggleTasks == "Expand") { |
|
|
|
|
updateProperty({task_open:true}) |
|
|
|
|
updateProperty({ task_open: true }) |
|
|
|
|
// console.log('to collapse');
|
|
|
|
|
toggleTasks = "Collapse"; |
|
|
|
|
$("#gantt_toggle_task_btn").prop('title', 'Collapse Activities'); |
|
|
|
@ -248,7 +248,7 @@ function toggleCollapseTasks() {
|
|
|
|
|
$("#gantt_toggle_task_btn").children().addClass('fa-compress-alt'); // change icon to collapse
|
|
|
|
|
} else { |
|
|
|
|
// console.log('to expand');
|
|
|
|
|
updateProperty({task_open:false}) |
|
|
|
|
updateProperty({ task_open: false }) |
|
|
|
|
toggleTasks = "Expand"; |
|
|
|
|
$("#gantt_toggle_task_btn").prop('title', 'Expand Activities'); |
|
|
|
|
$("#gantt_toggle_task_btn").children().removeClass('fa-compress-alt'); |
|
|
|
@ -260,42 +260,42 @@ function toggleCollapseTasks() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Function Show / Hide Columns
|
|
|
|
|
function getColumnsSelection(node){ |
|
|
|
|
function getColumnsSelection(node) { |
|
|
|
|
var selectedColumns = node.querySelectorAll(":checked"); |
|
|
|
|
var unselectedColumn = node.querySelectorAll('input[type="checkbox"]:not(:checked)'); |
|
|
|
|
// var allSelected = node.querySelector("#check-all").prop('checked');
|
|
|
|
|
// console.log("unselectedColumn", unselectedColumn)
|
|
|
|
|
var checkedColumns = {}; |
|
|
|
|
selectedColumns.forEach(function(node){ |
|
|
|
|
selectedColumns.forEach(function (node) { |
|
|
|
|
checkedColumns[node.name] = true; |
|
|
|
|
}); |
|
|
|
|
unselectedColumn.forEach(function(node){ |
|
|
|
|
unselectedColumn.forEach(function (node) { |
|
|
|
|
checkedColumns[node.name] = false; |
|
|
|
|
}); |
|
|
|
|
return checkedColumns; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function populateColumnsDropdown(node){ |
|
|
|
|
function populateColumnsDropdown(node) { |
|
|
|
|
var visibleColumns = {}; |
|
|
|
|
// var preventHide = ['action'];
|
|
|
|
|
gantt.config.columns.forEach(function(col){ |
|
|
|
|
gantt.config.columns.forEach(function (col) { |
|
|
|
|
visibleColumns[col.name] = true; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
var lines = []; |
|
|
|
|
allColumns.forEach(function(col){ |
|
|
|
|
allColumns.forEach(function (col) { |
|
|
|
|
var checked = visibleColumns[col.name] ? "checked" : ""; |
|
|
|
|
// skip action to be pushed
|
|
|
|
|
lines.push(`<label class="${col.name === 'action' ? 'elm-hide2': ''} dropdown-item"><input type="checkbox" name="${col.name}" ${checked}> ${col.label}</label>`); |
|
|
|
|
lines.push(`<label class="${col.name === 'action' ? 'elm-hide2' : ''} dropdown-item"><input type="checkbox" name="${col.name}" ${checked}> ${col.label}</label>`); |
|
|
|
|
}); |
|
|
|
|
node.innerHTML = '<span class="dropdown-title">Show / Hide Columns</span><br>' + lines.join("<br>"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function getDropdownNode(){ |
|
|
|
|
function getDropdownNode() { |
|
|
|
|
return document.querySelector("#gantt_dropdown"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
gantt.$showDropdown = function(node){ |
|
|
|
|
gantt.$showDropdown = function (node) { |
|
|
|
|
var position = node.getBoundingClientRect(); |
|
|
|
|
var dropDown = getDropdownNode(); |
|
|
|
|
dropDown.style.top = position.bottom + "px"; |
|
|
|
@ -303,9 +303,9 @@ gantt.$showDropdown = function(node){
|
|
|
|
|
dropDown.style.display = "block"; |
|
|
|
|
populateColumnsDropdown(dropDown); |
|
|
|
|
|
|
|
|
|
dropDown.onchange = function(){ |
|
|
|
|
dropDown.onchange = function () { |
|
|
|
|
var selection = getColumnsSelection(dropDown); |
|
|
|
|
if(readOnly && parseInt(readOnly)==0){ |
|
|
|
|
if (readOnly && parseInt(readOnly) == 0) { |
|
|
|
|
updateShowHideColumn(selection) |
|
|
|
|
} |
|
|
|
|
gantt.config.columns = createColumnsConfig(selection); |
|
|
|
@ -313,18 +313,18 @@ gantt.$showDropdown = function(node){
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
dropDown.keep = true; |
|
|
|
|
setTimeout(function(){ |
|
|
|
|
setTimeout(function () { |
|
|
|
|
dropDown.keep = false; |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
gantt.$hideDropdown = function(){ |
|
|
|
|
gantt.$hideDropdown = function () { |
|
|
|
|
var dropDown = getDropdownNode(); |
|
|
|
|
dropDown.style.display = "none"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
window.addEventListener("click", function(event){ |
|
|
|
|
if(!event.target.closest("#gantt_dropdown") && !getDropdownNode().keep){ |
|
|
|
|
window.addEventListener("click", function (event) { |
|
|
|
|
if (!event.target.closest("#gantt_dropdown") && !getDropdownNode().keep) { |
|
|
|
|
gantt.$hideDropdown(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -336,14 +336,14 @@ window.addEventListener("click", function(event){
|
|
|
|
|
function setBaseline() { |
|
|
|
|
var box = gantt.confirm({ |
|
|
|
|
text: "Set Baseline?", |
|
|
|
|
ok:"Yes", |
|
|
|
|
cancel:"No", |
|
|
|
|
callback: async function(result){ |
|
|
|
|
if(result){ |
|
|
|
|
ok: "Yes", |
|
|
|
|
cancel: "No", |
|
|
|
|
callback: async function (result) { |
|
|
|
|
if (result) { |
|
|
|
|
// gantt.message("Yes!");
|
|
|
|
|
// send to API
|
|
|
|
|
await setBaselineAPI(); |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
// gantt.message("No...");
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -351,6 +351,36 @@ function setBaseline() {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async function setBaselineAPI() { |
|
|
|
|
expandTask(); |
|
|
|
|
var allTasks = []; |
|
|
|
|
var taskCount = gantt.getTaskCount(); |
|
|
|
|
|
|
|
|
|
for (var i = 0; i < taskCount; i++) { |
|
|
|
|
var task = gantt.getTaskByIndex(i); |
|
|
|
|
allTasks.push(task); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$("body").addClass("loading"); |
|
|
|
|
const response = await gantt.ajax.post({ |
|
|
|
|
headers: { |
|
|
|
|
"Content-Type": "application/json", |
|
|
|
|
"Authorization": `Bearer ${token}` |
|
|
|
|
}, |
|
|
|
|
url: `${base_url}activity/import-update`, |
|
|
|
|
dataType: "json", |
|
|
|
|
data: JSON.stringify(allTasks) |
|
|
|
|
}).then(function (response) { |
|
|
|
|
$("body").removeClass("loading"); |
|
|
|
|
let res = response.responseText |
|
|
|
|
res = JSON.parse(res) |
|
|
|
|
}).catch(function (error) { |
|
|
|
|
$("body").removeClass("loading"); |
|
|
|
|
gantt.alert({ |
|
|
|
|
title: "Peringatan", |
|
|
|
|
type: "alert-error", |
|
|
|
|
text: "Update import gagal" |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
const res = await axiosInstance |
|
|
|
|
.get(ACTIVITY_SET_BASELINE_URL, HEADER) |
|
|
|
|
.then(res => res) |
|
|
|
@ -364,7 +394,7 @@ async function setBaselineAPI() {
|
|
|
|
|
window.location.reload(); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
gantt.alert({type: "error", text: "Failed to set baseline"}); |
|
|
|
|
gantt.alert({ type: "error", text: "Failed to set baseline" }); |
|
|
|
|
} |
|
|
|
|
gantt.render(); |
|
|
|
|
} |
|
|
|
@ -378,9 +408,9 @@ function setSynchronize() {
|
|
|
|
|
// });
|
|
|
|
|
gantt.confirm({ |
|
|
|
|
text: "Plase set baseline before continue.", |
|
|
|
|
ok:"Set Baseline", |
|
|
|
|
cancel:"Cancel", |
|
|
|
|
callback: async function(result) { |
|
|
|
|
ok: "Set Baseline", |
|
|
|
|
cancel: "Cancel", |
|
|
|
|
callback: async function (result) { |
|
|
|
|
if (result) { |
|
|
|
|
await setBaselineAPI(); |
|
|
|
|
} |
|
|
|
@ -391,14 +421,14 @@ function setSynchronize() {
|
|
|
|
|
|
|
|
|
|
var box = gantt.confirm({ |
|
|
|
|
text: "Synchronize to Report Activity?", |
|
|
|
|
ok:"Yes", |
|
|
|
|
cancel:"No", |
|
|
|
|
callback: async function(result){ |
|
|
|
|
if(result){ |
|
|
|
|
ok: "Yes", |
|
|
|
|
cancel: "No", |
|
|
|
|
callback: async function (result) { |
|
|
|
|
if (result) { |
|
|
|
|
// gantt.message("Yes!");
|
|
|
|
|
// send to API
|
|
|
|
|
await setSynchronizeAPI() |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
// gantt.message("No...");
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -420,7 +450,7 @@ async function setSynchronizeAPI() {
|
|
|
|
|
window.location.reload(); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
gantt.alert({type: "error", text: "Failed to Synchronize to Report"}); |
|
|
|
|
gantt.alert({ type: "error", text: "Failed to Synchronize to Report" }); |
|
|
|
|
} |
|
|
|
|
gantt.render(); |
|
|
|
|
} |
|
|
|
|