expose properties

This commit is contained in:
Niels Lyngsø
2024-09-12 11:45:06 +02:00
parent 6d3c7dfb2c
commit c2849ac81c

View File

@@ -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<T>) {
this.#contentTypes.updateOne(this.#ownerContentTypeUnique, entry);
}