{"version":3,"file":"trash.action-DK7r_f6k.js","sources":["../../../src/packages/core/recycle-bin/entity-action/trash/trash.action.ts"],"sourcesContent":["import { UmbEntityActionBase } from '../../../entity-action/entity-action-base.js';\nimport { UmbRequestReloadStructureForEntityEvent } from '../../../entity-action/request-reload-structure-for-entity.event.js';\nimport type { UmbRecycleBinRepository } from '../../recycle-bin-repository.interface.js';\nimport type { MetaEntityActionTrashKind } from '@umbraco-cms/backoffice/extension-registry';\nimport { createExtensionApiByAlias } from '@umbraco-cms/backoffice/extension-registry';\nimport { umbConfirmModal } from '@umbraco-cms/backoffice/modal';\nimport type { UmbItemRepository } from '@umbraco-cms/backoffice/repository';\nimport { UMB_ACTION_EVENT_CONTEXT } from '@umbraco-cms/backoffice/action';\n\n/**\n * Entity action for trashing an item.\n * @class UmbTrashEntityAction\n * @augments {UmbEntityActionBase}\n */\nexport class UmbTrashEntityAction extends UmbEntityActionBase {\n\t/**\n\t * Executes the action.\n\t * @memberof UmbTrashEntityAction\n\t */\n\toverride async execute() {\n\t\tif (!this.args.unique) throw new Error('Cannot trash an item without a unique identifier.');\n\n\t\tconst itemRepository = await createExtensionApiByAlias>(\n\t\t\tthis,\n\t\t\tthis.args.meta.itemRepositoryAlias,\n\t\t);\n\n\t\tconst { data } = await itemRepository.requestItems([this.args.unique]);\n\t\tconst item = data?.[0];\n\t\tif (!item) throw new Error('Item not found.');\n\n\t\t// TODO: handle items with variants\n\t\tawait umbConfirmModal(this._host, {\n\t\t\theadline: `Trash`,\n\t\t\tcontent: `Are you sure you want to move ${item.name} to the recycle bin?`,\n\t\t\tcolor: 'danger',\n\t\t\tconfirmLabel: 'Trash',\n\t\t});\n\n\t\tconst recycleBinRepository = await createExtensionApiByAlias(\n\t\t\tthis,\n\t\t\tthis.args.meta.recycleBinRepositoryAlias,\n\t\t);\n\t\tawait recycleBinRepository.requestTrash({ unique: this.args.unique });\n\n\t\tconst actionEventContext = await this.getContext(UMB_ACTION_EVENT_CONTEXT);\n\t\tconst event = new UmbRequestReloadStructureForEntityEvent({\n\t\t\tunique: this.args.unique,\n\t\t\tentityType: this.args.entityType,\n\t\t});\n\n\t\tactionEventContext.dispatchEvent(event);\n\n\t\t// TODO: reload destination\n\t}\n}\n\nexport { UmbTrashEntityAction as api };\n"],"names":["UmbTrashEntityAction","UmbEntityActionBase","itemRepository","createExtensionApiByAlias","data","item","umbConfirmModal","actionEventContext","UMB_ACTION_EVENT_CONTEXT","event","UmbRequestReloadStructureForEntityEvent"],"mappings":";;;;;AAcO,MAAMA,UAA6BC,EAA+C;AAAA;AAAA;AAAA;AAAA;AAAA,EAKxF,MAAe,UAAU;AACxB,QAAI,CAAC,KAAK,KAAK,OAAc,OAAA,IAAI,MAAM,mDAAmD;AAE1F,UAAMC,IAAiB,MAAMC;AAAA,MAC5B;AAAA,MACA,KAAK,KAAK,KAAK;AAAA,IAAA,GAGV,EAAE,MAAAC,MAAS,MAAMF,EAAe,aAAa,CAAC,KAAK,KAAK,MAAM,CAAC,GAC/DG,IAAOD,IAAO,CAAC;AACrB,QAAI,CAACC,EAAY,OAAA,IAAI,MAAM,iBAAiB;AAGtC,UAAAC,EAAgB,KAAK,OAAO;AAAA,MACjC,UAAU;AAAA,MACV,SAAS,iCAAiCD,EAAK,IAAI;AAAA,MACnD,OAAO;AAAA,MACP,cAAc;AAAA,IAAA,CACd,GAMD,OAJ6B,MAAMF;AAAA,MAClC;AAAA,MACA,KAAK,KAAK,KAAK;AAAA,IAAA,GAEW,aAAa,EAAE,QAAQ,KAAK,KAAK,QAAQ;AAEpE,UAAMI,IAAqB,MAAM,KAAK,WAAWC,CAAwB,GACnEC,IAAQ,IAAIC,EAAwC;AAAA,MACzD,QAAQ,KAAK,KAAK;AAAA,MAClB,YAAY,KAAK,KAAK;AAAA,IAAA,CACtB;AAED,IAAAH,EAAmB,cAAcE,CAAK;AAAA,EAGvC;AACD;"}