Unpublish
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { UmbBaseController } from '@umbraco-cms/backoffice/class-api';
|
||||
import { type UmbApi, UmbExtensionApiInitializer } from '@umbraco-cms/backoffice/extension-api';
|
||||
import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';
|
||||
@@ -6,7 +6,7 @@ import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registr
|
||||
export class UmbActionBase<RepositoryType> extends UmbBaseController implements UmbApi {
|
||||
repository?: RepositoryType;
|
||||
|
||||
constructor(host: UmbControllerHostElement, repositoryAlias: string) {
|
||||
constructor(host: UmbControllerHost, repositoryAlias: string) {
|
||||
super(host);
|
||||
|
||||
new UmbExtensionApiInitializer(this, umbExtensionsRegistry, repositoryAlias, [this._host], (permitted, ctrl) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { UmbAction} from '../action/index.js';
|
||||
import type { UmbAction } from '../action/index.js';
|
||||
import { UmbActionBase } from '../action/index.js';
|
||||
import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||
|
||||
export interface UmbEntityAction<RepositoryType> extends UmbAction<RepositoryType> {
|
||||
unique: string;
|
||||
@@ -11,7 +11,7 @@ export class UmbEntityActionBase<RepositoryType> extends UmbActionBase<Repositor
|
||||
unique: string;
|
||||
repositoryAlias: string;
|
||||
|
||||
constructor(host: UmbControllerHostElement, repositoryAlias: string, unique: string, entityType: string) {
|
||||
constructor(host: UmbControllerHost, repositoryAlias: string, unique: string, entityType: string) {
|
||||
super(host, repositoryAlias);
|
||||
this.entityType = entityType;
|
||||
this.unique = unique;
|
||||
|
||||
@@ -28,6 +28,7 @@ import {
|
||||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { UmbLanguageCollectionRepository, type UmbLanguageDetailModel } from '@umbraco-cms/backoffice/language';
|
||||
import { firstValueFrom } from '@umbraco-cms/backoffice/external/rxjs';
|
||||
import { UmbUnpublishDocumentEntityAction } from '../entity-actions/unpublish.action.js';
|
||||
|
||||
type EntityType = UmbDocumentDetailModel;
|
||||
export class UmbDocumentWorkspaceContext
|
||||
@@ -41,6 +42,7 @@ export class UmbDocumentWorkspaceContext
|
||||
/**
|
||||
* The document is the current state/draft version of the document.
|
||||
*/
|
||||
#persistedData = new UmbObjectState<EntityType | undefined>(undefined);
|
||||
#currentData = new UmbObjectState<EntityType | undefined>(undefined);
|
||||
#getDataPromise?: Promise<any>;
|
||||
// TODo: Optimize this so it uses either a App Language Context? [NL]
|
||||
@@ -68,7 +70,6 @@ export class UmbDocumentWorkspaceContext
|
||||
});
|
||||
});
|
||||
|
||||
readonly changedVariants = new UmbArrayState<UmbObjectWithVariantProperties>([], variantPropertiesObjectToString);
|
||||
readonly urls = this.#currentData.asObservablePart((data) => data?.urls || []);
|
||||
readonly templateId = this.#currentData.asObservablePart((data) => data?.template?.unique || null);
|
||||
|
||||
@@ -95,7 +96,7 @@ export class UmbDocumentWorkspaceContext
|
||||
if (!data) return undefined;
|
||||
|
||||
this.setIsNew(false);
|
||||
//this.#persisted.next(data);
|
||||
this.#persistedData.setValue(data);
|
||||
this.#currentData.setValue(data);
|
||||
return data || undefined;
|
||||
}
|
||||
@@ -206,7 +207,8 @@ export class UmbDocumentWorkspaceContext
|
||||
(x) => x.alias === alias && (variantId ? variantId.compare(x) : true),
|
||||
);
|
||||
this.#currentData.update({ values });
|
||||
this.changedVariants.appendOne(variantId);
|
||||
|
||||
// TODO: Ensure variant object..
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,6 +256,10 @@ export class UmbDocumentWorkspaceContext
|
||||
await this.#pickVariantsForAction('save');
|
||||
const data = this.getData();
|
||||
if (!data) throw new Error('Data is missing');
|
||||
|
||||
this.#persistedData.setValue(data);
|
||||
this.#currentData.setValue(data);
|
||||
|
||||
this.saveComplete(data);
|
||||
}
|
||||
|
||||
@@ -273,11 +279,7 @@ export class UmbDocumentWorkspaceContext
|
||||
const unique = this.getEntityId();
|
||||
|
||||
if (!unique) throw new Error('Unique is missing');
|
||||
//if (!this.#variantManagerContext) throw new Error('Variant manager context is missing');
|
||||
|
||||
//this.#variantManagerContext.unpublish(unique);
|
||||
alert('not implemented');
|
||||
throw new Error('Not implemented');
|
||||
new UmbUnpublishDocumentEntityAction(this, '', unique, '');
|
||||
}
|
||||
|
||||
async delete() {
|
||||
|
||||
Reference in New Issue
Block a user