UNPKG

@wcardinal/wcardinal-geditor

Version:

WebGL-based graphic editor, tester and viewer for supervisory systems

80 lines 2.99 kB
import { __extends } from "tslib"; import { DCommandBase, EShapeCapabilities, EShapeCapability } from "@wcardinal/wcardinal-ui"; var ECommandShapeDataMappingValueBringForward = /** @class */ (function (_super) { __extends(ECommandShapeDataMappingValueBringForward, _super); function ECommandShapeDataMappingValueBringForward(target, selection) { var _this = _super.call(this) || this; _this._selection = selection; _this._target = target; var indices = []; var shapes = _this._selection.get(); for (var i = 0, imax = shapes.length; i < imax; ++i) { var shape = shapes[i]; if (EShapeCapabilities.contains(shape, EShapeCapability.DATA_MAPPING)) { var mapping = shape.data.getMapping(); if (mapping) { var index = mapping.indexOf(target); indices.push(index); if (0 < index) { mapping.swap(index - 1, index); } } else { indices.push(-1); } } else { indices.push(-1); } } _this._indices = indices; _this._selection.update("PROPERTY"); return _this; } Object.defineProperty(ECommandShapeDataMappingValueBringForward.prototype, "selection", { get: function () { return this._selection; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandShapeDataMappingValueBringForward.prototype, "target", { get: function () { return this._target; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandShapeDataMappingValueBringForward.prototype, "indices", { get: function () { return this._indices; }, enumerable: false, configurable: true }); ECommandShapeDataMappingValueBringForward.prototype.execute = function () { return true; }; ECommandShapeDataMappingValueBringForward.prototype.redo = function () { var shapes = this._selection.get(); var indices = this._indices; for (var i = 0, imax = shapes.length; i < imax; ++i) { var shape = shapes[i]; var index = indices[i]; if (0 < index) { var mapping = shape.data.getMapping(); if (mapping) { mapping.swap(index - 1, index); } } } this._selection.update("PROPERTY"); return true; }; ECommandShapeDataMappingValueBringForward.prototype.undo = function () { return this.redo(); }; return ECommandShapeDataMappingValueBringForward; }(DCommandBase)); export { ECommandShapeDataMappingValueBringForward }; //# sourceMappingURL=e-command-shape-data-mapping-value-bring-forward.js.map