diff --git a/src/diagrams/gantt/ganttDb.js b/src/diagrams/gantt/ganttDb.js index 3f4328c1c..adf8304a6 100644 --- a/src/diagrams/gantt/ganttDb.js +++ b/src/diagrams/gantt/ganttDb.js @@ -158,30 +158,8 @@ const compileData = function (prevTask, dataStr) { const task = {} // Get tags like active, done, crit and milestone - let matchFound = true - while (matchFound) { - matchFound = false - if (data[0].match(/^\s*active\s*$/)) { - task.active = true - data.shift(1) - matchFound = true - } - if (data[0].match(/^\s*done\s*$/)) { - task.done = true - data.shift(1) - matchFound = true - } - if (data[0].match(/^\s*crit\s*$/)) { - task.crit = true - data.shift(1) - matchFound = true - } - if (data[0].match(/^\s*milestone\s*$/)) { - task.milestone = true - data.shift(1) - matchFound = true - } - } + getTaskTags(data, task) + for (let i = 0; i < data.length; i++) { data[i] = data[i].trim() } @@ -221,30 +199,8 @@ const parseData = function (prevTaskId, dataStr) { const task = {} // Get tags like active, done, crit and milestone - let matchFound = true - while (matchFound) { - matchFound = false - if (data[0].match(/^\s*active\s*$/)) { - task.active = true - data.shift(1) - matchFound = true - } - if (data[0].match(/^\s*done\s*$/)) { - task.done = true - data.shift(1) - matchFound = true - } - if (data[0].match(/^\s*crit\s*$/)) { - task.crit = true - data.shift(1) - matchFound = true - } - if (data[0].match(/^\s*milestone\s*$/)) { - task.milestone = true - data.shift(1) - matchFound = true - } - } + getTaskTags(data, task) + for (let i = 0; i < data.length; i++) { data[i] = data[i].trim() } @@ -373,3 +329,30 @@ export default { findTaskById, addTaskOrg } + +function getTaskTags (data, task) { + let matchFound = true + while (matchFound) { + matchFound = false + if (data[0].match(/^\s*active\s*$/)) { + task.active = true + data.shift(1) + matchFound = true + } + if (data[0].match(/^\s*done\s*$/)) { + task.done = true + data.shift(1) + matchFound = true + } + if (data[0].match(/^\s*crit\s*$/)) { + task.crit = true + data.shift(1) + matchFound = true + } + if (data[0].match(/^\s*milestone\s*$/)) { + task.milestone = true + data.shift(1) + matchFound = true + } + } +}