From 065dcc34894ec0f0d32fe0337b906acbdea195b4 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Wed, 1 Feb 2023 21:29:38 +0100 Subject: [PATCH] add js docs to template store --- .../tree/data/template.tree.store.ts | 38 +++++++++++++++++++ .../workspace/data/template.detail.store.ts | 15 ++++++++ 2 files changed, 53 insertions(+) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/templating/templates/tree/data/template.tree.store.ts b/src/Umbraco.Web.UI.Client/src/backoffice/templating/templates/tree/data/template.tree.store.ts index 558b211725..c9bbaaafba 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/templating/templates/tree/data/template.tree.store.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/templating/templates/tree/data/template.tree.store.ts @@ -13,14 +13,30 @@ import { UmbControllerHostInterface } from '@umbraco-cms/controller'; export class UmbTemplateTreeStore extends UmbStoreBase { #data = new ArrayState([], (x) => x.key); + /** + * Creates an instance of UmbTemplateTreeStore. + * @param {UmbControllerHostInterface} host + * @memberof UmbTemplateTreeStore + */ constructor(host: UmbControllerHostInterface) { super(host, UMB_TEMPLATE_TREE_STORE_CONTEXT_TOKEN.toString()); } + /** + * Appends items to the store + * @param {Array} items + * @memberof UmbTemplateTreeStore + */ appendItems(items: Array) { this.#data.append(items); } + /** + * Updates an item in the store + * @param {string} key + * @param {Partial} data + * @memberof UmbTemplateTreeStore + */ updateItem(key: string, data: Partial) { const entries = this.#data.getValue(); const entry = entries.find((entry) => entry.key === key); @@ -30,6 +46,11 @@ export class UmbTemplateTreeStore extends UmbStoreBase { } } + /** + * Removes an item from the store + * @param {string} key + * @memberof UmbTemplateTreeStore + */ removeItem(key: string) { const entries = this.#data.getValue(); const entry = entries.find((entry) => entry.key === key); @@ -39,14 +60,31 @@ export class UmbTemplateTreeStore extends UmbStoreBase { } } + /** + * Returns an observable to observe the root items + * @return {*} + * @memberof UmbTemplateTreeStore + */ rootItems() { return this.#data.getObservablePart((items) => items.filter((item) => item.parentKey === null)); } + /** + * Returns an observable to observe the children of a given parent + * @param {(string | null)} parentKey + * @return {*} + * @memberof UmbTemplateTreeStore + */ childrenOf(parentKey: string | null) { return this.#data.getObservablePart((items) => items.filter((item) => item.parentKey === parentKey)); } + /** + * Returns an observable to observe the items with the given keys + * @param {Array} keys + * @return {*} + * @memberof UmbTemplateTreeStore + */ items(keys: Array) { return this.#data.getObservablePart((items) => items.filter((item) => keys.includes(item.key ?? ''))); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/templating/templates/workspace/data/template.detail.store.ts b/src/Umbraco.Web.UI.Client/src/backoffice/templating/templates/workspace/data/template.detail.store.ts index 24e902be54..617c043d70 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/templating/templates/workspace/data/template.detail.store.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/templating/templates/workspace/data/template.detail.store.ts @@ -13,14 +13,29 @@ import { UmbControllerHostInterface } from '@umbraco-cms/controller'; export class UmbTemplateDetailStore extends UmbStoreBase { #data = new ArrayState