From 9043b2bb6d2aca4bf333a8fc8b9573773c13cd1a Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Fri, 3 Feb 2023 22:34:39 +0100 Subject: [PATCH] call repo from workspace actions --- .../workspace/actions/save-and-preview.action.ts | 14 +++++++++++--- .../workspace/actions/save-and-publish.action.ts | 14 +++++++++++--- .../workspace/actions/save-and-schedule.action.ts | 14 +++++++++++--- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/workspace/actions/save-and-preview.action.ts b/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/workspace/actions/save-and-preview.action.ts index 7a56c11c65..bf2fb9f9a0 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/workspace/actions/save-and-preview.action.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/workspace/actions/save-and-preview.action.ts @@ -1,13 +1,21 @@ import { UmbDocumentRepository } from '../../repository/document.repository'; -import { UmbEntityActionBase } from '../../../../shared/components/entity-action'; +import { UmbDocumentWorkspaceContext } from '../document-workspace.context'; +import { UmbWorkspaceAction } from '../../../../shared/components/workspace/workspace-action'; import { UmbControllerHostInterface } from '@umbraco-cms/controller'; -export class UmbSaveAndPreviewDocumentWorkspaceAction extends UmbEntityActionBase { +export class UmbSaveAndPreviewDocumentWorkspaceAction extends UmbWorkspaceAction { + #workspaceContext?: UmbDocumentWorkspaceContext; + constructor(host: UmbControllerHostInterface, unique: string) { super(host, UmbDocumentRepository, unique); } async execute() { - await this.repository.saveAndPreview(); + if (!this.workspaceContext) return; + // TODO: it doesn't get the updated value + const document = this.workspaceContext.getData(); + // TODO: handle errors + if (!document) return; + this.repository.saveAndPreview(); } } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/workspace/actions/save-and-publish.action.ts b/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/workspace/actions/save-and-publish.action.ts index feeebf2ac6..5d4afc747f 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/workspace/actions/save-and-publish.action.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/workspace/actions/save-and-publish.action.ts @@ -1,13 +1,21 @@ import { UmbDocumentRepository } from '../../repository/document.repository'; -import { UmbEntityActionBase } from '../../../../shared/components/entity-action'; +import { UmbDocumentWorkspaceContext } from '../document-workspace.context'; +import { UmbWorkspaceAction } from '../../../../shared/components/workspace/workspace-action'; import { UmbControllerHostInterface } from '@umbraco-cms/controller'; -export class UmbSaveAndPublishDocumentWorkspaceAction extends UmbEntityActionBase { +export class UmbSaveAndPublishDocumentWorkspaceAction extends UmbWorkspaceAction { + #workspaceContext?: UmbDocumentWorkspaceContext; + constructor(host: UmbControllerHostInterface, unique: string) { super(host, UmbDocumentRepository, unique); } async execute() { - await this.repository.saveAndPublish(); + if (!this.workspaceContext) return; + // TODO: it doesn't get the updated value + const document = this.workspaceContext.getData(); + // TODO: handle errors + if (!document) return; + this.repository.saveAndPublish(); } } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/workspace/actions/save-and-schedule.action.ts b/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/workspace/actions/save-and-schedule.action.ts index 26f99261a2..bb80b73e50 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/workspace/actions/save-and-schedule.action.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/workspace/actions/save-and-schedule.action.ts @@ -1,13 +1,21 @@ import { UmbDocumentRepository } from '../../repository/document.repository'; -import { UmbEntityActionBase } from '../../../../shared/components/entity-action'; +import { UmbDocumentWorkspaceContext } from '../document-workspace.context'; +import { UmbWorkspaceAction } from '../../../../shared/components/workspace/workspace-action'; import { UmbControllerHostInterface } from '@umbraco-cms/controller'; -export class UmbSaveAndScheduleDocumentWorkspaceAction extends UmbEntityActionBase { +export class UmbSaveAndScheduleDocumentWorkspaceAction extends UmbWorkspaceAction { + #workspaceContext?: UmbDocumentWorkspaceContext; + constructor(host: UmbControllerHostInterface, unique: string) { super(host, UmbDocumentRepository, unique); } async execute() { - await this.repository.saveAndSchedule(); + if (!this.workspaceContext) return; + // TODO: it doesn't get the updated value + const document = this.workspaceContext.getData(); + // TODO: handle errors + if (!document) return; + this.repository.saveAndSchedule(); } }