master
Igor Kulikov 6 years ago
parent 02481d9905
commit 103be44b26

@ -257,16 +257,6 @@
/** @type {?|undefined} */ /** @type {?|undefined} */
FcCoords.prototype.y; FcCoords.prototype.y;
} }
/**
* @record
*/
function FcOffset() { }
if (false) {
/** @type {?} */
FcOffset.prototype.top;
/** @type {?} */
FcOffset.prototype.left;
}
/** /**
* @record * @record
*/ */
@ -557,7 +547,7 @@
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/ */
var FcModelService = /** @class */ (function () { var FcModelService = /** @class */ (function () {
function FcModelService(modelValidation, model, cd, selectedObjects, dropNode, createEdge, edgeAddedCallback, nodeRemovedCallback, edgeRemovedCallback, canvasHtmlElement, svgHtmlElement) { function FcModelService(modelValidation, model, modelChanged, cd, selectedObjects, dropNode, createEdge, edgeAddedCallback, nodeRemovedCallback, edgeRemovedCallback, canvasHtmlElement, svgHtmlElement) {
this.connectorsHtmlElements = {}; this.connectorsHtmlElements = {};
this.nodesHtmlElements = {}; this.nodesHtmlElements = {};
this.canvasHtmlElement = null; this.canvasHtmlElement = null;
@ -565,6 +555,7 @@
this.svgHtmlElement = null; this.svgHtmlElement = null;
this.modelValidation = modelValidation; this.modelValidation = modelValidation;
this.model = model; this.model = model;
this.modelChanged = modelChanged;
this.cd = cd; this.cd = cd;
this.canvasHtmlElement = canvasHtmlElement; this.canvasHtmlElement = canvasHtmlElement;
this.svgHtmlElement = svgHtmlElement; this.svgHtmlElement = svgHtmlElement;
@ -596,6 +587,15 @@
this.nodes = new NodesModel(this); this.nodes = new NodesModel(this);
this.edges = new EdgesModel(this); this.edges = new EdgesModel(this);
} }
/**
* @return {?}
*/
FcModelService.prototype.notifyModelChanged = /**
* @return {?}
*/
function () {
this.modelChanged.emit();
};
/** /**
* @return {?} * @return {?}
*/ */
@ -986,6 +986,8 @@
/** @type {?} */ /** @type {?} */
FcModelService.prototype.dropTargetId; FcModelService.prototype.dropTargetId;
/** @type {?} */ /** @type {?} */
FcModelService.prototype.modelChanged;
/** @type {?} */
FcModelService.prototype.connectors; FcModelService.prototype.connectors;
/** @type {?} */ /** @type {?} */
FcModelService.prototype.nodes; FcModelService.prototype.nodes;
@ -1279,6 +1281,7 @@
} }
} }
model.nodes.splice(index, 1); model.nodes.splice(index, 1);
this.modelService.notifyModelChanged();
this.modelService.nodeRemovedCallback(node); this.modelService.nodeRemovedCallback(node);
}; };
/** /**
@ -1477,6 +1480,7 @@
this.deselect(edge); this.deselect(edge);
} }
model.edges.splice(index, 1); model.edges.splice(index, 1);
this.modelService.notifyModelChanged();
this.modelService.edgeRemovedCallback(edge); this.modelService.edgeRemovedCallback(edge);
}; };
/** /**
@ -1528,6 +1532,7 @@
/** @type {?} */ /** @type {?} */
var model = this.modelService.model; var model = this.modelService.model;
model.edges.push(edge); model.edges.push(edge);
this.modelService.notifyModelChanged();
}; };
/** /**
* @param {?} event * @param {?} event
@ -1561,6 +1566,7 @@
*/ */
function (created) { function (created) {
model.edges.push(created); model.edges.push(created);
_this.modelService.notifyModelChanged();
_this.modelService.edgeAddedCallback(created); _this.modelService.edgeAddedCallback(created);
})); }));
}; };
@ -2127,6 +2133,7 @@
draggedNode.y = Math.round(_this.getYCoordinate(dragOffset.y + event.clientY)); draggedNode.y = Math.round(_this.getYCoordinate(dragOffset.y + event.clientY));
} }
event.preventDefault(); event.preventDefault();
_this.modelService.notifyModelChanged();
return false; return false;
})); }));
} }
@ -2182,6 +2189,7 @@
_this.resizeCanvas(draggedNode, _this.draggedElements[i]); _this.resizeCanvas(draggedNode, _this.draggedElements[i]);
} }
event.preventDefault(); event.preventDefault();
_this.modelService.notifyModelChanged();
return false; return false;
})); }));
} }
@ -2244,6 +2252,7 @@
_this.modelService.canvasHtmlElement.removeChild(shadowElement[0]); _this.modelService.canvasHtmlElement.removeChild(shadowElement[0]);
} }
_this.nodeDraggingScope.shadowElements.length = 0; _this.nodeDraggingScope.shadowElements.length = 0;
_this.modelService.notifyModelChanged();
} }
if (_this.nodeDraggingScope.draggedNodes.length) { if (_this.nodeDraggingScope.draggedNodes.length) {
_this.nodeDraggingScope.draggedNodes.length = 0; _this.nodeDraggingScope.draggedNodes.length = 0;
@ -3292,6 +3301,7 @@
this.edgeDrawingService = edgeDrawingService; this.edgeDrawingService = edgeDrawingService;
this.cd = cd; this.cd = cd;
this.zone = zone; this.zone = zone;
this.modelChanged = new core.EventEmitter();
this.flowchartConstants = FlowchartConstants; this.flowchartConstants = FlowchartConstants;
this.nodesDiffer = this.differs.find([]).create((/** this.nodesDiffer = this.differs.find([]).create((/**
* @param {?} index * @param {?} index
@ -3359,7 +3369,7 @@
this.userNodeCallbacks = this.userCallbacks.nodeCallbacks; this.userNodeCallbacks = this.userCallbacks.nodeCallbacks;
/** @type {?} */ /** @type {?} */
var element = $(this.elementRef.nativeElement); var element = $(this.elementRef.nativeElement);
this.modelService = new FcModelService(this.modelValidation, this.model, this.cd, this.selectedObjects, this.userCallbacks.dropNode, this.userCallbacks.createEdge, this.userCallbacks.edgeAdded, this.userCallbacks.nodeRemoved, this.userCallbacks.edgeRemoved, element[0], element[0].querySelector('svg')); this.modelService = new FcModelService(this.modelValidation, this.model, this.modelChanged, this.cd, this.selectedObjects, this.userCallbacks.dropNode, this.userCallbacks.createEdge, this.userCallbacks.edgeAdded, this.userCallbacks.nodeRemoved, this.userCallbacks.edgeRemoved, element[0], element[0].querySelector('svg'));
if (this.dropTargetId) { if (this.dropTargetId) {
this.modelService.dropTargetId = this.dropTargetId; this.modelService.dropTargetId = this.dropTargetId;
} }
@ -3710,6 +3720,7 @@
nodeWidth: [{ type: core.Input }], nodeWidth: [{ type: core.Input }],
nodeHeight: [{ type: core.Input }], nodeHeight: [{ type: core.Input }],
dropTargetId: [{ type: core.Input }], dropTargetId: [{ type: core.Input }],
modelChanged: [{ type: core.Output }],
dragover: [{ type: core.HostListener, args: ['dragover', ['$event'],] }], dragover: [{ type: core.HostListener, args: ['dragover', ['$event'],] }],
drop: [{ type: core.HostListener, args: ['drop', ['$event'],] }], drop: [{ type: core.HostListener, args: ['drop', ['$event'],] }],
mousedown: [{ type: core.HostListener, args: ['mousedown', ['$event'],] }], mousedown: [{ type: core.HostListener, args: ['mousedown', ['$event'],] }],
@ -3738,6 +3749,8 @@
/** @type {?} */ /** @type {?} */
NgxFlowchartComponent.prototype.dropTargetId; NgxFlowchartComponent.prototype.dropTargetId;
/** @type {?} */ /** @type {?} */
NgxFlowchartComponent.prototype.modelChanged;
/** @type {?} */
NgxFlowchartComponent.prototype.callbacks; NgxFlowchartComponent.prototype.callbacks;
/** @type {?} */ /** @type {?} */
NgxFlowchartComponent.prototype.userNodeCallbacks; NgxFlowchartComponent.prototype.userNodeCallbacks;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,4 +1,4 @@
import { InjectionToken, Injectable, Component, ChangeDetectionStrategy, ElementRef, IterableDiffers, ChangeDetectorRef, NgZone, HostBinding, Input, HostListener, Directive, Inject, ComponentFactoryResolver, ViewChild, ViewContainerRef, NgModule } from '@angular/core'; import { InjectionToken, Injectable, EventEmitter, Component, ChangeDetectionStrategy, ElementRef, IterableDiffers, ChangeDetectorRef, NgZone, HostBinding, Input, Output, HostListener, Directive, Inject, ComponentFactoryResolver, ViewChild, ViewContainerRef, NgModule } from '@angular/core';
import { of } from 'rxjs'; import { of } from 'rxjs';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
@ -58,16 +58,6 @@ if (false) {
/** @type {?|undefined} */ /** @type {?|undefined} */
FcCoords.prototype.y; FcCoords.prototype.y;
} }
/**
* @record
*/
function FcOffset() { }
if (false) {
/** @type {?} */
FcOffset.prototype.top;
/** @type {?} */
FcOffset.prototype.left;
}
/** /**
* @record * @record
*/ */
@ -339,6 +329,7 @@ class FcModelService {
/** /**
* @param {?} modelValidation * @param {?} modelValidation
* @param {?} model * @param {?} model
* @param {?} modelChanged
* @param {?} cd * @param {?} cd
* @param {?} selectedObjects * @param {?} selectedObjects
* @param {?} dropNode * @param {?} dropNode
@ -349,7 +340,7 @@ class FcModelService {
* @param {?} canvasHtmlElement * @param {?} canvasHtmlElement
* @param {?} svgHtmlElement * @param {?} svgHtmlElement
*/ */
constructor(modelValidation, model, cd, selectedObjects, dropNode, createEdge, edgeAddedCallback, nodeRemovedCallback, edgeRemovedCallback, canvasHtmlElement, svgHtmlElement) { constructor(modelValidation, model, modelChanged, cd, selectedObjects, dropNode, createEdge, edgeAddedCallback, nodeRemovedCallback, edgeRemovedCallback, canvasHtmlElement, svgHtmlElement) {
this.connectorsHtmlElements = {}; this.connectorsHtmlElements = {};
this.nodesHtmlElements = {}; this.nodesHtmlElements = {};
this.canvasHtmlElement = null; this.canvasHtmlElement = null;
@ -357,6 +348,7 @@ class FcModelService {
this.svgHtmlElement = null; this.svgHtmlElement = null;
this.modelValidation = modelValidation; this.modelValidation = modelValidation;
this.model = model; this.model = model;
this.modelChanged = modelChanged;
this.cd = cd; this.cd = cd;
this.canvasHtmlElement = canvasHtmlElement; this.canvasHtmlElement = canvasHtmlElement;
this.svgHtmlElement = svgHtmlElement; this.svgHtmlElement = svgHtmlElement;
@ -388,6 +380,12 @@ class FcModelService {
this.nodes = new NodesModel(this); this.nodes = new NodesModel(this);
this.edges = new EdgesModel(this); this.edges = new EdgesModel(this);
} }
/**
* @return {?}
*/
notifyModelChanged() {
this.modelChanged.emit();
}
/** /**
* @return {?} * @return {?}
*/ */
@ -689,6 +687,8 @@ if (false) {
/** @type {?} */ /** @type {?} */
FcModelService.prototype.dropTargetId; FcModelService.prototype.dropTargetId;
/** @type {?} */ /** @type {?} */
FcModelService.prototype.modelChanged;
/** @type {?} */
FcModelService.prototype.connectors; FcModelService.prototype.connectors;
/** @type {?} */ /** @type {?} */
FcModelService.prototype.nodes; FcModelService.prototype.nodes;
@ -901,6 +901,7 @@ class NodesModel extends AbstractFcModel {
} }
} }
model.nodes.splice(index, 1); model.nodes.splice(index, 1);
this.modelService.notifyModelChanged();
this.modelService.nodeRemovedCallback(node); this.modelService.nodeRemovedCallback(node);
} }
/** /**
@ -1042,6 +1043,7 @@ class EdgesModel extends AbstractFcModel {
this.deselect(edge); this.deselect(edge);
} }
model.edges.splice(index, 1); model.edges.splice(index, 1);
this.modelService.notifyModelChanged();
this.modelService.edgeRemovedCallback(edge); this.modelService.edgeRemovedCallback(edge);
} }
/** /**
@ -1080,6 +1082,7 @@ class EdgesModel extends AbstractFcModel {
/** @type {?} */ /** @type {?} */
const model = this.modelService.model; const model = this.modelService.model;
model.edges.push(edge); model.edges.push(edge);
this.modelService.notifyModelChanged();
} }
/** /**
* @param {?} event * @param {?} event
@ -1105,6 +1108,7 @@ class EdgesModel extends AbstractFcModel {
*/ */
(created) => { (created) => {
model.edges.push(created); model.edges.push(created);
this.modelService.notifyModelChanged();
this.modelService.edgeAddedCallback(created); this.modelService.edgeAddedCallback(created);
})); }));
} }
@ -1576,6 +1580,7 @@ class FcNodeDraggingService {
draggedNode.y = Math.round(this.getYCoordinate(dragOffset.y + event.clientY)); draggedNode.y = Math.round(this.getYCoordinate(dragOffset.y + event.clientY));
} }
event.preventDefault(); event.preventDefault();
this.modelService.notifyModelChanged();
return false; return false;
})); }));
} }
@ -1626,6 +1631,7 @@ class FcNodeDraggingService {
this.resizeCanvas(draggedNode, this.draggedElements[i]); this.resizeCanvas(draggedNode, this.draggedElements[i]);
} }
event.preventDefault(); event.preventDefault();
this.modelService.notifyModelChanged();
return false; return false;
})); }));
} }
@ -1683,6 +1689,7 @@ class FcNodeDraggingService {
this.modelService.canvasHtmlElement.removeChild(shadowElement[0]); this.modelService.canvasHtmlElement.removeChild(shadowElement[0]);
} }
this.nodeDraggingScope.shadowElements.length = 0; this.nodeDraggingScope.shadowElements.length = 0;
this.modelService.notifyModelChanged();
} }
if (this.nodeDraggingScope.draggedNodes.length) { if (this.nodeDraggingScope.draggedNodes.length) {
this.nodeDraggingScope.draggedNodes.length = 0; this.nodeDraggingScope.draggedNodes.length = 0;
@ -2603,6 +2610,7 @@ class NgxFlowchartComponent {
this.edgeDrawingService = edgeDrawingService; this.edgeDrawingService = edgeDrawingService;
this.cd = cd; this.cd = cd;
this.zone = zone; this.zone = zone;
this.modelChanged = new EventEmitter();
this.flowchartConstants = FlowchartConstants; this.flowchartConstants = FlowchartConstants;
this.nodesDiffer = this.differs.find([]).create((/** this.nodesDiffer = this.differs.find([]).create((/**
* @param {?} index * @param {?} index
@ -2651,7 +2659,7 @@ class NgxFlowchartComponent {
this.userNodeCallbacks = this.userCallbacks.nodeCallbacks; this.userNodeCallbacks = this.userCallbacks.nodeCallbacks;
/** @type {?} */ /** @type {?} */
const element = $(this.elementRef.nativeElement); const element = $(this.elementRef.nativeElement);
this.modelService = new FcModelService(this.modelValidation, this.model, this.cd, this.selectedObjects, this.userCallbacks.dropNode, this.userCallbacks.createEdge, this.userCallbacks.edgeAdded, this.userCallbacks.nodeRemoved, this.userCallbacks.edgeRemoved, element[0], element[0].querySelector('svg')); this.modelService = new FcModelService(this.modelValidation, this.model, this.modelChanged, this.cd, this.selectedObjects, this.userCallbacks.dropNode, this.userCallbacks.createEdge, this.userCallbacks.edgeAdded, this.userCallbacks.nodeRemoved, this.userCallbacks.edgeRemoved, element[0], element[0].querySelector('svg'));
if (this.dropTargetId) { if (this.dropTargetId) {
this.modelService.dropTargetId = this.dropTargetId; this.modelService.dropTargetId = this.dropTargetId;
} }
@ -2927,6 +2935,7 @@ NgxFlowchartComponent.propDecorators = {
nodeWidth: [{ type: Input }], nodeWidth: [{ type: Input }],
nodeHeight: [{ type: Input }], nodeHeight: [{ type: Input }],
dropTargetId: [{ type: Input }], dropTargetId: [{ type: Input }],
modelChanged: [{ type: Output }],
dragover: [{ type: HostListener, args: ['dragover', ['$event'],] }], dragover: [{ type: HostListener, args: ['dragover', ['$event'],] }],
drop: [{ type: HostListener, args: ['drop', ['$event'],] }], drop: [{ type: HostListener, args: ['drop', ['$event'],] }],
mousedown: [{ type: HostListener, args: ['mousedown', ['$event'],] }], mousedown: [{ type: HostListener, args: ['mousedown', ['$event'],] }],
@ -2953,6 +2962,8 @@ if (false) {
/** @type {?} */ /** @type {?} */
NgxFlowchartComponent.prototype.dropTargetId; NgxFlowchartComponent.prototype.dropTargetId;
/** @type {?} */ /** @type {?} */
NgxFlowchartComponent.prototype.modelChanged;
/** @type {?} */
NgxFlowchartComponent.prototype.callbacks; NgxFlowchartComponent.prototype.callbacks;
/** @type {?} */ /** @type {?} */
NgxFlowchartComponent.prototype.userNodeCallbacks; NgxFlowchartComponent.prototype.userNodeCallbacks;

File diff suppressed because one or more lines are too long

@ -1,5 +1,5 @@
import { __extends, __values, __assign } from 'tslib'; import { __extends, __values, __assign } from 'tslib';
import { InjectionToken, Injectable, Component, ChangeDetectionStrategy, ElementRef, IterableDiffers, ChangeDetectorRef, NgZone, HostBinding, Input, HostListener, Directive, Inject, ComponentFactoryResolver, ViewChild, ViewContainerRef, NgModule } from '@angular/core'; import { InjectionToken, Injectable, EventEmitter, Component, ChangeDetectionStrategy, ElementRef, IterableDiffers, ChangeDetectorRef, NgZone, HostBinding, Input, Output, HostListener, Directive, Inject, ComponentFactoryResolver, ViewChild, ViewContainerRef, NgModule } from '@angular/core';
import { of } from 'rxjs'; import { of } from 'rxjs';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
@ -59,16 +59,6 @@ if (false) {
/** @type {?|undefined} */ /** @type {?|undefined} */
FcCoords.prototype.y; FcCoords.prototype.y;
} }
/**
* @record
*/
function FcOffset() { }
if (false) {
/** @type {?} */
FcOffset.prototype.top;
/** @type {?} */
FcOffset.prototype.left;
}
/** /**
* @record * @record
*/ */
@ -359,7 +349,7 @@ function fcTopSort(graph) {
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/ */
var FcModelService = /** @class */ (function () { var FcModelService = /** @class */ (function () {
function FcModelService(modelValidation, model, cd, selectedObjects, dropNode, createEdge, edgeAddedCallback, nodeRemovedCallback, edgeRemovedCallback, canvasHtmlElement, svgHtmlElement) { function FcModelService(modelValidation, model, modelChanged, cd, selectedObjects, dropNode, createEdge, edgeAddedCallback, nodeRemovedCallback, edgeRemovedCallback, canvasHtmlElement, svgHtmlElement) {
this.connectorsHtmlElements = {}; this.connectorsHtmlElements = {};
this.nodesHtmlElements = {}; this.nodesHtmlElements = {};
this.canvasHtmlElement = null; this.canvasHtmlElement = null;
@ -367,6 +357,7 @@ var FcModelService = /** @class */ (function () {
this.svgHtmlElement = null; this.svgHtmlElement = null;
this.modelValidation = modelValidation; this.modelValidation = modelValidation;
this.model = model; this.model = model;
this.modelChanged = modelChanged;
this.cd = cd; this.cd = cd;
this.canvasHtmlElement = canvasHtmlElement; this.canvasHtmlElement = canvasHtmlElement;
this.svgHtmlElement = svgHtmlElement; this.svgHtmlElement = svgHtmlElement;
@ -398,6 +389,15 @@ var FcModelService = /** @class */ (function () {
this.nodes = new NodesModel(this); this.nodes = new NodesModel(this);
this.edges = new EdgesModel(this); this.edges = new EdgesModel(this);
} }
/**
* @return {?}
*/
FcModelService.prototype.notifyModelChanged = /**
* @return {?}
*/
function () {
this.modelChanged.emit();
};
/** /**
* @return {?} * @return {?}
*/ */
@ -788,6 +788,8 @@ if (false) {
/** @type {?} */ /** @type {?} */
FcModelService.prototype.dropTargetId; FcModelService.prototype.dropTargetId;
/** @type {?} */ /** @type {?} */
FcModelService.prototype.modelChanged;
/** @type {?} */
FcModelService.prototype.connectors; FcModelService.prototype.connectors;
/** @type {?} */ /** @type {?} */
FcModelService.prototype.nodes; FcModelService.prototype.nodes;
@ -1081,6 +1083,7 @@ var NodesModel = /** @class */ (function (_super) {
} }
} }
model.nodes.splice(index, 1); model.nodes.splice(index, 1);
this.modelService.notifyModelChanged();
this.modelService.nodeRemovedCallback(node); this.modelService.nodeRemovedCallback(node);
}; };
/** /**
@ -1279,6 +1282,7 @@ var EdgesModel = /** @class */ (function (_super) {
this.deselect(edge); this.deselect(edge);
} }
model.edges.splice(index, 1); model.edges.splice(index, 1);
this.modelService.notifyModelChanged();
this.modelService.edgeRemovedCallback(edge); this.modelService.edgeRemovedCallback(edge);
}; };
/** /**
@ -1330,6 +1334,7 @@ var EdgesModel = /** @class */ (function (_super) {
/** @type {?} */ /** @type {?} */
var model = this.modelService.model; var model = this.modelService.model;
model.edges.push(edge); model.edges.push(edge);
this.modelService.notifyModelChanged();
}; };
/** /**
* @param {?} event * @param {?} event
@ -1363,6 +1368,7 @@ var EdgesModel = /** @class */ (function (_super) {
*/ */
function (created) { function (created) {
model.edges.push(created); model.edges.push(created);
_this.modelService.notifyModelChanged();
_this.modelService.edgeAddedCallback(created); _this.modelService.edgeAddedCallback(created);
})); }));
}; };
@ -1929,6 +1935,7 @@ var FcNodeDraggingService = /** @class */ (function () {
draggedNode.y = Math.round(_this.getYCoordinate(dragOffset.y + event.clientY)); draggedNode.y = Math.round(_this.getYCoordinate(dragOffset.y + event.clientY));
} }
event.preventDefault(); event.preventDefault();
_this.modelService.notifyModelChanged();
return false; return false;
})); }));
} }
@ -1984,6 +1991,7 @@ var FcNodeDraggingService = /** @class */ (function () {
_this.resizeCanvas(draggedNode, _this.draggedElements[i]); _this.resizeCanvas(draggedNode, _this.draggedElements[i]);
} }
event.preventDefault(); event.preventDefault();
_this.modelService.notifyModelChanged();
return false; return false;
})); }));
} }
@ -2046,6 +2054,7 @@ var FcNodeDraggingService = /** @class */ (function () {
_this.modelService.canvasHtmlElement.removeChild(shadowElement[0]); _this.modelService.canvasHtmlElement.removeChild(shadowElement[0]);
} }
_this.nodeDraggingScope.shadowElements.length = 0; _this.nodeDraggingScope.shadowElements.length = 0;
_this.modelService.notifyModelChanged();
} }
if (_this.nodeDraggingScope.draggedNodes.length) { if (_this.nodeDraggingScope.draggedNodes.length) {
_this.nodeDraggingScope.draggedNodes.length = 0; _this.nodeDraggingScope.draggedNodes.length = 0;
@ -3094,6 +3103,7 @@ var NgxFlowchartComponent = /** @class */ (function () {
this.edgeDrawingService = edgeDrawingService; this.edgeDrawingService = edgeDrawingService;
this.cd = cd; this.cd = cd;
this.zone = zone; this.zone = zone;
this.modelChanged = new EventEmitter();
this.flowchartConstants = FlowchartConstants; this.flowchartConstants = FlowchartConstants;
this.nodesDiffer = this.differs.find([]).create((/** this.nodesDiffer = this.differs.find([]).create((/**
* @param {?} index * @param {?} index
@ -3161,7 +3171,7 @@ var NgxFlowchartComponent = /** @class */ (function () {
this.userNodeCallbacks = this.userCallbacks.nodeCallbacks; this.userNodeCallbacks = this.userCallbacks.nodeCallbacks;
/** @type {?} */ /** @type {?} */
var element = $(this.elementRef.nativeElement); var element = $(this.elementRef.nativeElement);
this.modelService = new FcModelService(this.modelValidation, this.model, this.cd, this.selectedObjects, this.userCallbacks.dropNode, this.userCallbacks.createEdge, this.userCallbacks.edgeAdded, this.userCallbacks.nodeRemoved, this.userCallbacks.edgeRemoved, element[0], element[0].querySelector('svg')); this.modelService = new FcModelService(this.modelValidation, this.model, this.modelChanged, this.cd, this.selectedObjects, this.userCallbacks.dropNode, this.userCallbacks.createEdge, this.userCallbacks.edgeAdded, this.userCallbacks.nodeRemoved, this.userCallbacks.edgeRemoved, element[0], element[0].querySelector('svg'));
if (this.dropTargetId) { if (this.dropTargetId) {
this.modelService.dropTargetId = this.dropTargetId; this.modelService.dropTargetId = this.dropTargetId;
} }
@ -3512,6 +3522,7 @@ var NgxFlowchartComponent = /** @class */ (function () {
nodeWidth: [{ type: Input }], nodeWidth: [{ type: Input }],
nodeHeight: [{ type: Input }], nodeHeight: [{ type: Input }],
dropTargetId: [{ type: Input }], dropTargetId: [{ type: Input }],
modelChanged: [{ type: Output }],
dragover: [{ type: HostListener, args: ['dragover', ['$event'],] }], dragover: [{ type: HostListener, args: ['dragover', ['$event'],] }],
drop: [{ type: HostListener, args: ['drop', ['$event'],] }], drop: [{ type: HostListener, args: ['drop', ['$event'],] }],
mousedown: [{ type: HostListener, args: ['mousedown', ['$event'],] }], mousedown: [{ type: HostListener, args: ['mousedown', ['$event'],] }],
@ -3540,6 +3551,8 @@ if (false) {
/** @type {?} */ /** @type {?} */
NgxFlowchartComponent.prototype.dropTargetId; NgxFlowchartComponent.prototype.dropTargetId;
/** @type {?} */ /** @type {?} */
NgxFlowchartComponent.prototype.modelChanged;
/** @type {?} */
NgxFlowchartComponent.prototype.callbacks; NgxFlowchartComponent.prototype.callbacks;
/** @type {?} */ /** @type {?} */
NgxFlowchartComponent.prototype.userNodeCallbacks; NgxFlowchartComponent.prototype.userNodeCallbacks;

File diff suppressed because one or more lines are too long

@ -1,7 +1,7 @@
import { FcModelValidationService } from './modelvalidation.service'; import { FcModelValidationService } from './modelvalidation.service';
import { FcConnector, FcCoords, FcEdge, FcItemInfo, FcModel, FcNode, FcRectBox } from './ngx-flowchart.models'; import { FcConnector, FcCoords, FcEdge, FcItemInfo, FcModel, FcNode, FcRectBox } from './ngx-flowchart.models';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { ChangeDetectorRef } from '@angular/core'; import { ChangeDetectorRef, EventEmitter } from '@angular/core';
export declare class FcModelService { export declare class FcModelService {
modelValidation: FcModelValidationService; modelValidation: FcModelValidationService;
model: FcModel; model: FcModel;
@ -18,10 +18,12 @@ export declare class FcModelService {
nodeRemovedCallback: (node: FcNode) => void; nodeRemovedCallback: (node: FcNode) => void;
edgeRemovedCallback: (edge: FcEdge) => void; edgeRemovedCallback: (edge: FcEdge) => void;
dropTargetId: string; dropTargetId: string;
modelChanged: EventEmitter<any>;
connectors: ConnectorsModel; connectors: ConnectorsModel;
nodes: NodesModel; nodes: NodesModel;
edges: EdgesModel; edges: EdgesModel;
constructor(modelValidation: FcModelValidationService, model: FcModel, cd: ChangeDetectorRef, selectedObjects: any[], dropNode: (event: Event, node: FcNode) => void, createEdge: (event: Event, edge: FcEdge) => Observable<FcEdge>, edgeAddedCallback: (edge: FcEdge) => void, nodeRemovedCallback: (node: FcNode) => void, edgeRemovedCallback: (edge: FcEdge) => void, canvasHtmlElement: HTMLElement, svgHtmlElement: SVGElement); constructor(modelValidation: FcModelValidationService, model: FcModel, modelChanged: EventEmitter<any>, cd: ChangeDetectorRef, selectedObjects: any[], dropNode: (event: Event, node: FcNode) => void, createEdge: (event: Event, edge: FcEdge) => Observable<FcEdge>, edgeAddedCallback: (edge: FcEdge) => void, nodeRemovedCallback: (node: FcNode) => void, edgeRemovedCallback: (edge: FcEdge) => void, canvasHtmlElement: HTMLElement, svgHtmlElement: SVGElement);
notifyModelChanged(): void;
detectChanges(): void; detectChanges(): void;
selectObject(object: any): void; selectObject(object: any): void;
deselectObject(object: any): void; deselectObject(object: any): void;

@ -1,4 +1,4 @@
import { ChangeDetectorRef, DoCheck, ElementRef, IterableDiffers, NgZone, OnInit } from '@angular/core'; import { ChangeDetectorRef, DoCheck, ElementRef, EventEmitter, IterableDiffers, NgZone, OnInit } from '@angular/core';
import { FcCallbacks, FcEdge, FcModel, UserCallbacks, UserNodeCallbacks } from './ngx-flowchart.models'; import { FcCallbacks, FcEdge, FcModel, UserCallbacks, UserNodeCallbacks } from './ngx-flowchart.models';
import { FcModelService } from './model.service'; import { FcModelService } from './model.service';
import { FcModelValidationService } from './modelvalidation.service'; import { FcModelValidationService } from './modelvalidation.service';
@ -24,6 +24,7 @@ export declare class NgxFlowchartComponent implements OnInit, DoCheck {
nodeWidth: number; nodeWidth: number;
nodeHeight: number; nodeHeight: number;
dropTargetId: string; dropTargetId: string;
modelChanged: EventEmitter<any>;
callbacks: FcCallbacks; callbacks: FcCallbacks;
userNodeCallbacks: UserNodeCallbacks; userNodeCallbacks: UserNodeCallbacks;
modelService: FcModelService; modelService: FcModelService;

@ -34,10 +34,6 @@ export interface FcCoords {
x?: number; x?: number;
y?: number; y?: number;
} }
export interface FcOffset {
top: number;
left: number;
}
export interface FcRectBox { export interface FcRectBox {
top: number; top: number;
left: number; left: number;

File diff suppressed because one or more lines are too long

@ -1,7 +1,7 @@
import { FcModelValidationService } from './modelvalidation.service'; import { FcModelValidationService } from './modelvalidation.service';
import { FcConnector, FcCoords, FcEdge, FcItemInfo, FcModel, FcNode, FcRectBox } from './ngx-flowchart.models'; import { FcConnector, FcCoords, FcEdge, FcItemInfo, FcModel, FcNode, FcRectBox } from './ngx-flowchart.models';
import { Observable, of } from 'rxjs'; import { Observable, of } from 'rxjs';
import { ChangeDetectorRef } from '@angular/core'; import { ChangeDetectorRef, EventEmitter } from '@angular/core';
export class FcModelService { export class FcModelService {
@ -24,12 +24,15 @@ export class FcModelService {
dropTargetId: string; dropTargetId: string;
modelChanged: EventEmitter<any>;
connectors: ConnectorsModel; connectors: ConnectorsModel;
nodes: NodesModel; nodes: NodesModel;
edges: EdgesModel; edges: EdgesModel;
constructor(modelValidation: FcModelValidationService, constructor(modelValidation: FcModelValidationService,
model: FcModel, model: FcModel,
modelChanged: EventEmitter<any>,
cd: ChangeDetectorRef, cd: ChangeDetectorRef,
selectedObjects: any[], selectedObjects: any[],
dropNode: (event: Event, node: FcNode) => void, dropNode: (event: Event, node: FcNode) => void,
@ -42,6 +45,7 @@ export class FcModelService {
this.modelValidation = modelValidation; this.modelValidation = modelValidation;
this.model = model; this.model = model;
this.modelChanged = modelChanged;
this.cd = cd; this.cd = cd;
this.canvasHtmlElement = canvasHtmlElement; this.canvasHtmlElement = canvasHtmlElement;
this.svgHtmlElement = svgHtmlElement; this.svgHtmlElement = svgHtmlElement;
@ -59,6 +63,10 @@ export class FcModelService {
this.edges = new EdgesModel(this); this.edges = new EdgesModel(this);
} }
public notifyModelChanged() {
this.modelChanged.emit();
}
public detectChanges() { public detectChanges() {
setTimeout(() => { setTimeout(() => {
this.cd.detectChanges(); this.cd.detectChanges();
@ -358,6 +366,7 @@ class NodesModel extends AbstractFcModel<FcNode> {
} }
} }
model.nodes.splice(index, 1); model.nodes.splice(index, 1);
this.modelService.notifyModelChanged();
this.modelService.nodeRemovedCallback(node); this.modelService.nodeRemovedCallback(node);
} }
@ -446,6 +455,7 @@ class EdgesModel extends AbstractFcModel<FcEdge> {
this.deselect(edge); this.deselect(edge);
} }
model.edges.splice(index, 1); model.edges.splice(index, 1);
this.modelService.notifyModelChanged();
this.modelService.edgeRemovedCallback(edge); this.modelService.edgeRemovedCallback(edge);
} }
@ -468,6 +478,7 @@ class EdgesModel extends AbstractFcModel<FcEdge> {
public putEdge(edge: FcEdge) { public putEdge(edge: FcEdge) {
const model = this.modelService.model; const model = this.modelService.model;
model.edges.push(edge); model.edges.push(edge);
this.modelService.notifyModelChanged();
} }
public _addEdge(event: Event, sourceConnector: FcConnector, destConnector: FcConnector, label: string) { public _addEdge(event: Event, sourceConnector: FcConnector, destConnector: FcConnector, label: string) {
@ -482,6 +493,7 @@ class EdgesModel extends AbstractFcModel<FcEdge> {
this.modelService.createEdge(event, edge).subscribe( this.modelService.createEdge(event, edge).subscribe(
(created) => { (created) => {
model.edges.push(created); model.edges.push(created);
this.modelService.notifyModelChanged();
this.modelService.edgeAddedCallback(created); this.modelService.edgeAddedCallback(created);
} }
); );

@ -2,14 +2,14 @@ import {
ChangeDetectionStrategy, ChangeDetectorRef, ChangeDetectionStrategy, ChangeDetectorRef,
Component, Component,
DoCheck, DoCheck,
ElementRef, ElementRef, EventEmitter,
HostBinding, HostBinding,
HostListener, HostListener,
Input, Input,
IterableDiffer, IterableDiffer,
IterableDiffers, IterableDiffers,
NgZone, NgZone,
OnInit OnInit, Output
} from '@angular/core'; } from '@angular/core';
import { FcCallbacks, FcEdge, FcModel, FcNode, FlowchartConstants, UserCallbacks, UserNodeCallbacks } from './ngx-flowchart.models'; import { FcCallbacks, FcEdge, FcModel, FcNode, FlowchartConstants, UserCallbacks, UserNodeCallbacks } from './ngx-flowchart.models';
import { FcModelService } from './model.service'; import { FcModelService } from './model.service';
@ -60,6 +60,9 @@ export class NgxFlowchartComponent implements OnInit, DoCheck {
@Input() @Input()
dropTargetId: string; dropTargetId: string;
@Output()
modelChanged = new EventEmitter();
callbacks: FcCallbacks; callbacks: FcCallbacks;
userNodeCallbacks: UserNodeCallbacks; userNodeCallbacks: UserNodeCallbacks;
@ -114,7 +117,7 @@ export class NgxFlowchartComponent implements OnInit, DoCheck {
const element = $(this.elementRef.nativeElement); const element = $(this.elementRef.nativeElement);
this.modelService = new FcModelService(this.modelValidation, this.model, this.cd, this.selectedObjects, this.modelService = new FcModelService(this.modelValidation, this.model, this.modelChanged, this.cd, this.selectedObjects,
this.userCallbacks.dropNode, this.userCallbacks.createEdge, this.userCallbacks.edgeAdded, this.userCallbacks.nodeRemoved, this.userCallbacks.dropNode, this.userCallbacks.createEdge, this.userCallbacks.edgeAdded, this.userCallbacks.nodeRemoved,
this.userCallbacks.edgeRemoved, element[0], element[0].querySelector('svg')); this.userCallbacks.edgeRemoved, element[0], element[0].querySelector('svg'));

@ -44,11 +44,6 @@ export interface FcCoords {
y?: number; y?: number;
} }
export interface FcOffset {
top: number;
left: number;
}
export interface FcRectBox { export interface FcRectBox {
top: number; top: number;
left: number; left: number;

@ -207,6 +207,7 @@ export class FcNodeDraggingService {
draggedNode.y = Math.round(this.getYCoordinate(dragOffset.y + event.clientY)); draggedNode.y = Math.round(this.getYCoordinate(dragOffset.y + event.clientY));
} }
event.preventDefault(); event.preventDefault();
this.modelService.notifyModelChanged();
return false; return false;
}); });
} }
@ -245,6 +246,7 @@ export class FcNodeDraggingService {
this.resizeCanvas(draggedNode, this.draggedElements[i]); this.resizeCanvas(draggedNode, this.draggedElements[i]);
} }
event.preventDefault(); event.preventDefault();
this.modelService.notifyModelChanged();
return false; return false;
}); });
} }
@ -288,6 +290,7 @@ export class FcNodeDraggingService {
this.modelService.canvasHtmlElement.removeChild(shadowElement[0]); this.modelService.canvasHtmlElement.removeChild(shadowElement[0]);
} }
this.nodeDraggingScope.shadowElements.length = 0; this.nodeDraggingScope.shadowElements.length = 0;
this.modelService.notifyModelChanged();
} }
if (this.nodeDraggingScope.draggedNodes.length) { if (this.nodeDraggingScope.draggedNodes.length) {

Loading…
Cancel
Save