-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AJ-1953 Allow filtering columns for WDS #5024
base: dev
Are you sure you want to change the base?
Changes from 5 commits
ace8276
2aabceb
82252e5
0708156
9de982b
1370a32
055a3ad
d4a86ed
b89a540
3ae33cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,7 @@ export interface SearchRequest { | |
limit: number; | ||
sort: 'asc' | 'desc'; | ||
sortAttribute?: string; | ||
filter?: { ids?: string[]; query?: string }; | ||
} | ||
|
||
export type RecordAttributes = Record<string, unknown>; // truly "unknown" here; the backend Java representation is Map<String, Object> | ||
|
@@ -176,7 +177,7 @@ export class WdsDataTableProvider implements DataTableProvider { | |
supportsAttributeClearing: false, | ||
supportsExport: false, | ||
supportsPointCorrection: false, | ||
supportsFiltering: false, | ||
supportsFiltering: this.isCapabilityEnabled('search.filter.query.column.exact'), // TODO: check if we care about search.filter.query and/or search.filter.ids instead/as well | ||
supportsRowSelection: false, | ||
supportsPerColumnDatatype: true, | ||
}; | ||
|
@@ -240,6 +241,23 @@ export class WdsDataTableProvider implements DataTableProvider { | |
); | ||
}; | ||
|
||
protected transformQuery = (query: string): string => { | ||
const specialCharactersRegex = /([+\-&|!(){}[\]^"~*?:\\])/g; | ||
return query.replace(specialCharactersRegex, '\\$1').replace('=', ':'); | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a filter term containing spaces also causes query-parsing problems. That is solvable by double-quoting the entire search term … but then I fear that some of the escaping will be interpreted literally instead of as an escape sequence - we'll have to give it a try. And, if there are backend changes we need to support the front end, let's do that! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok I think including whitespace in the characters to escape works, with the exception of return lines ( |
||
|
||
protected queryOptionsToSearchRequest = (queryOptions: EntityQueryOptions): SearchRequest => { | ||
const baseRequest: SearchRequest = { | ||
offset: (queryOptions.pageNumber - 1) * queryOptions.itemsPerPage, | ||
limit: queryOptions.itemsPerPage, | ||
sort: queryOptions.sortDirection, | ||
}; | ||
if (queryOptions.sortField !== 'name') baseRequest.sortAttribute = queryOptions.sortField; | ||
if (queryOptions.columnFilter !== '') | ||
baseRequest.filter = { query: this.transformQuery(queryOptions.columnFilter) }; | ||
return baseRequest; | ||
}; | ||
|
||
protected transformPage = ( | ||
wdsPage: RecordQueryResponse, | ||
recordType: string, | ||
|
@@ -287,14 +305,7 @@ export class WdsDataTableProvider implements DataTableProvider { | |
this.proxyUrl, | ||
this.workspaceId, | ||
entityType, | ||
_.merge( | ||
{ | ||
offset: (queryOptions.pageNumber - 1) * queryOptions.itemsPerPage, | ||
limit: queryOptions.itemsPerPage, | ||
sort: queryOptions.sortDirection, | ||
}, | ||
queryOptions.sortField === 'name' ? {} : { sortAttribute: queryOptions.sortField } | ||
) | ||
this.queryOptionsToSearchRequest(queryOptions) | ||
); | ||
return this.transformPage(wdsPage, entityType, queryOptions, metadata); | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
search.filter.query.column.exact
is the right capability to check … and in hindsight, I regret adding that capability before it was supported for all datatypes; my bad on that!