Permalink
Browse files

[0.12.2] delete connection when deleting source model

  • Loading branch information...
dog-ears committed Feb 23, 2018
1 parent c6b7fa5 commit 579524ff6dfa637b522f0c1e9a6f313bddb662aa
Showing with 22 additions and 1 deletion.
  1. +7 −0 src/app/class/data.ts
  2. +4 −1 src/app/class/model.ts
  3. +11 −0 src/app/service/jsPlumb.service.ts
@@ -1,5 +1,6 @@
// class
import { Model } from './model';
import { Schema } from './schema';
export class Data {
@@ -32,4 +33,10 @@ export class Data {
public getModelByName(model_name:string): Model{
return this.models.filter( (v,i) => v.name===model_name )[0];
}
public getSchemaByElementId( schema_element_id:string ):Schema{
console.log('Data.getSchemaByElementId() is called!');
var ids = schema_element_id.replace('model','').split('-schema');
return this.getModelById( Number(ids[0]) ).getSchemaById( Number(ids[1]) );
}
}
@@ -34,5 +34,8 @@ export class Model {
public getElementH2Id(): string{
return "model" + this.id + "-h2";
}
public getSchemaById(schema_id:number): Schema{
return this.schemas.filter( (v,i)=> v.id===schema_id )[0];
}
}
@@ -67,6 +67,17 @@ export class JsPlumbService {
this._instance.selectEndpoints({
source: model.getElementH2Id()
}).delete();
//check connection exists as destroy-model source
var connections_to_delete = this._instance.getConnections({
source: model.getElementH2Id()
});
for( let i=0 ; i < connections_to_delete.length; i++){
var schema_to_delete = this.dataService.data.getSchemaByElementId( connections_to_delete[i].targetId );
this.dataService.deleteSchema( schema_to_delete );
}
}
public initSchema(schema:Schema){

0 comments on commit 579524f

Please sign in to comment.