Merge pull request #923 from paperless-ngx/fix-queryparams-comma-splitting

Fix: allow commas in non-multi rules query params
This commit is contained in:
shamoon 2022-05-11 11:15:39 -07:00 committed by GitHub
commit d230431227
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,7 @@
import { Injectable } from '@angular/core'
import { ParamMap, Params, Router } from '@angular/router'
import { FilterRule } from '../data/filter-rule'
import { FILTER_RULE_TYPES } from '../data/filter-rule-type'
import { FilterRuleType, FILTER_RULE_TYPES } from '../data/filter-rule-type'
import { PaperlessSavedView } from '../data/paperless-saved-view'
import { DocumentListViewService } from './document-list-view.service'
@ -135,17 +135,19 @@ export function filterRulesFromQueryParams(queryParams: ParamMap) {
allFilterRuleQueryParams
.filter((frqp) => queryParams.has(frqp))
.forEach((filterQueryParamName) => {
const filterQueryParamValues: string[] = queryParams
.get(filterQueryParamName)
.split(',')
const rule_type: FilterRuleType = FILTER_RULE_TYPES.find(
(rt) => rt.filtervar == filterQueryParamName
)
const valueURIComponent: string = queryParams.get(filterQueryParamName)
const filterQueryParamValues: string[] = rule_type.multi
? valueURIComponent.split(',')
: [valueURIComponent]
filterRulesFromQueryParams = filterRulesFromQueryParams.concat(
// map all values to filter rules
filterQueryParamValues.map((val) => {
return {
rule_type: FILTER_RULE_TYPES.find(
(rt) => rt.filtervar == filterQueryParamName
).id,
rule_type: rule_type.id,
value: val,
}
})