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> </span>
</label> </label>
<span class="float-right filter-value-count ml-auto"> <span class="float-right filter-value-count ml-auto">
<span class="badge badge-secondary badge-pill">{{filterValue.count}}</span> <span class="badge badge-secondary badge-pill">{{filterValue.count}}</span>
</span> </span>
</a> </a>

View File

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

View File

@@ -24,7 +24,7 @@
[name]="filterConfig.paramName" [name]="filterConfig.paramName"
[(ngModel)]="filter" [(ngModel)]="filter"
(submitSuggestion)="onSubmit($event)" (submitSuggestion)="onSubmit($event)"
(clickSuggestion)="onClick($event)" (clickSuggestion)="onSubmit($event)"
(findSuggestions)="findSuggestions($event)" (findSuggestions)="findSuggestions($event)"
ngDefaultControl ngDefaultControl
></ds-filter-input-suggestions> ></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 { renderFacetFor } from '../search-filter-type-decorator';
import { facetLoad, SearchFacetFilterComponent } from '../search-facet-filter/search-facet-filter.component'; import { facetLoad, SearchFacetFilterComponent } from '../search-facet-filter/search-facet-filter.component';
import { addOperatorToFilterValue } from '../../../search.utils'; import { addOperatorToFilterValue } from '../../../search.utils';
import { InputSuggestion } from '../../../../input-suggestions/input-suggestions.model';
@Component({ @Component({
selector: 'ds-search-hierarchy-filter', selector: 'ds-search-hierarchy-filter',
@@ -22,6 +23,8 @@ export class SearchHierarchyFilterComponent extends SearchFacetFilterComponent i
* @param data The string from the input field * @param data The string from the input field
*/ */
onSubmit(data: any) { 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" [name]="filterConfig.paramName"
[(ngModel)]="filter" [(ngModel)]="filter"
(submitSuggestion)="onSubmit($event)" (submitSuggestion)="onSubmit($event)"
(clickSuggestion)="onClick($event)" (clickSuggestion)="onSubmit($event)"
(findSuggestions)="findSuggestions($event)" (findSuggestions)="findSuggestions($event)"
ngDefaultControl></ds-filter-input-suggestions> ngDefaultControl></ds-filter-input-suggestions>
</div> </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 { facetLoad, SearchFacetFilterComponent } from '../search-facet-filter/search-facet-filter.component';
import { renderFacetFor } from '../search-filter-type-decorator'; import { renderFacetFor } from '../search-filter-type-decorator';
import { addOperatorToFilterValue, } from '../../../search.utils'; import { addOperatorToFilterValue, } from '../../../search.utils';
import { InputSuggestion } from '../../../../input-suggestions/input-suggestions.model';
/** /**
* This component renders a simple item page. * 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 * @param data The string from the input field
*/ */
onSubmit(data: any) { onSubmit(data: any) {
super.onSubmit(addOperatorToFilterValue(data, 'query')); this.filterSearchResults.subscribe((filterSearchResults: InputSuggestion[]) => {
super.onSubmit(addOperatorToFilterValue(data, filterSearchResults.length ? 'equals' : 'query'));
});
} }
} }