From 2040c9fe41c2d24342366f1fa92f582d1d97d19c Mon Sep 17 00:00:00 2001 From: Michael Shamoon <4887959+shamoon@users.noreply.github.com> Date: Wed, 11 May 2022 10:26:17 -0700 Subject: [PATCH] allow commas in non-multi rules query params --- src-ui/src/app/services/query-params.service.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src-ui/src/app/services/query-params.service.ts b/src-ui/src/app/services/query-params.service.ts index 1528dca57..da014a0a4 100644 --- a/src-ui/src/app/services/query-params.service.ts +++ b/src-ui/src/app/services/query-params.service.ts @@ -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, } })