diff --git a/edit-mode/function/function.js b/edit-mode/function/function.js index dde69da..68cb96d 100644 --- a/edit-mode/function/function.js +++ b/edit-mode/function/function.js @@ -716,8 +716,25 @@ function updateLinksLag(data) { if (link.target == task.id) { let predecessor = data.data.find(item => item.id == link.source); if (predecessor) { - let lag = gantt.calculateDuration(new Date(predecessor.end_date), new Date(task.start_date)); - if (link.type == "0" && isBaselineSet) { + let lag; + if (isBaselineSet) { + switch (link.type) { + case "0": + lag = gantt.calculateDuration(new Date(predecessor.end_date), new Date(task.start_date)); + break; + case "1": + lag = gantt.calculateDuration(new Date(predecessor.start_date), new Date(task.start_date)); + break; + case "2": + lag = gantt.calculateDuration(new Date(predecessor.end_date), new Date(task.end_date)); + break; + case "3": + lag = gantt.calculateDuration(new Date(predecessor.start_date), new Date(task.end_date)); + break; + default: + // Handle an unknown link type if needed + break; + } link.lag = lag; } }