UNPKG

@wcardinal/wcardinal-geditor

Version:

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

94 lines 3.4 kB
import { __extends } from "tslib"; import { DCommandBase, EShapeCapabilities, EShapeCapability } from "@wcardinal/wcardinal-ui"; var ECommandShapeDataMappingValueRemove = /** @class */ (function (_super) { __extends(ECommandShapeDataMappingValueRemove, _super); function ECommandShapeDataMappingValueRemove(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.remove(index); } } else { indices.push(-1); } } else { indices.push(-1); } } _this._indices = indices; _this._selection.update("PROPERTY"); return _this; } Object.defineProperty(ECommandShapeDataMappingValueRemove.prototype, "selection", { get: function () { return this._selection; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandShapeDataMappingValueRemove.prototype, "target", { get: function () { return this._target; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandShapeDataMappingValueRemove.prototype, "indices", { get: function () { return this._indices; }, enumerable: false, configurable: true }); ECommandShapeDataMappingValueRemove.prototype.execute = function () { return true; }; ECommandShapeDataMappingValueRemove.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.remove(index); } } } this._selection.update("PROPERTY"); return true; }; ECommandShapeDataMappingValueRemove.prototype.undo = function () { var target = this._target; 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.add(target, index); } } } this._selection.update("PROPERTY"); return true; }; return ECommandShapeDataMappingValueRemove; }(DCommandBase)); export { ECommandShapeDataMappingValueRemove }; //# sourceMappingURL=e-command-shape-data-mapping-value-remove.js.map