Skip to content

Commit 6a0f820

Browse files
author
Illia Obukhau
committed
feat(datagrid-dropdown-filter-web): use "or" statement in filter condition to match enum behavior
1 parent 7f77f0d commit 6a0f820

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

packages/pluggableWidgets/datagrid-dropdown-filter-web/src/features/referenceFilter.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
2-
referenceEqualsCondition,
3-
referenceSetContainsCondition
2+
referenceEqualsOneOf,
3+
referenceSetContainsOneOf
44
} from "@mendix/pluggable-widgets-commons/dist/builders/ConditionUtils";
55
import { ConditionDispatch } from "@mendix/pluggable-widgets-commons/dist/components/web";
66
import { tuple } from "@mendix/pluggable-widgets-commons/dist/utils/tuple";
@@ -44,9 +44,9 @@ export function getOnChange(
4444
return undefined;
4545
}
4646
if (association.type === "Reference") {
47-
return referenceEqualsCondition(association, values[0]);
47+
return referenceEqualsOneOf(association, values);
4848
}
49-
return referenceSetContainsCondition(association, values);
49+
return referenceSetContainsOneOf(association, values);
5050
}
5151
});
5252

packages/shared/pluggable-widgets-commons/src/builders/ConditionUtils.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ListReferenceSetValue, ListReferenceValue, ObjectItem } from "mendix";
2-
import { ContainsCondition, EqualsCondition } from "mendix/filters";
3-
import { association, literal, equals, contains, empty } from "mendix/filters/builders";
2+
import { ContainsCondition, EqualsCondition, FilterCondition } from "mendix/filters";
3+
import { association, literal, equals, contains, empty, or } from "mendix/filters/builders";
44

55
export function referenceEqualsCondition(associationValue: ListReferenceValue, value: ObjectItem): EqualsCondition {
66
return equals(association(associationValue.id), literal(value));
@@ -13,3 +13,23 @@ export function referenceSetContainsCondition(
1313
const v = value.length ? literal(value.slice()) : empty();
1414
return contains(association(associationValue.id), v);
1515
}
16+
17+
export function referenceEqualsOneOf(association: ListReferenceValue, values: ObjectItem[]): FilterCondition {
18+
const expressions = values.map(value => referenceEqualsCondition(association, value));
19+
20+
if (expressions.length > 1) {
21+
return or(...expressions);
22+
}
23+
24+
return expressions[0];
25+
}
26+
27+
export function referenceSetContainsOneOf(association: ListReferenceSetValue, values: ObjectItem[]): FilterCondition {
28+
const expressions = values.map(value => referenceSetContainsCondition(association, [value]));
29+
30+
if (expressions.length > 1) {
31+
return or(...expressions);
32+
}
33+
34+
return expressions[0];
35+
}

0 commit comments

Comments
 (0)