Browse Source

Fix duration editor

pull/1/head
Wahyu Ramadhan 1 year ago
parent
commit
82f32b4343
  1. 6
      edit-mode/function/ganttConfig.js
  2. 11
      edit-mode/function/ganttEvent.js

6
edit-mode/function/ganttConfig.js

@ -11,6 +11,7 @@ let activityId = 0;
let actionHappen = false;
let activityName = "";
let token = getUrlParameter("token");
let editDurationTriggered = false;
if (!token || token == "") {
token = `eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvYXBpLWl1Lm9zcHJvLmlkXC9hcGlcL2xvZ2luIiwiaWF0IjoxNjQ2ODA3OTA4LCJleHAiOjE2NDY4OTQzMDgsIm5iZiI6MTY0NjgwNzkwOCwianRpIjoiNmdtcEx3cjlob1JFZ0hSNSIsInN1YiI6MSwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.1xB2rvTJ6Edf7l_8jRPOmoMYnf8f59Rd8jJghJ39xps`;
}
@ -155,7 +156,12 @@ gantt.config.editor_types.end_date = gantt.mixin({
var durationEditor = gantt.config.editor_types.duration;
gantt.config.editor_types.duration = gantt.mixin({
get_value: function(id, column, node) {
var old_value = gantt.getTask(id);
var modifiedValue = durationEditor.get_value.apply(this, [id, column, node]);
if(old_value.duration == modifiedValue - 1){
editDurationTriggered = true;
return modifiedValue;
}
return modifiedValue - 1;
},
}, durationEditor);

11
edit-mode/function/ganttEvent.js

@ -57,7 +57,16 @@ gantt.attachEvent("onBeforeTaskUpdate", function(id,new_item){
new_item['duration'] = gantt.calculateDuration({
start_date: new_item['start_date'],
end_date: new_item['end_date']
})
});
if (editDurationTriggered) {
let tempDuration = new_item['duration'] - 1;
new_item['end_date'] = gantt.calculateEndDate({
start_date: new_item['start_date'],
duration: tempDuration
})
new_item['end_date'].setHours(23,59,59);
editDurationTriggered = false;
}
});
gantt.attachEvent("onAfterTaskDrag", function(id, mode, e){

Loading…
Cancel
Save