Skip to content

Commit 20314d4

Browse files
committed
[CST-6056] Fix issue with authority suggestion by adding the filter query in the input suggestion object
1 parent ac41e7b commit 20314d4

6 files changed

Lines changed: 18 additions & 19 deletions

File tree

src/app/shared/input-suggestions/filter-suggestions/filter-input-suggestions.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<div class="autocomplete dropdown-menu" [ngClass]="{'show': (show | async) && isNotEmpty(suggestions)}">
2828
<div class="dropdown-list">
2929
<div *ngFor="let suggestionOption of suggestions">
30-
<a href="javascript:void(0);" class="d-block dropdown-item" (click)="onClickSuggestion(suggestionOption.value)" #suggestion>
30+
<a href="javascript:void(0);" class="d-block dropdown-item" (click)="onClickSuggestion(suggestionOption)" #suggestion>
3131
<span [innerHTML]="suggestionOption.displayValue"></span>
3232
</a>
3333
</div>

src/app/shared/input-suggestions/filter-suggestions/filter-input-suggestions.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe('FilterInputSuggestionsComponent', () => {
5151
fixture.detectChanges();
5252
});
5353
it('should call onClickSuggestion() with the suggestion as a parameter', () => {
54-
expect(comp.onClickSuggestion).toHaveBeenCalledWith(suggestions[clickedIndex].value);
54+
expect(comp.onClickSuggestion).toHaveBeenCalledWith(suggestions[clickedIndex]);
5555
});
5656
});
5757
});

src/app/shared/input-suggestions/filter-suggestions/filter-input-suggestions.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ export class FilterInputSuggestionsComponent extends InputSuggestionsComponent {
3232
this.submitSuggestion.emit(data);
3333
}
3434

35-
onClickSuggestion(data) {
36-
this.value = data;
35+
onClickSuggestion(data: InputSuggestion) {
36+
this.value = data.value;
3737
this.clickSuggestion.emit(data);
3838
this.close();
3939
this.blockReopen = true;

src/app/shared/input-suggestions/input-suggestions.model.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ export interface InputSuggestion {
77
*/
88
displayValue: string;
99

10+
/**
11+
* The search query that can be used with filter suggestion.
12+
* It contains the value within the operator :
13+
* - value,equals
14+
* - value,authority
15+
*/
16+
query?: string;
17+
1018
/**
1119
* The actual value of the suggestion
1220
*/

src/app/shared/search/search-filters/search-filter/search-authority-filter/search-authority-filter.component.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Component, OnInit } from '@angular/core';
22
import { FilterType } from '../../../models/filter-type.model';
33
import { facetLoad, SearchFacetFilterComponent } from '../search-facet-filter/search-facet-filter.component';
44
import { renderFacetFor } from '../search-filter-type-decorator';
5-
import { addOperatorToFilterValue } from '../../../search.utils';
65

76
@Component({
87
selector: 'ds-search-authority-filter',
@@ -16,13 +15,4 @@ import { addOperatorToFilterValue } from '../../../search.utils';
1615
*/
1716
@renderFacetFor(FilterType.authority)
1817
export class SearchAuthorityFilterComponent extends SearchFacetFilterComponent implements OnInit {
19-
20-
/**
21-
* Submits a selected filter value to the filter
22-
* Adds the "authority" operator to the received data before passing it on
23-
* @param data The string selected from input suggestions
24-
*/
25-
onClick(data: any) {
26-
this.applyFilterValue(addOperatorToFilterValue(data, 'authority'));
27-
}
2818
}

src/app/shared/search/search-filters/search-filter/search-facet-filter/search-facet-filter.component.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { InputSuggestion } from '../../../../input-suggestions/input-suggestions
2929
import { SearchOptions } from '../../../models/search-options.model';
3030
import { SEARCH_CONFIG_SERVICE } from '../../../../../my-dspace-page/my-dspace-page.component';
3131
import { currentPath } from '../../../../utils/route.utils';
32-
import { addOperatorToFilterValue, getFacetValueForType, stripOperatorFromFilterValue } from '../../../search.utils';
32+
import { getFacetValueForType, stripOperatorFromFilterValue } from '../../../search.utils';
3333
import { createPendingRemoteDataObject } from '../../../../remote-data.utils';
3434

3535
@Component({
@@ -239,11 +239,11 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
239239

240240
/**
241241
* Submits a selected filter value to the filter
242-
* Adds the "equals" operator to the received data before passing it on
243-
* @param data The string selected from input suggestions
242+
* Take the query from the InputSuggestion object
243+
* @param data The input suggestion selected
244244
*/
245-
onClick(data: any) {
246-
this.applyFilterValue(addOperatorToFilterValue(data, 'equals'));
245+
onClick(data: InputSuggestion) {
246+
this.applyFilterValue(data.query);
247247
}
248248

249249
/**
@@ -279,6 +279,7 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
279279
return rd.payload.page.map((facet) => {
280280
return {
281281
displayValue: this.getDisplayValue(facet, data),
282+
query: this.getFacetValue(facet),
282283
value: stripOperatorFromFilterValue(this.getFacetValue(facet))
283284
};
284285
});

0 commit comments

Comments
 (0)