CST-6056 changes for filter result not working while lookup from text input

This commit is contained in:
nikunj59
2022-06-13 17:38:07 +05:30
parent 859172717a
commit 02b124f7dd
6 changed files with 26 additions and 21 deletions

View File

@@ -9,6 +9,6 @@
</span>
</label>
<span class="float-right filter-value-count ml-auto">
<span class="badge badge-secondary badge-pill">{{filterValue.count}}</span>
</span>
<span class="badge badge-secondary badge-pill">{{filterValue.count}}</span>
</span>
</a>

View File

@@ -236,22 +236,21 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
onSubmit(data: any) {
if (data.match(new RegExp(`^.+,(equals|query|authority)$`))) {
this.selectedValues$.pipe(take(1)).subscribe((selectedValues) => {
if (isNotEmpty(data)) {
this.router.navigate(this.getSearchLinkParts(), {
queryParams:
{
[this.filterConfig.paramName]: [
...selectedValues.map((facet) => this.getFacetValue(facet)),
data
]
},
queryParamsHandling: 'merge'
});
this.filter = '';
}
this.filterSearchResults = observableOf([]);
if (isNotEmpty(data)) {
this.router.navigate(this.getSearchLinkParts(), {
queryParams:
{
[this.filterConfig.paramName]: [
...selectedValues.map((facet) => this.getFacetValue(facet)),
data
]
},
queryParamsHandling: 'merge'
});
this.filter = '';
}
);
this.filterSearchResults = observableOf([]);
});
}
}

View File

@@ -24,7 +24,7 @@
[name]="filterConfig.paramName"
[(ngModel)]="filter"
(submitSuggestion)="onSubmit($event)"
(clickSuggestion)="onClick($event)"
(clickSuggestion)="onSubmit($event)"
(findSuggestions)="findSuggestions($event)"
ngDefaultControl
></ds-filter-input-suggestions>

View File

@@ -3,6 +3,7 @@ import { FilterType } from '../../../models/filter-type.model';
import { renderFacetFor } from '../search-filter-type-decorator';
import { facetLoad, SearchFacetFilterComponent } from '../search-facet-filter/search-facet-filter.component';
import { addOperatorToFilterValue } from '../../../search.utils';
import { InputSuggestion } from '../../../../input-suggestions/input-suggestions.model';
@Component({
selector: 'ds-search-hierarchy-filter',
@@ -22,6 +23,8 @@ export class SearchHierarchyFilterComponent extends SearchFacetFilterComponent i
* @param data The string from the input field
*/
onSubmit(data: any) {
super.onSubmit(addOperatorToFilterValue(data, 'query'));
this.filterSearchResults.subscribe((filterSearchResults: InputSuggestion[]) => {
super.onSubmit(addOperatorToFilterValue(data, filterSearchResults.length ? 'equals' : 'query'));
});
}
}

View File

@@ -24,7 +24,7 @@
[name]="filterConfig.paramName"
[(ngModel)]="filter"
(submitSuggestion)="onSubmit($event)"
(clickSuggestion)="onClick($event)"
(clickSuggestion)="onSubmit($event)"
(findSuggestions)="findSuggestions($event)"
ngDefaultControl></ds-filter-input-suggestions>
</div>

View File

@@ -3,6 +3,7 @@ import { FilterType } from '../../../models/filter-type.model';
import { facetLoad, SearchFacetFilterComponent } from '../search-facet-filter/search-facet-filter.component';
import { renderFacetFor } from '../search-filter-type-decorator';
import { addOperatorToFilterValue, } from '../../../search.utils';
import { InputSuggestion } from '../../../../input-suggestions/input-suggestions.model';
/**
* This component renders a simple item page.
@@ -28,6 +29,8 @@ export class SearchTextFilterComponent extends SearchFacetFilterComponent implem
* @param data The string from the input field
*/
onSubmit(data: any) {
super.onSubmit(addOperatorToFilterValue(data, 'query'));
this.filterSearchResults.subscribe((filterSearchResults: InputSuggestion[]) => {
super.onSubmit(addOperatorToFilterValue(data, filterSearchResults.length ? 'equals' : 'query'));
});
}
}