Skip to content

Commit feceb81

Browse files
authored
New Line Support for Multi Value Filters (#156)
1 parent 1ec2254 commit feceb81

File tree

5 files changed

+22
-16
lines changed

5 files changed

+22
-16
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.23.0 - 2023-27-14
2+
- Update filters to support newline delimiting as well as semicolon delimiting. Update constants and comments accordingly
3+
14
## 1.22.0 - 2023-07-14
25
- Support `plateMetadata` JSON property on `AssayDOM.importRun`.
36
- Rename `IImportRunOptions` to `ImportRunOptions`.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@labkey/api",
3-
"version": "1.22.0",
3+
"version": "1.23.0",
44
"description": "JavaScript client API for LabKey Server",
55
"scripts": {
66
"build": "npm run build:dist && npm run build:docs",

src/labkey/filter/Types.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ const GREATER_THAN_OR_EQUAL = registerFilterType(
7777
false,
7878
'>='
7979
);
80-
/** Finds rows where the column value equals one of the supplied filter values. The values should be supplied as a semi-colon-delimited list (example usage: a;b;c).*/
81-
const IN = registerFilterType('Equals One Of', null, 'in', true, ';', 'Equals One Of (example usage: a;b;c)');
80+
/** Finds rows where the column value equals one of the supplied filter values. Use semicolons or new lines to separate entries.*/
81+
const IN = registerFilterType('Equals One Of', null, 'in', true, ';', 'Equals One Of');
8282
/** Finds rows where the column value is less than the filter value.*/
8383
const LESS_THAN = registerFilterType(
8484
'Is Less Than',
@@ -118,14 +118,14 @@ const NOT_EQUAL = registerFilterType(
118118
false,
119119
'<>'
120120
);
121-
/** Finds rows where the column value is not in any of the supplied filter values. The values should be supplied as a semi-colon-delimited list (example usage: a;b;c).*/
121+
/** Finds rows where the column value is not in any of the supplied filter values. Use semicolons or new lines to separate entries.*/
122122
const NOT_IN = registerFilterType(
123123
'Does Not Equal Any Of',
124124
null,
125125
'notin',
126126
true,
127127
';',
128-
'Does Not Equal Any Of (example usage: a;b;c)'
128+
'Does Not Equal Any Of'
129129
);
130130
const NEQ_OR_NULL = registerFilterType(NOT_EQUAL.getDisplayText(), NOT_EQUAL.getDisplaySymbol(), 'neqornull', true);
131131

@@ -239,15 +239,15 @@ export const Types: Record<string, IFilterType> = {
239239
'containsoneof',
240240
true,
241241
';',
242-
'Contains One Of (example usage: a;b;c)'
242+
'Contains One Of'
243243
),
244244
CONTAINS_NONE_OF: registerFilterType(
245245
'Does Not Contain Any Of',
246246
null,
247247
'containsnoneof',
248248
true,
249249
';',
250-
'Does Not Contain Any Of (example usage: a;b;c)'
250+
'Does Not Contain Any Of'
251251
),
252252

253253
// NOTE: for some reason IN is aliased as EQUALS_ONE_OF. Not sure if this is for legacy purposes or it was
@@ -521,6 +521,8 @@ export function registerFilterType(
521521
const isDataValueRequired = () => dataValueRequired === true;
522522
const isMultiValued = () => multiValueSeparator != null;
523523
const isTableWise = () => tableWise === true;
524+
// Note that while ';' and ',' are both used as primary separators, '\n' is the only secondary separator
525+
const NEW_LINE_SEP = '\n';
524526

525527
const type: IFilterType = {
526528
getDisplaySymbol: () => displaySymbol ?? null,
@@ -543,7 +545,8 @@ export function registerFilterType(
543545
if (value.indexOf('{json:') === 0 && value.indexOf('}') === value.length - 1) {
544546
value = JSON.parse(value.substring('{json:'.length, value.length - 1));
545547
} else {
546-
value = value.split(type.getMultiValueSeparator());
548+
const regexPattern = new RegExp(`[${NEW_LINE_SEP}${type.getMultiValueSeparator()}]`);
549+
value = value.split(regexPattern);
547550
}
548551
}
549552

src/test/data/filter_types_snapshot.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"getDisplaySymbol": null,
3838
"getDisplayText": "Does Not Contain Any Of",
3939
"getLabKeySqlOperator": "undefined",
40-
"getLongDisplayText": "Does Not Contain Any Of (example usage: a;b;c)",
40+
"getLongDisplayText": "Does Not Contain Any Of",
4141
"getMultiValueFilter": null,
4242
"getMultiValueMaxOccurs": "undefined",
4343
"getMultiValueMinOccurs": "undefined",
@@ -54,7 +54,7 @@
5454
"getDisplaySymbol": null,
5555
"getDisplayText": "Contains One Of",
5656
"getLabKeySqlOperator": "undefined",
57-
"getLongDisplayText": "Contains One Of (example usage: a;b;c)",
57+
"getLongDisplayText": "Contains One Of",
5858
"getMultiValueFilter": null,
5959
"getMultiValueMaxOccurs": "undefined",
6060
"getMultiValueMinOccurs": "undefined",
@@ -241,7 +241,7 @@
241241
"getDisplaySymbol": null,
242242
"getDisplayText": "Does Not Equal Any Of",
243243
"getLabKeySqlOperator": "undefined",
244-
"getLongDisplayText": "Does Not Equal Any Of (example usage: a;b;c)",
244+
"getLongDisplayText": "Does Not Equal Any Of",
245245
"getMultiValueFilter": null,
246246
"getMultiValueMaxOccurs": "undefined",
247247
"getMultiValueMinOccurs": "undefined",
@@ -258,7 +258,7 @@
258258
"getDisplaySymbol": null,
259259
"getDisplayText": "Equals One Of",
260260
"getLabKeySqlOperator": "undefined",
261-
"getLongDisplayText": "Equals One Of (example usage: a;b;c)",
261+
"getLongDisplayText": "Equals One Of",
262262
"getMultiValueFilter": null,
263263
"getMultiValueMaxOccurs": "undefined",
264264
"getMultiValueMinOccurs": "undefined",
@@ -428,7 +428,7 @@
428428
"getDisplaySymbol": null,
429429
"getDisplayText": "Equals One Of",
430430
"getLabKeySqlOperator": "undefined",
431-
"getLongDisplayText": "Equals One Of (example usage: a;b;c)",
431+
"getLongDisplayText": "Equals One Of",
432432
"getMultiValueFilter": null,
433433
"getMultiValueMaxOccurs": "undefined",
434434
"getMultiValueMinOccurs": "undefined",
@@ -666,7 +666,7 @@
666666
"getDisplaySymbol": null,
667667
"getDisplayText": "Does Not Equal Any Of",
668668
"getLabKeySqlOperator": "undefined",
669-
"getLongDisplayText": "Does Not Equal Any Of (example usage: a;b;c)",
669+
"getLongDisplayText": "Does Not Equal Any Of",
670670
"getMultiValueFilter": null,
671671
"getMultiValueMaxOccurs": "undefined",
672672
"getMultiValueMinOccurs": "undefined",

0 commit comments

Comments
 (0)