From f96090bd74fc5727b5f3e14e15181ffb586dea65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Tue, 20 Dec 2022 13:36:53 +0100 Subject: [PATCH] move --- .../workspace-content.context.ts | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/Umbraco.Web.UI.Client/src/backoffice/workspaces/shared/workspace-context/workspace-content.context.ts diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/shared/workspace-context/workspace-content.context.ts b/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/shared/workspace-context/workspace-content.context.ts new file mode 100644 index 0000000000..906b08c26e --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/shared/workspace-context/workspace-content.context.ts @@ -0,0 +1,36 @@ + +import { UmbWorkspaceWithStoreContext } from "./workspace-with-store.context"; +import type { DocumentDetails } from "@umbraco-cms/models"; +import { UmbNodeStoreBase } from "@umbraco-cms/stores/store"; +import { UmbNotificationDefaultData } from "@umbraco-cms/services"; + +export class UmbWorkspaceContentContext> extends UmbWorkspaceWithStoreContext { + + constructor(target:HTMLElement, defaultData:ContentTypeType, storeAlias:string, entityType: string, entityKey: string) { + super(target, defaultData, storeAlias, entityType, entityKey); + } + + + protected _observeStore(): void { + this._dataObserver = this._store.getByKey(this.entityKey).subscribe((content) => { + if (!content) return; // TODO: Handle nicely if there is no content data. + this.update(content as any); + }); + } + + + + public save() { + this._store.save([this.getData()]).then(() => { + const data: UmbNotificationDefaultData = { message: 'Document Saved' }; + this._notificationService?.peek('positive', { data }); + }).catch(() => { + const data: UmbNotificationDefaultData = { message: 'Failed to save Document' }; + this._notificationService?.peek('danger', { data }); + }); + } + + // TODO: trash? + +} +