Override joint.util.deepClone and remove ugly workaround

This commit is contained in:
BoykoAlex
2018-09-08 11:58:53 -04:00
parent 1c7c2d7fad
commit b6e4f26ab1
6 changed files with 21 additions and 24 deletions

View File

@@ -13,7 +13,9 @@ export class Utils {
_.chain(graph.getConnectedLinks(cell)).groupBy((link: dia.Link) => {
// the key of the group is the model id of the link's source or target, but not our cell id.
return _.omit([link.get('source').id, link.get('target').id], cell.id)[0];
const sourceId = link.get('source').id;
const targetId = link.get('target').id;
return cell.id !== sourceId ? sourceId : targetId;
}).each((group: any, key: string) => {
// If the member of the group has both source and target model adjust vertices.
let toRoute: any = {};

View File

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

View File

@@ -238,14 +238,6 @@ 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,9 +248,7 @@ 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);
// Bug in JointJS removeAttr() kills all ES6 objects
// this.cell.removeAttr(property.attr);
Flo.removeAttr(this.cell, property.attr);
this.cell.removeAttr(property.attr);
}
} else {
this.cell.attr(property.attr, property.value);

View File

@@ -1,6 +1,5 @@
import { dia } from 'jointjs';
import { Flo } from './flo-common';
import EditorDescriptor = Flo.ViewerDescriptor;
import * as _ from 'lodash';
import * as _$ from 'jquery';
const joint: any = Flo.joint;
@@ -31,6 +30,15 @@ const DECORATION_ICON_MAP: Map<string, string> = new Map<string, string>();
const ERROR = 'error';
DECORATION_ICON_MAP.set(ERROR, 'icons/error.svg');
joint.util.cloneDeep = (obj: any) => {
return _.cloneDeep(obj, (o) => {
if (_.isObject(o) && !_.isPlainObject(o)) {
return o;
}
});
};
joint.util.filter.redscale = (args: Shapes.FilterOptions) => {
let amount = Number.isFinite(args.amount) ? args.amount : 1;