provide context from media workspace

This commit is contained in:
Mads Rasmussen
2024-05-02 10:13:15 +02:00
parent 81981b888f
commit f45531a102

View File

@@ -25,6 +25,8 @@ import { UmbRequestReloadTreeItemChildrenEvent } from '@umbraco-cms/backoffice/t
import { UmbRequestReloadStructureForEntityEvent } from '@umbraco-cms/backoffice/entity-action';
import type { UmbMediaTypeDetailModel } from '@umbraco-cms/backoffice/media-type';
import type { UmbContentWorkspaceContext } from '@umbraco-cms/backoffice/content';
import { UmbEntityContext } from '@umbraco-cms/backoffice/entity';
import { UmbEntityIsTrashedContext } from '@umbraco-cms/backoffice/recycle-bin';
type EntityType = UmbMediaDetailModel;
export class UmbMediaWorkspaceContext
@@ -107,6 +109,11 @@ export class UmbMediaWorkspaceContext
},
);
// TODO: this should be set up for all entity workspace contexts in a base class
#entityContext = new UmbEntityContext(this);
// TODO: this might not be the correct place to spin this up
#isTrashedContext = new UmbEntityIsTrashedContext(this);
constructor(host: UmbControllerHost) {
super(host, 'Umb.Workspace.Media');
@@ -162,6 +169,9 @@ export class UmbMediaWorkspaceContext
const { data, asObservable } = (await this.#getDataPromise) as GetDataType;
if (data) {
this.#entityContext.setEntityType(UMB_MEDIA_ENTITY_TYPE);
this.#entityContext.setUnique(unique);
this.#isTrashedContext.setIsTrashed(data.isTrashed);
this.setIsNew(false);
this.#persistedData.update(data);
this.#currentData.update(data);
@@ -184,6 +194,8 @@ export class UmbMediaWorkspaceContext
const { data } = await this.#getDataPromise;
if (!data) return undefined;
this.#entityContext.setEntityType(UMB_MEDIA_ENTITY_TYPE);
this.#entityContext.setUnique(data.unique);
this.setIsNew(true);
this.#persistedData.setValue(data);
this.#currentData.setValue(data);