[INFO REQ] Gantt - Successor task to obey percentDone
Posted: Thu Oct 06, 2022 10:58 am
by kmehmedov@iboris.eu
Hello, I hope this is the correct section to post this question.
I need to restrict the ability of a task to change its percentDone to greater than 0 if its predecessors percentDone is not 100. In other words - task can not be started if it`s predecessor is not "done".
Is this kind of behavior supported out of the box by the scheduling engine? If not - could it be included with a custom mixin ?
Thanks in advance.
Re: [INFO REQ] Gantt - Successor task to obey percentDone
Posted: Thu Oct 06, 2022 1:09 pm
by arcady
There is no such logic out of the box unfortunately.
This can be achieved by overriding TaskModelcalculatePercentDone method. Something like this:
class Task extends TaskModel {
* calculatePercentDone() {
const defaultValue = yield * super.calculatePercentDone();
let predecessorsAreDone = true;
for (const dependency of (yield this.$.incomingDeps)) {
const fromEvent = yield dependency.$.fromEvent;
predecessorsAreDone = (yield fromEvent.$.percentDone) === 100 & predecessorsAreDone;
}
if (!predecessorsAreDone) {
return 0;
}
return defaultValue;
}
}
It does what you want but this is not the final/polished code of course.
As bare minimum it must also take task inactive and dependency active field states into account.
Re: [INFO REQ] Gantt - Successor task to obey percentDone
Posted: Thu Oct 06, 2022 2:29 pm
by kmehmedov@iboris.eu
Thanks for the reply and the code snippet.
I will try to implement the checks on Project level with a message popping up if conflict occurs.