Fix legacy filter ingestion
This commit is contained in:
parent
4dfcce527b
commit
43dba51009
@ -97,6 +97,11 @@ import { RouterModule } from '@angular/router'
|
|||||||
import { SearchService } from 'src/app/services/rest/search.service'
|
import { SearchService } from 'src/app/services/rest/search.service'
|
||||||
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'
|
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'
|
||||||
import { CustomFieldsQueryDropdownComponent } from '../../common/custom-fields-query-dropdown/custom-fields-query-dropdown.component'
|
import { CustomFieldsQueryDropdownComponent } from '../../common/custom-fields-query-dropdown/custom-fields-query-dropdown.component'
|
||||||
|
import {
|
||||||
|
CustomFieldQueryAtom,
|
||||||
|
CustomFieldQueryLogicalOperator,
|
||||||
|
CustomFieldQueryOperator,
|
||||||
|
} from 'src/app/data/custom-field-query'
|
||||||
|
|
||||||
const tags: Tag[] = [
|
const tags: Tag[] = [
|
||||||
{
|
{
|
||||||
@ -842,70 +847,43 @@ describe('FilterEditorComponent', () => {
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
it('should ingest filter rules for has all custom fields', fakeAsync(() => {
|
it('should ingest filter rules for has all custom fields', fakeAsync(() => {
|
||||||
// expect(component.customFieldQueriesModel.getSelectedItems()).toHaveLength(0)
|
expect(component.customFieldQueriesModel.isEmpty()).toBeTruthy()
|
||||||
// component.filterRules = [
|
component.filterRules = [
|
||||||
// {
|
{
|
||||||
// rule_type: FILTER_HAS_CUSTOM_FIELDS_ALL,
|
rule_type: FILTER_HAS_CUSTOM_FIELDS_ALL,
|
||||||
// value: '42',
|
value: '42,43',
|
||||||
// },
|
},
|
||||||
// {
|
]
|
||||||
// rule_type: FILTER_HAS_CUSTOM_FIELDS_ALL,
|
expect(component.customFieldQueriesModel.queries[0].operator).toEqual(
|
||||||
// value: '43',
|
CustomFieldQueryLogicalOperator.And
|
||||||
// },
|
)
|
||||||
// ]
|
expect(component.customFieldQueriesModel.queries[0].value.length).toEqual(2)
|
||||||
// expect(component.customFieldQueriesModel.logicalOperator).toEqual(
|
expect(
|
||||||
// LogicalOperator.And
|
(
|
||||||
// )
|
component.customFieldQueriesModel.queries[0]
|
||||||
// expect(component.customFieldQueriesModel.getSelectedItems()).toEqual(
|
.value[0] as CustomFieldQueryAtom
|
||||||
// custom_fields
|
).serialize()
|
||||||
// )
|
).toEqual(['42', CustomFieldQueryOperator.Exists, 'true'])
|
||||||
// // coverage
|
|
||||||
// component.filterRules = [
|
|
||||||
// {
|
|
||||||
// rule_type: FILTER_HAS_CUSTOM_FIELDS_ALL,
|
|
||||||
// value: null,
|
|
||||||
// },
|
|
||||||
// ]
|
|
||||||
// component.toggleTag(2) // coverage
|
|
||||||
}))
|
}))
|
||||||
|
|
||||||
it('should ingest filter rules for has any custom fields', fakeAsync(() => {
|
it('should ingest filter rules for has any custom fields', fakeAsync(() => {
|
||||||
// expect(component.customFieldQueriesModel.getSelectedItems()).toHaveLength(0)
|
expect(component.customFieldQueriesModel.isEmpty()).toBeTruthy()
|
||||||
// component.filterRules = [
|
component.filterRules = [
|
||||||
// {
|
{
|
||||||
// rule_type: FILTER_HAS_CUSTOM_FIELDS_ANY,
|
rule_type: FILTER_HAS_CUSTOM_FIELDS_ANY,
|
||||||
// value: '42',
|
value: '42,43',
|
||||||
// },
|
},
|
||||||
// {
|
]
|
||||||
// rule_type: FILTER_HAS_CUSTOM_FIELDS_ANY,
|
expect(component.customFieldQueriesModel.queries[0].operator).toEqual(
|
||||||
// value: '43',
|
CustomFieldQueryLogicalOperator.Or
|
||||||
// },
|
)
|
||||||
// ]
|
expect(component.customFieldQueriesModel.queries[0].value.length).toEqual(2)
|
||||||
// expect(component.customFieldQueriesModel.logicalOperator).toEqual(
|
expect(
|
||||||
// LogicalOperator.Or
|
(
|
||||||
// )
|
component.customFieldQueriesModel.queries[0]
|
||||||
// expect(component.customFieldQueriesModel.getSelectedItems()).toEqual(
|
.value[0] as CustomFieldQueryAtom
|
||||||
// custom_fields
|
).serialize()
|
||||||
// )
|
).toEqual(['42', CustomFieldQueryOperator.Exists, 'true'])
|
||||||
// // coverage
|
|
||||||
// component.filterRules = [
|
|
||||||
// {
|
|
||||||
// rule_type: FILTER_HAS_CUSTOM_FIELDS_ANY,
|
|
||||||
// value: null,
|
|
||||||
// },
|
|
||||||
// ]
|
|
||||||
}))
|
|
||||||
|
|
||||||
it('should ingest filter rules for has any custom field', fakeAsync(() => {
|
|
||||||
// expect(component.customFieldQueriesModel.getSelectedItems()).toHaveLength(0)
|
|
||||||
// component.filterRules = [
|
|
||||||
// {
|
|
||||||
// rule_type: FILTER_HAS_ANY_CUSTOM_FIELDS,
|
|
||||||
// value: '1',
|
|
||||||
// },
|
|
||||||
// ]
|
|
||||||
// expect(component.customFieldQueriesModel.getSelectedItems()).toHaveLength(1)
|
|
||||||
// expect(component.customFieldQueriesModel.get(null)).toBeTruthy()
|
|
||||||
}))
|
}))
|
||||||
|
|
||||||
it('should ingest filter rules for exclude tag(s)', fakeAsync(() => {
|
it('should ingest filter rules for exclude tag(s)', fakeAsync(() => {
|
||||||
|
@ -96,6 +96,7 @@ import {
|
|||||||
CustomFieldQueryExpression,
|
CustomFieldQueryExpression,
|
||||||
CustomFieldQueryAtom,
|
CustomFieldQueryAtom,
|
||||||
CustomFieldQueryLogicalOperator,
|
CustomFieldQueryLogicalOperator,
|
||||||
|
CustomFieldQueryOperator,
|
||||||
} from 'src/app/data/custom-field-query'
|
} from 'src/app/data/custom-field-query'
|
||||||
import { CustomFieldQueriesModel } from '../../common/custom-fields-query-dropdown/custom-fields-query-dropdown.component'
|
import { CustomFieldQueriesModel } from '../../common/custom-fields-query-dropdown/custom-fields-query-dropdown.component'
|
||||||
|
|
||||||
@ -559,7 +560,9 @@ export class FilterEditorComponent
|
|||||||
this.customFieldQueriesModel.addExpression(
|
this.customFieldQueriesModel.addExpression(
|
||||||
new CustomFieldQueryExpression([
|
new CustomFieldQueryExpression([
|
||||||
CustomFieldQueryLogicalOperator.And,
|
CustomFieldQueryLogicalOperator.And,
|
||||||
rule.value.split(','),
|
rule.value
|
||||||
|
.split(',')
|
||||||
|
.map((id) => [id, CustomFieldQueryOperator.Exists, 'true']),
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
@ -567,7 +570,9 @@ export class FilterEditorComponent
|
|||||||
this.customFieldQueriesModel.addExpression(
|
this.customFieldQueriesModel.addExpression(
|
||||||
new CustomFieldQueryExpression([
|
new CustomFieldQueryExpression([
|
||||||
CustomFieldQueryLogicalOperator.Or,
|
CustomFieldQueryLogicalOperator.Or,
|
||||||
rule.value.split(','),
|
rule.value
|
||||||
|
.split(',')
|
||||||
|
.map((id) => [id, CustomFieldQueryOperator.Exists, 'true']),
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
|
@ -268,6 +268,8 @@ export class CustomFieldQueryExpression extends CustomFieldQueryElement {
|
|||||||
super(CustomFieldQueryElementType.Expression)
|
super(CustomFieldQueryElementType.Expression)
|
||||||
let values
|
let values
|
||||||
;[this._operator, values] = expressionArray
|
;[this._operator, values] = expressionArray
|
||||||
|
console.log(values)
|
||||||
|
|
||||||
if (!values || values.length === 0) {
|
if (!values || values.length === 0) {
|
||||||
this._value = []
|
this._value = []
|
||||||
} else if (values?.length > 0 && values[0] instanceof Array) {
|
} else if (values?.length > 0 && values[0] instanceof Array) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user