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.

36 lines 1.9 kB
import { PlaceholderItem, BarcodeFormat, BarcodeSubType, BarcodeData, BarcodeItem } from "@aurigma/design-atoms-model/Product/Items"; import { NotImplementedException } from "@aurigma/design-atoms-model/Exception"; import { BaseItemsCommand } from "./BaseItemsCommand"; import { ItemUtils } from "../../Utils/ItemUtils"; import { isEmpty } from "@aurigma/design-atoms-model"; export class ChangeBarcodeFormatCommand extends BaseItemsCommand { constructor(productHandler, args, historyArgs) { super(productHandler, historyArgs, args); } async _executeCommandBody() { var _a; if (this._args.barcodeFormat == null) return; const targetItems = (_a = this._getTargetItems(this._args.items, this._args.query, this._args.queryOptions)) !== null && _a !== void 0 ? _a : this._productHandler.selectedItems; if (isEmpty(targetItems)) return; const barcodeData = new BarcodeData(); barcodeData.barcodeFormat = this._args.barcodeFormat; barcodeData.barcodeSubType = this._args.barcodeFormat === BarcodeFormat.QR_CODE ? BarcodeSubType.VCard : BarcodeSubType.None; targetItems.filter(i => i instanceof PlaceholderItem).forEach((pl) => { if (pl.content == null || pl.barcodeFormat == null || !(pl.content instanceof BarcodeItem)) return false; pl.content = ItemUtils.createImageContentForPlaceholder(pl, barcodeData, this._productHandler); pl.content.barcodeContent = null; pl.isStubContent = true; this._productHandler.getHandler(pl).content = this._productHandler.getHandler(pl.content); }); } redo() { throw new NotImplementedException(); } undo() { throw new NotImplementedException(); } } //# sourceMappingURL=ChangeBarcodeFormatCommand.js.map