Browse Source

fix date range

pull/1/head
wahyu 1 year ago
parent
commit
7bf1731fb1
  1. 12
      edit-mode/function/ganttEvent.js

12
edit-mode/function/ganttEvent.js

@ -10,6 +10,7 @@ gantt.attachEvent("onAfterTaskAdd", function (id, item) {
gantt.updateTask(parentId); gantt.updateTask(parentId);
} }
} }
updateRange();
}); });
gantt.attachEvent("onTaskRowClick", function (id, row) { gantt.attachEvent("onTaskRowClick", function (id, row) {
@ -40,7 +41,16 @@ gantt.ext.inlineEditors.attachEvent("onBeforeEditStart", function (state) {
} }
return true return true
}); });
function updateRange(){
var range = gantt.getSubtaskDates();
var chart = gantt.getState();
if(range.start_date.valueOf() <= chart.min_date.valueOf() || range.end_date.valueOf() >= chart.max_date.valueOf()){
gantt.config.start_date = gantt.date.add(range.start_date, -1, "day");
gantt.config.end_date = gantt.date.add(range.end_date, 2, "day");
gantt.render();
}
}
gantt.attachEvent("onAfterTaskUpdate", updateRange);
gantt.attachEvent("onBeforeTaskUpdate", function (id, new_item) { gantt.attachEvent("onBeforeTaskUpdate", function (id, new_item) {
// format progress // format progress
let progress = new_item.progress; let progress = new_item.progress;

Loading…
Cancel
Save