From 2e8f102566c2d124350dd2d99241699498393cfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Fri, 3 Feb 2023 10:42:21 +0100 Subject: [PATCH 1/2] use interface --- .../workspace/document-workspace.context.ts | 21 ++++++++++++------- .../workspace-context.interface.ts | 7 ++----- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/workspace/document-workspace.context.ts b/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/workspace/document-workspace.context.ts index 1813bc1c16..6ff33f72af 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/workspace/document-workspace.context.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/workspace/document-workspace.context.ts @@ -1,15 +1,19 @@ import { UmbWorkspaceContext } from '../../../shared/components/workspace/workspace-context/workspace-context'; import { UmbDocumentRepository } from '../repository/document.repository'; +import { UmbWorkspaceContextInterface } from '../../../shared/components/workspace/workspace-context/workspace-context.interface'; import type { DocumentDetails } from '@umbraco-cms/models'; import { appendToFrozenArray, ObjectState } from '@umbraco-cms/observable-api'; import { UmbControllerHostInterface } from '@umbraco-cms/controller'; // TODO: should this contex be called DocumentDraft instead of workspace? or should the draft be part of this? -export class UmbDocumentWorkspaceContext extends UmbWorkspaceContext { + +type EntityType = DocumentDetails; +export class UmbDocumentWorkspaceContext extends UmbWorkspaceContext implements UmbWorkspaceContextInterface { + #host: UmbControllerHostInterface; #templateDetailRepo: UmbDocumentRepository; - #data = new ObjectState(undefined); + #data = new ObjectState(undefined); data = this.#data.asObservable(); name = this.#data.getObservablePart((data) => data?.name); @@ -23,6 +27,12 @@ export class UmbDocumentWorkspaceContext extends UmbWorkspaceContext { return this.#data.getValue(); } + /* + getUnique() { + return this.#data.getKey(); + } + */ + setName(name: string) { this.#data.update({ name }); } @@ -30,12 +40,7 @@ export class UmbDocumentWorkspaceContext extends UmbWorkspaceContext { getEntityType = this.#manager.getEntityType; getUnique = this.#manager.getEntityKey; getEntityKey = this.#manager.getEntityKey; - getStore = this.#manager.getStore; - getData = this.#manager.getData; - load = this.#manager.load; - create = this.#manager.create; - save = this.#manager.save; - destroy = this.#manager.destroy; + */ /** diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-context/workspace-context.interface.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-context/workspace-context.interface.ts index f5b370f707..52d91d41d3 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-context/workspace-context.interface.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-context/workspace-context.interface.ts @@ -4,13 +4,10 @@ export interface UmbWorkspaceContextInterface { readonly data: Observable; - getUnique(): string | undefined; + + //getUnique(): string | undefined; getData(): T; - load(unique: string): void; - - create(parentUnique: string | null): void; - destroy(): void; } From 213a9410e0b665924f6960be3090179413791136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Fri, 3 Feb 2023 11:03:13 +0100 Subject: [PATCH 2/2] getEntityType --- .../documents/workspace/document-workspace.context.ts | 4 ++++ .../workspace-context/workspace-context.interface.ts | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/workspace/document-workspace.context.ts b/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/workspace/document-workspace.context.ts index 6ff33f72af..020fcbe60d 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/workspace/document-workspace.context.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/workspace/document-workspace.context.ts @@ -33,6 +33,10 @@ export class UmbDocumentWorkspaceContext extends UmbWorkspaceContext implements } */ + getEntityType() { + return 'document'; + } + setName(name: string) { this.#data.update({ name }); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-context/workspace-context.interface.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-context/workspace-context.interface.ts index 52d91d41d3..af0d80e3cd 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-context/workspace-context.interface.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-context/workspace-context.interface.ts @@ -7,6 +7,8 @@ export interface UmbWorkspaceContextInterface { //getUnique(): string | undefined; + getEntityType(): string; + getData(): T; destroy(): void;