Change query defaulting behaviour
This commit is contained in:
parent
19609434f7
commit
6b610bd982
|
@ -177,16 +177,11 @@ export default class DataFetch {
|
|||
}
|
||||
}
|
||||
|
||||
let defaultQuery = {
|
||||
logicalOperator: FilterGroupLogicalOperator.ALL,
|
||||
groups: [],
|
||||
}
|
||||
|
||||
// Build the query
|
||||
let query = this.options.query
|
||||
|
||||
if (!query && this.features.supportsSearch) {
|
||||
query = buildQuery(filter || defaultQuery)
|
||||
query = buildQuery(filter)
|
||||
}
|
||||
|
||||
// Update store
|
||||
|
|
|
@ -574,12 +574,7 @@ export const buildQueryLegacy = (
|
|||
export const buildQuery = (
|
||||
filter?: SearchFilterGroup | SearchFilter[]
|
||||
): SearchFilters | undefined => {
|
||||
const parsedFilter: SearchFilterGroup | undefined =
|
||||
processSearchFilters(filter)
|
||||
|
||||
if (!parsedFilter) {
|
||||
return
|
||||
}
|
||||
const parsedFilter: SearchFilterGroup = processSearchFilters(filter)
|
||||
|
||||
const operatorMap: { [key in FilterGroupLogicalOperator]: LogicalOperator } =
|
||||
{
|
||||
|
|
|
@ -98,16 +98,17 @@ export function trimOtherProps(object: any, allowedProps: string[]) {
|
|||
*/
|
||||
export const processSearchFilters = (
|
||||
filters: SearchFilter[] | SearchFilterGroup | undefined
|
||||
): SearchFilterGroup | undefined => {
|
||||
if (!filters) {
|
||||
return
|
||||
}
|
||||
): SearchFilterGroup => {
|
||||
// Base search config.
|
||||
const defaultCfg: SearchFilterGroup = {
|
||||
logicalOperator: FilterGroupLogicalOperator.ALL,
|
||||
onEmptyFilter: EmptyFilterOption.RETURN_NONE,
|
||||
groups: [],
|
||||
}
|
||||
|
||||
if (!filters) {
|
||||
return defaultCfg
|
||||
}
|
||||
|
||||
const filterWhitelistKeys = [
|
||||
"field",
|
||||
"operator",
|
||||
|
@ -182,7 +183,7 @@ export const processSearchFilters = (
|
|||
|
||||
return migratedSetting
|
||||
} else if (!filters?.groups) {
|
||||
return
|
||||
return defaultCfg
|
||||
}
|
||||
return filters
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue