Dependency re-work. Workaround JointJS removeAttr bug

This commit is contained in:
BoykoAlex
2018-09-07 20:11:53 -04:00
parent 5d7f8929fb
commit 6655697fca
4 changed files with 21 additions and 13 deletions

View File

@@ -44,16 +44,10 @@
"postinstall": "postinstall-build --only-as-dependency dist \"npm run build && node postinstall.js\""
},
"dependencies": {
"@types/codemirror": "0.0.45",
"@types/lodash": "4.14.110",
"@types/backbone": "1.3.42",
"@types/jquery": "3.3.4",
"codemirror": "5.28.0",
"jointjs": "2.1.3",
"lodash": "3.10.1",
"jquery": "3.1.1",
"codemirror": "5.40.0",
"jointjs": "2.1.4",
"ts-disposables": "2.2.3",
"postinstall-build": "5.0.1"
"postinstall-build": "5.0.3"
},
"peerDependencies": {
"@angular/core": ">=6.0.0 <7.0.0",
@@ -128,6 +122,7 @@
"@types/codemirror",
"@types/lodash",
"@types/backbone",
"@types/jquery",
"@types/jasmine",
"@types/node",
"codemirror",

View File

@@ -430,11 +430,14 @@ export class EditorComponent implements OnInit, OnDestroy {
link.attr('.marker-vertices/display', 'none');
link.attr('.connection-wrap/display', 'none');
} else {
link.removeAttr('.link-tools/display');
// link.removeAttr('.link-tools/display');
Flo.removeAttr(link, '.link-tools/display');
if (this.editor && this.editor.allowLinkVertexEdit) {
link.removeAttr('.marker-vertices/display');
// link.removeAttr('.marker-vertices/display');
Flo.removeAttr(link, '.marker-vertices/display');
}
link.removeAttr('.connection-wrap/display');
// link.removeAttr('.connection-wrap/display');
Flo.removeAttr(link, '.connection-wrap/display');
}
});
}

View File

@@ -238,6 +238,14 @@ export namespace Flo {
}
}
export function removeAttr(cell: dia.Cell, attr: string) {
// Bug in JointJS removeAttr() kills all ES6 objects
const idx = attr.lastIndexOf('/');
const propertyConatiner = idx < 0 ? cell.attributes.attrs : cell.attr(attr.substring(0, idx));
const key = idx < 0 ? attr : attr.substr(idx + 1);
delete propertyConatiner[key];
}
}

View File

@@ -248,7 +248,9 @@ export namespace Properties {
if (currentValue !== undefined && currentValue !== null) {
// Remove attr doesn't fire appropriate event. Set default value first as a workaround to schedule DSL resync
this.cell.attr(property.attr, property.defaultValue === undefined ? null : property.defaultValue);
this.cell.removeAttr(property.attr);
// Bug in JointJS removeAttr() kills all ES6 objects
// this.cell.removeAttr(property.attr);
Flo.removeAttr(this.cell, property.attr);
}
} else {
this.cell.attr(property.attr, property.value);