From 257413dba1da4b60f08d1b103ff6a63adec07e4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Wed, 1 May 2024 14:13:42 +0200 Subject: [PATCH] impl mergeObservables for propertyStructure composition --- ...nt-type-property-structure-helper.class.ts | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-property-structure-helper.class.ts b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-property-structure-helper.class.ts index 3699a93cbe..8784968913 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-property-structure-helper.class.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-property-structure-helper.class.ts @@ -7,7 +7,7 @@ import type { import type { UmbContentTypeStructureManager } from './content-type-structure-manager.class.js'; import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; -import { UmbArrayState } from '@umbraco-cms/backoffice/observable-api'; +import { UmbArrayState, mergeObservables } from '@umbraco-cms/backoffice/observable-api'; type UmbPropertyTypeId = UmbPropertyTypeModel['id']; @@ -77,7 +77,14 @@ export class UmbContentTypePropertyStructureHelper { + this.#propertyStructure.setValue(properties); + }, + 'observePropertyStructures', + ); this.removeUmbControllerByAlias('_observeContainers'); } else { this.observe( @@ -140,13 +147,24 @@ export class UmbContentTypePropertyStructureHelper this.#observePropertyStructureOf(group.id)); + this.observe( + mergeObservables( + groupContainers.map((group) => this.#structure!.propertyStructuresOf(group.id)), + (sources) => { + return sources.flatMap((x) => x); + }, + ), + (properties) => { + this.#propertyStructure.setValue(properties); + }, + 'observePropertyStructures', + ); this.#containers = groupContainers; }, '_observeContainers', ); } - + /* #observePropertyStructureOf(groupId?: string | null) { if (!this.#structure || groupId === undefined) return; @@ -164,7 +182,7 @@ export class UmbContentTypePropertyStructureHelper