Skip to content

Commit

Permalink
fix: filterQueryOverride provide all search values (#1238)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding authored Jul 20, 2024
1 parent 0ffb701 commit 0c2aea3
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 117 deletions.
4 changes: 2 additions & 2 deletions docs/backend-services/OData.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ E.g. you could listen for a specific column and the active OperatorType.custom i
```ts
backendServiceApi: {
options: {
filterQueryOverride: ({ fieldName, columnDef, columnFilterOperator, searchValue }) => {
filterQueryOverride: ({ fieldName, columnDef, columnFilterOperator, searchValues }) => {
if (columnFilterOperator === OperatorType.custom && columnDef?.id === 'name') {
let matchesSearch = (searchValue as string).replace(/\*/g, '.*');
let matchesSearch = searchValues[0].replace(/\*/g, '.*');
matchesSearch = matchesSearch.slice(0, 1) + '%5E' + matchesSearch.slice(1);
matchesSearch = matchesSearch.slice(0, -1) + '$\'';

Expand Down
4 changes: 2 additions & 2 deletions docs/backend-services/graphql/GraphQL-Filtering.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ E.g. you could listen for a specific column and the active `OperatorType.custom`
```ts
backendServiceApi: {
options: {
filterQueryOverride: ({ fieldName, columnDef, columnFilterOperator, searchValue }) => {
filterQueryOverride: ({ fieldName, columnDef, columnFilterOperator, searchValues }) => {
if (columnFilterOperator === OperatorType.custom && columnDef?.id === 'name') {
// the `operator` is a string, make sure to implement this new operator in your GraphQL Schema
return { field: fieldName, operator: 'Like', value: searchValue };
return { field: fieldName, operator: 'Like', value: searchValues[0] };
}
},
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"@jest/types": "^29.6.3",
"@lerna-lite/cli": "^3.7.1",
"@lerna-lite/publish": "^3.7.1",
"@slickgrid-universal/common": "^5.3.4",
"@slickgrid-universal/common": "^5.4.0",
"@types/jest": "^29.5.12",
"@types/node": "^20.14.11",
"conventional-changelog-conventionalcommits": "^7.0.2",
Expand Down
14 changes: 7 additions & 7 deletions packages/aurelia-slickgrid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@
"@aurelia/runtime": "^2.0.0-beta.20",
"@aurelia/runtime-html": "^2.0.0-beta.20",
"@formkit/tempo": "^0.1.2",
"@slickgrid-universal/common": "~5.3.4",
"@slickgrid-universal/custom-footer-component": "~5.3.4",
"@slickgrid-universal/empty-warning-component": "~5.3.4",
"@slickgrid-universal/event-pub-sub": "~5.3.4",
"@slickgrid-universal/pagination-component": "~5.3.4",
"@slickgrid-universal/row-detail-view-plugin": "~5.3.4",
"@slickgrid-universal/utils": "~5.3.4",
"@slickgrid-universal/common": "~5.4.0",
"@slickgrid-universal/custom-footer-component": "~5.4.0",
"@slickgrid-universal/empty-warning-component": "~5.4.0",
"@slickgrid-universal/event-pub-sub": "~5.4.0",
"@slickgrid-universal/pagination-component": "~5.4.0",
"@slickgrid-universal/row-detail-view-plugin": "~5.4.0",
"@slickgrid-universal/utils": "~5.4.0",
"dequal": "^2.0.3",
"sortablejs": "^1.15.2"
},
Expand Down
20 changes: 10 additions & 10 deletions packages/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@
"@fnando/sparkline": "^0.3.10",
"@formkit/tempo": "^0.1.2",
"@popperjs/core": "^2.11.8",
"@slickgrid-universal/common": "^5.3.4",
"@slickgrid-universal/composite-editor-component": "^5.3.4",
"@slickgrid-universal/custom-tooltip-plugin": "^5.3.4",
"@slickgrid-universal/excel-export": "^5.3.4",
"@slickgrid-universal/graphql": "^5.3.4",
"@slickgrid-universal/odata": "^5.3.4",
"@slickgrid-universal/row-detail-view-plugin": "^5.3.4",
"@slickgrid-universal/rxjs-observable": "^5.3.4",
"@slickgrid-universal/text-export": "^5.3.4",
"@slickgrid-universal/common": "^5.4.0",
"@slickgrid-universal/composite-editor-component": "^5.4.0",
"@slickgrid-universal/custom-tooltip-plugin": "^5.4.0",
"@slickgrid-universal/excel-export": "^5.4.0",
"@slickgrid-universal/graphql": "^5.4.0",
"@slickgrid-universal/odata": "^5.4.0",
"@slickgrid-universal/row-detail-view-plugin": "^5.4.0",
"@slickgrid-universal/rxjs-observable": "^5.4.0",
"@slickgrid-universal/text-export": "^5.4.0",
"aurelia": "^2.0.0-beta.20",
"aurelia-slickgrid": "workspace:*",
"bootstrap": "^5.3.3",
"i18next": "^23.11.5",
"i18next": "^23.12.2",
"i18next-fetch-backend": "^6.0.0",
"rxjs": "^7.8.1"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/demo/src/examples/slickgrid/example5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ export class Example5 {
enableCount: this.isCountEnabled, // add the count in the OData query, which will return a property named "__count" (v2) or "@odata.count" (v4)
enableSelect: this.isSelectEnabled,
enableExpand: this.isExpandEnabled,
filterQueryOverride: ({ fieldName, columnDef, columnFilterOperator, searchValue }) => {
filterQueryOverride: ({ fieldName, columnDef, columnFilterOperator, searchValues }) => {
if (columnFilterOperator === OperatorType.custom && columnDef?.id === 'name') {
let matchesSearch = (searchValue as string).replace(/\*/g, '.*');
let matchesSearch = searchValues[0].replace(/\*/g, '.*');
matchesSearch = matchesSearch.slice(0, 1) + CARET_HTML_ESCAPED + matchesSearch.slice(1);
matchesSearch = matchesSearch.slice(0, -1) + '$\'';

Expand Down
4 changes: 2 additions & 2 deletions packages/demo/src/examples/slickgrid/example6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,13 @@ export class Example6 {
field: 'userId',
value: 123
}],
filterQueryOverride: ({ fieldName, columnDef, columnFilterOperator, searchValue }) => {
filterQueryOverride: ({ fieldName, columnDef, columnFilterOperator, searchValues }) => {
if (columnFilterOperator === OperatorType.custom && columnDef?.id === 'name') {
// technically speaking GraphQL isn't a database query language like SQL, it's an application query language.
// What that means is that GraphQL won't let you write arbitrary queries out of the box.
// It will only support the types of queries defined in your GraphQL schema.
// see this SO: https://stackoverflow.com/a/37981802/1212166
return { field: fieldName, operator: 'Like', value: searchValue };
return { field: fieldName, operator: 'Like', value: searchValues[0] };
}
return;
},
Expand Down
Loading

0 comments on commit 0c2aea3

Please sign in to comment.