UNPKG

@wcardinal/wcardinal-geditor

Version:

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

78 lines 3.01 kB
import { __extends } from "tslib"; import { DCommandBase, EShapeCapabilities, EShapeCapability } from "@wcardinal/wcardinal-ui"; var ECommandShapeDataMappingValueSendBackward = /** @class */ (function (_super) { __extends(ECommandShapeDataMappingValueSendBackward, _super); function ECommandShapeDataMappingValueSendBackward(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 && index < mapping.size() - 1) { mapping.swap(index + 1, index); } } else { indices.push(-1); } } else { indices.push(-1); } } _this._indices = indices; _this._selection.update("PROPERTY"); return _this; } Object.defineProperty(ECommandShapeDataMappingValueSendBackward.prototype, "selection", { get: function () { return this._selection; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandShapeDataMappingValueSendBackward.prototype, "target", { get: function () { return this._target; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandShapeDataMappingValueSendBackward.prototype, "indices", { get: function () { return this._indices; }, enumerable: false, configurable: true }); ECommandShapeDataMappingValueSendBackward.prototype.execute = function () { return true; }; ECommandShapeDataMappingValueSendBackward.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]; var mapping = shape.data.getMapping(); if (mapping && 0 <= index && index < mapping.size() - 1) { mapping.swap(index + 1, index); } } this._selection.update("PROPERTY"); return true; }; ECommandShapeDataMappingValueSendBackward.prototype.undo = function () { return this.redo(); }; return ECommandShapeDataMappingValueSendBackward; }(DCommandBase)); export { ECommandShapeDataMappingValueSendBackward }; //# sourceMappingURL=e-command-shape-data-mapping-value-send-backward.js.map