|
|
|
@ -56,23 +56,45 @@ gantt.attachEvent("onBeforeTaskUpdate", function (id, new_item) {
|
|
|
|
|
let link = task.$target; |
|
|
|
|
// link.length > 0 -> successor
|
|
|
|
|
new_item['progress'] = progress; |
|
|
|
|
if (editEndDateTriggered) { |
|
|
|
|
if (editEndDateDurationTriggered) { |
|
|
|
|
if(link.length == 0){ |
|
|
|
|
new_item['start_date'].setHours(0,0,0); |
|
|
|
|
} |
|
|
|
|
new_item['duration'] = new_item['duration'] + (link.length == 0 ? 0 : 1); |
|
|
|
|
new_item['end_date'] = gantt.calculateEndDate({ |
|
|
|
|
start_date: new_item['start_date'], |
|
|
|
|
duration: new_item['duration'] |
|
|
|
|
}) |
|
|
|
|
new_item['end_date'].setHours(23, 59, 59); |
|
|
|
|
if (editDurationTriggered) { |
|
|
|
|
if (forceDurationUpdateTriggered) { |
|
|
|
|
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; |
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const dateToCheck = new Date(new_item['end_date']); |
|
|
|
|
if (gantt.isWorkTime({ date: dateToCheck, hours: false })) { |
|
|
|
|
} else { |
|
|
|
|
if (link.length == 0) { |
|
|
|
|
let duration = gantt.calculateDuration({ |
|
|
|
|
start_date: new_item['start_date'], |
|
|
|
|
end_date: new_item['end_date'] |
|
|
|
|
}) |
|
|
|
|
let endDate = gantt.calculateEndDate({ |
|
|
|
|
start_date: new_item['start_date'], |
|
|
|
|
duration: duration + 1 |
|
|
|
|
}) |
|
|
|
|
endDate.setDate(endDate.getDate() - 1) |
|
|
|
|
endDate.setHours(23,59,59); |
|
|
|
|
new_item['end_date'] = endDate |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
editEndDateTriggered = false; |
|
|
|
|
|
|
|
|
|
forceDurationUpdateTriggered = false; |
|
|
|
|
editEndDateDurationTriggered = false; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|