Mega refactor v.1
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import { UmbVariantId } from '../../variant/variant-id.class.js';
|
||||
import { UUITextStyles, UUIInputElement, UUIInputEvent } from '@umbraco-cms/backoffice/external/uui';
|
||||
import { css, html, nothing, customElement, property, state, ifDefined } from '@umbraco-cms/backoffice/external/lit';
|
||||
import {
|
||||
UmbWorkspaceVariantContext,
|
||||
UMB_WORKSPACE_VARIANT_CONTEXT_TOKEN,
|
||||
UmbWorkspaceSplitViewContext,
|
||||
UMB_WORKSPACE_SPLIT_VIEW_CONTEXT,
|
||||
UMB_VARIANT_DATASET_CONTEXT,
|
||||
ActiveVariant,
|
||||
} from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
|
||||
@@ -23,7 +25,8 @@ export class UmbVariantSelectorElement extends UmbLitElement {
|
||||
return this._activeVariants.map((el) => el.culture ?? '') ?? [];
|
||||
}
|
||||
|
||||
private _variantContext?: UmbWorkspaceVariantContext;
|
||||
#splitViewContext?: UmbWorkspaceSplitViewContext;
|
||||
#datasetContext?: typeof UMB_VARIANT_DATASET_CONTEXT.TYPE;
|
||||
|
||||
@state()
|
||||
private _name?: string;
|
||||
@@ -43,18 +46,21 @@ export class UmbVariantSelectorElement extends UmbLitElement {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.consumeContext<UmbWorkspaceVariantContext>(UMB_WORKSPACE_VARIANT_CONTEXT_TOKEN, (instance) => {
|
||||
this._variantContext = instance;
|
||||
this.consumeContext(UMB_WORKSPACE_SPLIT_VIEW_CONTEXT, (instance) => {
|
||||
this.#splitViewContext = instance;
|
||||
this._observeVariants();
|
||||
this._observeActiveVariants();
|
||||
this._observeVariantContext();
|
||||
});
|
||||
this.consumeContext(UMB_VARIANT_DATASET_CONTEXT, (instance) => {
|
||||
this.#datasetContext = instance;
|
||||
this._observeDatasetContext();
|
||||
});
|
||||
}
|
||||
|
||||
private async _observeVariants() {
|
||||
if (!this._variantContext) return;
|
||||
if (!this.#splitViewContext) return;
|
||||
|
||||
const workspaceContext = this._variantContext.getWorkspaceContext();
|
||||
const workspaceContext = this.#splitViewContext.getWorkspaceContext();
|
||||
if (workspaceContext) {
|
||||
this.observe(
|
||||
workspaceContext.variants,
|
||||
@@ -69,9 +75,9 @@ export class UmbVariantSelectorElement extends UmbLitElement {
|
||||
}
|
||||
|
||||
private async _observeActiveVariants() {
|
||||
if (!this._variantContext) return;
|
||||
if (!this.#splitViewContext) return;
|
||||
|
||||
const workspaceContext = this._variantContext.getWorkspaceContext();
|
||||
const workspaceContext = this.#splitViewContext.getWorkspaceContext();
|
||||
if (workspaceContext) {
|
||||
this.observe(
|
||||
workspaceContext.splitView.activeVariantsInfo,
|
||||
@@ -85,32 +91,21 @@ export class UmbVariantSelectorElement extends UmbLitElement {
|
||||
}
|
||||
}
|
||||
|
||||
private async _observeVariantContext() {
|
||||
if (!this._variantContext) return;
|
||||
private async _observeDatasetContext() {
|
||||
if (!this.#datasetContext) return;
|
||||
|
||||
const variantId = this.#datasetContext.getVariantId();
|
||||
this._culture = variantId.culture;
|
||||
this._segment = variantId.segment;
|
||||
this.updateVariantDisplayName();
|
||||
|
||||
this.observe(
|
||||
this._variantContext.name,
|
||||
this.#datasetContext.name,
|
||||
(name) => {
|
||||
this._name = name;
|
||||
},
|
||||
'_name'
|
||||
);
|
||||
this.observe(
|
||||
this._variantContext.culture,
|
||||
(culture) => {
|
||||
this._culture = culture;
|
||||
this.updateVariantDisplayName();
|
||||
},
|
||||
'_culture'
|
||||
);
|
||||
this.observe(
|
||||
this._variantContext.segment,
|
||||
(segment) => {
|
||||
this._segment = segment;
|
||||
this.updateVariantDisplayName();
|
||||
},
|
||||
'_segment'
|
||||
);
|
||||
}
|
||||
|
||||
private updateVariantDisplayName() {
|
||||
@@ -128,8 +123,9 @@ export class UmbVariantSelectorElement extends UmbLitElement {
|
||||
const target = event.composedPath()[0] as UUIInputElement;
|
||||
|
||||
if (typeof target?.value === 'string') {
|
||||
// TODO: create a setName method on EntityWorkspace:
|
||||
this._variantContext?.setName(target.value);
|
||||
// TODO: Refactor: find a good way to mix these features... maybe we should request the context multiple times? or find a way to mix the discriminators? or a way to investigate the context for features?
|
||||
alert("cannot set name currently.")
|
||||
//this.#datasetContext?.setName(target.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -146,17 +142,17 @@ export class UmbVariantSelectorElement extends UmbLitElement {
|
||||
}
|
||||
|
||||
private _switchVariant(variant: DocumentVariantResponseModel) {
|
||||
this._variantContext?.switchVariant(variant);
|
||||
this.#splitViewContext?.switchVariant(UmbVariantId.Create(variant));
|
||||
this._close();
|
||||
}
|
||||
|
||||
private _openSplitView(variant: DocumentVariantResponseModel) {
|
||||
this._variantContext?.openSplitView(variant);
|
||||
this.#splitViewContext?.openSplitView(UmbVariantId.Create(variant));
|
||||
this._close();
|
||||
}
|
||||
|
||||
private _closeSplitView() {
|
||||
this._variantContext?.closeSplitView();
|
||||
this.#splitViewContext?.closeSplitView();
|
||||
}
|
||||
|
||||
private _isVariantActive(culture: string) {
|
||||
|
||||
@@ -307,6 +307,44 @@ export class UmbContentTypePropertyStructureManager<R extends UmbDetailRepositor
|
||||
this.#documentTypes.updateOne(documentTypeId, { properties });
|
||||
}
|
||||
|
||||
// TODO: Refactor: These property methods, could be named without structure in their name.
|
||||
async propertyStructureById(
|
||||
propertyId: string
|
||||
) {
|
||||
await this.#init;
|
||||
return this.#documentTypes.asObservablePart((docTypes) => {
|
||||
for (const docType of docTypes) {
|
||||
const foundProp = docType.properties?.find((property) => property.id === propertyId);
|
||||
if(foundProp) {
|
||||
return foundProp;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
}
|
||||
|
||||
async getPropertyStructureById(propertyId: string) {
|
||||
await this.#init;
|
||||
for (const docType of this.#documentTypes.getValue()) {
|
||||
const foundProp = docType.properties?.find((property) => property.id === propertyId);
|
||||
if(foundProp) {
|
||||
return foundProp;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
async getPropertyStructureByAlias(propertyAlias: string) {
|
||||
await this.#init;
|
||||
for (const docType of this.#documentTypes.getValue()) {
|
||||
const foundProp = docType.properties?.find((property) => property.alias === propertyAlias);
|
||||
if(foundProp) {
|
||||
return foundProp;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
rootDocumentTypeName() {
|
||||
return this.#documentTypes.asObservablePart((docTypes) => {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { UMB_WORKSPACE_VARIANT_CONTEXT_TOKEN } from '../../../workspace/workspace-variant/workspace-variant.context.js';
|
||||
import { UMB_WORKSPACE_PROPERTY_CONTEXT_TOKEN } from '../../../workspace/workspace-property/workspace-property.context.js';
|
||||
import { html, customElement, property, state } from '@umbraco-cms/backoffice/external/lit';
|
||||
import { UUITextStyles } from '@umbraco-cms/backoffice/external/uui';
|
||||
@@ -13,7 +12,6 @@ import type { UmbDataTypeConfigCollection } from '@umbraco-cms/backoffice/compon
|
||||
*/
|
||||
@customElement('umb-property-editor-ui-block-grid')
|
||||
export class UmbPropertyEditorUIBlockGridElement extends UmbLitElement implements UmbPropertyEditorExtensionElement {
|
||||
private _variantContext?: typeof UMB_WORKSPACE_VARIANT_CONTEXT_TOKEN.TYPE;
|
||||
|
||||
@property()
|
||||
value = '';
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export * from './repository.interface.js';
|
||||
@@ -0,0 +1,12 @@
|
||||
export interface UmbRepository<EntityType = unknown> {
|
||||
|
||||
/**
|
||||
* Get the type of the entity
|
||||
*
|
||||
* @public
|
||||
* @type {EntityType}
|
||||
* @returns undefined
|
||||
*/
|
||||
readonly ENTITY_TYPE: EntityType;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import { type Observable } from "@umbraco-cms/backoffice/external/rxjs";
|
||||
|
||||
/**
|
||||
* Represents a set of properties.
|
||||
* This can take form as many, so to list a few:
|
||||
* - A specific variant of content
|
||||
* - Content that does not vary
|
||||
* - A block.
|
||||
* - A DataType configuration.
|
||||
*
|
||||
* The base type of this holds a Name and some Properties.
|
||||
* Some might be enriches with Variant Info, like culture and segment.
|
||||
* Others might have saved publishing status.
|
||||
* Also setting the name is an additional feature.
|
||||
*/
|
||||
export interface UmbDatasetContext {
|
||||
|
||||
getType(): string;
|
||||
getUnique(): string | undefined;
|
||||
//getUniqueName(): string;
|
||||
|
||||
getName(): string | undefined;
|
||||
readonly name: Observable<string | undefined>;
|
||||
|
||||
destroy(): void;
|
||||
|
||||
// Property methods:
|
||||
propertyValueByAlias<ReturnType = unknown>(propertyAlias: string): Promise<Observable<ReturnType | undefined> | undefined>;
|
||||
setPropertyValue(propertyAlias: string, value: unknown): Promise<void>;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { type UmbDatasetContext } from "./dataset-context.interface.js";
|
||||
import { UmbContextToken } from "@umbraco-cms/backoffice/context-api";
|
||||
|
||||
export const UMB_DATASET_CONTEXT = new UmbContextToken<UmbDatasetContext>("UmbEntityContext");
|
||||
@@ -0,0 +1,4 @@
|
||||
export * from './dataset-context.interface.js';
|
||||
export * from './dataset-context.token.js';
|
||||
export * from './variant-dataset-context.interface.js';
|
||||
export * from './variant-dataset-context.token.js';
|
||||
@@ -0,0 +1,10 @@
|
||||
import { type UmbVariantId } from "../../variant/variant-id.class.js";
|
||||
import { UmbDatasetContext } from "./dataset-context.interface.js";
|
||||
import { type Observable } from "@umbraco-cms/backoffice/external/rxjs";
|
||||
|
||||
|
||||
export interface UmbVariantDatasetContext extends UmbDatasetContext {
|
||||
|
||||
getVariantId(): UmbVariantId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { type UmbDatasetContext } from "./dataset-context.interface.js";
|
||||
import { UmbVariantDatasetContext } from "./variant-dataset-context.interface.js";
|
||||
import { UmbContextToken } from "@umbraco-cms/backoffice/context-api";
|
||||
|
||||
export const UMB_VARIANT_DATASET_CONTEXT = new UmbContextToken<UmbDatasetContext, UmbVariantDatasetContext>(
|
||||
"UmbEntityContext",
|
||||
(context): context is UmbVariantDatasetContext => 'getVariantId' in context);
|
||||
@@ -1,5 +1,7 @@
|
||||
export * from './dataset-context/index.js';
|
||||
export * from './workspace-action-menu/index.js';
|
||||
export * from './workspace-action/index.js';
|
||||
export * from './workspace-alias.condition.js';
|
||||
export * from './workspace-context/index.js';
|
||||
export * from './workspace-editor/index.js';
|
||||
export * from './workspace-footer/index.js';
|
||||
@@ -9,4 +11,3 @@ export * from './workspace-property-layout/workspace-property-layout.element.js'
|
||||
export * from './workspace-property/index.js';
|
||||
export * from './workspace-split-view-manager.class.js';
|
||||
export * from './workspace-variant/index.js';
|
||||
export * from './workspace-alias.condition.js';
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
export * from './entity-manager-controller.js';
|
||||
export * from './workspace-context.js';
|
||||
export * from './workspace-context.interface.js';
|
||||
export * from './workspace-entity-context.interface.js';
|
||||
export * from './workspace-invariantable-entity-context.interface.js';
|
||||
export * from './saveable-workspace-context.interface.js';
|
||||
export * from './publishable-workspace-context.interface.js';
|
||||
export * from './property-structure-workspace-context.interface.js';
|
||||
export * from './workspace-invariable-entity-context.interface.js';
|
||||
export * from './workspace-variable-entity-context.interface.js';
|
||||
export * from './workspace-context.token.js';
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import type { UmbWorkspaceContextInterface } from './workspace-context.interface.js';
|
||||
|
||||
export interface UmbPropertyStructureWorkspaceContextInterface<EntityType = unknown>
|
||||
extends UmbWorkspaceContextInterface<EntityType> {
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import type { UmbSaveableWorkspaceContextInterface } from './saveable-workspace-context.interface.js';
|
||||
|
||||
export interface UmbPublishableWorkspaceContextInterface<EntityType = unknown>
|
||||
extends UmbSaveableWorkspaceContextInterface<EntityType> {
|
||||
//getData(): EntityType | undefined;
|
||||
publish(): Promise<void>;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import type { UmbWorkspaceContextInterface } from './workspace-context.interface.js';
|
||||
|
||||
export interface UmbSaveableWorkspaceContextInterface<EntityType = unknown>
|
||||
extends UmbWorkspaceContextInterface<EntityType> {
|
||||
//getData(): EntityType | undefined;
|
||||
save(): Promise<void>;
|
||||
}
|
||||
@@ -1,17 +1,25 @@
|
||||
import { Observable } from '@umbraco-cms/backoffice/external/rxjs';
|
||||
|
||||
export interface UmbWorkspaceContextInterface<DataType = unknown> {
|
||||
destroy(): void;
|
||||
workspaceAlias: string;
|
||||
repository: any; // TODO: add type
|
||||
|
||||
save(): Promise<void>;
|
||||
// TODO: temp solution to bubble validation errors to the UI
|
||||
setValidationErrors?(errorMap: any): void;
|
||||
|
||||
getEntityId(): string | undefined; // Consider if this should go away now that we have getUnique()
|
||||
// TODO: should we consider another name than entity type. File system files are not entities but still have this type.
|
||||
getEntityType(): string;
|
||||
|
||||
isNew: Observable<boolean | undefined>;
|
||||
getIsNew(): boolean | undefined;
|
||||
setIsNew(value: boolean): void;
|
||||
getEntityId(): string | undefined; // COnsider if this should go away now that we have getUnique()
|
||||
// TODO: should we consider another name than entity type. File system files are not entities but still have this type.
|
||||
getEntityType(): string;
|
||||
|
||||
/*
|
||||
// TODO: Refactor: This could maybe go away:
|
||||
repository: any; // TODO: add type
|
||||
getData(): DataType | undefined;
|
||||
save(): Promise<void>;
|
||||
destroy(): void;
|
||||
// TODO: temp solution to bubble validation errors to the UI
|
||||
setValidationErrors?(errorMap: any): void;
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { UmbEntityWorkspaceContextInterface } from './workspace-entity-context.interface.js';
|
||||
import { UmbSaveableWorkspaceContextInterface } from './saveable-workspace-context.interface.js';
|
||||
import { UmbBaseController, UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { UmbBooleanState } from '@umbraco-cms/backoffice/observable-api';
|
||||
import type { UmbEntityBase } from '@umbraco-cms/backoffice/models';
|
||||
@@ -12,13 +12,13 @@ If so we need to align on a interface that all of these implements. otherwise co
|
||||
*/
|
||||
export abstract class UmbWorkspaceContext<RepositoryType, EntityType extends UmbEntityBase>
|
||||
extends UmbBaseController
|
||||
implements UmbEntityWorkspaceContextInterface<EntityType>
|
||||
implements UmbSaveableWorkspaceContextInterface<EntityType>
|
||||
{
|
||||
public readonly host: UmbControllerHostElement;
|
||||
public readonly workspaceAlias: string;
|
||||
public readonly repository: RepositoryType;
|
||||
|
||||
// TODO: We could make a base type for workspace modal data, and use this here: As well as a base for the result, to make sure we always include the unique.
|
||||
// TODO: We could make a base type for workspace modal data, and use this here: As well as a base for the result, to make sure we always include the unique (instead of the object type)
|
||||
public readonly modalContext?: UmbModalContext<{ preset: object }>;
|
||||
|
||||
#isNew = new UmbBooleanState(undefined);
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
import type { UmbWorkspaceContextInterface } from './workspace-context.interface.js';
|
||||
|
||||
export interface UmbEntityWorkspaceContextInterface<EntityType = unknown>
|
||||
extends UmbWorkspaceContextInterface<EntityType> {
|
||||
getEntityType(): string; // TODO: consider of this should be on the repository because a repo is responsible for one entity type
|
||||
//getData(): EntityType | undefined;
|
||||
save(): Promise<void>;
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
import type { UmbEntityWorkspaceContextInterface } from './workspace-entity-context.interface.js';
|
||||
import type { UmbSaveableWorkspaceContextInterface } from './saveable-workspace-context.interface.js';
|
||||
import type { Observable } from '@umbraco-cms/backoffice/external/rxjs';
|
||||
import type { ValueModelBaseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
|
||||
export interface UmbWorkspaceInvariantableEntityContextInterface<T = unknown>
|
||||
extends UmbEntityWorkspaceContextInterface<T> {
|
||||
export interface UmbInvariableWorkspaceContextInterface<T = unknown>
|
||||
extends UmbSaveableWorkspaceContextInterface<T> {
|
||||
getName(): void;
|
||||
setName(name: string): void;
|
||||
|
||||
propertyDataByAlias(alias: string): Observable<ValueModelBaseModel | undefined>;
|
||||
propertyDataById(id: string): Observable<ValueModelBaseModel | undefined>;
|
||||
propertyValueByAlias(alias: string): Observable<any | undefined>;
|
||||
getPropertyValue(alias: string): void;
|
||||
setPropertyValue(alias: string, value: unknown): void;
|
||||
@@ -1,10 +1,12 @@
|
||||
import type { UmbWorkspaceSplitViewManager } from '../workspace-split-view-manager.class.js';
|
||||
import type { UmbEntityWorkspaceContextInterface } from './workspace-entity-context.interface.js';
|
||||
import type { UmbDatasetContext } from '../dataset-context/dataset-context.interface.js';
|
||||
import type { UmbSaveableWorkspaceContextInterface } from './saveable-workspace-context.interface.js';
|
||||
import type { Observable } from '@umbraco-cms/backoffice/external/rxjs';
|
||||
import { UmbVariantId } from '@umbraco-cms/backoffice/variant';
|
||||
import type { UmbVariantId } from '@umbraco-cms/backoffice/variant';
|
||||
import type { ValueModelBaseModel, VariantResponseModelBaseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||
|
||||
export interface UmbWorkspaceVariableEntityContextInterface<T = unknown> extends UmbEntityWorkspaceContextInterface<T> {
|
||||
export interface UmbVariableWorkspaceContextInterface<T = unknown> extends UmbSaveableWorkspaceContextInterface<T> {
|
||||
variants: Observable<Array<VariantResponseModelBaseModel>>;
|
||||
|
||||
splitView: UmbWorkspaceSplitViewManager;
|
||||
@@ -14,8 +16,14 @@ export interface UmbWorkspaceVariableEntityContextInterface<T = unknown> extends
|
||||
|
||||
getVariant(variantId: UmbVariantId): VariantResponseModelBaseModel | undefined;
|
||||
|
||||
propertyDataByAlias(alias: string, variantId?: UmbVariantId): Observable<ValueModelBaseModel | undefined>;
|
||||
//propertyDataByAlias(alias: string, variantId?: UmbVariantId): Observable<ValueModelBaseModel | undefined>;
|
||||
|
||||
// This one is async cause it needs to structure to provide this data:
|
||||
propertyDataById(id: string): Promise<Observable<ValueModelBaseModel | undefined>>;
|
||||
propertyValueByAlias(alias: string, variantId?: UmbVariantId): Observable<any | undefined>;
|
||||
getPropertyValue(alias: string, variantId?: UmbVariantId): void;
|
||||
setPropertyValue(alias: string, value: unknown, variantId?: UmbVariantId): void;
|
||||
|
||||
// Dataset methods:
|
||||
createVariableDatasetContext(host: UmbControllerHost, variantId: UmbVariantId): UmbDatasetContext;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { UmbWorkspaceVariableEntityContextInterface } from '../workspace-context/workspace-variable-entity-context.interface.js';
|
||||
import { UmbVariableWorkspaceContextInterface } from '../workspace-context/workspace-variable-entity-context.interface.js';
|
||||
import { UmbPropertyEditorExtensionElement } from '../../extension-registry/interfaces/property-editor-ui-extension-element.interface.js';
|
||||
import { type WorkspacePropertyData } from '../types/workspace-property-data.type.js';
|
||||
import { UMB_WORKSPACE_VARIANT_CONTEXT_TOKEN, UMB_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UMB_WORKSPACE_SPLIT_VIEW_CONTEXT, UMB_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbVariantId } from '@umbraco-cms/backoffice/variant';
|
||||
import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
import {
|
||||
@@ -51,13 +51,13 @@ export class UmbWorkspacePropertyContext<ValueType = any> {
|
||||
private _variantDifference = new UmbStringState(undefined);
|
||||
public readonly variantDifference = this._variantDifference.asObservable();
|
||||
|
||||
private _workspaceContext?: UmbWorkspaceVariableEntityContextInterface;
|
||||
private _workspaceVariantConsumer?: UmbContextConsumerController<typeof UMB_WORKSPACE_VARIANT_CONTEXT_TOKEN.TYPE>;
|
||||
private _workspaceContext?: UmbVariableWorkspaceContextInterface;
|
||||
private _workspaceVariantConsumer?: UmbContextConsumerController<typeof UMB_WORKSPACE_SPLIT_VIEW_CONTEXT.TYPE>;
|
||||
|
||||
constructor(host: UmbControllerHostElement) {
|
||||
this.#host = host;
|
||||
new UmbContextConsumerController(host, UMB_WORKSPACE_CONTEXT, (workspaceContext) => {
|
||||
this._workspaceContext = workspaceContext as UmbWorkspaceVariableEntityContextInterface;
|
||||
this._workspaceContext = workspaceContext as UmbVariableWorkspaceContextInterface;
|
||||
});
|
||||
|
||||
this._providerController = new UmbContextProviderController(host, UMB_WORKSPACE_PROPERTY_CONTEXT_TOKEN, this);
|
||||
@@ -71,7 +71,7 @@ export class UmbWorkspacePropertyContext<ValueType = any> {
|
||||
if (!this._workspaceVariantConsumer) {
|
||||
this._workspaceVariantConsumer = new UmbContextConsumerController(
|
||||
this.#host,
|
||||
UMB_WORKSPACE_VARIANT_CONTEXT_TOKEN,
|
||||
UMB_WORKSPACE_SPLIT_VIEW_CONTEXT,
|
||||
(workspaceVariantContext) => {
|
||||
new UmbObserverController(this.#host, workspaceVariantContext.variantId, (workspaceVariantId) => {
|
||||
this.#workspaceVariantId = workspaceVariantId;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export * from './variantable-property/variantable-property.element.js';
|
||||
export * from './workspace-variant.context.js';
|
||||
export * from './workspace-variant.element.js';
|
||||
export * from './workspace-split-view.context.js';
|
||||
export * from './workspace-split-view.element.js';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { UMB_WORKSPACE_VARIANT_CONTEXT_TOKEN } from '../workspace-variant.context.js';
|
||||
import { UMB_WORKSPACE_SPLIT_VIEW_CONTEXT } from '../workspace-split-view.context.js';
|
||||
import { UUITextStyles } from '@umbraco-cms/backoffice/external/uui';
|
||||
import { css, html, customElement, property, state } from '@umbraco-cms/backoffice/external/lit';
|
||||
import { UmbVariantId } from '@umbraco-cms/backoffice/variant';
|
||||
@@ -17,7 +17,7 @@ export class UmbVariantablePropertyElement extends UmbLitElement {
|
||||
this._updatePropertyVariantId();
|
||||
}
|
||||
|
||||
private _variantContext?: typeof UMB_WORKSPACE_VARIANT_CONTEXT_TOKEN.TYPE;
|
||||
private _variantContext?: typeof UMB_WORKSPACE_SPLIT_VIEW_CONTEXT.TYPE;
|
||||
|
||||
@state()
|
||||
private _workspaceVariantId?: UmbVariantId;
|
||||
@@ -27,7 +27,8 @@ export class UmbVariantablePropertyElement extends UmbLitElement {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.consumeContext(UMB_WORKSPACE_VARIANT_CONTEXT_TOKEN, (workspaceContext) => {
|
||||
// TODO: Refactor: this could use the new DataSetContext:
|
||||
this.consumeContext(UMB_WORKSPACE_SPLIT_VIEW_CONTEXT, (workspaceContext) => {
|
||||
this._variantContext = workspaceContext;
|
||||
this._observeVariantContext();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
import { UmbVariableWorkspaceContextInterface } from '../workspace-context/workspace-variable-entity-context.interface.js';
|
||||
import { UMB_WORKSPACE_CONTEXT } from '../workspace-context/workspace-context.token.js';
|
||||
import { UmbDatasetContext } from '../dataset-context/index.js';
|
||||
import { UmbVariantId } from '@umbraco-cms/backoffice/variant';
|
||||
import {
|
||||
UmbContextToken,
|
||||
} from '@umbraco-cms/backoffice/context-api';
|
||||
import { UmbBaseController, UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||
import {
|
||||
UmbClassState,
|
||||
UmbNumberState,
|
||||
} from '@umbraco-cms/backoffice/observable-api';
|
||||
|
||||
|
||||
export class UmbWorkspaceSplitViewContext extends UmbBaseController {
|
||||
|
||||
#workspaceContext?: UmbVariableWorkspaceContextInterface;
|
||||
public getWorkspaceContext() {
|
||||
return this.#workspaceContext;
|
||||
}
|
||||
|
||||
// TODO: Refactor: use a variable data set context interface here.
|
||||
#dataSetContext?: UmbDatasetContext;
|
||||
|
||||
#index = new UmbNumberState(undefined);
|
||||
index = this.#index.asObservable();
|
||||
|
||||
#variantId = new UmbClassState<UmbVariantId | undefined>(undefined);
|
||||
variantId = this.#variantId.asObservable();
|
||||
|
||||
constructor(host: UmbControllerHost) {
|
||||
super(host);
|
||||
|
||||
// TODO: Make a UMB_VARIANT_WORKSPACE_CONTEXT_TOKEN, and interface for such.
|
||||
this.consumeContext(UMB_WORKSPACE_CONTEXT, (context) => {
|
||||
this.#workspaceContext = context as UmbVariableWorkspaceContextInterface;
|
||||
this._observeVariant();
|
||||
});
|
||||
|
||||
this.observe(this.#index, () => {
|
||||
this._observeVariant();
|
||||
});
|
||||
|
||||
|
||||
this.provideContext(UMB_WORKSPACE_SPLIT_VIEW_CONTEXT, this);
|
||||
}
|
||||
|
||||
private _observeVariant() {
|
||||
if (!this.#workspaceContext) return;
|
||||
|
||||
const index = this.#index.getValue();
|
||||
if (index === undefined) return;
|
||||
|
||||
// TODO: Should splitView be put into its own context?... a split view manager context? one which might have a reference to the workspace context, so we still can ask that about how to create the dataset context.
|
||||
this.observe(
|
||||
this.#workspaceContext.splitView.activeVariantByIndex(index),
|
||||
async (activeVariantInfo) => {
|
||||
if (!activeVariantInfo) return;
|
||||
|
||||
// TODO: Ask workspace context to create the specific dataset.
|
||||
|
||||
this.#dataSetContext?.destroy();
|
||||
const variantId = this.#variantId.getValue();
|
||||
if(variantId) {
|
||||
this.#dataSetContext = this.#workspaceContext?.createVariableDatasetContext(this, UmbVariantId.Create(activeVariantInfo));
|
||||
}
|
||||
},
|
||||
'_observeActiveVariant'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public switchVariant(variant: UmbVariantId) {
|
||||
const index = this.#index.value;
|
||||
if (index === undefined) return;
|
||||
this.#workspaceContext?.splitView.switchVariant(index, variant);
|
||||
}
|
||||
|
||||
public closeSplitView() {
|
||||
const index = this.#index.value;
|
||||
if (index === undefined) return;
|
||||
this.#workspaceContext?.splitView.closeSplitView(index);
|
||||
}
|
||||
|
||||
public openSplitView(variant: UmbVariantId) {
|
||||
this.#workspaceContext?.splitView.openSplitView(variant);
|
||||
}
|
||||
|
||||
public changeVariant(culture: string | null, segment: string | null) {
|
||||
const index = this.#index.getValue();
|
||||
if (index === undefined) return;
|
||||
this.#workspaceContext?.splitView.setActiveVariant(index, culture, segment);
|
||||
}
|
||||
|
||||
public getSplitViewIndex() {
|
||||
return this.#index.getValue();
|
||||
}
|
||||
public setSplitViewIndex(index: number) {
|
||||
this.#index.next(index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* concept this class could have methods to set and get the culture and segment of the active variant? just by using the index.
|
||||
*/
|
||||
|
||||
/*
|
||||
public destroy(): void {
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
export const UMB_WORKSPACE_SPLIT_VIEW_CONTEXT = new UmbContextToken<UmbWorkspaceSplitViewContext>(
|
||||
'umbWorkspaceSplitViewContext'
|
||||
);
|
||||
@@ -1,6 +1,6 @@
|
||||
import { UmbWorkspaceVariantContext } from './workspace-variant.context.js';
|
||||
import { UmbWorkspaceSplitViewContext } from './workspace-split-view.context.js';
|
||||
import { UUITextStyles } from '@umbraco-cms/backoffice/external/uui';
|
||||
import { css, html, customElement, property, state } from '@umbraco-cms/backoffice/external/lit';
|
||||
import { css, html, customElement, property } from '@umbraco-cms/backoffice/external/lit';
|
||||
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
|
||||
|
||||
/**
|
||||
@@ -9,8 +9,8 @@ import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
|
||||
* As well breadcrumbs etc.
|
||||
*
|
||||
*/
|
||||
@customElement('umb-workspace-variant')
|
||||
export class UmbWorkspaceVariantContentElement extends UmbLitElement {
|
||||
@customElement('umb-workspace-split-view')
|
||||
export class UmbWorkspaceSplitViewElement extends UmbLitElement {
|
||||
// TODO: stop prop drilling this alias. Instead use the workspace context.
|
||||
@property()
|
||||
alias!: string;
|
||||
@@ -20,19 +20,14 @@ export class UmbWorkspaceVariantContentElement extends UmbLitElement {
|
||||
|
||||
@property({ type: Number })
|
||||
public set splitViewIndex(index: number) {
|
||||
this._splitViewIndex = index;
|
||||
this.variantContext.setSplitViewIndex(index);
|
||||
this.splitViewContext.setSplitViewIndex(index);
|
||||
}
|
||||
|
||||
@state()
|
||||
private _splitViewIndex = 0;
|
||||
|
||||
variantContext = new UmbWorkspaceVariantContext(this);
|
||||
splitViewContext = new UmbWorkspaceSplitViewContext(this);
|
||||
|
||||
render() {
|
||||
return html`
|
||||
<umb-workspace-editor
|
||||
.splitViewIndex=${this._splitViewIndex.toString()}
|
||||
alias=${this.alias}
|
||||
.hideNavigation=${!this.displayNavigation}
|
||||
.enforceNoFooter=${true}>
|
||||
@@ -67,10 +62,10 @@ export class UmbWorkspaceVariantContentElement extends UmbLitElement {
|
||||
];
|
||||
}
|
||||
|
||||
export default UmbWorkspaceVariantContentElement;
|
||||
export default UmbWorkspaceSplitViewElement;
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
'umb-workspace-variant': UmbWorkspaceVariantContentElement;
|
||||
'umb-workspace-split-view': UmbWorkspaceSplitViewElement;
|
||||
}
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
import { UmbWorkspaceVariableEntityContextInterface } from '../workspace-context/workspace-variable-entity-context.interface.js';
|
||||
import { UmbVariantId } from '@umbraco-cms/backoffice/variant';
|
||||
import {
|
||||
UmbContextConsumerController,
|
||||
UmbContextProviderController,
|
||||
UmbContextToken,
|
||||
} from '@umbraco-cms/backoffice/context-api';
|
||||
import { UMB_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
import {
|
||||
UmbClassState,
|
||||
UmbNumberState,
|
||||
UmbObjectState,
|
||||
UmbObserverController,
|
||||
} from '@umbraco-cms/backoffice/observable-api';
|
||||
import { DocumentVariantResponseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
|
||||
//type EntityType = DocumentModel;
|
||||
|
||||
export class UmbWorkspaceVariantContext {
|
||||
#host: UmbControllerHostElement;
|
||||
|
||||
#workspaceContext?: UmbWorkspaceVariableEntityContextInterface;
|
||||
public getWorkspaceContext() {
|
||||
return this.#workspaceContext;
|
||||
}
|
||||
|
||||
#index = new UmbNumberState(undefined);
|
||||
index = this.#index.asObservable();
|
||||
|
||||
#currentVariant = new UmbObjectState<DocumentVariantResponseModel | undefined>(undefined);
|
||||
currentVariant = this.#currentVariant.asObservable();
|
||||
|
||||
name = this.#currentVariant.asObservablePart((x) => x?.name);
|
||||
culture = this.#currentVariant.asObservablePart((x) => x?.culture);
|
||||
segment = this.#currentVariant.asObservablePart((x) => x?.segment);
|
||||
|
||||
#variantId = new UmbClassState<UmbVariantId | undefined>(undefined);
|
||||
variantId = this.#variantId.asObservable();
|
||||
|
||||
constructor(host: UmbControllerHostElement) {
|
||||
this.#host = host;
|
||||
|
||||
new UmbContextProviderController(host, UMB_WORKSPACE_VARIANT_CONTEXT_TOKEN.toString(), this);
|
||||
|
||||
// How do we ensure this connects to a document workspace context? and not just any other context? (We could start providing workspace contexts twice, under the general name and under a specific name)
|
||||
// TODO: Figure out if this is the best way to consume the context or if it can be strongly typed with an UmbContextToken
|
||||
new UmbContextConsumerController(host, UMB_WORKSPACE_CONTEXT, (context) => {
|
||||
this.#workspaceContext = context as UmbWorkspaceVariableEntityContextInterface;
|
||||
this._observeVariant();
|
||||
});
|
||||
|
||||
new UmbObserverController(host, this.#index, () => {
|
||||
this._observeVariant();
|
||||
});
|
||||
}
|
||||
|
||||
public switchVariant(variant: DocumentVariantResponseModel) {
|
||||
const index = this.#index.value;
|
||||
if (index === undefined) return;
|
||||
this.#workspaceContext?.splitView.switchVariant(index, new UmbVariantId(variant));
|
||||
}
|
||||
|
||||
public closeSplitView() {
|
||||
const index = this.#index.value;
|
||||
if (index === undefined) return;
|
||||
this.#workspaceContext?.splitView.closeSplitView(index);
|
||||
}
|
||||
|
||||
public openSplitView(variant: DocumentVariantResponseModel) {
|
||||
this.#workspaceContext?.splitView.openSplitView(new UmbVariantId(variant));
|
||||
}
|
||||
|
||||
private _setVariantId(variantId: UmbVariantId) {
|
||||
this.#variantId.next(variantId);
|
||||
return variantId;
|
||||
}
|
||||
|
||||
private _observeVariant() {
|
||||
if (!this.#workspaceContext) return;
|
||||
|
||||
const index = this.#index.getValue();
|
||||
if (index === undefined) return;
|
||||
|
||||
new UmbObserverController(
|
||||
this.#host,
|
||||
this.#workspaceContext.splitView.activeVariantByIndex(index),
|
||||
async (activeVariantInfo) => {
|
||||
if (!activeVariantInfo) return;
|
||||
const variantId = this._setVariantId(UmbVariantId.Create(activeVariantInfo));
|
||||
const currentVariant = await this.#workspaceContext?.getVariant(variantId);
|
||||
this.#currentVariant.next(currentVariant);
|
||||
},
|
||||
'_observeActiveVariant'
|
||||
);
|
||||
}
|
||||
|
||||
public changeVariant(culture: string | null, segment: string | null) {
|
||||
const index = this.#index.getValue();
|
||||
if (index === undefined) return;
|
||||
this.#workspaceContext?.splitView.setActiveVariant(index, culture, segment);
|
||||
}
|
||||
|
||||
public getSplitViewIndex() {
|
||||
return this.#index.getValue();
|
||||
}
|
||||
public setSplitViewIndex(index: number) {
|
||||
this.#index.next(index);
|
||||
}
|
||||
|
||||
public setName(newName: string) {
|
||||
const variantId = this.#variantId.getValue();
|
||||
if (!this.#workspaceContext || !variantId) return;
|
||||
this.#workspaceContext.setName(newName, variantId);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* concept this class could have methods to set and get the culture and segment of the active variant? just by using the index.
|
||||
*/
|
||||
|
||||
/*
|
||||
public destroy(): void {
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
export const UMB_WORKSPACE_VARIANT_CONTEXT_TOKEN = new UmbContextToken<UmbWorkspaceVariantContext>(
|
||||
'umbWorkspaceVariantContext'
|
||||
);
|
||||
@@ -1,5 +1,5 @@
|
||||
import { UmbDictionaryRepository } from '../repository/dictionary.repository.js';
|
||||
import { UmbEntityWorkspaceContextInterface, UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbSaveableWorkspaceContextInterface, UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { UmbObjectState } from '@umbraco-cms/backoffice/observable-api';
|
||||
import { DictionaryItemResponseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
@@ -7,7 +7,7 @@ import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
|
||||
export class UmbDictionaryWorkspaceContext
|
||||
extends UmbWorkspaceContext<UmbDictionaryRepository, DictionaryItemResponseModel>
|
||||
implements UmbEntityWorkspaceContextInterface<DictionaryItemResponseModel | undefined>
|
||||
implements UmbSaveableWorkspaceContextInterface<DictionaryItemResponseModel | undefined>
|
||||
{
|
||||
#data = new UmbObjectState<DictionaryItemResponseModel | undefined>(undefined);
|
||||
data = this.#data.asObservable();
|
||||
@@ -86,7 +86,7 @@ export class UmbDictionaryWorkspaceContext
|
||||
}
|
||||
|
||||
|
||||
export const UMB_DICTIONARY_WORKSPACE_CONTEXT = new UmbContextToken<UmbEntityWorkspaceContextInterface, UmbDictionaryWorkspaceContext>(
|
||||
export const UMB_DICTIONARY_WORKSPACE_CONTEXT = new UmbContextToken<UmbSaveableWorkspaceContextInterface, UmbDictionaryWorkspaceContext>(
|
||||
'UmbWorkspaceContext',
|
||||
(context): context is UmbDictionaryWorkspaceContext => context.getEntityType?.() === 'dictionary-item'
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { UmbDocumentTypeRepository } from '../repository/document-type.repository.js';
|
||||
import { UmbContentTypePropertyStructureManager } from '@umbraco-cms/backoffice/content-type';
|
||||
import { UmbWorkspaceContext, UmbEntityWorkspaceContextInterface } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbWorkspaceContext, UmbSaveableWorkspaceContextInterface } from '@umbraco-cms/backoffice/workspace';
|
||||
import type {
|
||||
ContentTypeCompositionModel,
|
||||
ContentTypeSortModel,
|
||||
@@ -12,7 +12,7 @@ import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
type EntityType = DocumentTypeResponseModel;
|
||||
export class UmbDocumentTypeWorkspaceContext
|
||||
extends UmbWorkspaceContext<UmbDocumentTypeRepository, EntityType>
|
||||
implements UmbEntityWorkspaceContextInterface<EntityType | undefined>
|
||||
implements UmbSaveableWorkspaceContextInterface<EntityType | undefined>
|
||||
{
|
||||
// Draft is located in structure manager
|
||||
|
||||
@@ -157,7 +157,7 @@ export class UmbDocumentTypeWorkspaceContext
|
||||
}
|
||||
|
||||
|
||||
export const UMB_DOCUMENT_TYPE_WORKSPACE_CONTEXT = new UmbContextToken<UmbEntityWorkspaceContextInterface, UmbDocumentTypeWorkspaceContext>(
|
||||
export const UMB_DOCUMENT_TYPE_WORKSPACE_CONTEXT = new UmbContextToken<UmbSaveableWorkspaceContextInterface, UmbDocumentTypeWorkspaceContext>(
|
||||
'UmbWorkspaceContext',
|
||||
(context): context is UmbDocumentTypeWorkspaceContext => context.getEntityType?.() === 'document-type'
|
||||
);
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
import { UmbDocumentWorkspaceContext } from "../workspace/index.js";
|
||||
import { DocumentVariantResponseModel, PropertyTypeModelBaseModel } from "@umbraco-cms/backoffice/backend-api";
|
||||
import { UmbBaseController, UmbControllerHost } from "@umbraco-cms/backoffice/controller-api";
|
||||
import { UmbObjectState } from "@umbraco-cms/backoffice/observable-api";
|
||||
import { UmbVariantId } from "@umbraco-cms/backoffice/variant";
|
||||
import { UMB_DATASET_CONTEXT, UmbVariantDatasetContext } from "@umbraco-cms/backoffice/workspace";
|
||||
|
||||
export class UmbDocumentDatasetContext extends UmbBaseController implements UmbVariantDatasetContext {
|
||||
|
||||
#workspace: UmbDocumentWorkspaceContext;
|
||||
#variantId: UmbVariantId;
|
||||
public getVariantId() {
|
||||
return this.#variantId;
|
||||
}
|
||||
|
||||
#currentVariant = new UmbObjectState<DocumentVariantResponseModel | undefined>(undefined);
|
||||
currentVariant = this.#currentVariant.asObservable();
|
||||
|
||||
name = this.#currentVariant.asObservablePart((x) => x?.name);
|
||||
culture = this.#currentVariant.asObservablePart((x) => x?.culture);
|
||||
segment = this.#currentVariant.asObservablePart((x) => x?.segment);
|
||||
|
||||
|
||||
getType(): string {
|
||||
return this.#workspace.getEntityType();
|
||||
}
|
||||
getUnique(): string | undefined {
|
||||
return this.#workspace.getEntityId();
|
||||
}
|
||||
getName(): string | undefined {
|
||||
return this.#workspace.getName(this.#variantId);
|
||||
}
|
||||
setName(name: string) {
|
||||
this.#workspace.setName(name, this.#variantId);
|
||||
}
|
||||
getVariantInfo() {
|
||||
return this.#workspace.getVariant(this.#variantId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
constructor(host: UmbControllerHost, workspace: UmbDocumentWorkspaceContext, variantId: UmbVariantId) {
|
||||
// The controller alias, is a very generic name cause we want only one of these for this controller host.
|
||||
super(host, 'dataSetContext');
|
||||
this.#workspace = workspace;
|
||||
this.#variantId = variantId;
|
||||
|
||||
this.observe(
|
||||
this.#workspace.variantById(this.#variantId),
|
||||
async (variantInfo) => {
|
||||
if (!variantInfo) return;
|
||||
this.#currentVariant.next(variantInfo);
|
||||
},
|
||||
'_observeActiveVariant'
|
||||
);
|
||||
|
||||
// TODO: Refactor: use the document dataset context token.
|
||||
this.provideContext(UMB_DATASET_CONTEXT, this);
|
||||
}
|
||||
|
||||
|
||||
#createPropertyVariantId(property:PropertyTypeModelBaseModel) {
|
||||
return UmbVariantId.Create({
|
||||
culture: property.variesByCulture ? this.#variantId.culture : null,
|
||||
segment: property.variesBySegment ? this.#variantId.segment : null,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Write proper JSDocs here.
|
||||
* Ideally do not use these methods, its better to communicate directly with the workspace, but if you do not know the property variant id, then this will figure it out for you. So good for externals to set or get values of a property.
|
||||
*/
|
||||
async propertyValueByAlias<ReturnType = unknown>(propertyAlias: string) {
|
||||
// This is not reacting to if the property variant settings changes while running.
|
||||
const property = await this.#workspace.structure.getPropertyStructureByAlias(propertyAlias);
|
||||
if(property) {
|
||||
const variantId = this.#createPropertyVariantId(property);
|
||||
if(property.alias) {
|
||||
return this.#workspace.propertyValueByAlias<ReturnType>(property.alias, variantId);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Write proper JSDocs here.
|
||||
* Ideally do not use these methods, its better to communicate directly with the workspace, but if you do not know the property variant id, then this will figure it out for you. So good for externals to set or get values of a property.
|
||||
*/
|
||||
async setPropertyValue(propertyAlias: string, value: unknown) {
|
||||
// This is not reacting to if the property variant settings changes while running.
|
||||
const property = await this.#workspace.structure.getPropertyStructureByAlias(propertyAlias);
|
||||
if(property) {
|
||||
const variantId = this.#createPropertyVariantId(property);
|
||||
|
||||
// This is not reacting to if the property variant settings changes while running.
|
||||
this.#workspace.setPropertyValue(propertyAlias, value, variantId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@ import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
|
||||
@customElement('umb-document-workspace-editor')
|
||||
export class UmbDocumentWorkspaceEditorElement extends UmbLitElement {
|
||||
//private _defaultVariant?: VariantViewModelBaseModel;
|
||||
|
||||
// TODO: Refactor: when having a split view/variants context token, we can rename the split view/variants component to a generic and make this component generic as well.
|
||||
private splitViewElement = new UmbDocumentWorkspaceSplitViewElement();
|
||||
|
||||
@state()
|
||||
|
||||
@@ -5,11 +5,9 @@ import { ActiveVariant } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
|
||||
@customElement('umb-document-workspace-split-view')
|
||||
export class UmbDocumentWorkspaceSplitViewElement extends UmbLitElement {
|
||||
// TOOD: Refactor: use the split view context token:
|
||||
private _workspaceContext?: typeof UMB_DOCUMENT_WORKSPACE_CONTEXT.TYPE;
|
||||
|
||||
@state()
|
||||
_unique?: string;
|
||||
|
||||
@state()
|
||||
_variants?: Array<ActiveVariant>;
|
||||
|
||||
@@ -41,10 +39,10 @@ export class UmbDocumentWorkspaceSplitViewElement extends UmbLitElement {
|
||||
(view) =>
|
||||
view.index + '_' + (view.culture ?? '') + '_' + (view.segment ?? '') + '_' + this._variants!.length,
|
||||
(view) => html`
|
||||
<umb-workspace-variant
|
||||
<umb-workspace-split-view
|
||||
alias="Umb.Workspace.Document"
|
||||
.splitViewIndex=${view.index}
|
||||
.displayNavigation=${view.index === this._variants!.length - 1}></umb-workspace-variant>
|
||||
.displayNavigation=${view.index === this._variants!.length - 1}></umb-workspace-split-view>
|
||||
`
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import { UmbDocumentRepository } from '../repository/document.repository.js';
|
||||
import { UmbDocumentTypeRepository } from '../../document-types/repository/document-type.repository.js';
|
||||
import { UmbVariantId } from '@umbraco-cms/backoffice/variant';
|
||||
import { UmbDocumentDatasetContext } from '../dataset-context/document-dataset-context.js';
|
||||
import { type UmbVariantId } from '@umbraco-cms/backoffice/variant';
|
||||
import { UmbContentTypePropertyStructureManager } from '@umbraco-cms/backoffice/content-type';
|
||||
import {
|
||||
UmbEntityWorkspaceContextInterface,
|
||||
UmbSaveableWorkspaceContextInterface,
|
||||
UmbWorkspaceContext,
|
||||
UmbWorkspaceSplitViewManager,
|
||||
UmbWorkspaceVariableEntityContextInterface,
|
||||
UmbVariableWorkspaceContextInterface,
|
||||
type UmbDatasetContext,
|
||||
} from '@umbraco-cms/backoffice/workspace';
|
||||
import type { CreateDocumentRequestModel, DocumentResponseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import {
|
||||
@@ -15,8 +17,9 @@ import {
|
||||
UmbObjectState,
|
||||
UmbObserverController,
|
||||
} from '@umbraco-cms/backoffice/observable-api';
|
||||
import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { UmbControllerHost, UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
import { Observable } from '@umbraco-cms/backoffice/external/rxjs';
|
||||
|
||||
// TODO: should this context be called DocumentDraft instead of workspace? or should the draft be part of this?
|
||||
// TODO: Should we have a DocumentStructureContext and maybe even a DocumentDraftContext?
|
||||
@@ -24,25 +27,25 @@ import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
type EntityType = DocumentResponseModel;
|
||||
export class UmbDocumentWorkspaceContext
|
||||
extends UmbWorkspaceContext<UmbDocumentRepository, EntityType>
|
||||
implements UmbWorkspaceVariableEntityContextInterface<EntityType | undefined>
|
||||
implements UmbVariableWorkspaceContextInterface<EntityType | undefined>
|
||||
{
|
||||
/**
|
||||
* The document is the current stored version of the document.
|
||||
* For now lets not share this publicly as it can become confusing.
|
||||
* TODO: Use this to compare, for variants with changes.
|
||||
* TODO: This concept is to be able to compare if there is changes since the saved one.
|
||||
*/
|
||||
#document = new UmbObjectState<EntityType | undefined>(undefined);
|
||||
//#persistedData = new UmbObjectState<EntityType | undefined>(undefined);
|
||||
|
||||
/**
|
||||
* The document is the current state/draft version of the document.
|
||||
*/
|
||||
#draft = new UmbObjectState<EntityType | undefined>(undefined);
|
||||
readonly unique = this.#draft.asObservablePart((data) => data?.id);
|
||||
readonly documentTypeKey = this.#draft.asObservablePart((data) => data?.contentTypeId);
|
||||
#currentData = new UmbObjectState<EntityType | undefined>(undefined);
|
||||
readonly unique = this.#currentData.asObservablePart((data) => data?.id);
|
||||
readonly documentTypeKey = this.#currentData.asObservablePart((data) => data?.contentTypeId);
|
||||
|
||||
readonly variants = this.#draft.asObservablePart((data) => data?.variants || []);
|
||||
readonly urls = this.#draft.asObservablePart((data) => data?.urls || []);
|
||||
readonly templateId = this.#draft.asObservablePart((data) => data?.templateId || null);
|
||||
readonly variants = this.#currentData.asObservablePart((data) => data?.variants || []);
|
||||
readonly urls = this.#currentData.asObservablePart((data) => data?.urls || []);
|
||||
readonly templateId = this.#currentData.asObservablePart((data) => data?.templateId || null);
|
||||
|
||||
readonly structure;
|
||||
readonly splitView;
|
||||
@@ -65,8 +68,8 @@ export class UmbDocumentWorkspaceContext
|
||||
if (!data) return undefined;
|
||||
|
||||
this.setIsNew(false);
|
||||
this.#document.next(data);
|
||||
this.#draft.next(data);
|
||||
//this.#persisted.next(data);
|
||||
this.#currentData.next(data);
|
||||
return data || undefined;
|
||||
}
|
||||
|
||||
@@ -75,13 +78,12 @@ export class UmbDocumentWorkspaceContext
|
||||
if (!data) return undefined;
|
||||
|
||||
this.setIsNew(true);
|
||||
this.#document.next(data);
|
||||
this.#draft.next(data);
|
||||
this.#currentData.next(data);
|
||||
return data || undefined;
|
||||
}
|
||||
|
||||
getData() {
|
||||
return this.#draft.getValue() || {};
|
||||
return this.#currentData.getValue() || {};
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -102,12 +104,16 @@ export class UmbDocumentWorkspaceContext
|
||||
return this.getData().contentTypeId;
|
||||
}
|
||||
|
||||
variantById(variantId: UmbVariantId) {
|
||||
return this.#currentData.asObservablePart((data) => data?.variants?.find((x) => variantId.compare(x)));
|
||||
}
|
||||
|
||||
getVariant(variantId: UmbVariantId) {
|
||||
return this.#draft.getValue()?.variants?.find((x) => variantId.compare(x));
|
||||
return this.#currentData.getValue()?.variants?.find((x) => variantId.compare(x));
|
||||
}
|
||||
|
||||
getName(variantId?: UmbVariantId) {
|
||||
const variants = this.#draft.getValue()?.variants;
|
||||
const variants = this.#currentData.getValue()?.variants;
|
||||
if (!variants) return;
|
||||
if (variantId) {
|
||||
return variants.find((x) => variantId.compare(x))?.name;
|
||||
@@ -117,67 +123,61 @@ export class UmbDocumentWorkspaceContext
|
||||
}
|
||||
|
||||
setName(name: string, variantId?: UmbVariantId) {
|
||||
const oldVariants = this.#draft.getValue()?.variants || [];
|
||||
const oldVariants = this.#currentData.getValue()?.variants || [];
|
||||
const variants = partialUpdateFrozenArray(
|
||||
oldVariants,
|
||||
{ name },
|
||||
variantId ? (x) => variantId.compare(x) : () => true
|
||||
);
|
||||
this.#draft.update({ variants });
|
||||
this.#currentData.update({ variants });
|
||||
}
|
||||
|
||||
propertyValuesOf(variantId?: UmbVariantId) {
|
||||
return this.#draft.asObservablePart((data) =>
|
||||
variantId ? data?.values?.filter((x) => variantId.compare(x)) : data?.values
|
||||
);
|
||||
propertyDataById(propertyId: string) {
|
||||
return this.structure.propertyStructureById(propertyId);
|
||||
}
|
||||
|
||||
propertyDataByAlias(propertyAlias: string, variantId?: UmbVariantId) {
|
||||
return this.#draft.asObservablePart((data) =>
|
||||
data?.values?.find((x) => x?.alias === propertyAlias && (variantId ? variantId.compare(x) : true))
|
||||
);
|
||||
}
|
||||
propertyValueByAlias(propertyAlias: string, variantId?: UmbVariantId) {
|
||||
return this.#draft.asObservablePart(
|
||||
propertyValueByAlias<PropertyValueType = unknown>(propertyAlias: string, variantId?: UmbVariantId): Observable<PropertyValueType> {
|
||||
return this.#currentData.asObservablePart(
|
||||
(data) =>
|
||||
data?.values?.find((x) => x?.alias === propertyAlias && (variantId ? variantId.compare(x) : true))?.value
|
||||
);
|
||||
}
|
||||
|
||||
getPropertyValue(alias: string, variantId?: UmbVariantId): void {
|
||||
const currentData = this.#draft.value;
|
||||
getPropertyValue<PropertyValueType = unknown>(alias: string, variantId?: UmbVariantId): PropertyValueType | undefined {
|
||||
const currentData = this.#currentData.value;
|
||||
if (currentData) {
|
||||
const newDataSet = currentData.values?.find(
|
||||
(x) => x.alias === alias && (variantId ? variantId.compare(x) : true)
|
||||
);
|
||||
return newDataSet?.value;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
setPropertyValue(alias: string, value: unknown, variantId?: UmbVariantId) {
|
||||
setPropertyValue<PropertyValueType = unknown>(alias: string, value: PropertyValueType, variantId?: UmbVariantId) {
|
||||
const entry = { ...variantId?.toObject(), alias, value };
|
||||
const currentData = this.#draft.value;
|
||||
const currentData = this.#currentData.value;
|
||||
if (currentData) {
|
||||
const values = appendToFrozenArray(
|
||||
currentData.values || [],
|
||||
entry,
|
||||
(x) => x.alias === alias && (variantId ? variantId.compare(x) : true)
|
||||
);
|
||||
this.#draft.update({ values });
|
||||
this.#currentData.update({ values });
|
||||
}
|
||||
}
|
||||
|
||||
async save() {
|
||||
if (!this.#draft.value) return;
|
||||
if (!this.#draft.value.id) return;
|
||||
if (!this.#currentData.value) return;
|
||||
if (!this.#currentData.value.id) return;
|
||||
|
||||
if (this.getIsNew()) {
|
||||
// TODO: typescript hack until we get the create type
|
||||
const value = this.#draft.value as CreateDocumentRequestModel & { id: string };
|
||||
const value = this.#currentData.value as CreateDocumentRequestModel & { id: string };
|
||||
if ((await this.repository.create(value)).data !== undefined) {
|
||||
this.setIsNew(false);
|
||||
}
|
||||
} else {
|
||||
await this.repository.save(this.#draft.value.id, this.#draft.value);
|
||||
await this.repository.save(this.#currentData.value.id, this.#currentData.value);
|
||||
}
|
||||
|
||||
this.saveComplete(this.getData());
|
||||
@@ -199,8 +199,12 @@ export class UmbDocumentWorkspaceContext
|
||||
}
|
||||
*/
|
||||
|
||||
public createVariableDatasetContext(host: UmbControllerHost, variantId: UmbVariantId): UmbDatasetContext {
|
||||
return new UmbDocumentDatasetContext(host, this, variantId);
|
||||
}
|
||||
|
||||
public destroy(): void {
|
||||
this.#draft.complete();
|
||||
this.#currentData.complete();
|
||||
this.structure.destroy();
|
||||
super.destroy();
|
||||
}
|
||||
@@ -209,7 +213,8 @@ export class UmbDocumentWorkspaceContext
|
||||
export default UmbDocumentWorkspaceContext;
|
||||
|
||||
|
||||
export const UMB_DOCUMENT_WORKSPACE_CONTEXT = new UmbContextToken<UmbEntityWorkspaceContextInterface, UmbDocumentWorkspaceContext>(
|
||||
export const UMB_DOCUMENT_WORKSPACE_CONTEXT = new UmbContextToken<UmbSaveableWorkspaceContextInterface, UmbDocumentWorkspaceContext>(
|
||||
'UmbWorkspaceContext',
|
||||
// TODO: Refactor: make a better generic way to identify workspaces, maybe workspaceType or workspaceAlias?.
|
||||
(context): context is UmbDocumentWorkspaceContext => context.getEntityType?.() === 'document'
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { UmbMediaTypeRepository } from '../repository/media-type.repository.js';
|
||||
import type { MediaTypeDetails } from '../types.js';
|
||||
import { UmbEntityWorkspaceContextInterface, UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbSaveableWorkspaceContextInterface, UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { UmbObjectState } from '@umbraco-cms/backoffice/observable-api';
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
@@ -8,7 +8,7 @@ import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
type EntityType = MediaTypeDetails;
|
||||
export class UmbMediaTypeWorkspaceContext
|
||||
extends UmbWorkspaceContext<UmbMediaTypeRepository, EntityType>
|
||||
implements UmbEntityWorkspaceContextInterface<EntityType | undefined>
|
||||
implements UmbSaveableWorkspaceContextInterface<EntityType | undefined>
|
||||
{
|
||||
#data = new UmbObjectState<MediaTypeDetails | undefined>(undefined);
|
||||
data = this.#data.asObservable();
|
||||
@@ -64,7 +64,7 @@ export class UmbMediaTypeWorkspaceContext
|
||||
}
|
||||
|
||||
|
||||
export const UMB_MEDIA_TYPE_WORKSPACE_CONTEXT = new UmbContextToken<UmbEntityWorkspaceContextInterface, UmbMediaTypeWorkspaceContext>(
|
||||
export const UMB_MEDIA_TYPE_WORKSPACE_CONTEXT = new UmbContextToken<UmbSaveableWorkspaceContextInterface, UmbMediaTypeWorkspaceContext>(
|
||||
'UmbWorkspaceContext',
|
||||
(context): context is UmbMediaTypeWorkspaceContext => context.getEntityType?.() === 'media-type'
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { UmbMediaRepository } from '../repository/media.repository.js';
|
||||
import type { MediaDetails } from '../index.js';
|
||||
import { UmbEntityWorkspaceContextInterface, UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbSaveableWorkspaceContextInterface, UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
|
||||
import { appendToFrozenArray, UmbObjectState } from '@umbraco-cms/backoffice/observable-api';
|
||||
import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
@@ -8,7 +8,7 @@ import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
type EntityType = MediaDetails;
|
||||
export class UmbMediaWorkspaceContext
|
||||
extends UmbWorkspaceContext<UmbMediaRepository, EntityType>
|
||||
implements UmbEntityWorkspaceContextInterface<EntityType | undefined>
|
||||
implements UmbSaveableWorkspaceContextInterface<EntityType | undefined>
|
||||
{
|
||||
#data = new UmbObjectState<EntityType | undefined>(undefined);
|
||||
data = this.#data.asObservable();
|
||||
@@ -83,7 +83,7 @@ export class UmbMediaWorkspaceContext
|
||||
}
|
||||
}
|
||||
|
||||
export const UMB_MEDIA_WORKSPACE_CONTEXT = new UmbContextToken<UmbEntityWorkspaceContextInterface, UmbMediaWorkspaceContext>(
|
||||
export const UMB_MEDIA_WORKSPACE_CONTEXT = new UmbContextToken<UmbSaveableWorkspaceContextInterface, UmbMediaWorkspaceContext>(
|
||||
'UmbWorkspaceContext',
|
||||
(context): context is UmbMediaWorkspaceContext => context.getEntityType?.() === 'media'
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { UmbMemberGroupRepository } from '../repository/member-group.repository.js';
|
||||
import type { MemberGroupDetails } from '../types.js';
|
||||
import { UmbEntityWorkspaceContextInterface, UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbSaveableWorkspaceContextInterface, UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { UmbObjectState } from '@umbraco-cms/backoffice/observable-api';
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
@@ -8,7 +8,7 @@ import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
type EntityType = MemberGroupDetails;
|
||||
export class UmbMemberGroupWorkspaceContext
|
||||
extends UmbWorkspaceContext<UmbMemberGroupRepository, EntityType>
|
||||
implements UmbEntityWorkspaceContextInterface<EntityType | undefined>
|
||||
implements UmbSaveableWorkspaceContextInterface<EntityType | undefined>
|
||||
{
|
||||
#data = new UmbObjectState<EntityType | undefined>(undefined);
|
||||
data = this.#data.asObservable();
|
||||
@@ -67,7 +67,7 @@ export class UmbMemberGroupWorkspaceContext
|
||||
|
||||
|
||||
|
||||
export const UMB_MEMBER_GROUP_WORKSPACE_CONTEXT = new UmbContextToken<UmbEntityWorkspaceContextInterface, UmbMemberGroupWorkspaceContext>(
|
||||
export const UMB_MEMBER_GROUP_WORKSPACE_CONTEXT = new UmbContextToken<UmbSaveableWorkspaceContextInterface, UmbMemberGroupWorkspaceContext>(
|
||||
'UmbWorkspaceContext',
|
||||
(context): context is UmbMemberGroupWorkspaceContext => context.getEntityType?.() === 'member-group'
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { UmbMemberTypeRepository } from '../repository/member-type.repository.js';
|
||||
import { UmbEntityWorkspaceContextInterface, UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbSaveableWorkspaceContextInterface, UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbObjectState } from '@umbraco-cms/backoffice/observable-api';
|
||||
import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
@@ -9,7 +9,7 @@ type EntityType = any;
|
||||
|
||||
export class UmbMemberTypeWorkspaceContext
|
||||
extends UmbWorkspaceContext<UmbMemberTypeRepository, EntityType>
|
||||
implements UmbEntityWorkspaceContextInterface<EntityType | undefined>
|
||||
implements UmbSaveableWorkspaceContextInterface<EntityType | undefined>
|
||||
{
|
||||
#data = new UmbObjectState<EntityType | undefined>(undefined);
|
||||
name = this.#data.asObservablePart((data) => data?.name);
|
||||
@@ -75,7 +75,7 @@ export class UmbMemberTypeWorkspaceContext
|
||||
}
|
||||
}
|
||||
|
||||
export const UMB_MEMBER_TYPE_WORKSPACE_CONTEXT = new UmbContextToken<UmbEntityWorkspaceContextInterface, UmbMemberTypeWorkspaceContext>(
|
||||
export const UMB_MEMBER_TYPE_WORKSPACE_CONTEXT = new UmbContextToken<UmbSaveableWorkspaceContextInterface, UmbMemberTypeWorkspaceContext>(
|
||||
'UmbWorkspaceContext',
|
||||
(context): context is UmbMemberTypeWorkspaceContext => context.getEntityType?.() === 'member-type'
|
||||
);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { UmbMemberRepository } from '../repository/member.repository.js';
|
||||
import type { MemberDetails } from '../types.js';
|
||||
import { UmbEntityWorkspaceContextInterface, UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbSaveableWorkspaceContextInterface, UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
|
||||
export class UmbMemberWorkspaceContext
|
||||
extends UmbWorkspaceContext<UmbMemberRepository, MemberDetails>
|
||||
implements UmbEntityWorkspaceContextInterface<MemberDetails | undefined>
|
||||
implements UmbSaveableWorkspaceContextInterface<MemberDetails | undefined>
|
||||
{
|
||||
constructor(host: UmbControllerHostElement) {
|
||||
super(host, 'Umb.Workspace.Member', new UmbMemberRepository(host));
|
||||
@@ -37,7 +37,7 @@ export class UmbMemberWorkspaceContext
|
||||
}
|
||||
}
|
||||
|
||||
export const UMB_MEMBER_WORKSPACE_CONTEXT = new UmbContextToken<UmbEntityWorkspaceContextInterface, UmbMemberWorkspaceContext>(
|
||||
export const UMB_MEMBER_WORKSPACE_CONTEXT = new UmbContextToken<UmbSaveableWorkspaceContextInterface, UmbMemberWorkspaceContext>(
|
||||
'UmbWorkspaceContext',
|
||||
(context): context is UmbMemberWorkspaceContext => context.getEntityType?.() === 'member'
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { UmbDataTypeRepository } from '../repository/data-type.repository.js';
|
||||
import { UmbEntityWorkspaceContextInterface, UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbSaveableWorkspaceContextInterface, UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
|
||||
import type { DataTypeResponseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import { appendToFrozenArray, UmbObjectState } from '@umbraco-cms/backoffice/observable-api';
|
||||
import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
@@ -7,7 +7,7 @@ import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
|
||||
export class UmbDataTypeWorkspaceContext
|
||||
extends UmbWorkspaceContext<UmbDataTypeRepository, DataTypeResponseModel>
|
||||
implements UmbEntityWorkspaceContextInterface<DataTypeResponseModel | undefined>
|
||||
implements UmbSaveableWorkspaceContextInterface<DataTypeResponseModel | undefined>
|
||||
{
|
||||
// TODO: revisit. temp solution because the create and response models are different.
|
||||
#data = new UmbObjectState<DataTypeResponseModel | undefined>(undefined);
|
||||
@@ -97,7 +97,7 @@ export class UmbDataTypeWorkspaceContext
|
||||
}
|
||||
}
|
||||
|
||||
export const UMB_DATA_TYPE_WORKSPACE_CONTEXT = new UmbContextToken<UmbEntityWorkspaceContextInterface, UmbDataTypeWorkspaceContext>(
|
||||
export const UMB_DATA_TYPE_WORKSPACE_CONTEXT = new UmbContextToken<UmbSaveableWorkspaceContextInterface, UmbDataTypeWorkspaceContext>(
|
||||
'UmbWorkspaceContext',
|
||||
(context): context is UmbDataTypeWorkspaceContext => context.getEntityType?.() === 'data-type'
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { UmbLanguageRepository } from '../../repository/language.repository.js';
|
||||
import { UmbEntityWorkspaceContextInterface, UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbSaveableWorkspaceContextInterface, UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
|
||||
import { ApiError, LanguageResponseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import { UmbObjectState } from '@umbraco-cms/backoffice/observable-api';
|
||||
import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
@@ -7,7 +7,7 @@ import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
|
||||
export class UmbLanguageWorkspaceContext
|
||||
extends UmbWorkspaceContext<UmbLanguageRepository, LanguageResponseModel>
|
||||
implements UmbEntityWorkspaceContextInterface
|
||||
implements UmbSaveableWorkspaceContextInterface
|
||||
{
|
||||
#data = new UmbObjectState<LanguageResponseModel | undefined>(undefined);
|
||||
data = this.#data.asObservable();
|
||||
@@ -103,7 +103,7 @@ export class UmbLanguageWorkspaceContext
|
||||
}
|
||||
|
||||
|
||||
export const UMB_LANGUAGE_WORKSPACE_CONTEXT = new UmbContextToken<UmbEntityWorkspaceContextInterface, UmbLanguageWorkspaceContext>(
|
||||
export const UMB_LANGUAGE_WORKSPACE_CONTEXT = new UmbContextToken<UmbSaveableWorkspaceContextInterface, UmbLanguageWorkspaceContext>(
|
||||
'UmbWorkspaceContext',
|
||||
(context): context is UmbLanguageWorkspaceContext => context.getEntityType?.() === 'language'
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { UmbRelationTypeRepository } from '../repository/relation-type.repository.js';
|
||||
import { UmbEntityWorkspaceContextInterface, UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbSaveableWorkspaceContextInterface, UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
|
||||
import type { RelationTypeBaseModel, RelationTypeResponseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import { UmbObjectState } from '@umbraco-cms/backoffice/observable-api';
|
||||
import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
@@ -7,7 +7,7 @@ import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
|
||||
export class UmbRelationTypeWorkspaceContext
|
||||
extends UmbWorkspaceContext<UmbRelationTypeRepository, RelationTypeResponseModel>
|
||||
implements UmbEntityWorkspaceContextInterface<RelationTypeResponseModel | undefined>
|
||||
implements UmbSaveableWorkspaceContextInterface<RelationTypeResponseModel | undefined>
|
||||
{
|
||||
#data = new UmbObjectState<RelationTypeResponseModel | undefined>(undefined);
|
||||
data = this.#data.asObservable();
|
||||
@@ -79,7 +79,7 @@ export class UmbRelationTypeWorkspaceContext
|
||||
|
||||
|
||||
|
||||
export const UMB_RELATION_TYPE_WORKSPACE_CONTEXT = new UmbContextToken<UmbEntityWorkspaceContextInterface, UmbRelationTypeWorkspaceContext>(
|
||||
export const UMB_RELATION_TYPE_WORKSPACE_CONTEXT = new UmbContextToken<UmbSaveableWorkspaceContextInterface, UmbRelationTypeWorkspaceContext>(
|
||||
'UmbWorkspaceContext',
|
||||
(context): context is UmbRelationTypeWorkspaceContext => context.getEntityType?.() === 'relation-type'
|
||||
);
|
||||
|
||||
@@ -2,7 +2,7 @@ import { UmbPartialViewsRepository } from '../repository/partial-views.repositor
|
||||
import { PartialViewDetails } from '../config.js';
|
||||
import { createObservablePart, UmbBooleanState, UmbDeepState } from '@umbraco-cms/backoffice/observable-api';
|
||||
import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { UmbEntityWorkspaceContextInterface, UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbSaveableWorkspaceContextInterface, UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
|
||||
import { loadCodeEditor } from '@umbraco-cms/backoffice/code-editor';
|
||||
import { UpdatePartialViewRequestModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
@@ -10,7 +10,7 @@ import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
export class UmbPartialViewWorkspaceContext extends UmbWorkspaceContext<
|
||||
UmbPartialViewsRepository,
|
||||
PartialViewDetails
|
||||
> implements UmbEntityWorkspaceContextInterface {
|
||||
> implements UmbSaveableWorkspaceContextInterface {
|
||||
getEntityId(): string | undefined {
|
||||
return this.getData()?.path;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ export class UmbPartialViewWorkspaceContext extends UmbWorkspaceContext<
|
||||
|
||||
|
||||
|
||||
export const UMB_PARTIAL_VIEW_WORKSPACE_CONTEXT = new UmbContextToken<UmbEntityWorkspaceContextInterface, UmbPartialViewWorkspaceContext>(
|
||||
export const UMB_PARTIAL_VIEW_WORKSPACE_CONTEXT = new UmbContextToken<UmbSaveableWorkspaceContextInterface, UmbPartialViewWorkspaceContext>(
|
||||
'UmbWorkspaceContext',
|
||||
(context): context is UmbPartialViewWorkspaceContext => context.getEntityType?.() === 'partial-view'
|
||||
);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { UmbStylesheetRepository } from '../repository/stylesheet.repository.js';
|
||||
import { StylesheetDetails } from '../index.js';
|
||||
import { UmbEntityWorkspaceContextInterface, UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbSaveableWorkspaceContextInterface, UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { UmbObjectState } from '@umbraco-cms/backoffice/observable-api';
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
|
||||
export class UmbStylesheetWorkspaceContext extends UmbWorkspaceContext<UmbStylesheetRepository, StylesheetDetails> implements UmbEntityWorkspaceContextInterface {
|
||||
export class UmbStylesheetWorkspaceContext extends UmbWorkspaceContext<UmbStylesheetRepository, StylesheetDetails> implements UmbSaveableWorkspaceContextInterface {
|
||||
#data = new UmbObjectState<StylesheetDetails | undefined>(undefined);
|
||||
data = this.#data.asObservable();
|
||||
|
||||
@@ -42,7 +42,7 @@ export class UmbStylesheetWorkspaceContext extends UmbWorkspaceContext<UmbStyles
|
||||
}
|
||||
}
|
||||
|
||||
export const UMB_STYLESHEET_WORKSPACE_CONTEXT = new UmbContextToken<UmbEntityWorkspaceContextInterface, UmbStylesheetWorkspaceContext>(
|
||||
export const UMB_STYLESHEET_WORKSPACE_CONTEXT = new UmbContextToken<UmbSaveableWorkspaceContextInterface, UmbStylesheetWorkspaceContext>(
|
||||
'UmbWorkspaceContext',
|
||||
(context): context is UmbStylesheetWorkspaceContext => context.getEntityType?.() === 'stylesheet'
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { UmbTemplateRepository } from '../repository/template.repository.js';
|
||||
import { loadCodeEditor } from '@umbraco-cms/backoffice/code-editor';
|
||||
import { UmbEntityWorkspaceContextInterface, UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbSaveableWorkspaceContextInterface, UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
|
||||
import {
|
||||
createObservablePart,
|
||||
UmbBooleanState,
|
||||
@@ -11,7 +11,7 @@ import type { TemplateItemResponseModel, TemplateResponseModel } from '@umbraco-
|
||||
import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
|
||||
export class UmbTemplateWorkspaceContext extends UmbWorkspaceContext<UmbTemplateRepository, TemplateResponseModel> implements UmbEntityWorkspaceContextInterface {
|
||||
export class UmbTemplateWorkspaceContext extends UmbWorkspaceContext<UmbTemplateRepository, TemplateResponseModel> implements UmbSaveableWorkspaceContextInterface {
|
||||
#data = new UmbDeepState<TemplateResponseModel | undefined>(undefined);
|
||||
data = this.#data.asObservable();
|
||||
#masterTemplate = new UmbObjectState<TemplateItemResponseModel | null>(null);
|
||||
@@ -170,7 +170,7 @@ ${currentContent}`;
|
||||
|
||||
|
||||
|
||||
export const UMB_TEMPLATE_WORKSPACE_CONTEXT = new UmbContextToken<UmbEntityWorkspaceContextInterface, UmbTemplateWorkspaceContext>(
|
||||
export const UMB_TEMPLATE_WORKSPACE_CONTEXT = new UmbContextToken<UmbSaveableWorkspaceContextInterface, UmbTemplateWorkspaceContext>(
|
||||
'UmbWorkspaceContext',
|
||||
(context): context is UmbTemplateWorkspaceContext => context.getEntityType?.() === 'template'
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { UmbUserGroupRepository } from '../repository/user-group.repository.js';
|
||||
import { UmbUserRepository } from '../../users/repository/user.repository.js';
|
||||
import { UmbEntityWorkspaceContextInterface, UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbSaveableWorkspaceContextInterface, UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
|
||||
import type { UserGroupResponseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import { UmbArrayState, UmbObjectState } from '@umbraco-cms/backoffice/observable-api';
|
||||
import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
@@ -8,7 +8,7 @@ import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
|
||||
export class UmbUserGroupWorkspaceContext
|
||||
extends UmbWorkspaceContext<UmbUserGroupRepository, UserGroupResponseModel>
|
||||
implements UmbEntityWorkspaceContextInterface<UserGroupResponseModel | undefined>
|
||||
implements UmbSaveableWorkspaceContextInterface<UserGroupResponseModel | undefined>
|
||||
{
|
||||
#data = new UmbObjectState<UserGroupResponseModel | undefined>(undefined);
|
||||
data = this.#data.asObservable();
|
||||
@@ -105,7 +105,7 @@ export class UmbUserGroupWorkspaceContext
|
||||
}
|
||||
|
||||
|
||||
export const UMB_USER_GROUP_WORKSPACE_CONTEXT = new UmbContextToken<UmbEntityWorkspaceContextInterface, UmbUserGroupWorkspaceContext>(
|
||||
export const UMB_USER_GROUP_WORKSPACE_CONTEXT = new UmbContextToken<UmbSaveableWorkspaceContextInterface, UmbUserGroupWorkspaceContext>(
|
||||
'UmbWorkspaceContext',
|
||||
(context): context is UmbUserGroupWorkspaceContext => context.getEntityType?.() === 'user-group'
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { UmbUserRepository } from '../repository/user.repository.js';
|
||||
import { type UmbUserDetail } from '../index.js';
|
||||
import { UmbEntityWorkspaceContextInterface, UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbSaveableWorkspaceContextInterface, UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
|
||||
import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
import type { UpdateUserRequestModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import { UmbObjectState } from '@umbraco-cms/backoffice/observable-api';
|
||||
@@ -10,7 +10,7 @@ import { firstValueFrom } from '@umbraco-cms/backoffice/external/rxjs';
|
||||
|
||||
export class UmbUserWorkspaceContext
|
||||
extends UmbWorkspaceContext<UmbUserRepository, UmbUserDetail>
|
||||
implements UmbEntityWorkspaceContextInterface<UmbUserDetail | undefined>
|
||||
implements UmbSaveableWorkspaceContextInterface<UmbUserDetail | undefined>
|
||||
{
|
||||
#authContext?: typeof UMB_AUTH.TYPE;
|
||||
|
||||
@@ -82,7 +82,7 @@ export class UmbUserWorkspaceContext
|
||||
}
|
||||
}
|
||||
|
||||
export const UMB_USER_WORKSPACE_CONTEXT = new UmbContextToken<UmbEntityWorkspaceContextInterface, UmbUserWorkspaceContext>(
|
||||
export const UMB_USER_WORKSPACE_CONTEXT = new UmbContextToken<UmbSaveableWorkspaceContextInterface, UmbUserWorkspaceContext>(
|
||||
'UmbWorkspaceContext',
|
||||
(context): context is UmbUserWorkspaceContext => context.getEntityType?.() === 'user'
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user