Skip to content

Commit f2d68da

Browse files
committed
rename filter to disallow
1 parent 3c3d56f commit f2d68da

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ describe('UmbSelectionManager', () => {
7777
expect(manager).to.have.property('clearSelection').that.is.a('function');
7878
});
7979

80-
it('has a setFilter method', () => {
81-
expect(manager).to.have.property('setFilter').that.is.a('function');
80+
it('has a setDisallow method', () => {
81+
expect(manager).to.have.property('setDisallow').that.is.a('function');
8282
});
8383
});
8484
});
@@ -155,8 +155,8 @@ describe('UmbSelectionManager', () => {
155155
expect(manager.getSelection()).to.deep.equal([]);
156156
});
157157

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

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

Lines changed: 6 additions & 6 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-
#selectionFilter = (unique: ValueType) => true;
22+
#disallow = (unique: ValueType) => true;
2323

2424
constructor(host: UmbControllerHost) {
2525
super(host);
@@ -112,7 +112,7 @@ 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.#selectionFilter(unique) === false) {
115+
if (this.#disallow(unique) === false) {
116116
throw new Error('The selection filter does not allow this item to be selected.');
117117
}
118118
const newSelection = this.getMultiple() ? [...this.getSelection(), unique] : [unique];
@@ -154,11 +154,11 @@ export class UmbSelectionManager<ValueType extends string | null = string | null
154154
}
155155

156156
/**
157-
* Sets the selection filter.
158-
* @param filter The selection filter.
157+
* Sets a function that determines if an item is selectable or not.
158+
* @param compareFn A function that determines if an item is selectable or not.
159159
* @memberof UmbSelectionManager
160160
*/
161-
public setFilter(filter: (unique: ValueType) => boolean): void {
162-
this.#selectionFilter = filter;
161+
public setDisallow(compareFn: (unique: ValueType) => boolean): void {
162+
this.#disallow = 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.setFilter((unique) => {
47+
this.#selectionManager.setDisallow((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.setFilter((unique) => {
53+
this.#selectionManager.setDisallow((unique) => {
5454
const option = this.variantLanguageOptions.find((o) => o.unique === unique);
5555
return option ? this.pickableFilter!(option) : true;
5656
});

0 commit comments

Comments
 (0)