From c2849ac81cdb9f4c76a0a4c7c8e7294e620ea854 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Thu, 12 Sep 2024 11:45:06 +0200 Subject: [PATCH] expose properties --- .../content-type-structure-manager.class.ts | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-structure-manager.class.ts b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-structure-manager.class.ts index 268bea7841..9b87b7f6bc 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-structure-manager.class.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-structure-manager.class.ts @@ -46,8 +46,13 @@ export class UmbContentTypeStructureManager< (x) => x.find((y) => y.unique === this.#ownerContentTypeUnique)?.compositions, ); - readonly #contentTypeContainers = this.#contentTypes.asObservablePart(() => { - return this.#contentTypes.getValue().flatMap((x) => x.containers ?? []); + readonly #contentTypeContainers = this.#contentTypes.asObservablePart((contentTypes) => { + // Notice this may need to use getValue to avoid resetting it self. [NL] + return contentTypes.flatMap((x) => x.containers ?? []); + }); + readonly contentTypeProperties = this.#contentTypes.asObservablePart((contentTypes) => { + // Notice this may need to use getValue to avoid resetting it self. [NL] + return contentTypes.flatMap((x) => x.properties ?? []); }); readonly contentTypeUniques = this.#contentTypes.asObservablePart((x) => x.map((y) => y.unique)); readonly contentTypeAliases = this.#contentTypes.asObservablePart((x) => x.map((y) => y.alias)); @@ -77,7 +82,8 @@ export class UmbContentTypeStructureManager< /** * loadType will load the ContentType and all inherited and composed ContentTypes. * This will give us all the structure for properties and containers. - * @param unique + * @param {string} unique - The unique of the ContentType to load. + * @returns {Promise} - Promise resolved */ public async loadType(unique?: string) { this._reset(); @@ -219,6 +225,14 @@ export class UmbContentTypeStructureManager< return this.#ownerContentTypeUnique; } + /** + * Figure out if any of the Content Types has a Property. + * @returns {boolean} - true if any of the Content Type in this composition has a Property. + */ + getHasProperties() { + return this.#contentTypes.getValue().some((y) => y.properties.length > 0); + } + updateOwnerContentType(entry: Partial) { this.#contentTypes.updateOne(this.#ownerContentTypeUnique, entry); }