From 2e3e8c5443787264f2cdfe8cbffa09116b8a2f30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Fri, 16 Aug 2024 19:52:45 +0200 Subject: [PATCH 1/4] parse VariantId from DataSet to Block Workspace to Block DataSet --- .../block/workspace/block-element-manager.ts | 16 +++++++++++++++- .../block-element-property-dataset.context.ts | 4 ++++ .../block/workspace/block-workspace.context.ts | 17 ++++++++++++++++- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-element-manager.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-element-manager.ts index 54bcd7aeff..d7b64b1d4b 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-element-manager.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-element-manager.ts @@ -2,10 +2,11 @@ import type { UmbBlockDataType } from '../types.js'; import { UmbBlockElementPropertyDatasetContext } from './block-element-property-dataset.context.js'; import type { UmbContentTypeModel } from '@umbraco-cms/backoffice/content-type'; import { UmbContentTypeStructureManager } from '@umbraco-cms/backoffice/content-type'; -import { UmbObjectState } from '@umbraco-cms/backoffice/observable-api'; +import { UmbClassState, UmbObjectState } from '@umbraco-cms/backoffice/observable-api'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api'; import { UmbDocumentTypeDetailRepository } from '@umbraco-cms/backoffice/document-type'; +import type { UmbVariantId } from '@umbraco-cms/backoffice/variant'; export class UmbBlockElementManager extends UmbControllerBase { // @@ -16,6 +17,9 @@ export class UmbBlockElementManager extends UmbControllerBase { }); #getDataResolver!: () => void; + #variantId = new UmbClassState(undefined); + readonly variantId = this.#variantId.asObservable(); + readonly unique = this.#data.asObservablePart((data) => data?.udi); readonly contentTypeId = this.#data.asObservablePart((data) => data?.contentTypeKey); @@ -35,6 +39,10 @@ export class UmbBlockElementManager extends UmbControllerBase { this.#data.setValue(undefined); } + setVariantId(variantId: UmbVariantId | undefined) { + this.#variantId.setValue(variantId); + } + setData(data: UmbBlockDataType | undefined) { this.#data.setValue(data); this.#getDataResolver(); @@ -56,6 +64,12 @@ export class UmbBlockElementManager extends UmbControllerBase { return this.getData()?.contentTypeKey; } + // We will implement propertyAlias in the future, when implementing Varying Blocks. [NL] + // eslint-disable-next-line @typescript-eslint/no-unused-vars + async propertyVariantId(propertyAlias: string) { + return this.variantId; + } + async propertyValueByAlias(propertyAlias: string) { await this.#getDataPromise; diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-element-property-dataset.context.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-element-property-dataset.context.ts index 22a0d90c66..683d639a18 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-element-property-dataset.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-element-property-dataset.context.ts @@ -35,6 +35,10 @@ export class UmbBlockElementPropertyDatasetContext extends UmbControllerBase imp this.provideContext(UMB_BLOCK_ELEMENT_PROPERTY_DATASET_CONTEXT, this); } + propertyVariantId?(propertyAlias: string): Promise> { + return this.#elementManager.propertyVariantId(propertyAlias); + } + /** * TODO: Write proper JSDocs here. * @param propertyAlias diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-workspace.context.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-workspace.context.ts index 0464b2fe88..81e7bae117 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-workspace.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-workspace.context.ts @@ -6,7 +6,7 @@ import { type UmbRoutableWorkspaceContext, UmbWorkspaceIsNewRedirectController, } from '@umbraco-cms/backoffice/workspace'; -import { UmbObjectState, UmbStringState } from '@umbraco-cms/backoffice/observable-api'; +import { UmbClassState, UmbObjectState, UmbStringState } from '@umbraco-cms/backoffice/observable-api'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; import type { ManifestWorkspace } from '@umbraco-cms/backoffice/extension-registry'; import { UMB_MODAL_CONTEXT } from '@umbraco-cms/backoffice/modal'; @@ -16,6 +16,8 @@ import { UMB_BLOCK_MANAGER_CONTEXT, type UmbBlockWorkspaceData, } from '@umbraco-cms/backoffice/block'; +import { UMB_PROPERTY_CONTEXT } from '@umbraco-cms/backoffice/property'; +import type { UmbVariantId } from '@umbraco-cms/backoffice/variant'; export type UmbBlockWorkspaceElementManagerNames = 'content' | 'settings'; export class UmbBlockWorkspaceContext @@ -55,6 +57,9 @@ export class UmbBlockWorkspaceContext(undefined); readonly name = this.#label.asObservable(); + #variantId = new UmbClassState(undefined); + readonly variantId = this.#variantId.asObservable(); + constructor(host: UmbControllerHost, workspaceArgs: { manifest: ManifestWorkspace }) { super(host, workspaceArgs.manifest.alias); const manifest = workspaceArgs.manifest; @@ -83,6 +88,16 @@ export class UmbBlockWorkspaceContext { + this.observe(context.variantId, (variantId) => { + this.#variantId.setValue(variantId); + }); + }); + + this.observe(this.variantId, (variantId) => { + this.content.setVariantId(variantId); + }); + this.routes.setRoutes([ { path: 'create/:elementTypeKey', From 538e1651bf4d83aa6e7010bdb8874f6a1503058a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Fri, 16 Aug 2024 19:53:13 +0200 Subject: [PATCH 2/4] Added JSDocs --- .../block-grid-area-type-workspace.context.ts | 13 +++++++++++++ ...ock-grid-inline-property-dataset.context.ts | 14 +++++++++----- .../workspace/block-type-workspace.context.ts | 13 +++++++++++++ .../block/workspace/block-element-manager.ts | 13 +++++++++++++ .../block-element-property-dataset.context.ts | 18 +++++++++++------- .../block/workspace/block-workspace.context.ts | 15 +++++++++++++-- .../content-property-dataset.context.ts | 8 ++------ .../property-type-workspace.context.ts | 13 +++++++++++++ .../property-dataset-base-context.ts | 14 +++++++++----- .../property-dataset-context.interface.ts | 1 - .../core/property/property/property.context.ts | 1 + ...riant-workspace-property-dataset-context.ts | 6 ++++-- .../workspace/data-type-workspace.context.ts | 6 ++++++ .../document-blueprint-workspace.context.ts | 7 ++++++- .../workspace/document-workspace.context.ts | 7 +++++++ .../media/workspace/media-workspace.context.ts | 8 +++++++- .../workspace/member-workspace.context.ts | 7 +++++++ .../property-editor-ui-text-box.element.ts | 15 +++++++++++++-- 18 files changed, 147 insertions(+), 32 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/components/block-grid-area-config-entry/workspace/block-grid-area-type-workspace.context.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/components/block-grid-area-config-entry/workspace/block-grid-area-type-workspace.context.ts index 10dd58fa03..24ccefc904 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/components/block-grid-area-config-entry/workspace/block-grid-area-type-workspace.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/components/block-grid-area-config-entry/workspace/block-grid-area-type-workspace.context.ts @@ -129,6 +129,12 @@ export class UmbBlockGridAreaTypeWorkspaceContext throw new Error('You cannot set a name of a area-type.'); } + /** + * @function propertyValueByAlias + * @param {string} propertyAlias + * @returns {Promise | undefined>} + * @description Get an Observable for the value of this property. + */ async propertyValueByAlias(propertyAlias: keyof UmbBlockGridTypeAreaType) { return this.#data.asObservablePart((data) => data?.[propertyAlias as keyof UmbBlockGridTypeAreaType] as ReturnType); } @@ -137,6 +143,13 @@ export class UmbBlockGridAreaTypeWorkspaceContext return this.#data.getValue()?.[propertyAlias as keyof UmbBlockGridTypeAreaType] as ReturnType; } + /** + * @function setPropertyValue + * @param {string} alias + * @param {unknown} value - value can be a promise resolving into the actual value or the raw value it self. + * @returns {Promise} + * @description Set the value of this property. + */ async setPropertyValue(alias: string, value: unknown) { const currentData = this.#data.value; if (currentData) { diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/components/block-grid-block-inline/block-grid-inline-property-dataset.context.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/components/block-grid-block-inline/block-grid-inline-property-dataset.context.ts index 6f8f9c6a95..d57f88b590 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/components/block-grid-block-inline/block-grid-inline-property-dataset.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/components/block-grid-block-inline/block-grid-inline-property-dataset.context.ts @@ -36,8 +36,10 @@ export class UmbBlockGridInlinePropertyDatasetContext extends UmbControllerBase } /** - * TODO: Write proper JSDocs here. - * @param propertyAlias + * @function propertyValueByAlias + * @param {string} propertyAlias + * @returns {Promise | undefined>} + * @description Get an Observable for the value of this property. */ async propertyValueByAlias(propertyAlias: string) { // TODO: Investigate how I do that with the workspaces.. @@ -45,9 +47,11 @@ export class UmbBlockGridInlinePropertyDatasetContext extends UmbControllerBase } /** - * TODO: Write proper JSDocs here. - * @param propertyAlias - * @param value + * @function setPropertyValue + * @param {string} propertyAlias + * @param {unknown} value - value can be a promise resolving into the actual value or the raw value it self. + * @returns {Promise} + * @description Set the value of this property. */ async setPropertyValue(propertyAlias: string, value: unknown) { // TODO: Investigate how I do that with the workspaces.. diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-type/workspace/block-type-workspace.context.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-type/workspace/block-type-workspace.context.ts index 74b2b8bfcb..c50aad7dbb 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block-type/workspace/block-type-workspace.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-type/workspace/block-type-workspace.context.ts @@ -136,6 +136,12 @@ export class UmbBlockTypeWorkspaceContext | undefined>} + * @description Get an Observable for the value of this property. + */ async propertyValueByAlias(propertyAlias: string) { return this.#data.asObservablePart((data) => data?.[propertyAlias as keyof BlockTypeData] as ReturnType); } @@ -144,6 +150,13 @@ export class UmbBlockTypeWorkspaceContext} + * @description Set the value of this property. + */ async setPropertyValue(alias: string, value: unknown) { const currentData = this.#data.value; if (currentData) { diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-element-manager.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-element-manager.ts index d7b64b1d4b..15946e4f01 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-element-manager.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-element-manager.ts @@ -70,6 +70,12 @@ export class UmbBlockElementManager extends UmbControllerBase { return this.variantId; } + /** + * @function propertyValueByAlias + * @param {string} propertyAlias + * @returns {Promise | undefined>} + * @description Get an Observable for the value of this property. + */ async propertyValueByAlias(propertyAlias: string) { await this.#getDataPromise; @@ -82,6 +88,13 @@ export class UmbBlockElementManager extends UmbControllerBase { return this.#data.getValue()?.[propertyAlias] as ReturnType; } + /** + * @function setPropertyValue + * @param {string} alias + * @param {unknown} value - value can be a promise resolving into the actual value or the raw value it self. + * @returns {Promise} + * @description Set the value of this property. + */ async setPropertyValue(alias: string, value: unknown) { this.initiatePropertyValueChange(); await this.#getDataPromise; diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-element-property-dataset.context.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-element-property-dataset.context.ts index 683d639a18..8c6064d601 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-element-property-dataset.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-element-property-dataset.context.ts @@ -40,19 +40,23 @@ export class UmbBlockElementPropertyDatasetContext extends UmbControllerBase imp } /** - * TODO: Write proper JSDocs here. - * @param propertyAlias + * @function propertyValueByAlias + * @param {string} propertyAlias + * @returns {Promise | undefined>} + * @description Get an Observable for the value of this property. */ async propertyValueByAlias(propertyAlias: string) { return await this.#elementManager.propertyValueByAlias(propertyAlias); } /** - * TODO: Write proper JSDocs here. - * @param propertyAlias - * @param value + * @function setPropertyValue + * @param {string} alias + * @param {unknown} value - value can be a promise resolving into the actual value or the raw value it self. + * @returns {Promise} + * @description Set the value of this property. */ - async setPropertyValue(propertyAlias: string, value: unknown) { - return this.#elementManager.setPropertyValue(propertyAlias, value); + async setPropertyValue(alias: string, value: unknown) { + return this.#elementManager.setPropertyValue(alias, value); } } diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-workspace.context.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-workspace.context.ts index 81e7bae117..b448865e9a 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-workspace.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-workspace.context.ts @@ -309,8 +309,12 @@ export class UmbBlockWorkspaceContext | undefined>} + * @description Get an Observable for the value of this property. + */ async propertyValueByAlias(propertyAlias: propertyAliasType) { return this.#layout.asObservablePart( (layout) => layout?.[propertyAlias as keyof LayoutDataType] as LayoutDataType[propertyAliasType], @@ -322,6 +326,13 @@ export class UmbBlockWorkspaceContext} + * @description Set the value of this property. + */ async setPropertyValue(alias: string, value: unknown) { const currentData = this.#layout.value; if (currentData) { diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/content/property-dataset-context/content-property-dataset.context.ts b/src/Umbraco.Web.UI.Client/src/packages/core/content/property-dataset-context/content-property-dataset.context.ts index 1f981f0da4..8975b77b29 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/content/property-dataset-context/content-property-dataset.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/content/property-dataset-context/content-property-dataset.context.ts @@ -113,16 +113,12 @@ export class UmbContentPropertyDatasetContext< /** * @function setPropertyValueByVariant * @param {string} propertyAlias - * @param {PromiseLike} value - value can be a promise resolving into the actual value or the raw value it self. + * @param {unknown} value - value can be a promise resolving into the actual value or the raw value it self. * @param {UmbVariantId} propertyVariantId - The variant id for the value to be set for. * @returns {Promise} * @description Get the value of this property. */ - setPropertyValueByVariant( - propertyAlias: string, - value: PromiseLike, - propertyVariantId: UmbVariantId, - ): Promise { + setPropertyValueByVariant(propertyAlias: string, value: unknown, propertyVariantId: UmbVariantId): Promise { return this.#workspace.setPropertyValue(propertyAlias, value, propertyVariantId); } diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/property-type/workspace/property-type-workspace.context.ts b/src/Umbraco.Web.UI.Client/src/packages/core/property-type/workspace/property-type-workspace.context.ts index 880e05d8c2..cea75edff0 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/property-type/workspace/property-type-workspace.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/property-type/workspace/property-type-workspace.context.ts @@ -168,6 +168,12 @@ export class UmbPropertyTypeWorkspaceContext | undefined>} + * @description Get an Observable for the value of this property. + */ async propertyValueByAlias(propertyAlias: string) { return this.#data.asObservablePart((data) => data?.[propertyAlias as keyof PropertyTypeData] as ReturnType); } @@ -176,6 +182,13 @@ export class UmbPropertyTypeWorkspaceContext} value - value can be a promise resolving into the actual value or the raw value it self. + * @returns {Promise} + * @description Set the value of this property. + */ async setPropertyValue(alias: string, value: unknown) { const currentData = this.#data.value; if (currentData) { diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/property/property-dataset/property-dataset-base-context.ts b/src/Umbraco.Web.UI.Client/src/packages/core/property/property-dataset/property-dataset-base-context.ts index 0527d11772..33fe7070bb 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/property/property-dataset/property-dataset-base-context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/property/property-dataset/property-dataset-base-context.ts @@ -47,8 +47,10 @@ export class UmbPropertyDatasetContextBase } /** - * TODO: Write proper JSDocs here. - * @param propertyAlias + * @function propertyValueByAlias + * @param {string} propertyAlias + * @returns {Promise | undefined>} + * @description Get an Observable for the value of this property. */ async propertyValueByAlias(propertyAlias: string) { return this.#values.asObservablePart((values) => { @@ -58,9 +60,11 @@ export class UmbPropertyDatasetContextBase } /** - * TODO: Write proper JSDocs here. - * @param alias - * @param value + * @function setPropertyValue + * @param {string} alias + * @param {PromiseLike} value - value can be a promise resolving into the actual value or the raw value it self. + * @returns {Promise} + * @description Set the value of this property. */ setPropertyValue(alias: string, value: unknown) { this.#values.appendOne({ alias, value }); diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/property/property-dataset/property-dataset-context.interface.ts b/src/Umbraco.Web.UI.Client/src/packages/core/property/property-dataset/property-dataset-context.interface.ts index 92527fa278..12cf856163 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/property/property-dataset/property-dataset-context.interface.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/property/property-dataset/property-dataset-context.interface.ts @@ -33,6 +33,5 @@ export interface UmbPropertyDatasetContext extends UmbContext { propertyValueByAlias( propertyAlias: string, ): Promise | undefined>; - // TODO: Append the andCulture method as well.. setPropertyValue(propertyAlias: string, value: unknown): void; } diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/property/property/property.context.ts b/src/Umbraco.Web.UI.Client/src/packages/core/property/property/property.context.ts index 76a0dbaa15..b285836f93 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/property/property/property.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/property/property/property.context.ts @@ -151,6 +151,7 @@ export class UmbPropertyContext extends UmbContextBase | undefined>} + * @description Get an Observable for the value of this property. */ async propertyValueByAlias(propertyAlias: string) { return await this.#workspace.propertyValueByAlias(propertyAlias); diff --git a/src/Umbraco.Web.UI.Client/src/packages/data-type/workspace/data-type-workspace.context.ts b/src/Umbraco.Web.UI.Client/src/packages/data-type/workspace/data-type-workspace.context.ts index 49aa80140f..85b078bc0d 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/data-type/workspace/data-type-workspace.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/data-type/workspace/data-type-workspace.context.ts @@ -341,6 +341,12 @@ export class UmbDataTypeWorkspaceContext this.#currentData.update({ editorUiAlias: alias }); } + /** + * @function propertyValueByAlias + * @param {string} propertyAlias + * @returns {Promise | undefined>} + * @description Get an Observable for the value of this property. + */ async propertyValueByAlias(propertyAlias: string) { await this.#getDataPromise; return this.#currentData.asObservablePart( diff --git a/src/Umbraco.Web.UI.Client/src/packages/documents/document-blueprints/workspace/document-blueprint-workspace.context.ts b/src/Umbraco.Web.UI.Client/src/packages/documents/document-blueprints/workspace/document-blueprint-workspace.context.ts index de04460e28..857419aa90 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/documents/document-blueprints/workspace/document-blueprint-workspace.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/documents/document-blueprints/workspace/document-blueprint-workspace.context.ts @@ -251,7 +251,12 @@ export class UmbDocumentBlueprintWorkspaceContext async propertyStructureById(propertyId: string) { return this.structure.propertyStructureById(propertyId); } - + /** + * @function propertyValueByAlias + * @param {string} propertyAlias + * @returns {Promise | undefined>} + * @description Get an Observable for the value of this property. + */ async propertyValueByAlias(propertyAlias: string, variantId?: UmbVariantId) { return this.#currentData.asObservablePart( (data) => diff --git a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/workspace/document-workspace.context.ts b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/workspace/document-workspace.context.ts index df3d705077..bac6f64933 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/workspace/document-workspace.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/workspace/document-workspace.context.ts @@ -351,6 +351,13 @@ export class UmbDocumentWorkspaceContext return this.structure.propertyStructureById(propertyId); } + /** + * @function propertyValueByAlias + * @param {string} propertyAlias + * @param {UmbVariantId} variantId + * @returns {Promise | undefined>} + * @description Get an Observable for the value of this property. + */ async propertyValueByAlias( propertyAlias: string, variantId?: UmbVariantId, diff --git a/src/Umbraco.Web.UI.Client/src/packages/media/media/workspace/media-workspace.context.ts b/src/Umbraco.Web.UI.Client/src/packages/media/media/workspace/media-workspace.context.ts index 6c5f34884b..dc22cf60a7 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/media/media/workspace/media-workspace.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/media/media/workspace/media-workspace.context.ts @@ -256,7 +256,13 @@ export class UmbMediaWorkspaceContext async propertyStructureById(propertyId: string) { return this.structure.propertyStructureById(propertyId); } - + /** + * @function propertyValueByAlias + * @param {string} propertyAlias + * @param {UmbVariantId} variantId + * @returns {Promise | undefined>} + * @description Get an Observable for the value of this property. + */ async propertyValueByAlias(propertyAlias: string, variantId?: UmbVariantId) { return this.#currentData.asObservablePart( (data) => diff --git a/src/Umbraco.Web.UI.Client/src/packages/members/member/workspace/member-workspace.context.ts b/src/Umbraco.Web.UI.Client/src/packages/members/member/workspace/member-workspace.context.ts index 1e249d615a..df3323d2d1 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/members/member/workspace/member-workspace.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/members/member/workspace/member-workspace.context.ts @@ -227,6 +227,13 @@ export class UmbMemberWorkspaceContext return this.structure.propertyStructureById(propertyId); } + /** + * @function propertyValueByAlias + * @param {string} propertyAlias + * @param {UmbVariantId} variantId + * @returns {Promise | undefined>} + * @description Get an Observable for the value of this property. + */ async propertyValueByAlias(propertyAlias: string, variantId?: UmbVariantId) { return this.#currentData.asObservablePart( (data) => diff --git a/src/Umbraco.Web.UI.Client/src/packages/property-editors/text-box/property-editor-ui-text-box.element.ts b/src/Umbraco.Web.UI.Client/src/packages/property-editors/text-box/property-editor-ui-text-box.element.ts index 2e3397c100..9f25f98a62 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/property-editors/text-box/property-editor-ui-text-box.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/property-editors/text-box/property-editor-ui-text-box.element.ts @@ -8,12 +8,13 @@ import { } from '@umbraco-cms/backoffice/property-editor'; import type { UUIInputElement } from '@umbraco-cms/backoffice/external/uui'; import { UmbFormControlMixin } from '@umbraco-cms/backoffice/validation'; +import { UMB_PROPERTY_CONTEXT } from '@umbraco-cms/backoffice/property'; type UuiInputTypeType = typeof UUIInputElement.prototype.type; @customElement('umb-property-editor-ui-text-box') export class UmbPropertyEditorUITextBoxElement - extends UmbFormControlMixin(UmbLitElement, undefined) + extends UmbFormControlMixin(UmbLitElement, undefined) implements UmbPropertyEditorUiElement { /** @@ -48,6 +49,16 @@ export class UmbPropertyEditorUITextBoxElement protected override firstUpdated(): void { this.addFormControlElement(this.shadowRoot!.querySelector('uui-input')!); + + this.consumeContext(UMB_PROPERTY_CONTEXT, (context) => { + this.observe(context.variantId, (variantId) => { + console.log('text box variant ', variantId); + }); + }); + } + + override focus() { + return this.shadowRoot?.querySelector('uui-input')?.focus(); } #onInput(e: InputEvent) { @@ -68,7 +79,7 @@ export class UmbPropertyEditorUITextBoxElement ?readonly=${this.readonly}>`; } - static styles = [ + static override styles = [ UmbTextStyles, css` uui-input { From c52f2a248172d398eacbcb5d54115b7663d23c41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Fri, 16 Aug 2024 20:00:24 +0200 Subject: [PATCH 3/4] remove test code --- .../text-box/property-editor-ui-text-box.element.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/property-editors/text-box/property-editor-ui-text-box.element.ts b/src/Umbraco.Web.UI.Client/src/packages/property-editors/text-box/property-editor-ui-text-box.element.ts index 9f25f98a62..c1f3eb193a 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/property-editors/text-box/property-editor-ui-text-box.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/property-editors/text-box/property-editor-ui-text-box.element.ts @@ -49,12 +49,6 @@ export class UmbPropertyEditorUITextBoxElement protected override firstUpdated(): void { this.addFormControlElement(this.shadowRoot!.querySelector('uui-input')!); - - this.consumeContext(UMB_PROPERTY_CONTEXT, (context) => { - this.observe(context.variantId, (variantId) => { - console.log('text box variant ', variantId); - }); - }); } override focus() { From 264df73fea656ef7dd6aa096c94e297a27e5324b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Fri, 16 Aug 2024 20:00:54 +0200 Subject: [PATCH 4/4] remove import --- .../text-box/property-editor-ui-text-box.element.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/property-editors/text-box/property-editor-ui-text-box.element.ts b/src/Umbraco.Web.UI.Client/src/packages/property-editors/text-box/property-editor-ui-text-box.element.ts index c1f3eb193a..f942cbeb72 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/property-editors/text-box/property-editor-ui-text-box.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/property-editors/text-box/property-editor-ui-text-box.element.ts @@ -8,7 +8,6 @@ import { } from '@umbraco-cms/backoffice/property-editor'; import type { UUIInputElement } from '@umbraco-cms/backoffice/external/uui'; import { UmbFormControlMixin } from '@umbraco-cms/backoffice/validation'; -import { UMB_PROPERTY_CONTEXT } from '@umbraco-cms/backoffice/property'; type UuiInputTypeType = typeof UUIInputElement.prototype.type;