Skip to content

Commit 7b21139

Browse files
committed
turn filter around to allow + fix test
1 parent f2d68da commit 7b21139

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

src/packages/core/utils/selection-manager/selection.manager.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,9 @@ describe('UmbSelectionManager', () => {
155155
expect(manager.getSelection()).to.deep.equal([]);
156156
});
157157

158-
it('can not select an item if it does not pass the disallow function', () => {
159-
manager.setDisallow((item) => item !== '2');
160-
manager.select('2');
158+
it('can not select an item if it does not pass the allow function', () => {
159+
manager.setAllow((item) => item !== '2');
160+
expect(() => manager.select('2')).to.throw();
161161
expect(manager.getSelection()).to.deep.equal([]);
162162

163163
manager.select('1');

src/packages/core/utils/selection-manager/selection.manager.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class UmbSelectionManager<ValueType extends string | null = string | null
1919
public readonly multiple = this.#multiple.asObservable();
2020

2121
// eslint-disable-next-line @typescript-eslint/no-unused-vars
22-
#disallow = (unique: ValueType) => true;
22+
#allow = (unique: ValueType) => true;
2323

2424
constructor(host: UmbControllerHost) {
2525
super(host);
@@ -112,8 +112,8 @@ export class UmbSelectionManager<ValueType extends string | null = string | null
112112
public select(unique: ValueType) {
113113
if (this.getSelectable() === false) return;
114114
if (this.isSelected(unique)) return;
115-
if (this.#disallow(unique) === false) {
116-
throw new Error('The selection filter does not allow this item to be selected.');
115+
if (this.#allow(unique) === false) {
116+
throw new Error('The item is now allowed to be selected');
117117
}
118118
const newSelection = this.getMultiple() ? [...this.getSelection(), unique] : [unique];
119119
this.#selection.setValue(newSelection);
@@ -158,7 +158,7 @@ export class UmbSelectionManager<ValueType extends string | null = string | null
158158
* @param compareFn A function that determines if an item is selectable or not.
159159
* @memberof UmbSelectionManager
160160
*/
161-
public setDisallow(compareFn: (unique: ValueType) => boolean): void {
162-
this.#disallow = compareFn;
161+
public setAllow(compareFn: (unique: ValueType) => boolean): void {
162+
this.#allow = compareFn;
163163
}
164164
}

src/packages/documents/documents/modals/schedule-modal/document-schedule-modal.element.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class UmbDocumentScheduleModalElement extends UmbModalBaseElement<
4444
const pickableFilter = this.data?.pickableFilter;
4545

4646
if (pickableFilter) {
47-
this.#selectionManager.setDisallow((unique) => {
47+
this.#selectionManager.setAllow((unique) => {
4848
const option = this.data?.options.find((o) => o.unique === unique);
4949
return option ? pickableFilter(option) : true;
5050
});

src/packages/documents/documents/modals/shared/document-variant-language-picker.element.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class UmbDocumentVariantLanguagePickerElement extends UmbLitElement {
5050
super.updated(_changedProperties);
5151

5252
if (this.selectionManager && this.pickableFilter) {
53-
this.#selectionManager.setDisallow((unique) => {
53+
this.#selectionManager.setAllow((unique) => {
5454
const option = this.variantLanguageOptions.find((o) => o.unique === unique);
5555
return option ? this.pickableFilter!(option) : true;
5656
});

0 commit comments

Comments
 (0)