add move kind
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
import { manifest as moveKindManifest } from './move.action.kind.js';
|
||||||
|
|
||||||
|
export const manifests = [moveKindManifest];
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { UmbMoveEntityAction } from './move.action.js';
|
||||||
|
import type { UmbBackofficeManifestKind } from '@umbraco-cms/backoffice/extension-registry';
|
||||||
|
|
||||||
|
export const manifest: UmbBackofficeManifestKind = {
|
||||||
|
type: 'kind',
|
||||||
|
alias: 'Umb.Kind.EntityAction.Move',
|
||||||
|
matchKind: 'move',
|
||||||
|
matchType: 'entityAction',
|
||||||
|
manifest: {
|
||||||
|
type: 'entityAction',
|
||||||
|
kind: 'move',
|
||||||
|
api: UmbMoveEntityAction,
|
||||||
|
weight: 700,
|
||||||
|
meta: {
|
||||||
|
icon: 'icon-enter',
|
||||||
|
label: 'Move to (TBD)...',
|
||||||
|
entityTypes: [],
|
||||||
|
itemRepositoryAlias: '',
|
||||||
|
moveRepositoryAlias: '',
|
||||||
|
pickerModalAlias: '',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -1,13 +1,54 @@
|
|||||||
import { UmbEntityActionBase } from '../../entity-action-base.js';
|
import { UmbEntityActionBase } from '../../entity-action-base.js';
|
||||||
|
import type { UmbEntityActionArgs } from '../../types.js';
|
||||||
|
import { UMB_MODAL_MANAGER_CONTEXT } from '@umbraco-cms/backoffice/modal';
|
||||||
|
import type { UmbItemRepository, UmbMoveRepository } from '@umbraco-cms/backoffice/repository';
|
||||||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||||
|
import { umbExtensionsRegistry, type MetaEntityActionMoveKind } from '@umbraco-cms/backoffice/extension-registry';
|
||||||
|
import { UmbExtensionApiInitializer } from '@umbraco-cms/backoffice/extension-api';
|
||||||
|
|
||||||
export class UmbMoveEntityAction extends UmbEntityActionBase<any> {
|
export class UmbMoveEntityAction extends UmbEntityActionBase<any> {
|
||||||
constructor(host: UmbControllerHost, args: any) {
|
// TODO: make base type for item and detail models
|
||||||
|
#itemRepository?: UmbItemRepository<any>;
|
||||||
|
#moveRepository?: UmbMoveRepository;
|
||||||
|
#init: Promise<unknown>;
|
||||||
|
|
||||||
|
constructor(host: UmbControllerHost, args: UmbEntityActionArgs<MetaEntityActionMoveKind>) {
|
||||||
super(host, args);
|
super(host, args);
|
||||||
|
|
||||||
|
// TODO: We should properly look into how we can simplify the one time usage of a extension api, as its a bit of overkill to take conditions/overwrites and observation of extensions into play here: [NL]
|
||||||
|
// But since this happens when we execute an action, it does most likely not hurt any users, but it is a bit of a overkill to do this for every action: [NL]
|
||||||
|
this.#init = Promise.all([
|
||||||
|
new UmbExtensionApiInitializer(
|
||||||
|
this._host,
|
||||||
|
umbExtensionsRegistry,
|
||||||
|
this.args.meta.itemRepositoryAlias,
|
||||||
|
[this._host],
|
||||||
|
(permitted, ctrl) => {
|
||||||
|
this.#itemRepository = permitted ? (ctrl.api as UmbItemRepository<any>) : undefined;
|
||||||
|
},
|
||||||
|
).asPromise(),
|
||||||
|
|
||||||
|
new UmbExtensionApiInitializer(
|
||||||
|
this._host,
|
||||||
|
umbExtensionsRegistry,
|
||||||
|
this.args.meta.moveRepositoryAlias,
|
||||||
|
[this._host],
|
||||||
|
(permitted, ctrl) => {
|
||||||
|
this.#moveRepository = permitted ? (ctrl.api as UmbMoveRepository) : undefined;
|
||||||
|
},
|
||||||
|
).asPromise(),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute() {
|
async execute() {
|
||||||
console.log(`execute move for: ${this.args.unique}`);
|
if (!this.args.unique) throw new Error('Unique is not available');
|
||||||
|
await this.#init;
|
||||||
|
|
||||||
|
const modalManager = await this.getContext(UMB_MODAL_MANAGER_CONTEXT);
|
||||||
|
const modalContext = modalManager.open(this, this.args.meta.pickerModalAlias) as any; // TODO: make generic picker interface with selection
|
||||||
|
const value = await modalContext.onSubmit();
|
||||||
|
if (!value) return;
|
||||||
|
await this.#moveRepository!.move(this.args.unique, value.selection[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy(): void {}
|
destroy(): void {}
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
import { manifests as copyEntityActionManifests } from './common/duplicate/manifests.js';
|
import { manifests as copyEntityActionManifests } from './common/duplicate/manifests.js';
|
||||||
import { manifests as deleteEntityActionManifests } from './common/delete/manifests.js';
|
import { manifests as deleteEntityActionManifests } from './common/delete/manifests.js';
|
||||||
|
import { manifests as moveEntityActionManifests } from './common/move/manifests.js';
|
||||||
import { manifests as renameEntityActionManifests } from './common/rename/manifests.js';
|
import { manifests as renameEntityActionManifests } from './common/rename/manifests.js';
|
||||||
|
|
||||||
export const manifests = [...copyEntityActionManifests, ...renameEntityActionManifests, deleteEntityActionManifests];
|
export const manifests = [
|
||||||
|
...copyEntityActionManifests,
|
||||||
|
...deleteEntityActionManifests,
|
||||||
|
...moveEntityActionManifests,
|
||||||
|
...renameEntityActionManifests,
|
||||||
|
];
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ export interface ManifestEntityActionReloadTreeItemChildrenKind extends Manifest
|
|||||||
|
|
||||||
export interface MetaEntityActionReloadTreeItemChildrenKind extends MetaEntityAction {}
|
export interface MetaEntityActionReloadTreeItemChildrenKind extends MetaEntityAction {}
|
||||||
|
|
||||||
// COPY
|
// DUPLICATE
|
||||||
export interface ManifestEntityActionDuplicateKind extends ManifestEntityAction {
|
export interface ManifestEntityActionDuplicateKind extends ManifestEntityAction {
|
||||||
type: 'entityAction';
|
type: 'entityAction';
|
||||||
kind: 'duplicate';
|
kind: 'duplicate';
|
||||||
@@ -79,3 +79,17 @@ export interface MetaEntityActionDuplicateKind extends MetaEntityAction {
|
|||||||
itemRepositoryAlias: string;
|
itemRepositoryAlias: string;
|
||||||
pickerModalAlias: string;
|
pickerModalAlias: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MOVE
|
||||||
|
|
||||||
|
export interface ManifestEntityActionMoveKind extends ManifestEntityAction {
|
||||||
|
type: 'entityAction';
|
||||||
|
kind: 'move';
|
||||||
|
meta: MetaEntityActionMoveKind;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MetaEntityActionMoveKind extends MetaEntityAction {
|
||||||
|
itemRepositoryAlias: string;
|
||||||
|
moveRepositoryAlias: string;
|
||||||
|
pickerModalAlias: string;
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import type {
|
|||||||
ManifestEntityActionRenameKind,
|
ManifestEntityActionRenameKind,
|
||||||
ManifestEntityActionReloadTreeItemChildrenKind,
|
ManifestEntityActionReloadTreeItemChildrenKind,
|
||||||
ManifestEntityActionDuplicateKind,
|
ManifestEntityActionDuplicateKind,
|
||||||
|
ManifestEntityActionMoveKind,
|
||||||
} from './entity-action.model.js';
|
} from './entity-action.model.js';
|
||||||
import type { ManifestDynamicRootOrigin, ManifestDynamicRootQueryStep } from './dynamic-root.model.js';
|
import type { ManifestDynamicRootOrigin, ManifestDynamicRootQueryStep } from './dynamic-root.model.js';
|
||||||
import type { ManifestEntityBulkAction } from './entity-bulk-action.model.js';
|
import type { ManifestEntityBulkAction } from './entity-bulk-action.model.js';
|
||||||
@@ -104,6 +105,7 @@ export type ManifestTypes =
|
|||||||
| ManifestEntityActionRenameKind
|
| ManifestEntityActionRenameKind
|
||||||
| ManifestEntityActionReloadTreeItemChildrenKind
|
| ManifestEntityActionReloadTreeItemChildrenKind
|
||||||
| ManifestEntityActionDuplicateKind
|
| ManifestEntityActionDuplicateKind
|
||||||
|
| ManifestEntityActionMoveKind
|
||||||
| ManifestEntityBulkAction
|
| ManifestEntityBulkAction
|
||||||
| ManifestEntryPoint
|
| ManifestEntryPoint
|
||||||
| ManifestExternalLoginProvider
|
| ManifestExternalLoginProvider
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
import { UMB_DATA_TYPE_PICKER_MODAL } from '@umbraco-cms/backoffice/modal';
|
||||||
import { UMB_DATA_TYPE_ENTITY_TYPE } from '../../entity.js';
|
import { UMB_DATA_TYPE_ENTITY_TYPE } from '../../entity.js';
|
||||||
|
import { UMB_DATA_TYPE_ITEM_REPOSITORY_ALIAS } from '../../repository/index.js';
|
||||||
import { UMB_MOVE_DATA_TYPE_REPOSITORY_ALIAS } from '../../repository/move/manifests.js';
|
import { UMB_MOVE_DATA_TYPE_REPOSITORY_ALIAS } from '../../repository/move/manifests.js';
|
||||||
import { UmbMoveDataTypeEntityAction } from './move.action.js';
|
|
||||||
import type { ManifestEntityAction } from '@umbraco-cms/backoffice/extension-registry';
|
import type { ManifestEntityAction } from '@umbraco-cms/backoffice/extension-registry';
|
||||||
|
|
||||||
const entityActions: Array<ManifestEntityAction> = [
|
const entityActions: Array<ManifestEntityAction> = [
|
||||||
@@ -8,13 +9,12 @@ const entityActions: Array<ManifestEntityAction> = [
|
|||||||
type: 'entityAction',
|
type: 'entityAction',
|
||||||
alias: 'Umb.EntityAction.DataType.Move',
|
alias: 'Umb.EntityAction.DataType.Move',
|
||||||
name: 'Move Data Type Entity Action',
|
name: 'Move Data Type Entity Action',
|
||||||
weight: 900,
|
kind: 'move',
|
||||||
api: UmbMoveDataTypeEntityAction,
|
|
||||||
meta: {
|
meta: {
|
||||||
icon: 'icon-enter',
|
|
||||||
label: 'Move to...',
|
|
||||||
repositoryAlias: UMB_MOVE_DATA_TYPE_REPOSITORY_ALIAS,
|
|
||||||
entityTypes: [UMB_DATA_TYPE_ENTITY_TYPE],
|
entityTypes: [UMB_DATA_TYPE_ENTITY_TYPE],
|
||||||
|
itemRepositoryAlias: UMB_DATA_TYPE_ITEM_REPOSITORY_ALIAS,
|
||||||
|
moveRepositoryAlias: UMB_MOVE_DATA_TYPE_REPOSITORY_ALIAS,
|
||||||
|
pickerModalAlias: UMB_DATA_TYPE_PICKER_MODAL.toString(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
import type { UmbMoveDataTypeRepository } from '../../repository/move/data-type-move.repository.js';
|
|
||||||
import { UmbEntityActionBase } from '@umbraco-cms/backoffice/entity-action';
|
|
||||||
import { UMB_MODAL_MANAGER_CONTEXT, UMB_DATA_TYPE_PICKER_MODAL } from '@umbraco-cms/backoffice/modal';
|
|
||||||
|
|
||||||
// TODO: investigate what we need to make a generic move action
|
|
||||||
export class UmbMoveDataTypeEntityAction extends UmbEntityActionBase<UmbMoveDataTypeRepository> {
|
|
||||||
async execute() {
|
|
||||||
if (!this.unique) throw new Error('Unique is not available');
|
|
||||||
if (!this.repository) throw new Error('Repository is not available');
|
|
||||||
|
|
||||||
const modalManager = await this.getContext(UMB_MODAL_MANAGER_CONTEXT);
|
|
||||||
const modalContext = modalManager.open(this, UMB_DATA_TYPE_PICKER_MODAL);
|
|
||||||
const { selection } = await modalContext.onSubmit();
|
|
||||||
await this.repository.move(this.unique, selection[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -27,7 +27,6 @@ const entityActions: Array<ManifestTypes> = [
|
|||||||
meta: {
|
meta: {
|
||||||
icon: 'icon-blueprint',
|
icon: 'icon-blueprint',
|
||||||
label: 'Create Document Blueprint (TBD)',
|
label: 'Create Document Blueprint (TBD)',
|
||||||
repositoryAlias: UMB_DOCUMENT_DETAIL_REPOSITORY_ALIAS,
|
|
||||||
entityTypes: [UMB_DOCUMENT_ENTITY_TYPE],
|
entityTypes: [UMB_DOCUMENT_ENTITY_TYPE],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user