UNPKG

@aurigma/design-atoms

Version:

Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.

35 lines 1.91 kB
import { NotImplementedException } from "@aurigma/design-atoms-model/Exception"; import { GroupItem, LayoutItem, } from "@aurigma/design-atoms-model/Product/Items"; import { BaseItemsCommand } from "./BaseItemsCommand"; import { ItemsCommand, SurfaceCommand } from "@aurigma/design-atoms-interfaces"; export class ConvertLayoutIntoGroupCommand extends BaseItemsCommand { constructor(productHandler, historyArgs, args, _commandManager) { super(productHandler, historyArgs, args); this._commandManager = _commandManager; } 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 groupItems = []; 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 LayoutItem) { const group = new GroupItem(item.items.toArray().map(item => item.clone(true))); group.name = item.name.includes(layoutName) ? item.name.replace(layoutName, groupName) : item.name; groupItems.push(group); } }); await this._commandManager.execute(SurfaceCommand.addItems, { items: groupItems }); return groupItems; } redo() { throw new NotImplementedException(); } undo() { throw new NotImplementedException(); } } //# sourceMappingURL=ConvertLayoutIntoGroupCommand.js.map