front end client support for filtering for no correspondent/document type

This commit is contained in:
jonaswinkler 2020-12-25 19:06:12 +01:00
parent f7f78d80b7
commit b9cf517cd1
2 changed files with 5 additions and 2 deletions

View File

@ -25,8 +25,8 @@ export const FILTER_RULE_TYPES: FilterRuleType[] = [
{id: FILTER_ASN, name: "ASN is", filtervar: "archive_serial_number", datatype: "number", multi: false},
{id: FILTER_CORRESPONDENT, name: "Correspondent is", filtervar: "correspondent__id", datatype: "correspondent", multi: false},
{id: FILTER_DOCUMENT_TYPE, name: "Document type is", filtervar: "document_type__id", datatype: "document_type", multi: false},
{id: FILTER_CORRESPONDENT, name: "Correspondent is", filtervar: "correspondent__id", isnull_filtervar: "correspondent__isnull", datatype: "correspondent", multi: false},
{id: FILTER_DOCUMENT_TYPE, name: "Document type is", filtervar: "document_type__id", isnull_filtervar: "document_type__isnull", datatype: "document_type", multi: false},
{id: FILTER_IS_IN_INBOX, name: "Is in Inbox", filtervar: "is_in_inbox", datatype: "boolean", multi: false, default: true},
{id: FILTER_HAS_TAG, name: "Has tag", filtervar: "tags__id__all", datatype: "tag", multi: true},
@ -51,6 +51,7 @@ export interface FilterRuleType {
id: number
name: string
filtervar: string
isnull_filtervar?: string
datatype: string //number, string, boolean, date
multi: boolean
default?: any

View File

@ -38,6 +38,8 @@ export class DocumentService extends AbstractPaperlessService<PaperlessDocument>
let ruleType = FILTER_RULE_TYPES.find(t => t.id == rule.rule_type)
if (ruleType.multi) {
params[ruleType.filtervar] = params[ruleType.filtervar] ? params[ruleType.filtervar] + "," + rule.value : rule.value
} else if (ruleType.isnull_filtervar && rule.value == null) {
params[ruleType.isnull_filtervar] = true
} else {
params[ruleType.filtervar] = rule.value
}