call repo from workspace actions

This commit is contained in:
Mads Rasmussen
2023-02-03 22:34:39 +01:00
parent 3e9b097d8b
commit 9043b2bb6d
3 changed files with 33 additions and 9 deletions

View File

@@ -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<UmbDocumentRepository> {
export class UmbSaveAndPreviewDocumentWorkspaceAction extends UmbWorkspaceAction<UmbDocumentRepository> {
#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();
}
}

View File

@@ -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<UmbDocumentRepository> {
export class UmbSaveAndPublishDocumentWorkspaceAction extends UmbWorkspaceAction<UmbDocumentRepository> {
#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();
}
}

View File

@@ -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<UmbDocumentRepository> {
export class UmbSaveAndScheduleDocumentWorkspaceAction extends UmbWorkspaceAction<UmbDocumentRepository> {
#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();
}
}