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