mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-01-06 21:46:11 +01:00
Feature: custom fields queries (#7761)
This commit is contained in:
parent
2e3637d712
commit
f8d79b012f
26 changed files with 2130 additions and 599 deletions
|
|
@ -2,13 +2,17 @@ import { convertToParamMap } from '@angular/router'
|
|||
import { FilterRule } from '../data/filter-rule'
|
||||
import {
|
||||
FILTER_CORRESPONDENT,
|
||||
FILTER_CUSTOM_FIELDS_QUERY,
|
||||
FILTER_HAS_ANY_TAG,
|
||||
FILTER_HAS_CUSTOM_FIELDS_ALL,
|
||||
FILTER_HAS_CUSTOM_FIELDS_ANY,
|
||||
FILTER_HAS_TAGS_ALL,
|
||||
} from '../data/filter-rule-type'
|
||||
import { paramsToViewState } from './query-params'
|
||||
import { paramsToViewState, transformLegacyFilterRules } from './query-params'
|
||||
import { paramsFromViewState } from './query-params'
|
||||
import { queryParamsFromFilterRules } from './query-params'
|
||||
import { filterRulesFromQueryParams } from './query-params'
|
||||
import { CustomFieldQueryLogicalOperator } from '../data/custom-field-query'
|
||||
|
||||
const tags__id__all = '9'
|
||||
const filterRules: FilterRule[] = [
|
||||
|
|
@ -193,4 +197,58 @@ describe('QueryParams Utils', () => {
|
|||
},
|
||||
])
|
||||
})
|
||||
|
||||
it('should transform legacy filter rules', () => {
|
||||
let filterRules: FilterRule[] = [
|
||||
{
|
||||
rule_type: FILTER_HAS_CUSTOM_FIELDS_ANY,
|
||||
value: '1',
|
||||
},
|
||||
{
|
||||
rule_type: FILTER_HAS_CUSTOM_FIELDS_ANY,
|
||||
value: '2',
|
||||
},
|
||||
]
|
||||
|
||||
let transformedFilterRules = transformLegacyFilterRules(filterRules)
|
||||
|
||||
expect(transformedFilterRules).toEqual([
|
||||
{
|
||||
rule_type: FILTER_CUSTOM_FIELDS_QUERY,
|
||||
value: JSON.stringify([
|
||||
CustomFieldQueryLogicalOperator.Or,
|
||||
[
|
||||
[1, 'exists', true],
|
||||
[2, 'exists', true],
|
||||
],
|
||||
]),
|
||||
},
|
||||
])
|
||||
|
||||
filterRules = [
|
||||
{
|
||||
rule_type: FILTER_HAS_CUSTOM_FIELDS_ALL,
|
||||
value: '3',
|
||||
},
|
||||
{
|
||||
rule_type: FILTER_HAS_CUSTOM_FIELDS_ALL,
|
||||
value: '4',
|
||||
},
|
||||
]
|
||||
|
||||
transformedFilterRules = transformLegacyFilterRules(filterRules)
|
||||
|
||||
expect(transformedFilterRules).toEqual([
|
||||
{
|
||||
rule_type: FILTER_CUSTOM_FIELDS_QUERY,
|
||||
value: JSON.stringify([
|
||||
CustomFieldQueryLogicalOperator.And,
|
||||
[
|
||||
[3, 'exists', true],
|
||||
[4, 'exists', true],
|
||||
],
|
||||
]),
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue