Skip to content
This repository has been archived by the owner on Mar 11, 2023. It is now read-only.

Commit

Permalink
delete communication dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mkuo005 committed Mar 29, 2021
1 parent 2ae1410 commit 0c85299
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions sources/model/ls.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Model {
constructor() { }

get modelTask() {
this._modelTask.registerModelDependency(this._modelDependency);
return this._modelTask;
}

Expand Down
24 changes: 20 additions & 4 deletions sources/model/ls.model.task.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class ModelTask {
updateTasks = null; // Callback to function in ls.view.task
updateDependencySelectors = null; // Callback to function in ls.view.dependency
updateConstraintSelectors = null; // Callback to function in ls.view.constraint
modelDependency = null;
database = null;

constructor() { }
Expand All @@ -24,6 +25,9 @@ class ModelTask {
this.updateConstraintSelectors = callback;
}

registerModelDependency(modelDependency) {
this.modelDependency = modelDependency;
}

// -----------------------------------------------------
// Registration of model database
Expand All @@ -49,10 +53,22 @@ class ModelTask {

deleteTask(name) {
// TODO: Delete associated communication dependencies
this.database.deleteTask(name)
.then(this.database.deleteTaskInstances(name))
.then(result => this.getAllTasks())
.then(result => { this.updateTasks(result); this.updateDependencySelectors(result) });
this.database.getAllDependencies().then(
result => {
console.log(result);
for (let i in result) {
let dependency = result[i];
console.log(dependency);
if (dependency.destination.task == name || dependency.source.task == name) {
this.modelDependency.deleteDependency(dependency.name);
}
}
}
)
.then (this.database.deleteTask(name))
.then(this.database.deleteTaskInstances(name))
.then(result => this.getAllTasks())
.then(result => { this.updateTasks(result); this.updateDependencySelectors(result) })
}

toString() {
Expand Down

0 comments on commit 0c85299

Please sign in to comment.