From 78e4fead49736d0f52a0649792a7d28a06987f3b Mon Sep 17 00:00:00 2001 From: Itprdev Date: Thu, 28 Nov 2019 16:12:45 +0200 Subject: [PATCH 1/3] 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 From fcf20215a69b870696ef140da7fd51b952ec8928 Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Wed, 11 Dec 2019 21:12:48 +0100 Subject: [PATCH 2/3] #552 Adding rendering test --- cypress/integration/rendering/gantt.spec.js | 16 ++++++++++++++ cypress/platform/current.html | 23 ++++++++++++++------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/cypress/integration/rendering/gantt.spec.js b/cypress/integration/rendering/gantt.spec.js index c1bdee040..027c893a7 100644 --- a/cypress/integration/rendering/gantt.spec.js +++ b/cypress/integration/rendering/gantt.spec.js @@ -38,4 +38,20 @@ describe('Sequencediagram', () => { {} ); }); + it('Multiple dependencies syntax', () => { + imgSnapshotTest( + ` + gantt + dateFormat YYYY-MM-DD + axisFormat %d/%m + title Adding GANTT diagram to mermaid + excludes weekdays 2014-01-10 + + apple :a, 2017-07-20, 1w + banana :crit, b, 2017-07-23, 1d + cherry :active, c, after b a, 1d + `, + {} + ); + }); }); diff --git a/cypress/platform/current.html b/cypress/platform/current.html index 283deff93..9e5267768 100644 --- a/cypress/platform/current.html +++ b/cypress/platform/current.html @@ -5,7 +5,7 @@ rel="stylesheet" />