You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need help in dependency task. I am not able to draw line to show depended task.
I need help in this line var sup = this.tasks[parseInt(supStr)-1]; how we are subtract please help me.
of this function GanttMaster.prototype.updateLinks in ganttmaster file.
GanttMaster.prototype.updateLinks = function (task) {
//console.debug("updateLinks",task);
//var prof= new Profiler("gm_updateLinks");
// defines isLoop function
function isLoop(task, target, visited) {
//var prof= new Profiler("gm_isLoop");
//console.debug("isLoop :"+task.name+" - "+target.name);
if (target == task) {
return true;
}
var sups = task.getSuperiors();
//my parent' superiors are my superiors too
var p = task.getParent();
while (p) {
sups = sups.concat(p.getSuperiors());
p = p.getParent();
}
//my children superiors are my superiors too
var chs = task.getChildren();
for (var i = 0; i < chs.length; i++) {
sups = sups.concat(chs[i].getSuperiors());
}
var loop = false;
//check superiors
for (var i = 0; i < sups.length; i++) {
var supLink = sups[i];
if (supLink.from == target) {
loop = true;
break;
} else {
if (visited.indexOf(supLink.from.id + "x" + target.id) <= 0) {
visited.push(supLink.from.id + "x" + target.id);
if (isLoop(supLink.from, target, visited)) {
loop = true;
break;
}
}
}
}
//check target parent
var tpar = target.getParent();
if (tpar) {
if (visited.indexOf(task.id + "x" + tpar.id) <= 0) {
visited.push(task.id + "x" + tpar.id);
if (isLoop(task, tpar, visited)) {
loop = true;
}
}
}
//prof.stop();
return loop;
var todoOk = true;
if (task.depends) {
//cannot depend from an ancestor
var parents = task.getParents();
//cannot depend from descendants
var descendants = task.getDescendant();
var deps = task.depends.split(",");
var newDepsString = "";
var visited = [];
var depsEqualCheck = [];
console.log('deps.length', deps.length);
console.log('deps', deps);
for (var j = 0; j < deps.length; j++) {
var depString = deps[j]; // in the form of row(lag) e.g. 2:3,3:4,5
var supStr =depString;
var lag = 0;
var pos = depString.indexOf(":");
if (pos>0){
supStr=depString.substr(0,pos);
var lagStr=depString.substr(pos+1);
lag=Math.ceil((stringToDuration(lagStr)) / Date.workingPeriodResolution) * Date.workingPeriodResolution;
}
var sup = this.tasks[parseInt(supStr)-1];
console.log('this.tasks', this.tasks);
console.log('[parseInt(supStr)-1]', [parseInt(supStr)-1]);
if (sup) {
if (parents && parents.indexOf(sup) >= 0) {
this.setErrorOnTransaction("\""+task.name + "\"\n" + GanttMaster.messages.CANNOT_DEPENDS_ON_ANCESTORS + "\n\"" + sup.name+"\"");
todoOk = false;
} else if (descendants && descendants.indexOf(sup) >= 0) {
this.setErrorOnTransaction("\""+task.name + "\"\n" + GanttMaster.messages.CANNOT_DEPENDS_ON_DESCENDANTS + "\n\"" + sup.name+"\"");
todoOk = false;
} else if (isLoop(sup, task, visited)) {
todoOk = false;
this.setErrorOnTransaction(GanttMaster.messages.CIRCULAR_REFERENCE + "\n\"" + task.id +" - "+ task.name + "\" -> \"" + sup.id +" - "+sup.name+"\"");
} else if(depsEqualCheck.indexOf(sup)>=0) {
this.setErrorOnTransaction(GanttMaster.messages.CANNOT_CREATE_SAME_LINK + "\n\"" + sup.name+"\" -> \""+task.name+"\"");
todoOk = false;
} else {
this.links.push(new Link(sup, task, lag));
newDepsString = newDepsString + (newDepsString.length > 0 ? "," : "") + supStr+(lag==0?"":":"+durationToString(lag));
}
if (todoOk)
depsEqualCheck.push(sup);
}
}
task.depends = newDepsString;
}
//prof.stop();
return todoOk;
};
The text was updated successfully, but these errors were encountered:
Hi ,
I need help in dependency task. I am not able to draw line to show depended task.
I need help in this line var sup = this.tasks[parseInt(supStr)-1]; how we are subtract please help me.
of this function GanttMaster.prototype.updateLinks in ganttmaster file.
GanttMaster.prototype.updateLinks = function (task) {
//console.debug("updateLinks",task);
//var prof= new Profiler("gm_updateLinks");
// defines isLoop function
function isLoop(task, target, visited) {
//var prof= new Profiler("gm_isLoop");
//console.debug("isLoop :"+task.name+" - "+target.name);
if (target == task) {
return true;
}
}
//remove my depends
this.links = this.links.filter(function (link) {
return link.to != task;
});
var todoOk = true;
if (task.depends) {
//cannot depend from an ancestor
var parents = task.getParents();
//cannot depend from descendants
var descendants = task.getDescendant();
}
//prof.stop();
return todoOk;
};
The text was updated successfully, but these errors were encountered: