add action event context

This commit is contained in:
Mads Rasmussen
2023-12-15 12:56:16 +01:00
parent 3ea9b95c7b
commit da72eb9d2c
3 changed files with 42 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
import { UmbContextBase } from '@umbraco-cms/backoffice/class-api';
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
import { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
export class UmbActionEventContext extends UmbContextBase<UmbActionEventContext> {
constructor(host: UmbControllerHost) {
super(host, UMB_ACTION_EVENT_CONTEXT);
}
}
export const UMB_ACTION_EVENT_CONTEXT = new UmbContextToken<UmbActionEventContext, UmbActionEventContext>(
'UmbActionEventContext',
);

View File

@@ -0,0 +1,27 @@
export class UmbControllerEvent extends Event {
public constructor(type: string) {
super(type, { bubbles: false, composed: false, cancelable: false });
}
}
export interface UmbActionEventArgs {
entityType: string;
unique: string;
}
export class UmbActionEvent extends UmbControllerEvent {
#args: UmbActionEventArgs;
public constructor(type: string, args: UmbActionEventArgs) {
super(type);
this.#args = args;
}
getEntityType(): string {
return this.#args.entityType;
}
getUnique(): string {
return this.#args.unique;
}
}

View File

@@ -1,2 +1,4 @@
export * from './repository-action.js';
export * from './action.interface.js';
export * from './action-event.context.js';
export * from './action.event.js';