Merge pull request #930 from paperless-ngx/fix-unassigned-filtering-query-params

Fix: unassigned query params ignored
This commit is contained in:
Quinn Casey 2022-05-12 09:53:00 -07:00 committed by GitHub
commit 2decae6586
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -129,6 +129,8 @@ export function filterRulesFromQueryParams(queryParams: ParamMap) {
const allFilterRuleQueryParams: string[] = FILTER_RULE_TYPES.map( const allFilterRuleQueryParams: string[] = FILTER_RULE_TYPES.map(
(rt) => rt.filtervar (rt) => rt.filtervar
) )
.concat(FILTER_RULE_TYPES.map((rt) => rt.isnull_filtervar))
.filter((rt) => rt !== undefined)
// transform query params to filter rules // transform query params to filter rules
let filterRulesFromQueryParams: FilterRule[] = [] let filterRulesFromQueryParams: FilterRule[] = []
@ -136,8 +138,11 @@ export function filterRulesFromQueryParams(queryParams: ParamMap) {
.filter((frqp) => queryParams.has(frqp)) .filter((frqp) => queryParams.has(frqp))
.forEach((filterQueryParamName) => { .forEach((filterQueryParamName) => {
const rule_type: FilterRuleType = FILTER_RULE_TYPES.find( const rule_type: FilterRuleType = FILTER_RULE_TYPES.find(
(rt) => rt.filtervar == filterQueryParamName (rt) =>
rt.filtervar == filterQueryParamName ||
rt.isnull_filtervar == filterQueryParamName
) )
const isNullRuleType = rule_type.isnull_filtervar == filterQueryParamName
const valueURIComponent: string = queryParams.get(filterQueryParamName) const valueURIComponent: string = queryParams.get(filterQueryParamName)
const filterQueryParamValues: string[] = rule_type.multi const filterQueryParamValues: string[] = rule_type.multi
? valueURIComponent.split(',') ? valueURIComponent.split(',')
@ -148,7 +153,7 @@ export function filterRulesFromQueryParams(queryParams: ParamMap) {
filterQueryParamValues.map((val) => { filterQueryParamValues.map((val) => {
return { return {
rule_type: rule_type.id, rule_type: rule_type.id,
value: val, value: isNullRuleType ? null : val,
} }
}) })
) )