add reload tree item children kind

This commit is contained in:
Mads Rasmussen
2024-03-03 10:51:13 +01:00
parent 7adda872e1
commit 3258f3897e
7 changed files with 49 additions and 17 deletions

View File

@@ -1,7 +1,7 @@
import { UmbControllerEvent } from '@umbraco-cms/backoffice/controller-api';
export interface UmbEntityActionEventArgs {
unique: string;
unique: string | null;
entityType: string;
}
@@ -17,7 +17,7 @@ export class UmbEntityActionEvent extends UmbControllerEvent {
return this.#args.entityType;
}
getUnique(): string {
getUnique(): string | null {
return this.#args.unique;
}
}

View File

@@ -57,3 +57,12 @@ export interface MetaEntityActionRenameKind extends MetaEntityAction {
renameRepositoryAlias: string;
itemRepositoryAlias: string;
}
// RELOAD TREE ITEM CHILDREN
export interface ManifestEntityActionReloadTreeItemChildrenKind extends ManifestEntityAction {
type: 'entityAction';
kind: 'reloadTreeItemChildren';
meta: MetaEntityActionRenameKind;
}
export interface MetaEntityActionReloadTreeItemChildrenKind extends MetaEntityAction {}

View File

@@ -7,6 +7,7 @@ import type {
ManifestEntityAction,
ManifestEntityActionDeleteKind,
ManifestEntityActionRenameKind,
ManifestEntityActionReloadTreeItemChildrenKind,
} from './entity-action.model.js';
import type { ManifestDynamicRootOrigin, ManifestDynamicRootQueryStep } from './dynamic-root.model.js';
import type { ManifestEntityBulkAction } from './entity-bulk-action.model.js';
@@ -100,6 +101,7 @@ export type ManifestTypes =
| ManifestEntityAction
| ManifestEntityActionDeleteKind
| ManifestEntityActionRenameKind
| ManifestEntityActionReloadTreeItemChildrenKind
| ManifestEntityBulkAction
| ManifestEntryPoint
| ManifestExternalLoginProvider

View File

@@ -2,10 +2,12 @@ import { manifests as folderManifests } from './folder/manifests.js';
import { manifests as defaultTreeItemManifests } from './tree-item/tree-item-default/manifests.js';
import { manifests as defaultTreeManifests } from './default/manifests.js';
import { manifests as treePickerManifests } from './tree-picker/manifests.js';
import { manifests as reloadTreeItemChildrenManifests } from './reload-tree-item-children/manifests.js';
export const manifests = [
...defaultTreeManifests,
...folderManifests,
...defaultTreeItemManifests,
...treePickerManifests,
...reloadTreeItemChildrenManifests,
];

View File

@@ -0,0 +1,3 @@
import { manifest as reloadTreeItemChildren } from './reload-tree-item-children.action.kind.js';
export const manifests = [reloadTreeItemChildren];

View File

@@ -0,0 +1,18 @@
import { UmbReloadTreeItemChildrenEntityAction } from './reload-tree-item-children.action.js';
import type { UmbBackofficeManifestKind } from '@umbraco-cms/backoffice/extension-registry';
export const manifest: UmbBackofficeManifestKind = {
type: 'kind',
alias: 'Umb.Kind.EntityAction.Tree.ReloadChildrenOf',
matchKind: 'reloadTreeItemChildren',
matchType: 'entityAction',
manifest: {
type: 'entityAction',
kind: 'reloadTreeItemChildren',
api: UmbReloadTreeItemChildrenEntityAction,
weight: 800,
meta: {
entityTypes: [],
},
},
};

View File

@@ -1,27 +1,25 @@
import { UmbReloadTreeItemChildrenRequestEntityActionEvent } from './reload-tree-item-children-request.event.js';
import type { UmbCopyDataTypeRepository } from '@umbraco-cms/backoffice/data-type';
import type { UmbEntityActionArgs } from '@umbraco-cms/backoffice/entity-action';
import { UmbEntityActionBase } from '@umbraco-cms/backoffice/entity-action';
import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
import { UMB_ACTION_EVENT_CONTEXT, type UmbActionEventContext } from '@umbraco-cms/backoffice/action';
import { UMB_ACTION_EVENT_CONTEXT } from '@umbraco-cms/backoffice/action';
import type { MetaEntityActionReloadTreeItemChildrenKind } from '@umbraco-cms/backoffice/extension-registry';
export class UmbReloadTreeItemChildrenEntityAction extends UmbEntityActionBase<UmbCopyDataTypeRepository> {
#actionEventContext?: UmbActionEventContext;
constructor(host: UmbControllerHostElement, repositoryAlias: string, unique: string, entityType: string) {
super(host, repositoryAlias, unique, entityType);
this.consumeContext(UMB_ACTION_EVENT_CONTEXT, (instance) => {
this.#actionEventContext = instance;
});
export class UmbReloadTreeItemChildrenEntityAction extends UmbEntityActionBase<MetaEntityActionReloadTreeItemChildrenKind> {
constructor(host: UmbControllerHostElement, args: UmbEntityActionArgs<MetaEntityActionReloadTreeItemChildrenKind>) {
super(host, args);
}
async execute() {
if (!this.#actionEventContext) throw new Error('Action Event context is not available');
this.#actionEventContext.dispatchEvent(
const eventContext = await this.getContext(UMB_ACTION_EVENT_CONTEXT);
eventContext.dispatchEvent(
new UmbReloadTreeItemChildrenRequestEntityActionEvent({
unique: this.unique,
entityType: this.entityType,
unique: this.args.unique,
entityType: this.args.entityType,
}),
);
}
destroy(): void {}
}