@slickgrid-universal/graphql 5.0.0 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/services/graphql.service.js +89 -56
- package/dist/cjs/services/graphql.service.js.map +1 -1
- package/dist/esm/services/graphql.service.js +89 -56
- package/dist/esm/services/graphql.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/interfaces/graphqlFilteringOption.interface.d.ts +8 -0
- package/dist/types/interfaces/graphqlFilteringOption.interface.d.ts.map +1 -1
- package/dist/types/interfaces/graphqlServiceOption.interface.d.ts +4 -2
- package/dist/types/interfaces/graphqlServiceOption.interface.d.ts.map +1 -1
- package/dist/types/services/graphql.service.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/interfaces/graphqlFilteringOption.interface.ts +11 -0
- package/src/interfaces/graphqlServiceOption.interface.ts +5 -2
- package/src/services/graphql.service.ts +92 -57
|
@@ -7,4 +7,12 @@ export interface GraphqlFilteringOption {
|
|
|
7
7
|
/** Value to use when filtering */
|
|
8
8
|
value: any | any[];
|
|
9
9
|
}
|
|
10
|
+
export interface GraphqlCustomFilteringOption {
|
|
11
|
+
/** Field name to use when filtering */
|
|
12
|
+
field: string;
|
|
13
|
+
/** Custom Operator to use when filtering. Please note that any new Custom Operator must be implemented in your GraphQL Schema. */
|
|
14
|
+
operator: OperatorType | OperatorString;
|
|
15
|
+
/** Value to use when filtering */
|
|
16
|
+
value: any | any[];
|
|
17
|
+
}
|
|
10
18
|
//# sourceMappingURL=graphqlFilteringOption.interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphqlFilteringOption.interface.d.ts","sourceRoot":"","sources":["../../../src/interfaces/graphqlFilteringOption.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhF,MAAM,WAAW,sBAAsB;IACrC,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IAEd,qCAAqC;IACrC,QAAQ,EAAE,YAAY,GAAG,cAAc,CAAC;IAExC,kCAAkC;IAClC,KAAK,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC;CACpB"}
|
|
1
|
+
{"version":3,"file":"graphqlFilteringOption.interface.d.ts","sourceRoot":"","sources":["../../../src/interfaces/graphqlFilteringOption.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhF,MAAM,WAAW,sBAAsB;IACrC,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IAEd,qCAAqC;IACrC,QAAQ,EAAE,YAAY,GAAG,cAAc,CAAC;IAExC,kCAAkC;IAClC,KAAK,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,4BAA4B;IAC3C,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IAEd,kIAAkI;IAClI,QAAQ,EAAE,YAAY,GAAG,cAAc,CAAC;IAExC,kCAAkC;IAClC,KAAK,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC;CACpB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { BackendServiceOption } from '@slickgrid-universal/common';
|
|
2
|
-
import type { GraphqlFilteringOption } from './graphqlFilteringOption.interface';
|
|
1
|
+
import type { BackendServiceOption, BackendServiceFilterQueryOverrideArgs } from '@slickgrid-universal/common';
|
|
2
|
+
import type { GraphqlCustomFilteringOption, GraphqlFilteringOption } from './graphqlFilteringOption.interface';
|
|
3
3
|
import type { GraphqlSortingOption } from './graphqlSortingOption.interface';
|
|
4
4
|
import type { GraphqlCursorPaginationOption } from './graphqlCursorPaginationOption.interface';
|
|
5
5
|
import type { GraphqlPaginationOption } from './graphqlPaginationOption.interface';
|
|
@@ -22,6 +22,8 @@ export interface GraphqlServiceOption extends BackendServiceOption {
|
|
|
22
22
|
extraQueryArguments?: QueryArgument[];
|
|
23
23
|
/** array of Filtering Options, ex.: { field: name, operator: EQ, value: "John" } */
|
|
24
24
|
filteringOptions?: GraphqlFilteringOption[];
|
|
25
|
+
/** An optional predicate function to overide the built-in filter construction */
|
|
26
|
+
filterQueryOverride?: (args: BackendServiceFilterQueryOverrideArgs) => GraphqlCustomFilteringOption | undefined;
|
|
25
27
|
/** What are the pagination options? ex.: (first, last, offset) */
|
|
26
28
|
paginationOptions?: GraphqlPaginationOption | GraphqlCursorPaginationOption;
|
|
27
29
|
/** array of Filtering Options, ex.: { field: name, direction: DESC } */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphqlServiceOption.interface.d.ts","sourceRoot":"","sources":["../../../src/interfaces/graphqlServiceOption.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"graphqlServiceOption.interface.d.ts","sourceRoot":"","sources":["../../../src/interfaces/graphqlServiceOption.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,qCAAqC,EAAE,MAAM,6BAA6B,CAAC;AAE/G,OAAO,KAAK,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC/G,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,2CAA2C,CAAC;AAC/F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AACnF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,MAAM,WAAW,oBAAqB,SAAQ,oBAAoB;IAChE;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B,8EAA8E;IAC9E,WAAW,EAAE,MAAM,CAAC;IAEpB,2EAA2E;IAC3E,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,aAAa,EAAE,CAAC;IAEtC,qFAAqF;IACrF,gBAAgB,CAAC,EAAE,sBAAsB,EAAE,CAAC;IAE5C,kFAAkF;IAClF,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,qCAAqC,KAAK,4BAA4B,GAAG,SAAS,CAAC;IAEhH,kEAAkE;IAClE,iBAAiB,CAAC,EAAE,uBAAuB,GAAG,6BAA6B,CAAC;IAE5E,yEAAyE;IACzE,cAAc,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAExC;;;OAGG;IACH,6BAA6B,CAAC,EAAE,OAAO,CAAC;IAExC,kDAAkD;IAClD,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.service.d.ts","sourceRoot":"","sources":["../../../src/services/graphql.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,MAAM,EAEN,aAAa,EACb,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,UAAU,EACV,eAAe,EAEf,UAAU,EACV,qBAAqB,EACrB,2BAA2B,EAC3B,aAAa,EACb,gBAAgB,EAChB,SAAS,EAEV,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,SAAS,EAMV,MAAM,6BAA6B,CAAC;AAGrC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"graphql.service.d.ts","sourceRoot":"","sources":["../../../src/services/graphql.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,MAAM,EAEN,aAAa,EACb,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,UAAU,EACV,eAAe,EAEf,UAAU,EACV,qBAAqB,EACrB,2BAA2B,EAC3B,aAAa,EACb,gBAA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rid-universal/graphql",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "GraphQL Service to sync a grid with a GraphQL backend server",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
"not dead"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@slickgrid-universal/common": "~5.
|
|
41
|
+
"@slickgrid-universal/common": "~5.1.0",
|
|
42
42
|
"@slickgrid-universal/utils": "~5.0.0"
|
|
43
43
|
},
|
|
44
44
|
"funding": {
|
|
45
45
|
"type": "ko_fi",
|
|
46
46
|
"url": "https://ko-fi.com/ghiscoding"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "dec8be36272c9111cd708a1836e1697ac81be323"
|
|
49
49
|
}
|
|
@@ -10,3 +10,14 @@ export interface GraphqlFilteringOption {
|
|
|
10
10
|
/** Value to use when filtering */
|
|
11
11
|
value: any | any[];
|
|
12
12
|
}
|
|
13
|
+
|
|
14
|
+
export interface GraphqlCustomFilteringOption {
|
|
15
|
+
/** Field name to use when filtering */
|
|
16
|
+
field: string;
|
|
17
|
+
|
|
18
|
+
/** Custom Operator to use when filtering. Please note that any new Custom Operator must be implemented in your GraphQL Schema. */
|
|
19
|
+
operator: OperatorType | OperatorString;
|
|
20
|
+
|
|
21
|
+
/** Value to use when filtering */
|
|
22
|
+
value: any | any[];
|
|
23
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { BackendServiceOption } from '@slickgrid-universal/common';
|
|
1
|
+
import type { BackendServiceOption, BackendServiceFilterQueryOverrideArgs } from '@slickgrid-universal/common';
|
|
2
2
|
|
|
3
|
-
import type { GraphqlFilteringOption } from './graphqlFilteringOption.interface';
|
|
3
|
+
import type { GraphqlCustomFilteringOption, GraphqlFilteringOption } from './graphqlFilteringOption.interface';
|
|
4
4
|
import type { GraphqlSortingOption } from './graphqlSortingOption.interface';
|
|
5
5
|
import type { GraphqlCursorPaginationOption } from './graphqlCursorPaginationOption.interface';
|
|
6
6
|
import type { GraphqlPaginationOption } from './graphqlPaginationOption.interface';
|
|
@@ -29,6 +29,9 @@ export interface GraphqlServiceOption extends BackendServiceOption {
|
|
|
29
29
|
/** array of Filtering Options, ex.: { field: name, operator: EQ, value: "John" } */
|
|
30
30
|
filteringOptions?: GraphqlFilteringOption[];
|
|
31
31
|
|
|
32
|
+
/** An optional predicate function to overide the built-in filter construction */
|
|
33
|
+
filterQueryOverride?: (args: BackendServiceFilterQueryOverrideArgs) => GraphqlCustomFilteringOption | undefined;
|
|
34
|
+
|
|
32
35
|
/** What are the pagination options? ex.: (first, last, offset) */
|
|
33
36
|
paginationOptions?: GraphqlPaginationOption | GraphqlCursorPaginationOption;
|
|
34
37
|
|
|
@@ -31,6 +31,7 @@ import { getHtmlStringOutput, stripTags } from '@slickgrid-universal/utils';
|
|
|
31
31
|
|
|
32
32
|
import type {
|
|
33
33
|
GraphqlCursorPaginationOption,
|
|
34
|
+
GraphqlCustomFilteringOption,
|
|
34
35
|
GraphqlDatasetFilter,
|
|
35
36
|
GraphqlFilteringOption,
|
|
36
37
|
GraphqlPaginationOption,
|
|
@@ -378,7 +379,7 @@ export class GraphqlService implements BackendService {
|
|
|
378
379
|
* @param columnFilters
|
|
379
380
|
*/
|
|
380
381
|
updateFilters(columnFilters: ColumnFilters | CurrentFilter[], isUpdatedByPresetOrDynamically: boolean) {
|
|
381
|
-
const searchByArray: GraphqlFilteringOption
|
|
382
|
+
const searchByArray: Array<GraphqlCustomFilteringOption | GraphqlFilteringOption> = [];
|
|
382
383
|
let searchValue: string | string[];
|
|
383
384
|
|
|
384
385
|
// on filter preset load, we need to keep current filters
|
|
@@ -425,81 +426,115 @@ export class GraphqlService implements BackendService {
|
|
|
425
426
|
|
|
426
427
|
// run regex to find possible filter operators unless the user disabled the feature
|
|
427
428
|
const autoParseInputFilterOperator = columnDef.autoParseInputFilterOperator ?? this._gridOptions.autoParseInputFilterOperator;
|
|
429
|
+
|
|
430
|
+
// group (2): comboStartsWith, (3): comboEndsWith, (4): Operator, (1 or 5): searchValue, (6): last char is '*' (meaning starts with, ex.: abc*)
|
|
428
431
|
const matches = autoParseInputFilterOperator !== false
|
|
429
|
-
? fieldSearchValue.match(/^([<>!=*]{0,2})(.*[^<>!=*])([*]?)$/)
|
|
430
|
-
: [fieldSearchValue, '',
|
|
432
|
+
? fieldSearchValue.match(/^((.*[^\\*\r\n])[*]{1}(.*[^*\r\n]))|^([<>!=*]{0,2})(.*[^<>!=*])([*]?)$/) || []
|
|
433
|
+
: [fieldSearchValue, '', '', '', '', fieldSearchValue, ''];
|
|
431
434
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
+
const comboStartsWith = matches?.[2] || '';
|
|
436
|
+
const comboEndsWith = matches?.[3] || '';
|
|
437
|
+
let operator = columnFilter.operator || matches?.[4];
|
|
438
|
+
searchValue = matches?.[1] || matches?.[5] || '';
|
|
439
|
+
const lastValueChar = matches?.[6] || (operator === '*z' || operator === OperatorType.endsWith) ? '*' : '';
|
|
435
440
|
|
|
436
441
|
// no need to query if search value is empty
|
|
437
442
|
if (fieldName && searchValue === '' && searchTerms.length === 0) {
|
|
438
443
|
continue;
|
|
439
444
|
}
|
|
440
445
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
446
|
+
let filterQueryOverride: GraphqlCustomFilteringOption | undefined = undefined;
|
|
447
|
+
if (typeof this.options?.filterQueryOverride === 'function') {
|
|
448
|
+
filterQueryOverride = this.options?.filterQueryOverride({
|
|
449
|
+
fieldName: getHtmlStringOutput(fieldName),
|
|
450
|
+
columnDef,
|
|
451
|
+
operator,
|
|
452
|
+
columnFilterOperator: columnFilter.operator,
|
|
453
|
+
searchValue,
|
|
454
|
+
grid: this._grid
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
if (filterQueryOverride !== undefined) {
|
|
459
|
+
// since this is a Custom Filter, we expect Operator to be a string
|
|
460
|
+
// and it is assumed that the developer will implement this custom operator in their GraphQL Schema
|
|
461
|
+
// e.g.: https://stackoverflow.com/a/37981802/1212166
|
|
462
|
+
searchByArray.push(filterQueryOverride);
|
|
463
|
+
} else {
|
|
464
|
+
if (comboStartsWith && comboEndsWith) {
|
|
465
|
+
searchTerms = [comboStartsWith, comboEndsWith];
|
|
466
|
+
operator = OperatorType.startsWithEndsWith;
|
|
467
|
+
} else if (Array.isArray(searchTerms) && searchTerms.length === 1 && typeof searchTerms[0] === 'string' && searchTerms[0].indexOf('..') >= 0) {
|
|
468
|
+
if (operator !== OperatorType.rangeInclusive && operator !== OperatorType.rangeExclusive) {
|
|
469
|
+
operator = this._gridOptions.defaultFilterRangeOperator ?? OperatorType.rangeInclusive;
|
|
470
|
+
}
|
|
471
|
+
searchTerms = searchTerms[0].split('..', 2);
|
|
472
|
+
if (searchTerms[0] === '') {
|
|
473
|
+
operator = operator === OperatorType.rangeInclusive ? '<=' : operator === OperatorType.rangeExclusive ? '<' : operator;
|
|
474
|
+
searchTerms = searchTerms.slice(1);
|
|
475
|
+
searchValue = searchTerms[0];
|
|
476
|
+
} else if (searchTerms[1] === '') {
|
|
477
|
+
operator = operator === OperatorType.rangeInclusive ? '>=' : operator === OperatorType.rangeExclusive ? '>' : operator;
|
|
478
|
+
searchTerms = searchTerms.slice(0, 1);
|
|
479
|
+
searchValue = searchTerms[0];
|
|
480
|
+
}
|
|
444
481
|
}
|
|
445
|
-
|
|
446
|
-
if (
|
|
447
|
-
operator
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
} else if (searchTerms[1] === '') {
|
|
451
|
-
operator = operator === OperatorType.rangeInclusive ? '>=' : operator === OperatorType.rangeExclusive ? '>' : operator;
|
|
452
|
-
searchTerms = searchTerms.slice(0, 1);
|
|
453
|
-
searchValue = searchTerms[0];
|
|
482
|
+
|
|
483
|
+
if (typeof searchValue === 'string') {
|
|
484
|
+
if (operator === '*' || operator === 'a*' || operator === '*z' || lastValueChar === '*') {
|
|
485
|
+
operator = ((operator === '*' || operator === '*z') ? 'EndsWith' : 'StartsWith') as OperatorString;
|
|
486
|
+
}
|
|
454
487
|
}
|
|
455
|
-
}
|
|
456
488
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
489
|
+
// if we didn't find an Operator but we have a Column Operator inside the Filter (DOM Element), we should use its default Operator
|
|
490
|
+
// multipleSelect is "IN", while singleSelect is "EQ", else don't map any operator
|
|
491
|
+
if (!operator && columnDef.filter && columnDef.filter.operator) {
|
|
492
|
+
operator = columnDef.filter.operator;
|
|
460
493
|
}
|
|
461
|
-
}
|
|
462
494
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
}
|
|
495
|
+
// No operator and 2 search terms should lead to default range operator.
|
|
496
|
+
if (!operator && Array.isArray(searchTerms) && searchTerms.length === 2 && searchTerms[0] && searchTerms[1]) {
|
|
497
|
+
operator = this._gridOptions.defaultFilterRangeOperator as OperatorString;
|
|
498
|
+
}
|
|
468
499
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
500
|
+
// Range with 1 searchterm should lead to equals for a date field.
|
|
501
|
+
if ((operator === OperatorType.rangeInclusive || operator === OperatorType.rangeExclusive) && Array.isArray(searchTerms) && searchTerms.length === 1 && fieldType === FieldType.date) {
|
|
502
|
+
operator = OperatorType.equal;
|
|
503
|
+
}
|
|
473
504
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
505
|
+
// Normalize all search values
|
|
506
|
+
searchValue = this.normalizeSearchValue(fieldType, searchValue);
|
|
507
|
+
if (Array.isArray(searchTerms)) {
|
|
508
|
+
searchTerms.forEach((_part, index) => {
|
|
509
|
+
searchTerms[index] = this.normalizeSearchValue(fieldType, searchTerms[index]);
|
|
510
|
+
});
|
|
511
|
+
}
|
|
478
512
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
513
|
+
// StartsWith + EndsWith combo
|
|
514
|
+
if (operator === OperatorType.startsWithEndsWith && Array.isArray(searchTerms) && searchTerms.length === 2) {
|
|
515
|
+
// add 2 conditions (StartsWith A + EndsWith B) to the search array
|
|
516
|
+
searchByArray.push({ field: getHtmlStringOutput(fieldName), operator: OperatorType.startsWith, value: comboStartsWith });
|
|
517
|
+
searchByArray.push({ field: getHtmlStringOutput(fieldName), operator: OperatorType.endsWith, value: comboEndsWith });
|
|
518
|
+
continue;
|
|
519
|
+
}
|
|
486
520
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
521
|
+
// when having more than 1 search term (we need to create a CSV string for GraphQL "IN" or "NOT IN" filter search)
|
|
522
|
+
if (searchTerms?.length > 1 && (operator === 'IN' || operator === 'NIN' || operator === 'NOT_IN')) {
|
|
523
|
+
searchValue = searchTerms.join(',');
|
|
524
|
+
} else if (searchTerms?.length === 2 && (operator === OperatorType.rangeExclusive || operator === OperatorType.rangeInclusive)) {
|
|
525
|
+
searchByArray.push({ field: getHtmlStringOutput(fieldName), operator: (operator === OperatorType.rangeInclusive ? 'GE' : 'GT'), value: searchTerms[0] });
|
|
526
|
+
searchByArray.push({ field: getHtmlStringOutput(fieldName), operator: (operator === OperatorType.rangeInclusive ? 'LE' : 'LT'), value: searchTerms[1] });
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
495
529
|
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
530
|
+
// if we still don't have an operator find the proper Operator to use according field type
|
|
531
|
+
if (!operator) {
|
|
532
|
+
operator = mapOperatorByFieldType(fieldType);
|
|
533
|
+
}
|
|
500
534
|
|
|
501
|
-
|
|
502
|
-
|
|
535
|
+
// build the search array
|
|
536
|
+
searchByArray.push({ field: getHtmlStringOutput(fieldName), operator: mapOperatorType(operator), value: searchValue });
|
|
537
|
+
}
|
|
503
538
|
}
|
|
504
539
|
}
|
|
505
540
|
|