Merge pull request #12 from sgotti/tasksgraph_fix_parent_row
tasksgraphs: fix parent task row
This commit is contained in:
commit
f3e4306fa5
|
@ -205,12 +205,29 @@ export default {
|
||||||
return levelTasks;
|
return levelTasks;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let levelsTasks = function(tasks, startLevel) {
|
||||||
|
let levelTasks = [];
|
||||||
|
for (let task of tasks) {
|
||||||
|
if (task.level < startLevel) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
levelTasks.push(task);
|
||||||
|
}
|
||||||
|
return levelTasks;
|
||||||
|
};
|
||||||
|
|
||||||
let levelTasksByRow = function(tasks, level) {
|
let levelTasksByRow = function(tasks, level) {
|
||||||
return levelTasks(tasks, level).sort((a, b) =>
|
return levelTasks(tasks, level).sort((a, b) =>
|
||||||
a.row > b.row ? 1 : b.row > a.row ? -1 : 0
|
a.row > b.row ? 1 : b.row > a.row ? -1 : 0
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let levelsTasksByRow = function(tasks, startLevel) {
|
||||||
|
return levelsTasks(tasks, startLevel).sort((a, b) =>
|
||||||
|
a.row > b.row ? 1 : b.row > a.row ? -1 : 0
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
let levelFreeRow = function(tasks, level) {
|
let levelFreeRow = function(tasks, level) {
|
||||||
let rows = [];
|
let rows = [];
|
||||||
for (let task of tasks) {
|
for (let task of tasks) {
|
||||||
|
@ -254,7 +271,7 @@ export default {
|
||||||
let row = 0;
|
let row = 0;
|
||||||
// if not at the last level fetch parents by their childs
|
// if not at the last level fetch parents by their childs
|
||||||
if (l < maxlevel) {
|
if (l < maxlevel) {
|
||||||
for (let curTask of levelTasksByRow(graphTasks, l + 1)) {
|
for (let curTask of levelsTasksByRow(graphTasks, l + 1)) {
|
||||||
for (let depTaskID in curTask.depends) {
|
for (let depTaskID in curTask.depends) {
|
||||||
for (let parent of levelTasks(graphTasks, l)) {
|
for (let parent of levelTasks(graphTasks, l)) {
|
||||||
if (seenTasks.has(parent.id)) {
|
if (seenTasks.has(parent.id)) {
|
||||||
|
@ -266,7 +283,7 @@ export default {
|
||||||
let maxChildLevel = taskMaxChildLevel(graphTasks, parent);
|
let maxChildLevel = taskMaxChildLevel(graphTasks, parent);
|
||||||
if (maxChildLevel > parent.level + 1) {
|
if (maxChildLevel > parent.level + 1) {
|
||||||
// put parent in a row greater than the max row the next levels until the child level
|
// put parent in a row greater than the max row the next levels until the child level
|
||||||
let mrow = levelsMaxRow(graphTasks, maxChildLevel) + 1;
|
let mrow = levelsMaxRow(graphTasks, maxChildLevel - 1) + 1;
|
||||||
parent.row = mrow;
|
parent.row = mrow;
|
||||||
row = mrow + 1;
|
row = mrow + 1;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue