@aurigma/design-atoms
Version:
Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.
40 lines • 2.17 kB
JavaScript
import { NotImplementedException } from "@aurigma/design-atoms-model/Exception";
import { DefaultLayoutSettings, GroupItem, LayoutItem, } from "@aurigma/design-atoms-model/Product/Items";
import { BaseItemsCommand } from "./BaseItemsCommand";
import { ItemsCommand, SurfaceCommand } from "@aurigma/design-atoms-interfaces";
export class ConvertGroupIntoLayoutCommand extends BaseItemsCommand {
constructor(productHandler, historyArgs, args, _commandManager, _canvas) {
super(productHandler, historyArgs, args);
this._commandManager = _commandManager;
this._canvas = _canvas;
}
async _executeCommandBody() {
var _a, _b, _c, _d;
const targetItems = this._getTargetItems(this._args.items, this._args.query, this._args.queryOptions);
await this._commandManager.execute(ItemsCommand.deleteItems, { items: targetItems, force: true });
const items = targetItems;
const layoutItems = [];
const layoutName = (_b = (_a = this._args.names) === null || _a === void 0 ? void 0 : _a.layoutName) !== null && _b !== void 0 ? _b : "Layout item";
const groupName = (_d = (_c = this._args.names) === null || _c === void 0 ? void 0 : _c.groupName) !== null && _d !== void 0 ? _d : "Group item";
items.forEach((item) => {
if (item instanceof GroupItem) {
const layout = new LayoutItem(item.items.toArray(), new DefaultLayoutSettings());
layout.name = item.name.includes(groupName) ? item.name.replace(groupName, layoutName) : item.name;
layoutItems.push(layout);
}
});
await this._commandManager.execute(SurfaceCommand.addItems, { items: layoutItems });
layoutItems.forEach((layoutItem) => {
const handler = this._canvas.viewer.getHandler(layoutItem);
handler.generateAndApplyAutolayoutSettings();
});
return layoutItems;
}
redo() {
throw new NotImplementedException();
}
undo() {
throw new NotImplementedException();
}
}
//# sourceMappingURL=ConvertGroupIntoLayoutCommand.js.map