Skip to content

Commit 608e338

Browse files
committed
clean up
1 parent 650dcec commit 608e338

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

src/Umbraco.Web.UI.Client/src/packages/core/collection/default/collection-default.context.ts

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,6 @@ export class UmbDefaultCollectionContext<
9393
this.#defaultViewAlias = defaultViewAlias;
9494
this.#defaultFilter = defaultFilter;
9595

96-
this.selection.setSelectable(false);
97-
98-
this.observe(
99-
this.bulkAction.hasBulkActions,
100-
(hasBulkActions) => {
101-
// Allow selection if there are bulk actions available
102-
if (hasBulkActions) {
103-
this.selection.setSelectable(true);
104-
}
105-
},
106-
'umbCollectionHasBulkActionsObserver',
107-
);
108-
10996
this.pagination.addEventListener(UmbChangeEvent.TYPE, this.#onPageChange);
11097
this.#listenToEntityEvents();
11198

@@ -178,7 +165,7 @@ export class UmbDefaultCollectionContext<
178165
protected _configure() {
179166
if (!this.#config) return;
180167

181-
this.selection.setMultiple(true);
168+
this.#configureSelection();
182169

183170
if (this.#config.pageSize) {
184171
this.pagination.setPageSize(this.#config.pageSize);
@@ -209,6 +196,26 @@ export class UmbDefaultCollectionContext<
209196
this._configured = true;
210197
}
211198

199+
#configureSelection() {
200+
// TODO: We need support a collecion selection configuration here so ex. Pickers can turn on single and multi select and set a selection.
201+
this.selection.setSelectable(false);
202+
this.selection.setMultiple(false);
203+
204+
// Observe bulk actions to enable selection when bulk actions are available
205+
// Bulk Actions are an integrated part of a Collection so we handle it here instead of a configuration
206+
this.observe(
207+
this.bulkAction.hasBulkActions,
208+
(hasBulkActions) => {
209+
// Allow selection if there are bulk actions available
210+
if (hasBulkActions) {
211+
this.selection.setSelectable(true);
212+
this.selection.setMultiple(true);
213+
}
214+
},
215+
'umbCollectionHasBulkActionsObserver',
216+
);
217+
}
218+
212219
#checkIfInitialized() {
213220
if (this._repository) {
214221
this.#initialized = true;
@@ -373,7 +380,7 @@ export class UmbDefaultCollectionContext<
373380

374381
/**
375382
* Sets the manifest for the collection.
376-
* @param {ManifestCollection} manifest
383+
* @param {ManifestCollection} manifest - The manifest for the collection.
377384
* @memberof UmbCollectionContext
378385
* @deprecated Use set the `.manifest` property instead.
379386
*/
@@ -387,7 +394,7 @@ export class UmbDefaultCollectionContext<
387394

388395
/**
389396
* Returns the manifest for the collection.
390-
* @returns {ManifestCollection}
397+
* @returns {ManifestCollection} - The manifest for the collection.
391398
* @memberof UmbCollectionContext
392399
* @deprecated Use the `.manifest` property instead.
393400
*/

0 commit comments

Comments
 (0)