Add back custom field text search field

This commit is contained in:
shamoon 2024-09-02 20:11:58 -07:00
parent 36f33e59de
commit 047754ea63
2 changed files with 43 additions and 43 deletions

View File

@ -316,15 +316,15 @@ describe('FilterEditorComponent', () => {
}))
it('should ingest text filter rules for custom fields', fakeAsync(() => {
// expect(component.textFilter).toEqual(null)
// component.filterRules = [
// {
// rule_type: FILTER_CUSTOM_FIELDS_TEXT,
// value: 'foo',
// },
// ]
// expect(component.textFilter).toEqual('foo')
// expect(component.textFilterTarget).toEqual('custom-fields') // TEXT_FILTER_TARGET_CUSTOM_FIELDS
expect(component.textFilter).toEqual(null)
component.filterRules = [
{
rule_type: FILTER_CUSTOM_FIELDS_TEXT,
value: 'foo',
},
]
expect(component.textFilter).toEqual('foo')
expect(component.textFilterTarget).toEqual('custom-fields') // TEXT_FILTER_TARGET_CUSTOM_FIELDS
}))
it('should ingest text filter rules for doc asn is null', fakeAsync(() => {
@ -1170,21 +1170,21 @@ describe('FilterEditorComponent', () => {
}))
it('should convert user input to correct filter rules on custom fields query', fakeAsync(() => {
// component.textFilterInput.nativeElement.value = 'foo'
// component.textFilterInput.nativeElement.dispatchEvent(new Event('input'))
// const textFieldTargetDropdown = fixture.debugElement.queryAll(
// By.directive(NgbDropdownItem)
// )[3]
// textFieldTargetDropdown.triggerEventHandler('click') // TEXT_FILTER_TARGET_CUSTOM_FIELDS
// fixture.detectChanges()
// tick(400)
// expect(component.textFilterTarget).toEqual('custom-fields')
// expect(component.filterRules).toEqual([
// {
// rule_type: FILTER_CUSTOM_FIELDS_TEXT,
// value: 'foo',
// },
// ])
component.textFilterInput.nativeElement.value = 'foo'
component.textFilterInput.nativeElement.dispatchEvent(new Event('input'))
const textFieldTargetDropdown = fixture.debugElement.queryAll(
By.directive(NgbDropdownItem)
)[3]
textFieldTargetDropdown.triggerEventHandler('click') // TEXT_FILTER_TARGET_CUSTOM_FIELDS
fixture.detectChanges()
tick(400)
expect(component.textFilterTarget).toEqual('custom-fields')
expect(component.filterRules).toEqual([
{
rule_type: FILTER_CUSTOM_FIELDS_TEXT,
value: 'foo',
},
])
}))
it('should convert user input to correct filter rules on full text query', fakeAsync(() => {
@ -1192,7 +1192,7 @@ describe('FilterEditorComponent', () => {
component.textFilterInput.nativeElement.dispatchEvent(new Event('input'))
const textFieldTargetDropdown = fixture.debugElement.queryAll(
By.directive(NgbDropdownItem)
)[3]
)[4]
textFieldTargetDropdown.triggerEventHandler('click') // TEXT_FILTER_TARGET_ASN
fixture.detectChanges()
tick(400)
@ -1596,7 +1596,7 @@ describe('FilterEditorComponent', () => {
component.textFilterInput.nativeElement.dispatchEvent(new Event('input'))
const textFieldTargetDropdown = fixture.debugElement.queryAll(
By.directive(NgbDropdownItem)
)[3]
)[4]
textFieldTargetDropdown.triggerEventHandler('click')
fixture.detectChanges()
tick(400)

View File

@ -97,6 +97,7 @@ import {
CustomFieldQueriesModel,
CustomFieldQueryAtom,
CustomFieldQueryExpression,
CustomFieldQueryLogicalOperator,
} from '../../common/custom-fields-query-dropdown/custom-fields-query-dropdown.component'
const TEXT_FILTER_TARGET_TITLE = 'title'
@ -104,6 +105,7 @@ const TEXT_FILTER_TARGET_TITLE_CONTENT = 'title-content'
const TEXT_FILTER_TARGET_ASN = 'asn'
const TEXT_FILTER_TARGET_FULLTEXT_QUERY = 'fulltext-query'
const TEXT_FILTER_TARGET_FULLTEXT_MORELIKE = 'fulltext-morelike'
const TEXT_FILTER_TARGET_CUSTOM_FIELDS = 'custom-fields'
const TEXT_FILTER_MODIFIER_EQUALS = 'equals'
const TEXT_FILTER_MODIFIER_NULL = 'is null'
@ -139,6 +141,10 @@ const DEFAULT_TEXT_FILTER_TARGET_OPTIONS = [
name: $localize`Title & content`,
},
{ id: TEXT_FILTER_TARGET_ASN, name: $localize`ASN` },
{
id: TEXT_FILTER_TARGET_CUSTOM_FIELDS,
name: $localize`Custom fields`,
},
{
id: TEXT_FILTER_TARGET_FULLTEXT_QUERY,
name: $localize`Advanced search`,
@ -384,7 +390,8 @@ export class FilterEditorComponent
this.textFilterTarget = TEXT_FILTER_TARGET_ASN
break
case FILTER_CUSTOM_FIELDS_TEXT:
console.log('FILTER_CUSTOM_FIELDS_TEXT', rule.value)
this._textFilter = rule.value
this.textFilterTarget = TEXT_FILTER_TARGET_CUSTOM_FIELDS
break
case FILTER_FULLTEXT_QUERY:
let allQueryArgs = rule.value.split(',')
@ -543,22 +550,6 @@ export class FilterEditorComponent
// TODO: handle error?
}
break
case FILTER_HAS_CUSTOM_FIELDS_ALL:
console.log('FILTER_HAS_CUSTOM_FIELDS_ALL', rule.value)
// TODO: fully implement
break
case FILTER_HAS_CUSTOM_FIELDS_ANY:
console.log('FILTER_HAS_CUSTOM_FIELDS_ANY', rule.value)
// TODO: fully implement
break
case FILTER_HAS_ANY_CUSTOM_FIELDS:
console.log('FILTER_HAS_ANY_CUSTOM_FIELDS', rule.value)
// TODO: fully implement
break
case FILTER_DOES_NOT_HAVE_CUSTOM_FIELDS:
console.log('FILTER_DOES_NOT_HAVE_CUSTOM_FIELDS', rule.value)
// TODO: fully implement
break
case FILTER_ASN_ISNULL:
this.textFilterTarget = TEXT_FILTER_TARGET_ASN
this.textFilterModifier =
@ -661,6 +652,15 @@ export class FilterEditorComponent
})
}
}
if (
this._textFilter &&
this.textFilterTarget == TEXT_FILTER_TARGET_CUSTOM_FIELDS
) {
filterRules.push({
rule_type: FILTER_CUSTOM_FIELDS_TEXT,
value: this._textFilter,
})
}
if (
this._textFilter &&
this.textFilterTarget == TEXT_FILTER_TARGET_FULLTEXT_QUERY