diff --git a/src/demo/app/editor.ts b/src/demo/app/editor.ts index 8b0f806..878ed7b 100644 --- a/src/demo/app/editor.ts +++ b/src/demo/app/editor.ts @@ -89,7 +89,7 @@ export class Editor implements Flo.Editor { } handleNodeDropping(context : Flo.EditorContext, dragDescriptor : Flo.DnDDescriptor) { - let relinking = dragDescriptor.context === Constants.PALETTE_CONTEXT; + let relinking = dragDescriptor.sourceComponent === Constants.PALETTE_CONTEXT; let graph = context.getGraph(); let source = dragDescriptor.source ? dragDescriptor.source.view.model : undefined; let target = dragDescriptor.target ? dragDescriptor.target.view.model : undefined; @@ -155,6 +155,7 @@ export class Editor implements Flo.Editor { if (distance < range && distance < minDistance) { minDistance = distance; closestData = { + sourceComponent: sourceComponent, source: { view: draggedView, cssClassSelector: type === 'output' ? '.input-port' : '.output-port' @@ -180,6 +181,7 @@ export class Editor implements Flo.Editor { sourceGroup === 'processor' && graph.getConnectedLinks(source).length === 0) { // jshint ignore:line return { + sourceComponent: sourceComponent, source: { view: draggedView }, @@ -190,6 +192,7 @@ export class Editor implements Flo.Editor { } return { + sourceComponent: sourceComponent, source: { view: draggedView } diff --git a/src/lib/src/editor/editor.component.ts b/src/lib/src/editor/editor.component.ts index 6d00a02..fc6d185 100644 --- a/src/lib/src/editor/editor.component.ts +++ b/src/lib/src/editor/editor.component.ts @@ -509,7 +509,7 @@ export class EditorComponent implements OnInit, OnDestroy, OnChanges { if (this.highlighted === dragDescriptor) { return; } - if (this.highlighted && dragDescriptor && _.isEqual(this.highlighted.context, dragDescriptor.context)) { + if (this.highlighted && dragDescriptor && _.isEqual(this.highlighted.sourceComponent, dragDescriptor.sourceComponent)) { if (this.highlighted.source === dragDescriptor.source && this.highlighted.target === dragDescriptor.target) { return; } @@ -888,7 +888,7 @@ export class EditorComponent implements OnInit, OnDestroy, OnChanges { initGraph() { this.graph = new joint.dia.Graph(); - this.graph.attributes.type = joint.shapes.flo.CANVAS_TYPE; + this.graph.set('type', Constants.CANVAS_CONTEXT); } postValidation() { diff --git a/src/lib/src/palette/palette.component.ts b/src/lib/src/palette/palette.component.ts index 7764b3c..1724063 100644 --- a/src/lib/src/palette/palette.component.ts +++ b/src/lib/src/palette/palette.component.ts @@ -3,7 +3,7 @@ import { BehaviorSubject } from 'rxjs/BehaviorSubject'; import 'rxjs/add/operator/debounceTime'; import { dia } from 'jointjs'; import { Flo } from './../shared/flo.common'; -import { Shapes } from './../shared/shapes'; +import { Shapes, Constants } from './../shared/shapes'; import { DOCUMENT } from '@angular/platform-browser' import * as _$ from 'jquery'; import * as _joint from 'jointjs'; @@ -109,7 +109,7 @@ export class Palette implements OnInit, OnDestroy, OnChanges { constructor(private element: ElementRef, @Inject(DOCUMENT) private document : any) { this.paletteGraph = new joint.dia.Graph(); - this.paletteGraph.set('type', joint.shapes.flo.PALETTE_TYPE); + this.paletteGraph.set('type', Constants.PALETTE_CONTEXT); this._filterText = ''; this.closedGroups = new Set(); @@ -471,7 +471,7 @@ export class Palette implements OnInit, OnDestroy, OnChanges { }).appendTo($('body')); let floatergraph : dia.Graph = new joint.dia.Graph(); - floatergraph.attributes.type = joint.shapes.flo.FEEDBACK_TYPE; + floatergraph.set('type', Constants.FEEDBACK_CONTEXT); let floaterpaper : dia.Paper = new joint.dia.Paper({ el: $('#palette-floater'), diff --git a/src/lib/src/shared/flo.common.ts b/src/lib/src/shared/flo.common.ts index 9b45e00..eef801a 100644 --- a/src/lib/src/shared/flo.common.ts +++ b/src/lib/src/shared/flo.common.ts @@ -153,7 +153,7 @@ export namespace Flo { } export interface DnDDescriptor { - context? : string; + sourceComponent? : string; range?: number; source? : LinkEndDescriptor; target? : LinkEndDescriptor; diff --git a/src/lib/src/shared/shapes.ts b/src/lib/src/shared/shapes.ts index 2d0fd69..ff370e7 100644 --- a/src/lib/src/shared/shapes.ts +++ b/src/lib/src/shared/shapes.ts @@ -24,10 +24,6 @@ joint.shapes.flo.LINK_TYPE = 'sinspctr.Link'; joint.shapes.flo.DECORATION_TYPE = 'decoration'; joint.shapes.flo.HANDLE_TYPE = 'handle'; -joint.shapes.flo.CANVAS_TYPE = 'canvas'; -joint.shapes.flo.PALETTE_TYPE = 'palette'; -joint.shapes.flo.FEEDBACK_TYPE = 'feedback'; - const HANDLE_ICON_MAP : Map= new Map(); const REMOVE = 'remove'; HANDLE_ICON_MAP.set(REMOVE, 'icons/delete.svg'); @@ -466,6 +462,7 @@ export namespace Constants { export const CANVAS_CONTEXT = 'canvas'; + export const FEEDBACK_CONTEXT = 'feedback'; }