Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

Commit

Permalink
fix(dependencies): remove dependencies fromTask model on remove event.
Browse files Browse the repository at this point in the history
Close #585
  • Loading branch information
jluis.cabrera authored and Toilal committed Oct 6, 2016
1 parent e7d0e44 commit 890085c
Show file tree
Hide file tree
Showing 6 changed files with 184 additions and 48 deletions.
58 changes: 46 additions & 12 deletions assets/angular-gantt-dependencies-plugin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 46 additions & 12 deletions assets/angular-gantt-plugins.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 46 additions & 12 deletions demo/dist/scripts/vendor.js
Original file line number Diff line number Diff line change
Expand Up @@ -53861,7 +53861,7 @@ Github: https://github.com/angular-gantt/angular-gantt.git
});

api.tasks.on.add(scope, function(task) {
manager.addDependenciesFromTask(task);
manager.addDependenciesFromTask(task, true);
});

api.tasks.on.remove(scope, function(task) {
Expand Down Expand Up @@ -53910,7 +53910,21 @@ Github: https://github.com/angular-gantt/angular-gantt.git

api.dependencies.on.remove(scope, function(dependency) {
if (scope.conflictChecker && scope.enabled) {
checker.refresh([dependency.getFromTask(), dependency.getToTask()]);
var fromTask = dependency.getFromTask();
var toTask = dependency.getToTask();

if (fromTask && toTask) {
checker.refresh([fromTask, toTask]);
} else {

if (fromTask) {
checker.removeConflictClass(fromTask);
} else {
checker.removeConflictClass(toTask);
}

}

}
});

Expand Down Expand Up @@ -55402,6 +55416,10 @@ Github: https://github.com/angular-gantt/angular-gantt.git
handleTaskNonConflict(conflictsList, allTasks);
};

this.removeConflictClass = function(task) {
task.$element.removeClass('gantt-task-conflict');
};

/**
* Remove the conflict status of given tasks.
*
Expand Down Expand Up @@ -55601,8 +55619,9 @@ Github: https://github.com/angular-gantt/angular-gantt.git
* Add all dependencies defined from a task. Dependencies will be added only if plugin is enabled.
*
* @param task
* @param allowPartial if true, dependency linking to a missing task will still be added.
*/
this.addDependenciesFromTask = function(task) {
this.addDependenciesFromTask = function(task, allowPartial) {
if (this.pluginScope.enabled) {
var taskDependencies = task.model.dependencies;

Expand All @@ -55613,8 +55632,10 @@ Github: https://github.com/angular-gantt/angular-gantt.git
}

for (var i = 0, l = taskDependencies.length; i < l; i++) {
var dependency = self.addDependency(task, taskDependencies[i]);
dependency.connect();
var dependency = self.addDependency(task, taskDependencies[i], allowPartial);
if (dependency) {
dependency.connect();
}
}
}
}
Expand Down Expand Up @@ -55644,12 +55665,15 @@ Github: https://github.com/angular-gantt/angular-gantt.git
*
* @param task Task defining the dependency.
* @param model Model object for the dependency.
* @param allowPartial if true, dependency linking to a missing task will still be added.
*/
this.addDependency = function(task, model) {
this.addDependency = function(task, model, allowPartial) {
var dependency = new Dependency(this, task, model);

var fromTaskId = dependency.getFromTaskId();
var fromTask = dependency.getFromTask();
var toTaskId = dependency.getToTaskId();
var toTask = dependency.getToTask();
var manager = dependency.manager;

if (!(fromTaskId in this.dependenciesFrom)) {
this.dependenciesFrom[fromTaskId] = [];
Expand All @@ -55658,14 +55682,24 @@ Github: https://github.com/angular-gantt/angular-gantt.git
this.dependenciesTo[toTaskId] = [];
}

if (fromTaskId) {
this.dependenciesFrom[fromTaskId].push(dependency);
}
if (!allowPartial && (!toTask || !fromTask)) {
// Partial dependency is not allowed, remove it.
this.removeDependency(dependency, true);

manager.api.dependencies.raise.remove(dependency);

if (toTaskId) {
this.dependenciesTo[toTaskId].push(dependency);
return null;
} else {
if (fromTaskId) {
this.dependenciesFrom[fromTaskId].push(dependency);
}

if (toTaskId) {
this.dependenciesTo[toTaskId].push(dependency);
}
}


return dependency;
};

Expand Down
18 changes: 16 additions & 2 deletions src/plugins/dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
});

api.tasks.on.add(scope, function(task) {
manager.addDependenciesFromTask(task);
manager.addDependenciesFromTask(task, true);
});

api.tasks.on.remove(scope, function(task) {
Expand Down Expand Up @@ -190,7 +190,21 @@

api.dependencies.on.remove(scope, function(dependency) {
if (scope.conflictChecker && scope.enabled) {
checker.refresh([dependency.getFromTask(), dependency.getToTask()]);
var fromTask = dependency.getFromTask();
var toTask = dependency.getToTask();

if (fromTask && toTask) {
checker.refresh([fromTask, toTask]);
} else {

if (fromTask) {
checker.removeConflictClass(fromTask);
} else {
checker.removeConflictClass(toTask);
}

}

}
});

Expand Down
4 changes: 4 additions & 0 deletions src/plugins/dependencies/dependenciesChecker.factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
handleTaskNonConflict(conflictsList, allTasks);
};

this.removeConflictClass = function(task) {
task.$element.removeClass('gantt-task-conflict');
};

/**
* Remove the conflict status of given tasks.
*
Expand Down

0 comments on commit 890085c

Please sign in to comment.