{"version":3,"file":"move-to.action-BrC6KKI7.js","sources":["../../../src/packages/core/tree/entity-actions/move/move-to.action.ts"],"sourcesContent":["import type { UmbMoveRepository } from './move-repository.interface.js';\nimport { UmbEntityActionBase, UmbRequestReloadStructureForEntityEvent } from '@umbraco-cms/backoffice/entity-action';\nimport { UMB_MODAL_MANAGER_CONTEXT } from '@umbraco-cms/backoffice/modal';\nimport type { MetaEntityActionMoveToKind } from '@umbraco-cms/backoffice/extension-registry';\nimport { createExtensionApiByAlias } from '@umbraco-cms/backoffice/extension-registry';\nimport { UMB_ACTION_EVENT_CONTEXT } from '@umbraco-cms/backoffice/action';\nimport { UMB_TREE_PICKER_MODAL } from '@umbraco-cms/backoffice/tree';\n\nexport class UmbMoveToEntityAction extends UmbEntityActionBase {\n\toverride async execute() {\n\t\tif (!this.args.unique) throw new Error('Unique is not available');\n\t\tif (!this.args.entityType) throw new Error('Entity Type is not available');\n\n\t\tconst modalManager = await this.getContext(UMB_MODAL_MANAGER_CONTEXT);\n\t\tconst modalContext = modalManager.open(this, UMB_TREE_PICKER_MODAL, {\n\t\t\tdata: {\n\t\t\t\ttreeAlias: this.args.meta.treeAlias,\n\t\t\t\tfoldersOnly: this.args.meta.foldersOnly,\n\t\t\t},\n\t\t});\n\n\t\tconst value = await modalContext.onSubmit();\n\t\tconst destinationUnique = value.selection[0];\n\t\tif (destinationUnique === undefined) throw new Error('Destination Unique is not available');\n\n\t\tconst moveRepository = await createExtensionApiByAlias(this, this.args.meta.moveRepositoryAlias);\n\t\tif (!moveRepository) throw new Error('Move Repository is not available');\n\n\t\tawait moveRepository.requestMoveTo({ unique: this.args.unique, destination: { unique: destinationUnique } });\n\n\t\tthis.#reloadMenu();\n\t}\n\n\tasync #reloadMenu() {\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 default UmbMoveToEntityAction;\n"],"names":["UmbMoveToEntityAction","UmbEntityActionBase","destinationUnique","UMB_MODAL_MANAGER_CONTEXT","UMB_TREE_PICKER_MODAL","moveRepository","createExtensionApiByAlias","#reloadMenu","actionEventContext","UMB_ACTION_EVENT_CONTEXT","event","UmbRequestReloadStructureForEntityEvent"],"mappings":";;;;;AAQO,MAAMA,UAA8BC,EAAgD;AAAA,EAC1F,MAAe,UAAU;AACxB,QAAI,CAAC,KAAK,KAAK,OAAc,OAAA,IAAI,MAAM,yBAAyB;AAChE,QAAI,CAAC,KAAK,KAAK,WAAkB,OAAA,IAAI,MAAM,8BAA8B;AAWnE,UAAAC,KADQ,OARO,MAAM,KAAK,WAAWC,CAAyB,GAClC,KAAK,MAAMC,GAAuB;AAAA,MACnE,MAAM;AAAA,QACL,WAAW,KAAK,KAAK,KAAK;AAAA,QAC1B,aAAa,KAAK,KAAK,KAAK;AAAA,MAC7B;AAAA,IAAA,CACA,EAEgC,YACD,UAAU,CAAC;AAC3C,QAAIF,MAAsB,OAAiB,OAAA,IAAI,MAAM,qCAAqC;AAE1F,UAAMG,IAAiB,MAAMC,EAA6C,MAAM,KAAK,KAAK,KAAK,mBAAmB;AAClH,QAAI,CAACD,EAAsB,OAAA,IAAI,MAAM,kCAAkC;AAEvE,UAAMA,EAAe,cAAc,EAAE,QAAQ,KAAK,KAAK,QAAQ,aAAa,EAAE,QAAQH,EAAkB,EAAG,CAAA,GAE3G,KAAKK,GAAY;AAAA,EAClB;AAAA,EAEA,MAAMA,KAAc;AACnB,UAAMC,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;"}