From 23f2625bd9991075b0d3b848c2fec98fa873b376 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Fri, 24 Nov 2023 11:30:07 +0100 Subject: [PATCH] add getUnique --- .../core/collection/collection.context.ts | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) 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 14dd632904..e36e9452bc 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 @@ -2,22 +2,21 @@ import { UmbCollectionConfiguration } from './types.js'; import { UmbCollectionRepository } from '@umbraco-cms/backoffice/repository'; import { UmbBaseController, type UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; import { UmbContextToken } from '@umbraco-cms/backoffice/context-api'; -import { - UmbArrayState, - UmbNumberState, - UmbObjectState, -} from '@umbraco-cms/backoffice/observable-api'; +import { UmbArrayState, UmbNumberState, UmbObjectState } from '@umbraco-cms/backoffice/observable-api'; import { UmbExtensionsManifestInitializer, createExtensionApi } from '@umbraco-cms/backoffice/extension-api'; import { ManifestCollectionView, umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry'; import type { UmbCollectionFilterModel } from '@umbraco-cms/backoffice/collection'; import { UmbSelectionManager, UmbPaginationManager } from '@umbraco-cms/backoffice/utils'; import { UmbChangeEvent } from '@umbraco-cms/backoffice/event'; -export class UmbCollectionContext extends UmbBaseController { +export class UmbCollectionContext< + ItemType, + FilterModelType extends UmbCollectionFilterModel, +> extends UmbBaseController { protected entityType: string; protected init; - #items = new UmbArrayState([]); + #items = new UmbArrayState([], (x) => x); public readonly items = this.#items.asObservable(); #totalItems = new UmbNumberState(0); @@ -29,7 +28,7 @@ export class UmbCollectionContext({}); public readonly filter = this.#filter.asObservable(); - #views = new UmbArrayState([]); + #views = new UmbArrayState([], (x) => x.alias); public readonly views = this.#views.asObservable(); #currentView = new UmbObjectState(undefined); @@ -40,7 +39,12 @@ export class UmbCollectionContext { - this.#views.next(views.map(view => view.manifest)); + this.#views.next(views.map((view) => view.manifest)); this.#setCurrentView(); }); } @@ -202,7 +203,7 @@ export class UmbCollectionContext; this.setFilter(skipFilter); - } + }; #setCurrentView() { const currentUrl = new URL(window.location.href);