From da72eb9d2cabf70f61c3e8fbd775502cec3a9365 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Fri, 15 Dec 2023 12:56:16 +0100 Subject: [PATCH] add action event context --- .../core/action/action-event.context.ts | 13 +++++++++ .../src/packages/core/action/action.event.ts | 27 +++++++++++++++++++ .../src/packages/core/action/index.ts | 2 ++ 3 files changed, 42 insertions(+) create mode 100644 src/Umbraco.Web.UI.Client/src/packages/core/action/action-event.context.ts create mode 100644 src/Umbraco.Web.UI.Client/src/packages/core/action/action.event.ts diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/action/action-event.context.ts b/src/Umbraco.Web.UI.Client/src/packages/core/action/action-event.context.ts new file mode 100644 index 0000000000..945fadf152 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/core/action/action-event.context.ts @@ -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 { + constructor(host: UmbControllerHost) { + super(host, UMB_ACTION_EVENT_CONTEXT); + } +} + +export const UMB_ACTION_EVENT_CONTEXT = new UmbContextToken( + 'UmbActionEventContext', +); diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/action/action.event.ts b/src/Umbraco.Web.UI.Client/src/packages/core/action/action.event.ts new file mode 100644 index 0000000000..24e4901ba9 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/core/action/action.event.ts @@ -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; + } +} diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/action/index.ts b/src/Umbraco.Web.UI.Client/src/packages/core/action/index.ts index b9a260ce0b..05f892981b 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/action/index.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/action/index.ts @@ -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';