Browse Source

Fix duration

pull/1/head
Wahyu Ramadhan 1 year ago
parent
commit
778bb9f6d7
  1. 3
      edit-mode/function/ganttConfig.js
  2. 3
      edit-mode/function/ganttEvent.js
  3. 4
      edit-mode/function/restActivityLink.js

3
edit-mode/function/ganttConfig.js

@ -12,6 +12,7 @@ let actionHappen = false;
let activityName = "";
let token = getUrlParameter("token");
let editDurationTriggered = false;
let editEndDateTriggered = false;
if (!token || token == "") {
token = `eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvYXBpLWl1Lm9zcHJvLmlkXC9hcGlcL2xvZ2luIiwiaWF0IjoxNjQ2ODA3OTA4LCJleHAiOjE2NDY4OTQzMDgsIm5iZiI6MTY0NjgwNzkwOCwianRpIjoiNmdtcEx3cjlob1JFZ0hSNSIsInN1YiI6MSwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.1xB2rvTJ6Edf7l_8jRPOmoMYnf8f59Rd8jJghJ39xps`;
}
@ -150,6 +151,7 @@ gantt.config.editor_types.end_date = gantt.mixin({
},
get_value: function(id, column, node) {
var selectedValue = dateEditor.get_value.apply(this, [id, column, node]);
editEndDateTriggered = true;
return gantt.date.add(selectedValue, 1, "day");
},
}, dateEditor);
@ -158,6 +160,7 @@ 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]);
editEndDateTriggered = true;
if(old_value.duration == modifiedValue - 1){
editDurationTriggered = true;
return modifiedValue;

3
edit-mode/function/ganttEvent.js

@ -56,6 +56,7 @@ gantt.attachEvent("onBeforeTaskUpdate", function(id,new_item){
let link = task.$target;
// link.length > 0 -> successor
new_item['progress'] = progress;
if (editEndDateTriggered) {
new_item['duration'] = new_item['duration'] + (link.length == 0 ? 0 : 1);
new_item['end_date'] = gantt.calculateEndDate({
start_date: new_item['start_date'],
@ -71,6 +72,8 @@ gantt.attachEvent("onBeforeTaskUpdate", function(id,new_item){
new_item['end_date'].setHours(23, 59, 59);
editDurationTriggered = false;
}
editEndDateTriggered = false;
}
});
gantt.attachEvent("onAfterTaskDrag", function(id, mode, e){

4
edit-mode/function/restActivityLink.js

@ -162,6 +162,10 @@ var dp = gantt.createDataProcessor(function(entity, action, data, id) {
}
});
}
data['duration'] = gantt.calculateDuration({
start_date: new Date(data['start_date']),
end_date: new Date(data['end_date'])
});
data['geom'] = geom.find(obj => obj.activity_id == id)?.geom;
return gantt.ajax.put({
headers: {

Loading…
Cancel
Save