devexpress-reporting
Version:
DevExpress Reporting provides the capability to develop a reporting application to create and customize reports.
894 lines (891 loc) • 489 kB
JavaScript
/**
* DevExpress HTML/JS Query Builder (dx-querybuilder.js)
* Version: 18.1.10
* Build date: 2019-03-10
* Copyright (c) 2012 - 2019 Developer Express Inc. ALL RIGHTS RESERVED
* License: https://www.devexpress.com/Support/EULAs/NetComponents.xml
*/
var DevExpress = require('./dx-designer');
var $ = require('jquery');
var ko = require('knockout');
require('devextreme/ui/check_box');
require('devextreme/ui/radio_group');
DevExpress.validationEngine = require("devextreme/ui/validation_engine");
module.exports = DevExpress;
var DevExpress;
(function (DevExpress) {
var Analytics;
(function (Analytics) {
var Diagram;
(function (Diagram) {
ko.bindingHandlers["routeLineDraggable"] = {
init: function (element, valueAccessor) {
var values = valueAccessor(), options = $.extend({ snap: '.dxrd-drag-snap-line', snapTolerance: Analytics.Internal.SnapLinesHelper.snapTolerance }, ko.unwrap(values), {
start: function (event, ui) {
values.starting();
},
stop: function (event, ui) {
values.stopped();
},
drag: function (event, ui) {
var dx = ui.position.left - ui["originalPosition"].left, dy = ui.position.top - ui["originalPosition"].top;
values.forceResize({ delta: { dx: dx, dy: dy } });
}
});
$(element).draggable(options);
}
};
function getInternetExplorerVersion() {
var rv = -1;
if (navigator.appName == 'Microsoft Internet Explorer') {
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(navigator.userAgent) != null)
rv = parseFloat(RegExp.$1);
}
else if (navigator.appName == 'Netscape') {
var re = new RegExp("Trident/.*rv:([0-9]{1,}[\.0-9]{0,})");
if (re.exec(navigator.userAgent) != null)
rv = parseFloat(RegExp.$1);
}
return rv;
}
ko.bindingHandlers["updateConnectorArrow"] = {
init: function (svgNode, valueAccessor, allBindings, viewModel, bindingContext) {
var ieVersion = getInternetExplorerVersion();
if (ieVersion > -1 && ieVersion <= 11) {
var updateSubscription = bindingContext.$data.routePointsSet.subscribe(function () {
if (bindingContext.$data.showArrow())
svgNode.parentNode.insertBefore(svgNode, svgNode);
});
ko.utils.domNodeDisposal.addDisposeCallback(svgNode.parentNode, function () { return updateSubscription.dispose(); });
}
}
};
})(Diagram = Analytics.Diagram || (Analytics.Diagram = {}));
})(Analytics = DevExpress.Analytics || (DevExpress.Analytics = {}));
})(DevExpress || (DevExpress = {}));
var DevExpress;
(function (DevExpress) {
var Analytics;
(function (Analytics) {
var Diagram;
(function (Diagram) {
Diagram.controlsFactory = new Analytics.Utils.ControlsFactory();
function registerControls() {
Diagram.controlsFactory.registerControl("Unknown", {
info: Diagram.unknownSerializationsInfo,
type: Analytics.ElementViewModel,
nonToolboxItem: true,
surfaceType: Analytics.SurfaceElementBase
});
Diagram.controlsFactory.registerControl("Connector", {
info: [
Diagram.name,
{ propertyName: "location", displayName: "Location", editor: DevExpress.JS.Widgets.editorTemplates.objecteditor },
{ propertyName: "startPoint", modelName: "@StartPoint", link: true },
{ propertyName: "endPoint", modelName: "@EndPoint", link: true }
],
surfaceType: Diagram.ConnectorSurface,
type: Diagram.ConnectorViewModel,
elementActionsTypes: [],
nonToolboxItem: false
});
Diagram.controlsFactory.registerControl("RoutedConnector", {
info: [
Diagram.name,
{ propertyName: "location", displayName: "Location", editor: DevExpress.JS.Widgets.editorTemplates.objecteditor },
{ propertyName: "startPoint", modelName: "@StartPoint", link: true },
{ propertyName: "endPoint", modelName: "@EndPoint", link: true }
],
surfaceType: Diagram.RoutedConnectorSurface,
type: Diagram.RoutedConnectorViewModel,
elementActionsTypes: [],
nonToolboxItem: false
});
Diagram.controlsFactory.registerControl("ConnectionPoint", {
info: Diagram.connectionPointSerializationInfo,
surfaceType: Diagram.ConnectionPointSurface,
type: Diagram.ConnectionPointViewModel,
elementActionsTypes: [],
nonToolboxItem: true
});
Diagram.controlsFactory.registerControl("Diagram", {
info: Diagram.diagramSerializationsInfo,
surfaceType: Diagram.DiagramSurface,
popularProperties: ["name"],
type: Diagram.DiagramViewModel,
elementActionsTypes: [],
isContainer: true,
nonToolboxItem: true
});
Diagram.controlsFactory.registerControl("DiagramElement", {
info: Diagram.diagramElementSerializationInfo,
defaultVal: {
"@SizeF": "150,50",
"ConnectingPoints": {
"Item1": {
"@ControlType": "ConnectingPoint",
"@PercentOffsetX": "1",
"@PercentOffsetY": "0.5",
},
"Item2": {
"@ControlType": "ConnectingPoint",
"@PercentOffsetX": "0.5",
"@PercentOffsetY": "1",
},
"Item3": {
"@ControlType": "ConnectingPoint",
"@PercentOffsetX": "0.5",
"@PercentOffsetY": "0",
},
"Item4": {
"@ControlType": "ConnectingPoint",
"@PercentOffsetX": "0",
"@PercentOffsetY": "0.5",
}
}
},
surfaceType: Diagram.DiagramElementSurface,
popularProperties: ["text"],
type: Diagram.DiagramElementViewModel,
elementActionsTypes: [],
nonToolboxItem: false
});
Diagram.controlsFactory.registerControl("Ellipse", {
info: Diagram.diagramElementSerializationInfo,
defaultVal: {
"@SizeF": "150,50",
"@Type": "Ellipse",
"ConnectingPoints": {
"Item1": {
"@ControlType": "ConnectingPoint",
"@PercentOffsetX": "1",
"@PercentOffsetY": "0.5",
},
"Item2": {
"@ControlType": "ConnectingPoint",
"@PercentOffsetX": "0.5",
"@PercentOffsetY": "1",
},
"Item3": {
"@ControlType": "ConnectingPoint",
"@PercentOffsetX": "0.5",
"@PercentOffsetY": "0",
},
"Item4": {
"@ControlType": "ConnectingPoint",
"@PercentOffsetX": "0",
"@PercentOffsetY": "0.5",
}
}
},
surfaceType: Diagram.DiagramElementSurface,
popularProperties: ["text"],
type: Diagram.DiagramElementViewModel,
elementActionsTypes: [],
nonToolboxItem: false
});
Diagram.controlsFactory.registerControl("Condition", {
info: Diagram.diagramElementSerializationInfo,
defaultVal: {
"@SizeF": "150,50",
"@Type": "Condition",
"ConnectingPoints": {
"Item1": {
"@ControlType": "ConnectingPoint",
"@PercentOffsetX": "1",
"@PercentOffsetY": "0.5",
},
"Item2": {
"@ControlType": "ConnectingPoint",
"@PercentOffsetX": "0.5",
"@PercentOffsetY": "1",
},
"Item3": {
"@ControlType": "ConnectingPoint",
"@PercentOffsetX": "0.5",
"@PercentOffsetY": "0",
},
"Item4": {
"@ControlType": "ConnectingPoint",
"@PercentOffsetX": "0",
"@PercentOffsetY": "0.5",
}
}
},
surfaceType: Diagram.DiagramElementSurface,
popularProperties: ["text"],
type: Diagram.DiagramElementViewModel,
elementActionsTypes: [],
nonToolboxItem: false
});
Diagram.controlsFactory.registerControl("ConnectingPoint", {
info: Diagram.connectingPointSerializationInfo,
surfaceType: Diagram.ConnectingPointSurface,
type: Diagram.ConnectingPointViewModel,
elementActionsTypes: [],
nonToolboxItem: true
});
}
Diagram.registerControls = registerControls;
})(Diagram = Analytics.Diagram || (Analytics.Diagram = {}));
})(Analytics = DevExpress.Analytics || (DevExpress.Analytics = {}));
})(DevExpress || (DevExpress = {}));
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var DevExpress;
(function (DevExpress) {
var Analytics;
(function (Analytics) {
var Diagram;
(function (Diagram) {
var ConnectingPointDragHandler = (function (_super) {
__extends(ConnectingPointDragHandler, _super);
function ConnectingPointDragHandler(surface, selection, undoEngine, snapHelper, dragHelperContent) {
_super.call(this, surface, selection, undoEngine, snapHelper);
this.startConnectingPoint = null;
this.newConnector = null;
this.cursor = 'arrow';
this.containment = '.dxrd-ghost-container';
this["helper"] = function (draggable) {
dragHelperContent.update(draggable);
};
}
ConnectingPointDragHandler.prototype.startDrag = function (control) {
if (!(control instanceof Diagram.ConnectingPointSurface)) {
throw new Error("ConnectingPointDragHandler can be applied to the ConnectingPoint only.");
}
this.startConnectingPoint = control;
var diagramElement = this.startConnectingPoint.parent.getControlModel();
this.newConnector = diagramElement.parentModel().createChild({ "@ControlType": "RoutedConnector" });
this.newConnector.startPoint().connectingPoint(this.startConnectingPoint.getControlModel());
};
ConnectingPointDragHandler.prototype.drag = function (event, ui) {
ui.position.left += ui["scroll"].left;
ui.position.top += ui["scroll"].top;
var position = this._getAbsoluteSurfacePosition(ui);
this.newConnectorSurface.endPoint().rect({ top: position.top, left: position.left });
};
ConnectingPointDragHandler.prototype.doStopDrag = function () {
if (this.selection.dropTarget) {
var dropTarget = this.selection.dropTarget.getControlModel();
if (dropTarget instanceof Diagram.ConnectingPointViewModel) {
this.newConnector.endPoint().connectingPoint(dropTarget);
}
else if (dropTarget instanceof Diagram.DiagramElementViewModel) {
var connectings = dropTarget.connectingPoints();
this.newConnector.endPoint().connectingPoint(connectings[0]);
}
this.selection.initialize(this.newConnectorSurface);
}
};
Object.defineProperty(ConnectingPointDragHandler.prototype, "newConnectorSurface", {
get: function () {
return this.newConnector && Analytics.Internal.findSurface(this.newConnector);
},
enumerable: true,
configurable: true
});
return ConnectingPointDragHandler;
})(Analytics.Internal.DragDropHandler);
Diagram.ConnectingPointDragHandler = ConnectingPointDragHandler;
})(Diagram = Analytics.Diagram || (Analytics.Diagram = {}));
})(Analytics = DevExpress.Analytics || (DevExpress.Analytics = {}));
})(DevExpress || (DevExpress = {}));
var DevExpress;
(function (DevExpress) {
var Analytics;
(function (Analytics) {
var Diagram;
(function (Diagram) {
var ConnectionPointDragHandler = (function (_super) {
__extends(ConnectionPointDragHandler, _super);
function ConnectionPointDragHandler(surface, selection, undoEngine, snapHelper, dragHelperContent) {
_super.call(this, surface, selection, undoEngine, snapHelper);
this.currentConnectionPoint = null;
this.cursor = 'arrow';
this.containment = '.dxrd-ghost-container';
this["helper"] = function (draggable) {
dragHelperContent.update(draggable);
};
}
ConnectionPointDragHandler.prototype.startDrag = function (control) {
if (!(control instanceof Diagram.ConnectionPointSurface)) {
throw new Error("ConnectionPointDragHandler can be applied to the ConnectionPoint only.");
}
this.currentConnectionPoint = control;
};
ConnectionPointDragHandler.prototype.drag = function (event, ui) {
ui.position.left += ui["scroll"].left;
ui.position.top += ui["scroll"].top;
var position = this._getAbsoluteSurfacePosition(ui);
this.currentConnectionPoint.rect({ top: position.top, left: position.left });
};
ConnectionPointDragHandler.prototype.doStopDrag = function () {
if (this.selection.dropTarget) {
var dropTarget = this.selection.dropTarget.getControlModel();
if (dropTarget instanceof Diagram.ConnectingPointViewModel) {
var connector = this.currentConnectionPoint.parent.getControlModel();
if (this.currentConnectionPoint.getControlModel() === connector.startPoint()) {
connector.startPoint().connectingPoint(dropTarget);
}
else {
connector.endPoint().connectingPoint(dropTarget);
}
}
else if (dropTarget instanceof Diagram.DiagramElementViewModel) {
var connector = this.currentConnectionPoint.parent.getControlModel();
var connectings = dropTarget.connectingPoints();
if (this.currentConnectionPoint.getControlModel() === connector.startPoint()) {
connector.startPoint().connectingPoint(connectings[0]);
}
else {
connector.endPoint().connectingPoint(connectings[0]);
}
}
}
};
return ConnectionPointDragHandler;
})(Analytics.Internal.DragDropHandler);
Diagram.ConnectionPointDragHandler = ConnectionPointDragHandler;
})(Diagram = Analytics.Diagram || (Analytics.Diagram = {}));
})(Analytics = DevExpress.Analytics || (DevExpress.Analytics = {}));
})(DevExpress || (DevExpress = {}));
var DevExpress;
(function (DevExpress) {
var Analytics;
(function (Analytics) {
var Diagram;
(function (Diagram) {
Diagram.name = { propertyName: "name", modelName: "@Name", displayName: "Name", editor: Analytics.Widgets.editorTemplates.text, validationRules: Analytics.Internal.nameValidationRules };
Diagram.text = { propertyName: "text", modelName: "@Text", displayName: "Text", editor: Analytics.Widgets.editorTemplates.text };
Diagram.size = { propertyName: "size", modelName: "@Size", defaultVal: "100,50", from: Analytics.Size.fromString, displayName: "Size", editor: Analytics.Widgets.editorTemplates.objecteditor };
Diagram.location = { propertyName: "location", modelName: "@Location", from: Analytics.Point.fromString, displayName: "Location", editor: Analytics.Widgets.editorTemplates.objecteditor };
Diagram.sizeLocation = [Diagram.size, Diagram.location];
Diagram.unknownSerializationsInfo = [Diagram.name].concat(Diagram.sizeLocation);
})(Diagram = Analytics.Diagram || (Analytics.Diagram = {}));
})(Analytics = DevExpress.Analytics || (DevExpress.Analytics = {}));
})(DevExpress || (DevExpress = {}));
///<reference path="../metadata.ts" />
var DevExpress;
(function (DevExpress) {
var Analytics;
(function (Analytics) {
var Diagram;
(function (Diagram) {
var DiagramElementBaseViewModel = (function (_super) {
__extends(DiagramElementBaseViewModel, _super);
function DiagramElementBaseViewModel(control, parent, serializer) {
_super.call(this, control, parent, serializer);
}
DiagramElementBaseViewModel.prototype.getControlFactory = function () {
return Diagram.controlsFactory;
};
return DiagramElementBaseViewModel;
})(Analytics.ElementViewModel);
Diagram.DiagramElementBaseViewModel = DiagramElementBaseViewModel;
var DiagramElementViewModel = (function (_super) {
__extends(DiagramElementViewModel, _super);
function DiagramElementViewModel(control, parent, serializer) {
var _this = this;
_super.call(this, $.extend({ "@ControlType": "DiagramElement" }, control), parent, serializer);
this.connectingPoints = Analytics.Utils.deserializeArray(control && control.ConnectingPoints || [], function (item) { return new Diagram.ConnectingPointViewModel(item, _this, serializer); });
if (this.text() === undefined) {
this.text(this.name());
}
}
return DiagramElementViewModel;
})(DiagramElementBaseViewModel);
Diagram.DiagramElementViewModel = DiagramElementViewModel;
Diagram.diagramElementSerializationInfo = [Diagram.size, Diagram.location, Diagram.name, Diagram.text, { propertyName: "type", modelName: "@Type" }];
})(Diagram = Analytics.Diagram || (Analytics.Diagram = {}));
})(Analytics = DevExpress.Analytics || (DevExpress.Analytics = {}));
})(DevExpress || (DevExpress = {}));
///<reference path="diagramElementModel.ts" />
var DevExpress;
(function (DevExpress) {
var Analytics;
(function (Analytics) {
var Diagram;
(function (Diagram) {
var ConnectingPointViewModel = (function (_super) {
__extends(ConnectingPointViewModel, _super);
function ConnectingPointViewModel(control, parent, serializer) {
var _this = this;
_super.call(this, $.extend({ "@ControlType": "ConnectingPoint" }, control), parent, serializer);
this.side = ko.pureComputed(function () {
if (_this.percentOffsetY() >= _this.percentOffsetX()) {
if (_this.percentOffsetY() > 1 - _this.percentOffsetX()) {
return Diagram.PointSide.South;
}
else {
return Diagram.PointSide.West;
}
}
else {
if (_this.percentOffsetY() > 1 - _this.percentOffsetX()) {
return Diagram.PointSide.East;
}
else {
return Diagram.PointSide.North;
}
}
});
this.size = new Analytics.Size(7, 7);
this.location = new Analytics.Point(0, 0);
this.location.x = ko.pureComputed(function () {
var parentModel = _this.parentModel();
return parentModel.location.x() + parentModel.size.width() * _this.percentOffsetX();
});
this.location.y = ko.pureComputed(function () {
var parentModel = _this.parentModel();
return parentModel.location.y() + parentModel.size.height() * _this.percentOffsetY();
});
}
return ConnectingPointViewModel;
})(Diagram.DiagramElementBaseViewModel);
Diagram.ConnectingPointViewModel = ConnectingPointViewModel;
Diagram.connectingPointSerializationInfo = [
{ propertyName: "percentOffsetX", modelName: "@PercentOffsetX", defaultVal: 0.5, from: Analytics.Utils.floatFromModel },
{ propertyName: "percentOffsetY", modelName: "@PercentOffsetY", defaultVal: 0.5, from: Analytics.Utils.floatFromModel }
];
})(Diagram = Analytics.Diagram || (Analytics.Diagram = {}));
})(Analytics = DevExpress.Analytics || (DevExpress.Analytics = {}));
})(DevExpress || (DevExpress = {}));
var DevExpress;
(function (DevExpress) {
var Analytics;
(function (Analytics) {
var Diagram;
(function (Diagram) {
var DiagramElementBaseSurface = (function (_super) {
__extends(DiagramElementBaseSurface, _super);
function DiagramElementBaseSurface(control, context, unitProperties) {
_super.call(this, control, context, $.extend({}, DiagramElementBaseSurface._unitProperties, unitProperties));
this.template = "dx-diagram-element";
this.selectiontemplate = "dx-diagram-element-selection";
this.contenttemplate = "dx-diagram-element-content";
this.margin = ko.observable(0);
}
DiagramElementBaseSurface._unitProperties = {
_height: function (o) {
return o.size.height;
},
_width: function (o) {
return o.size.width;
},
_x: function (o) {
return o.location.x;
},
_y: function (o) {
return o.location.y;
}
};
return DiagramElementBaseSurface;
})(Analytics.SurfaceElementBase);
Diagram.DiagramElementBaseSurface = DiagramElementBaseSurface;
var DiagramElementSurface = (function (_super) {
__extends(DiagramElementSurface, _super);
function DiagramElementSurface(control, context) {
_super.call(this, control, context, null);
this.contenttemplate = "dxdd-element-content-with-connecting-points";
}
DiagramElementSurface.prototype._getChildrenHolderName = function () { return "connectingPoints"; };
return DiagramElementSurface;
})(DiagramElementBaseSurface);
Diagram.DiagramElementSurface = DiagramElementSurface;
})(Diagram = Analytics.Diagram || (Analytics.Diagram = {}));
})(Analytics = DevExpress.Analytics || (DevExpress.Analytics = {}));
})(DevExpress || (DevExpress = {}));
///<reference path="diagramElementSurface.ts" />
var DevExpress;
(function (DevExpress) {
var Analytics;
(function (Analytics) {
var Diagram;
(function (Diagram) {
var ConnectingPointSurface = (function (_super) {
__extends(ConnectingPointSurface, _super);
function ConnectingPointSurface(control, context) {
_super.call(this, control, context, ConnectingPointSurface._unitProperties);
this.template = "dxdd-connecting-point";
this.selectiontemplate = "dxdd-connection-point-selection";
this.contenttemplate = "";
}
ConnectingPointSurface._unitProperties = {
_x: function (o) {
return ko.pureComputed(function () { return o.location.x() - o.parentModel().location.x(); });
},
_y: function (o) {
return ko.pureComputed(function () { return o.location.y() - o.parentModel().location.y(); });
}
};
return ConnectingPointSurface;
})(Diagram.DiagramElementBaseSurface);
Diagram.ConnectingPointSurface = ConnectingPointSurface;
})(Diagram = Analytics.Diagram || (Analytics.Diagram = {}));
})(Analytics = DevExpress.Analytics || (DevExpress.Analytics = {}));
})(DevExpress || (DevExpress = {}));
///<reference path="../diagramElementModel.ts" />
var DevExpress;
(function (DevExpress) {
var Analytics;
(function (Analytics) {
var Diagram;
(function (Diagram) {
var ConnectionPointViewModel = (function (_super) {
__extends(ConnectionPointViewModel, _super);
function ConnectionPointViewModel(control, parent, serializer) {
var _this = this;
_super.call(this, $.extend(control, { "@ControlType": "ConnectionPoint" }), parent, serializer);
var _x = this.location.x, _y = this.location.y;
this.location.x = ko.pureComputed({
read: function () {
return _this.connectingPoint() && _this.connectingPoint().location.x() || _x();
},
write: function (value) {
_this.connectingPoint(null);
_x(value);
}
});
this.location.y = ko.pureComputed({
read: function () {
return _this.connectingPoint() && _this.connectingPoint().location.y() || _y();
},
write: function (value) {
_this.connectingPoint(null);
_y(value);
}
});
}
return ConnectionPointViewModel;
})(Diagram.DiagramElementBaseViewModel);
Diagram.ConnectionPointViewModel = ConnectionPointViewModel;
Diagram.connectionPointSerializationInfo = [
Diagram.location,
{ propertyName: "connectingPoint", modelName: "@ConnectingPoint", link: true }
];
})(Diagram = Analytics.Diagram || (Analytics.Diagram = {}));
})(Analytics = DevExpress.Analytics || (DevExpress.Analytics = {}));
})(DevExpress || (DevExpress = {}));
var DevExpress;
(function (DevExpress) {
var Analytics;
(function (Analytics) {
var Diagram;
(function (Diagram) {
var ConnectionPointSurface = (function (_super) {
__extends(ConnectionPointSurface, _super);
function ConnectionPointSurface(control, context) {
var _this = this;
_super.call(this, control, context, ConnectionPointSurface._unitProperties);
this.template = "dx-diagram-connection-point";
this.selectiontemplate = "dx-diagram-connection-point";
this.relativeX = ko.pureComputed(function () {
return _this.rect().left - _this.parent.rect().left;
});
this.relativeY = ko.pureComputed(function () {
return _this.rect().top - _this.parent.rect().top;
});
}
ConnectionPointSurface.prototype.container = function () {
return this.getRoot();
};
ConnectionPointSurface._unitProperties = {
_x: function (o) {
return o.location.x;
},
_y: function (o) {
return o.location.y;
}
};
return ConnectionPointSurface;
})(Analytics.SurfaceElementBase);
Diagram.ConnectionPointSurface = ConnectionPointSurface;
})(Diagram = Analytics.Diagram || (Analytics.Diagram = {}));
})(Analytics = DevExpress.Analytics || (DevExpress.Analytics = {}));
})(DevExpress || (DevExpress = {}));
///<reference path="../diagramElementModel.ts" />
var DevExpress;
(function (DevExpress) {
var Analytics;
(function (Analytics) {
var Diagram;
(function (Diagram) {
var ConnectorViewModel = (function (_super) {
__extends(ConnectorViewModel, _super);
function ConnectorViewModel(control, parent, serializer) {
var _this = this;
_super.call(this, $.extend({ "@ControlType": "Connector" }, control), parent, serializer);
this.startPoint(this.startPoint() || new Diagram.ConnectionPointViewModel({ "@Location": "0, 0" }, this, serializer));
this.endPoint(this.endPoint() || new Diagram.ConnectionPointViewModel({ "@Location": "150, 75" }, this, serializer));
this.location = new Analytics.Point(0, 0);
this.location.x = ko.pureComputed({
read: function () {
return _this.getX();
},
write: function (value) {
var oldValue = _this.startPoint().location.x() < _this.endPoint().location.x() ? _this.startPoint().location.x() : _this.endPoint().location.x();
var delta = value - oldValue;
_this.startPoint().location.x(_this.startPoint().location.x() + delta);
_this.endPoint().location.x(_this.endPoint().location.x() + delta);
}
});
this.location.y = ko.pureComputed({
read: function () {
return _this.getY();
},
write: function (value) {
var oldValue = _this.startPoint().location.y() < _this.endPoint().location.y() ? _this.startPoint().location.y() : _this.endPoint().location.y();
var delta = value - oldValue;
_this.startPoint().location.y(_this.startPoint().location.y() + delta);
_this.endPoint().location.y(_this.endPoint().location.y() + delta);
}
});
this.size = new Analytics.Size(0, 0);
this.size.width = ko.pureComputed({
read: function () {
return _this.getWidth();
},
write: function (value) {
if (_this.startPoint().location.x() < _this.endPoint().location.x()) {
_this.endPoint().location.x(_this.startPoint().location.x() + value);
}
else {
_this.startPoint().location.x(_this.endPoint().location.x() + value);
}
}
});
this.size.height = ko.pureComputed({
read: function () {
return _this.getHeight();
},
write: function (value) {
if (_this.startPoint().location.y() < _this.endPoint().location.y()) {
_this.endPoint().location.y(_this.startPoint().location.y() + value);
}
else {
_this.startPoint().location.y(_this.endPoint().location.y() + value);
}
}
});
}
ConnectorViewModel.prototype.getX = function () {
return this.startPoint().location.x() < this.endPoint().location.x() ? this.startPoint().location.x() : this.endPoint().location.x();
};
ConnectorViewModel.prototype.getY = function () {
return this.startPoint().location.y() < this.endPoint().location.y() ? this.startPoint().location.y() : this.endPoint().location.y();
};
ConnectorViewModel.prototype.getWidth = function () {
return Math.abs(this.startPoint().location.x() - this.endPoint().location.x()) || ConnectorViewModel.MIN_LINE_THICKNESS;
};
ConnectorViewModel.prototype.getHeight = function () {
return Math.abs(this.startPoint().location.y() - this.endPoint().location.y()) || ConnectorViewModel.MIN_LINE_THICKNESS;
};
ConnectorViewModel.MIN_LINE_THICKNESS = 3;
return ConnectorViewModel;
})(Diagram.DiagramElementBaseViewModel);
Diagram.ConnectorViewModel = ConnectorViewModel;
})(Diagram = Analytics.Diagram || (Analytics.Diagram = {}));
})(Analytics = DevExpress.Analytics || (DevExpress.Analytics = {}));
})(DevExpress || (DevExpress = {}));
///<reference path="../diagramElementSurface.ts" />
var DevExpress;
(function (DevExpress) {
var Analytics;
(function (Analytics) {
var Diagram;
(function (Diagram) {
var ConnectorSurface = (function (_super) {
__extends(ConnectorSurface, _super);
function ConnectorSurface(control, context) {
_super.call(this, control, context, null);
this.template = "dxdd-connector";
this.selectiontemplate = "dxdd-connector-selection";
this.startPoint = ko.pureComputed(function () {
return new Diagram.ConnectionPointSurface(control.startPoint(), context);
});
this.endPoint = ko.pureComputed(function () {
return new Diagram.ConnectionPointSurface(control.endPoint(), context);
});
}
return ConnectorSurface;
})(Diagram.DiagramElementBaseSurface);
Diagram.ConnectorSurface = ConnectorSurface;
})(Diagram = Analytics.Diagram || (Analytics.Diagram = {}));
})(Analytics = DevExpress.Analytics || (DevExpress.Analytics = {}));
})(DevExpress || (DevExpress = {}));
var DevExpress;
(function (DevExpress) {
var Analytics;
(function (Analytics) {
var Diagram;
(function (Diagram) {
var RoutedConnectorViewModel = (function (_super) {
__extends(RoutedConnectorViewModel, _super);
function RoutedConnectorViewModel(control, parent, serializer) {
var _this = this;
_super.call(this, $.extend({ "@ControlType": "RoutedConnector" }, control), parent, serializer);
this._isUpdating = false;
this._getPower = function (_n) {
for (var i = 0; i < 10; i++) {
if (_n >= Math.pow(2, i) && _n < Math.pow(2, i + 1)) {
return i + 1;
}
}
return 1;
};
this.seriesNumber = ko.observable(1);
this.routePoints = ko.observable([]);
this.freezeRoute = ko.observable(false);
this._disposables.push(ko.computed(function () {
var freezeRoute = !(1 + _this.startPoint().location.x() + _this.startPoint().location.y()
+ _this.endPoint().location.x() + _this.endPoint().location.y());
if (!_this._isUpdating) {
_this.freezeRoute(freezeRoute);
}
}));
this._disposables.push(ko.computed(function () {
if (!_this.freezeRoute()) {
var result = [];
var startPointSide = _this._getStartPointSide();
var endPointSide = _this._getEndPointSide();
var startPoint = new Analytics.Point(_this.startPoint().location.x(), _this.startPoint().location.y()), endPoint = new Analytics.Point(_this.endPoint().location.x(), _this.endPoint().location.y());
if (_this.startPoint().connectingPoint()) {
_this._fixPoint(startPoint, _this.startPoint().connectingPoint().side());
result.push(startPoint);
}
if (_this.endPoint().connectingPoint()) {
_this._fixPoint(endPoint, _this.endPoint().connectingPoint().side());
}
var baseX = Math.min(startPoint.x(), endPoint.x()), baseY = Math.min(startPoint.y(), endPoint.y()), width = Math.abs(startPoint.x() - endPoint.x()), height = Math.abs(startPoint.y() - endPoint.y());
var number = _this.seriesNumber();
var ratio = _this._getRatio(number);
var indent = (number - 1) * RoutedConnectorViewModel.GRID_SIZE;
if (startPoint.y() - endPoint.y() > 0) {
if (startPoint.x() - endPoint.x() > 0) {
if (startPointSide === Diagram.PointSide.North || startPointSide === Diagram.PointSide.East) {
if (endPointSide === Diagram.PointSide.North || endPointSide === Diagram.PointSide.East) {
if (number !== 1) {
width += indent;
result.push(new Analytics.Point(baseX + width, baseY + height));
}
result.push(new Analytics.Point(baseX + width, baseY));
}
else {
result.push(new Analytics.Point(baseX + width, baseY + height * ratio));
result.push(new Analytics.Point(baseX, baseY + height * ratio));
}
}
else {
if (endPointSide === Diagram.PointSide.South || endPointSide === Diagram.PointSide.West) {
result.push(new Analytics.Point(baseX, baseY + height));
}
else {
result.push(new Analytics.Point(baseX + width * ratio, baseY + height));
result.push(new Analytics.Point(baseX + width * ratio, baseY));
}
}
}
else {
if (startPointSide === Diagram.PointSide.North || startPointSide === Diagram.PointSide.West) {
if (endPointSide === Diagram.PointSide.North || endPointSide === Diagram.PointSide.West) {
if (number !== 1) {
baseX -= indent;
result.push(new Analytics.Point(baseX, baseY + height));
}
result.push(new Analytics.Point(baseX, baseY));
}
else {
result.push(new Analytics.Point(baseX, baseY + height * ratio));
result.push(new Analytics.Point(baseX + width, baseY + height * ratio));
}
}
else {
if (endPointSide === Diagram.PointSide.South || endPointSide === Diagram.PointSide.East) {
result.push(new Analytics.Point(baseX + width, baseY + height));
}
else {
result.push(new Analytics.Point(baseX + width * ratio, baseY + height));
result.push(new Analytics.Point(baseX + width * ratio, baseY));
}
}
}
}
else {
if (startPoint.x() - endPoint.x() > 0) {
if (startPointSide === Diagram.PointSide.South || startPointSide === Diagram.PointSide.East) {
if (endPointSide === Diagram.PointSide.South || endPointSide === Diagram.PointSide.East) {
if (number !== 1) {
width += indent;
result.push(new Analytics.Point(baseX + width, baseY));
}
result.push(new Analytics.Point(baseX + width, baseY + height));
}
else {
result.push(new Analytics.Point(baseX + width, baseY + height * ratio));
result.push(new Analytics.Point(baseX, baseY + height * ratio));
}
}
else {
if (endPointSide === Diagram.PointSide.North || endPointSide === Diagram.PointSide.West) {
result.push(new Analytics.Point(baseX, baseY));
}
else {
result.push(new Analytics.Point(baseX + width * ratio, baseY));
result.push(new Analytics.Point(baseX + width * ratio, baseY + height));
}
}
}
else {
if (startPointSide === Diagram.PointSide.South || startPointSide === Diagram.PointSide.West) {
if (endPointSide === Diagram.PointSide.South || endPointSide === Diagram.PointSide.West) {
if (number !== 1) {
baseX -= indent;
result.push(new Analytics.Point(baseX, baseY));
}
result.push(new Analytics.Point(baseX, baseY + height));
}
else {
result.push(new Analytics.Point(baseX, baseY + height * ratio));
result.push(new Analytics.Point(baseX + width, baseY + height * ratio));
}
}
else {
if (endPointSide === Diagram.PointSide.North || endPointSide === Diagram.PointSide.East) {
result.push(new Analytics.Point(baseX + width, baseY));
}
else {
result.push(new Analytics.Point(baseX + width * ratio, baseY));
result.push(new Analytics.Point(baseX + width * ratio, baseY + height));
}
}
}
}
if (_this.endPoint().connectingPoint()) {
result.push(endPoint);
}
_this.routePoints(result);
}
}));
}
RoutedConnectorViewModel.prototype.getX = function () {
var result = _super.prototype.getX.call(this);
this.routePoints && this.routePoints().forEach(function (point) {
if (point.x() < result) {
result = point.x();
}
});
return result;
};
RoutedConnectorViewModel.prototype.getY = function () {
var result = _super.prototype.getY.call(this);
this.routePoints && this.routePoints().forEach(function (point) {
if (point.y() < result) {
result = point.y();
}
});
return result;