Browse Source

Fix duration

pull/1/head
Wahyu Ramadhan 1 year ago
parent
commit
c41c8d98ff
  1. 16
      edit-mode/function/ganttConfig.js
  2. 6
      edit-mode/function/ganttEvent.js
  3. 25
      edit-mode/function/restActivityLink.js

16
edit-mode/function/ganttConfig.js

@ -152,6 +152,13 @@ gantt.config.editor_types.end_date = gantt.mixin({
return gantt.date.add(selectedValue, 1, "day");
},
}, dateEditor);
var durationEditor = gantt.config.editor_types.duration;
gantt.config.editor_types.duration = gantt.mixin({
get_value: function(id, column, node) {
var modifiedValue = durationEditor.get_value.apply(this, [id, column, node]);
return modifiedValue - 1;
},
}, durationEditor);
const editor = {
text: { type: "text", map_to: "text" },
@ -493,6 +500,15 @@ gantt.templates.task_end_date = function(date){
return gantt.templates.task_date(new Date(date.valueOf() - 1));
};
var gridDateToStr = gantt.date.date_to_str("%Y-%m-%d");
gantt.templates.grid_date_format = function(date, column){
if(column === "end_date"){
return gridDateToStr(new Date(date.valueOf() - 1));
}else{
return gridDateToStr(date);
}
}
gantt.templates.rightside_text = function (start, end, task) {
if (task.planned_end) {
if (end.getTime() > task.planned_end.getTime()) {

6
edit-mode/function/ganttEvent.js

@ -54,11 +54,7 @@ gantt.attachEvent("onBeforeTaskUpdate", function(id,new_item){
progress = progress/100;
new_item['progress'] = progress;
new_item['end_date'].setHours(23,59,59);
let newDuration = gantt.calculateDuration({
start_date: new_item['start_date'],
end_date: new_item['end_date']
})
new_item['duration'] = newDuration;
new_item['duration'] += 1;
});
gantt.attachEvent("onAfterTaskDrag", function(id, mode, e){

25
edit-mode/function/restActivityLink.js

@ -23,15 +23,6 @@ gantt.ajax.get({
gantt.parse(data);
});
if (Date.now() < timestamp) {
expandTask();
var allTasks = [];
var taskCount = gantt.getTaskCount();
for (var i = 0; i < taskCount; i++) {
var task = gantt.getTaskByIndex(i);
allTasks.push(task);
}
gantt.ajax.post({
headers: {
"Content-Type": "application/json",
@ -134,12 +125,6 @@ var dp = gantt.createDataProcessor(function(entity, action, data, id) {
let startDate = moment(data.start_date, "YYYY-MM-DD");
// data['start_date'] = startDate.format("YYYY-MM-DD")+" 00:00:00+07";
let endDate = moment(data.end_date, "YYYY-MM-DD");
data['end_date'] = endDate.format("YYYY-MM-DD")+" 23:59:59+07";
let newDuration = gantt.calculateDuration({
start_date: new Date(data['start_date']),
end_date: new Date(data['end_date'])
})
data['duration'] = newDuration;
if(startDate > endDate){
gantt.alert({
@ -176,11 +161,13 @@ var dp = gantt.createDataProcessor(function(entity, action, data, id) {
let responseText = JSON.parse(response.responseText)
let resData = responseText
let updateBobot = resData.update_bobot || false
if(parent && parent > 0){
if (updateBobot) {
if (parent && parent > 0) {
updateActivity(parent);
}
if(updateBobot){
refresData(id);
}
refresData(id);
} else if (parent && parent > 0) {
updateActivity(parent);
}
}
});

Loading…
Cancel
Save