Skip to content

Commit

Permalink
Merge branch 'issue-552' of https://github.com/itprdev/mermaid into i…
Browse files Browse the repository at this point in the history
…tprdev-issue-552
  • Loading branch information
knsv committed Dec 11, 2019
2 parents 1811318 + 78e4fea commit aa2f962
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/diagrams/gantt/ganttDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aa2f962

Please sign in to comment.