|
|
@ -47,6 +47,9 @@ $(document).ready(function() { |
|
|
|
selectDayOffChoices = new Choices('#select_dayoff', { |
|
|
|
selectDayOffChoices = new Choices('#select_dayoff', { |
|
|
|
removeItemButton: true, |
|
|
|
removeItemButton: true, |
|
|
|
shouldSort: false |
|
|
|
shouldSort: false |
|
|
|
|
|
|
|
// maxItemCount: 5,
|
|
|
|
|
|
|
|
// searchResultLimit: 5,
|
|
|
|
|
|
|
|
// renderChoiceLimit: 5
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
$('#gantt_setting_btn').on('click', async function() { |
|
|
|
$('#gantt_setting_btn').on('click', async function() { |
|
|
@ -54,9 +57,13 @@ $(document).ready(function() { |
|
|
|
.get(VERSION_GANTT_EDIT_URL, HEADER) |
|
|
|
.get(VERSION_GANTT_EDIT_URL, HEADER) |
|
|
|
.then(res => res) |
|
|
|
.then(res => res) |
|
|
|
.catch((error) => error.response); |
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// console.log("get version gantt result", result)
|
|
|
|
|
|
|
|
|
|
|
|
if(result && result.status==200){ |
|
|
|
if(result && result.status==200){ |
|
|
|
if (result.data && result.data.data) { |
|
|
|
if (result.data && result.data.data) { |
|
|
|
var config_dayoff = null; |
|
|
|
var config_dayoff = null; |
|
|
|
|
|
|
|
// console.log('result.data.data.config_dayoff', result.data.data.config_dayoff)
|
|
|
|
if (result.data.data.config_dayoff !== null) { |
|
|
|
if (result.data.data.config_dayoff !== null) { |
|
|
|
config_dayoff = result.data.data.config_dayoff; |
|
|
|
config_dayoff = result.data.data.config_dayoff; |
|
|
|
|
|
|
|
|
|
|
@ -65,13 +72,17 @@ $(document).ready(function() { |
|
|
|
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])); |
|
|
|
var day = daysObj.find(o => parseInt(o.value) === parseInt(config_dayoff_arr[i])); |
|
|
|
// $('#select_dayoff option[value='+day.value+']').prop("selected", true);
|
|
|
|
// $('#select_dayoff option[value='+day.value+']').prop("selected", true);
|
|
|
|
|
|
|
|
// console.log('day', day);
|
|
|
|
selectDayOffChoices.setChoiceByValue(day.value); |
|
|
|
selectDayOffChoices.setChoiceByValue(day.value); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
|
|
|
|
// closeDialog('failed upload')
|
|
|
|
|
|
|
|
console.log('failed get version gantt'); |
|
|
|
gantt.alert({type: "error", text: "Failed to get settings. Please check your internet connection."}); |
|
|
|
gantt.alert({type: "error", text: "Failed to get settings. Please check your internet connection."}); |
|
|
|
|
|
|
|
// alert('Upload failed');
|
|
|
|
} |
|
|
|
} |
|
|
|
$('#modal_gantt_setting').modal('show'); |
|
|
|
$('#modal_gantt_setting').modal('show'); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -92,7 +103,16 @@ $(document).ready(function() { |
|
|
|
// }
|
|
|
|
// }
|
|
|
|
var holidays = []; |
|
|
|
var holidays = []; |
|
|
|
var dayoff = $('#select_dayoff').val(); |
|
|
|
var dayoff = $('#select_dayoff').val(); |
|
|
|
|
|
|
|
// console.log('dayoff', dayoff);
|
|
|
|
|
|
|
|
// if (dayoff.length < 1) return alert('Please add a day off');
|
|
|
|
|
|
|
|
|
|
|
|
dayoff = dayoff.map(item => parseInt(item)); |
|
|
|
dayoff = dayoff.map(item => parseInt(item)); |
|
|
|
|
|
|
|
// console.log('dayoff after', dayoff);
|
|
|
|
|
|
|
|
var workdays = _.difference(days, dayoff); |
|
|
|
|
|
|
|
// console.log('workdays', workdays);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// getCurrentWorkdays();
|
|
|
|
|
|
|
|
|
|
|
|
// reset the dayoff first
|
|
|
|
// reset the dayoff first
|
|
|
|
for (var i=0; i < days.length; i++) { |
|
|
|
for (var i=0; i < days.length; i++) { |
|
|
|
gantt.unsetWorkTime({day: days[i], hours: false}); |
|
|
|
gantt.unsetWorkTime({day: days[i], hours: false}); |
|
|
@ -114,6 +134,8 @@ $(document).ready(function() { |
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// console.log('dayoff.length', dayoff.length);
|
|
|
|
|
|
|
|
|
|
|
|
if (dayoff.length > 0) { |
|
|
|
if (dayoff.length > 0) { |
|
|
|
for (var i=0; i < dayoff.length; i++) { |
|
|
|
for (var i=0; i < dayoff.length; i++) { |
|
|
|
gantt.setWorkTime({ day:dayoff[i], hours:false }); |
|
|
|
gantt.setWorkTime({ day:dayoff[i], hours:false }); |
|
|
@ -130,10 +152,13 @@ $(document).ready(function() { |
|
|
|
let payload = { |
|
|
|
let payload = { |
|
|
|
"config_dayoff": dayoff.join(',') |
|
|
|
"config_dayoff": dayoff.join(',') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// console.log('payload', payload);
|
|
|
|
|
|
|
|
// console.log('HEADER', HEADER);
|
|
|
|
const result = await axiosInstance |
|
|
|
const result = await axiosInstance |
|
|
|
.put(VERSION_GANTT_UPDATE_URL, payload, HEADER) |
|
|
|
.put(VERSION_GANTT_UPDATE_URL, payload, HEADER) |
|
|
|
.then(res => res) |
|
|
|
.then(res => res) |
|
|
|
.catch((error) => error.response); |
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
// console.log("update settings result", result)
|
|
|
|
if (result && result.status === 200) { |
|
|
|
if (result && result.status === 200) { |
|
|
|
$('#modal_gantt_setting').modal('hide'); |
|
|
|
$('#modal_gantt_setting').modal('hide'); |
|
|
|
// gantt.alert("Settings updated");
|
|
|
|
// gantt.alert("Settings updated");
|
|
|
@ -183,6 +208,7 @@ async function initHolidays(){ |
|
|
|
url: `${base_url}holiday/search`, |
|
|
|
url: `${base_url}holiday/search`, |
|
|
|
type: "POST", |
|
|
|
type: "POST", |
|
|
|
success: function (result) { |
|
|
|
success: function (result) { |
|
|
|
|
|
|
|
// console.log("cek data", result.data);
|
|
|
|
let dataHolidays = result.data || [] |
|
|
|
let dataHolidays = result.data || [] |
|
|
|
dataHolidays.map((val, index) => { |
|
|
|
dataHolidays.map((val, index) => { |
|
|
|
// let day = moment(val.date).format("YYYY-MM-DD");
|
|
|
|
// let day = moment(val.date).format("YYYY-MM-DD");
|
|
|
@ -190,6 +216,7 @@ async function initHolidays(){ |
|
|
|
var b = moment(a).add(val.duration, 'days'); |
|
|
|
var b = moment(a).add(val.duration, 'days'); |
|
|
|
for (var m = moment(a); m.isBefore(b); m.add(1, 'days')) { |
|
|
|
for (var m = moment(a); m.isBefore(b); m.add(1, 'days')) { |
|
|
|
let holiday = new Date(m.format('YYYY-MM-DD')); |
|
|
|
let holiday = new Date(m.format('YYYY-MM-DD')); |
|
|
|
|
|
|
|
// console.log("cek holiday", holiday)
|
|
|
|
gantt.setWorkTime({ |
|
|
|
gantt.setWorkTime({ |
|
|
|
date: holiday, |
|
|
|
date: holiday, |
|
|
|
hours: false |
|
|
|
hours: false |
|
|
@ -210,6 +237,7 @@ async function initHolidays(){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function initGanttSettings() { |
|
|
|
async function initGanttSettings() { |
|
|
|
|
|
|
|
console.log('initGanttSettings'); |
|
|
|
// if zoom is day
|
|
|
|
// if zoom is day
|
|
|
|
$("#scale3").attr('checked', true); |
|
|
|
$("#scale3").attr('checked', true); |
|
|
|
// toggleCollapseTasks();
|
|
|
|
// toggleCollapseTasks();
|
|
|
@ -242,6 +270,7 @@ async function initGanttSettings() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function expandTask(){ |
|
|
|
function expandTask(){ |
|
|
|
|
|
|
|
console.log("check expandTask") |
|
|
|
gantt.eachTask(function(task){ |
|
|
|
gantt.eachTask(function(task){ |
|
|
|
task.$open = true; |
|
|
|
task.$open = true; |
|
|
|
}); |
|
|
|
}); |
|
|
@ -255,16 +284,19 @@ function expandTask(){ |
|
|
|
|
|
|
|
|
|
|
|
function toggleCollapseTasks() { |
|
|
|
function toggleCollapseTasks() { |
|
|
|
// collapse task / activity
|
|
|
|
// collapse task / activity
|
|
|
|
|
|
|
|
console.log('toggleCollapseTasks'); |
|
|
|
gantt.eachTask(function(task){ |
|
|
|
gantt.eachTask(function(task){ |
|
|
|
task.$open = toggleTasks == "Expand"; |
|
|
|
task.$open = toggleTasks == "Expand"; |
|
|
|
}); |
|
|
|
}); |
|
|
|
if (toggleTasks == "Expand") { |
|
|
|
if (toggleTasks == "Expand") { |
|
|
|
updateProperty({task_open:true}) |
|
|
|
updateProperty({task_open:true}) |
|
|
|
|
|
|
|
// console.log('to collapse');
|
|
|
|
toggleTasks = "Collapse"; |
|
|
|
toggleTasks = "Collapse"; |
|
|
|
$("#gantt_toggle_task_btn").prop('title', 'Collapse Activities'); |
|
|
|
$("#gantt_toggle_task_btn").prop('title', 'Collapse Activities'); |
|
|
|
$("#gantt_toggle_task_btn").children().removeClass('fa-expand-alt'); |
|
|
|
$("#gantt_toggle_task_btn").children().removeClass('fa-expand-alt'); |
|
|
|
$("#gantt_toggle_task_btn").children().addClass('fa-compress-alt'); // change icon to collapse
|
|
|
|
$("#gantt_toggle_task_btn").children().addClass('fa-compress-alt'); // change icon to collapse
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
// console.log('to expand');
|
|
|
|
updateProperty({task_open:false}) |
|
|
|
updateProperty({task_open:false}) |
|
|
|
toggleTasks = "Expand"; |
|
|
|
toggleTasks = "Expand"; |
|
|
|
$("#gantt_toggle_task_btn").prop('title', 'Expand Activities'); |
|
|
|
$("#gantt_toggle_task_btn").prop('title', 'Expand Activities'); |
|
|
@ -280,6 +312,7 @@ function getColumnsSelection(node){ |
|
|
|
var selectedColumns = node.querySelectorAll(":checked"); |
|
|
|
var selectedColumns = node.querySelectorAll(":checked"); |
|
|
|
var unselectedColumn = node.querySelectorAll('input[type="checkbox"]:not(:checked)'); |
|
|
|
var unselectedColumn = node.querySelectorAll('input[type="checkbox"]:not(:checked)'); |
|
|
|
// var allSelected = node.querySelector("#check-all").prop('checked');
|
|
|
|
// var allSelected = node.querySelector("#check-all").prop('checked');
|
|
|
|
|
|
|
|
// console.log("unselectedColumn", unselectedColumn)
|
|
|
|
var checkedColumns = {}; |
|
|
|
var checkedColumns = {}; |
|
|
|
selectedColumns.forEach(function(node){ |
|
|
|
selectedColumns.forEach(function(node){ |
|
|
|
checkedColumns[node.name] = true; |
|
|
|
checkedColumns[node.name] = true; |
|
|
@ -287,6 +320,7 @@ function getColumnsSelection(node){ |
|
|
|
unselectedColumn.forEach(function(node){ |
|
|
|
unselectedColumn.forEach(function(node){ |
|
|
|
checkedColumns[node.name] = false; |
|
|
|
checkedColumns[node.name] = false; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
// console.log("checkedColumns", checkedColumns)
|
|
|
|
return checkedColumns; |
|
|
|
return checkedColumns; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -370,6 +404,7 @@ async function setBaselineAPI() { |
|
|
|
.get(ACTIVITY_SET_BASELINE_URL, HEADER) |
|
|
|
.get(ACTIVITY_SET_BASELINE_URL, HEADER) |
|
|
|
.then(res => res) |
|
|
|
.then(res => res) |
|
|
|
.catch((error) => error.response); |
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
console.log('set baseline res', res); |
|
|
|
if (res && res.status === 200) { |
|
|
|
if (res && res.status === 200) { |
|
|
|
// $('#modal_gantt_setting').modal('hide');
|
|
|
|
// $('#modal_gantt_setting').modal('hide');
|
|
|
|
// gantt.alert("Settings updated");
|
|
|
|
// gantt.alert("Settings updated");
|
|
|
@ -425,6 +460,7 @@ async function setSynchronizeAPI() { |
|
|
|
.then(res => res) |
|
|
|
.then(res => res) |
|
|
|
.catch((error) => error.response); |
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log('synchronize res', res); |
|
|
|
if (res && res.status === 200) { |
|
|
|
if (res && res.status === 200) { |
|
|
|
// $('#modal_gantt_setting').modal('hide');
|
|
|
|
// $('#modal_gantt_setting').modal('hide');
|
|
|
|
// gantt.alert("Settings updated");
|
|
|
|
// gantt.alert("Settings updated");
|
|
|
|