diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/collection/collection.context.ts b/src/Umbraco.Web.UI.Client/src/packages/core/collection/collection.context.ts index 23fa34990f..ecd3108861 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/collection/collection.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/collection/collection.context.ts @@ -49,30 +49,66 @@ export class UmbCollectionContext) { - if (!value) return; - this.#selection.next(value); + /** + * Sets the current selection. + * @param {Array} selection + * @memberof UmbCollectionContext + */ + public setSelection(selection: Array) { + if (!selection) return; + this.#selection.next(selection); } + + /** + * Returns the current selection. + * @return {Array} + * @memberof UmbCollectionContext + */ public getSelection() { this.#selection.getValue(); } + /** + * Clears the current selection. + * @memberof UmbCollectionContext + */ public clearSelection() { this.#selection.next([]); } + /** + * Appends the given id to the current selection. + * @param {string} id + * @memberof UmbCollectionContext + */ public select(id: string) { this.#selection.appendOne(id); } + /** + * Removes the given id from the current selection. + * @param {string} id + * @memberof UmbCollectionContext + */ public deselect(id: string) { this.#selection.filter((k) => k !== id); } + /** + * Returns the collection entity type + * @return {string} + * @memberof UmbCollectionContext + */ public getEntityType() { return this._entityType; } @@ -82,6 +118,11 @@ export class UmbCollectionContext} filter + * @memberof UmbCollectionContext + */ setFilter(filter: Partial) { this.#filter.next({ ...this.#filter.getValue(), ...filter }); this.requestCollection(); } - - // TODO: how can we make sure to call this. - public destroy(): void { - this.#items.unsubscribe(); - } } export const UMB_COLLECTION_CONTEXT = new UmbContextToken>('UmbCollectionContext');