Browse Source

remove unused codes

pull/1/head
Muhammad Sulaiman Yusuf 2 years ago
parent
commit
b8b55535d7
  1. 2
      edit-mode/function/ganttEvent.js
  2. 83
      edit-mode/function/ganttSettings.js

2
edit-mode/function/ganttEvent.js

@ -13,7 +13,7 @@ gantt.attachEvent("onAfterTaskAdd", function(id,item){
gantt.attachEvent("onTaskRowClick", function(id,row){
activityId = id;
var activity = gantt.getTaskBy("id", id);
activityName = activity[0].name;
activityName = activity[0]?.name;
});
gantt.ext.inlineEditors.attachEvent("onBeforeEditStart", function(state){

83
edit-mode/function/ganttSettings.js

@ -58,12 +58,9 @@ $(document).ready(function() {
.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;
@ -71,106 +68,50 @@ $(document).ready(function() {
var config_dayoff_arr = config_dayoff.split(',');
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 {
// default
// console.log('default');
// $('#select_dayoff option[value="0"]').prop("selected", "selected"); // Sunday
// $('#select_dayoff option[value="6"]').prop("selected", "selected"); // Saturday
// $("#select_dayoff").choices.setValue([0, 6]);
selectDayOffChoices.setChoiceByValue('0');
selectDayOffChoices.setChoiceByValue('6');
}
}
}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');
});
// $('#gantt_setting_btn').on('click', async function() {
// $('#modal_gantt_setting').modal('show');
// // $('#')
// });
$('#btn_save_setting').on('click', async function() {
// arr.forEach(function (element, key) {
// $('#choices-multiple-remove-button3').append(`<option value="${element.id}">${element.name}</option>`)
// });
// var days = [0,1,2,3,4,5,6]; // Sunday -> Saturday
// for (var i=0; i < days.length; i++) {
// gantt.unsetWorkTime({ day:days[i], hours:false });
// }
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});
}
// gantt.unsetWorkTime({day: 0, hours: false});
// gantt.unsetWorkTime({day: 1, hours: false});
// gantt.unsetWorkTime({day: 2, hours: false});
// gantt.unsetWorkTime({day: 3, hours: false});
// gantt.unsetWorkTime({day: 4, hours: false});
// gantt.unsetWorkTime({day: 5, hours: false});
// gantt.unsetWorkTime({day: 6, hours: false});
// gantt.setWorkTime({hours: ["8:00-17:00"]});//global working hours
// gantt.setWorkTime({day: 2, hours: false});// make Tuesdays day-off
// if (workdays.length > 0) {
// for (var i=0; i < workdays.length; i++) {
// gantt.setWorkTime({ day:workdays[i], hours:false });
// }
// }
// 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 });
}
}
// else if (dayoff.length < 1) {
// // work everyday
// for (var i=0; i < days.length; i++) {
// gantt.unsetWorkTime({day: days[i], hours: false});
// }
// }
// saveSettings()
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");
gantt.message("Settings updated");
}
else {
@ -185,10 +126,6 @@ $(document).ready(function() {
toggleCollapseTasks();
});
// $("#gantt_toggle_columns_btn").on('click', function(event) {
// toggleColumns();
// })
$("#gantt-baseline").on('click', function(event) {
setBaseline();
});
@ -217,39 +154,26 @@ 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");
var a = moment(val.date);
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)
console.log("holiday", holiday);
gantt.setWorkTime({
date: holiday,
hours: false
});
}
// let holiday = new Date(day);
// gantt.setWorkTime({
// date: holiday,
// hours: false
// });
});
gantt.render();
},
error: function (data) {
}
});
}
async function initGanttSettings() {
console.log('initGanttSettings');
// if zoom is day
$("#scale1").attr('checked', true);
// toggleCollapseTasks();
// init to gantt chart view (holidays)
const result = await axiosInstance
@ -263,7 +187,6 @@ async function initGanttSettings() {
if(config_dayoff && config_dayoff.length > 0){
dayoff = config_dayoff.split(',');
}
// var dayoff = config_dayoff.split(',');
// reset the dayoff first
for (var i=0; i < days.length; i++) {

Loading…
Cancel
Save