@wcardinal/wcardinal-geditor
Version:
WebGL-based graphic editor, tester and viewer for supervisory systems
50 lines • 2 kB
JavaScript
import { __extends } from "tslib";
import { DCommandBase } from "@wcardinal/wcardinal-ui";
import { EShapeTable } from "./e-shape-table";
var ECommandShapeTableColumnValueBringForward = /** @class */ (function (_super) {
__extends(ECommandShapeTableColumnValueBringForward, _super);
function ECommandShapeTableColumnValueBringForward(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 (shape instanceof EShapeTable) {
var index = shape.column.indexOf(target);
indices.push(index);
if (0 < index) {
shape.column.swap(index - 1, index);
}
}
}
_this._indices = indices;
_this._selection.update("PROPERTY");
return _this;
}
ECommandShapeTableColumnValueBringForward.prototype.execute = function () {
return true;
};
ECommandShapeTableColumnValueBringForward.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];
if (shape instanceof EShapeTable) {
var index = indices[i];
if (0 < index) {
shape.column.swap(index - 1, index);
}
}
}
this._selection.update("PROPERTY");
return true;
};
ECommandShapeTableColumnValueBringForward.prototype.undo = function () {
return this.redo();
};
return ECommandShapeTableColumnValueBringForward;
}(DCommandBase));
export { ECommandShapeTableColumnValueBringForward };
//# sourceMappingURL=e-command-shape-table-column-value-bring-forward.js.map