From 78e4fead49736d0f52a0649792a7d28a06987f3b Mon Sep 17 00:00:00 2001 From: Itprdev Date: Thu, 28 Nov 2019 16:12:45 +0200 Subject: [PATCH] Feature request 552. Gnatt chart task with multiple dependencies --- src/diagrams/gantt/ganttDb.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/diagrams/gantt/ganttDb.js b/src/diagrams/gantt/ganttDb.js index 90f5066a0..c5b266414 100644 --- a/src/diagrams/gantt/ganttDb.js +++ b/src/diagrams/gantt/ganttDb.js @@ -134,18 +134,32 @@ const getStartDate = function(prevTime, dateFormat, str) { str = str.trim(); // Test for after - const re = /^after\s+([\d\w-]+)/; + const re = /^after\s+([\d\w- ]+)/; const afterStatement = re.exec(str.trim()); if (afterStatement !== null) { - const task = findTaskById(afterStatement[1]); + // check all after ids and take the latest + let latestEndingTask = null; + afterStatement[1].split(' ').forEach(function(id) { + let task = findTaskById(id); + if (typeof task !== 'undefined') { + if (!latestEndingTask) { + latestEndingTask = task; + } else { + if (task.endTime > latestEndingTask.endTime) { + latestEndingTask = task; + } + } + } + }); - if (typeof task === 'undefined') { + if (!latestEndingTask) { const dt = new Date(); dt.setHours(0, 0, 0, 0); return dt; + } else { + return latestEndingTask.endTime; } - return task.endTime; } // Check for actual date set