DnDDescriptor refactoring

This commit is contained in:
BoykoAlex
2017-08-24 23:07:24 -04:00
parent 47c08d7906
commit 80d02bdeba
5 changed files with 11 additions and 11 deletions

View File

@@ -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
}

View File

@@ -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() {

View File

@@ -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<string>();
@@ -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'),

View File

@@ -153,7 +153,7 @@ export namespace Flo {
}
export interface DnDDescriptor {
context? : string;
sourceComponent? : string;
range?: number;
source? : LinkEndDescriptor;
target? : LinkEndDescriptor;

View File

@@ -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<string, string>= new Map<string, string>();
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';
}