diff --git a/package.json b/package.json index fb135cf..0e371c3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "LiteRyzJS/Project", - "version": "0.2.0.256", + "version": "0.2.0.508", "devDependencies": { "css-loader": "^7.1.2", "sass": "^1.77.8", diff --git a/src/project/project.js b/src/project/project.js index 9529a36..600967f 100644 --- a/src/project/project.js +++ b/src/project/project.js @@ -9,7 +9,7 @@ class Project { const a = this; const _options = Object.assign(a.DefaultOptions, options); - a.Debug = false; + a.Debug = true; a.Project = _options; a.Tasks = []; } @@ -190,19 +190,18 @@ class Project { a.Sort(); // Get flat references - let result = a.Tasks.flatten("Tasks"); + let allTasks = a.Tasks.flatten("Tasks"); // Reset calculated values - for (var i=0; i { - if (e.FinishDate > node2FinishDate) { - node2FinishDate = e.FinishDate; + a.#log("> Set StartDate from Predecessor"); + } + } + } else if (task.CollatedTaskID != null) { + const groupTask = allTasks.first("ID", task.CollatedTaskID); + if (groupTask != null) { + if (groupTask.StartDate != null) { + task.StartDate = Date.addDays(groupTask.StartDate, task.StartDelay); + + a.#log("> Set StartDate from Group"); + } + } + } else { + task.StartDate = Date.addDays(a.Project.StartDate, task.StartDelay); + + a.#log("> Set StartDate from Project"); } - }); - array[index].Progress = Math.average(node2.toList("Progress")); - array[index].FinishDate = new Date(node2FinishDate); - array[index].Duration = Date.diffDays(array[index].StartDate, array[index].FinishDate); + // if (task.IsCollated) { + if (task.Tasks.length > 0) { + a.#recalculateTask(allTasks, task.Tasks); + + a.#log("> Calc inner"); + } + // } + + if (task.StartDate != null) { + if (task.IsCollated) { + + const childTasks = task.Tasks.select("CollatedTaskID", task.ID); + if (childTasks.length <= 0) { + task.FinishDate = task.StartDate; + task.Duration = 0; + + a.#log("> Set FinishDate from Group (0)"); + } else { + + if (!childTasks.any("FinishDate", null)) { + task.FinishDate = childTasks.orderByDesc("FinishDate")[0].FinishDate; + task.Duration = Date.diffDays(task.StartDate, task.FinishDate); + + a.#log("> Set FinishDate from Group"); + } + } + + } else { + task.FinishDate = Date.addDays(task.StartDate, task.Duration); + + a.#log("> Set FinishDate"); + } + } + + } } #sortNode(node) {