mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
[CST-6056] Fix issue with authority suggestion by adding the filter query in the input suggestion object
This commit is contained in:
@@ -27,7 +27,7 @@
|
|||||||
<div class="autocomplete dropdown-menu" [ngClass]="{'show': (show | async) && isNotEmpty(suggestions)}">
|
<div class="autocomplete dropdown-menu" [ngClass]="{'show': (show | async) && isNotEmpty(suggestions)}">
|
||||||
<div class="dropdown-list">
|
<div class="dropdown-list">
|
||||||
<div *ngFor="let suggestionOption of suggestions">
|
<div *ngFor="let suggestionOption of suggestions">
|
||||||
<a href="javascript:void(0);" class="d-block dropdown-item" (click)="onClickSuggestion(suggestionOption.value)" #suggestion>
|
<a href="javascript:void(0);" class="d-block dropdown-item" (click)="onClickSuggestion(suggestionOption)" #suggestion>
|
||||||
<span [innerHTML]="suggestionOption.displayValue"></span>
|
<span [innerHTML]="suggestionOption.displayValue"></span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -51,7 +51,7 @@ describe('FilterInputSuggestionsComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
it('should call onClickSuggestion() with the suggestion as a parameter', () => {
|
it('should call onClickSuggestion() with the suggestion as a parameter', () => {
|
||||||
expect(comp.onClickSuggestion).toHaveBeenCalledWith(suggestions[clickedIndex].value);
|
expect(comp.onClickSuggestion).toHaveBeenCalledWith(suggestions[clickedIndex]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -32,8 +32,8 @@ export class FilterInputSuggestionsComponent extends InputSuggestionsComponent {
|
|||||||
this.submitSuggestion.emit(data);
|
this.submitSuggestion.emit(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
onClickSuggestion(data) {
|
onClickSuggestion(data: InputSuggestion) {
|
||||||
this.value = data;
|
this.value = data.value;
|
||||||
this.clickSuggestion.emit(data);
|
this.clickSuggestion.emit(data);
|
||||||
this.close();
|
this.close();
|
||||||
this.blockReopen = true;
|
this.blockReopen = true;
|
||||||
|
@@ -7,6 +7,14 @@ export interface InputSuggestion {
|
|||||||
*/
|
*/
|
||||||
displayValue: string;
|
displayValue: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The search query that can be used with filter suggestion.
|
||||||
|
* It contains the value within the operator :
|
||||||
|
* - value,equals
|
||||||
|
* - value,authority
|
||||||
|
*/
|
||||||
|
query?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The actual value of the suggestion
|
* The actual value of the suggestion
|
||||||
*/
|
*/
|
||||||
|
@@ -2,7 +2,6 @@ import { Component, OnInit } from '@angular/core';
|
|||||||
import { FilterType } from '../../../models/filter-type.model';
|
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';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-search-authority-filter',
|
selector: 'ds-search-authority-filter',
|
||||||
@@ -16,13 +15,4 @@ import { addOperatorToFilterValue } from '../../../search.utils';
|
|||||||
*/
|
*/
|
||||||
@renderFacetFor(FilterType.authority)
|
@renderFacetFor(FilterType.authority)
|
||||||
export class SearchAuthorityFilterComponent extends SearchFacetFilterComponent implements OnInit {
|
export class SearchAuthorityFilterComponent extends SearchFacetFilterComponent implements OnInit {
|
||||||
|
|
||||||
/**
|
|
||||||
* Submits a selected filter value to the filter
|
|
||||||
* Adds the "authority" operator to the received data before passing it on
|
|
||||||
* @param data The string selected from input suggestions
|
|
||||||
*/
|
|
||||||
onClick(data: any) {
|
|
||||||
this.applyFilterValue(addOperatorToFilterValue(data, 'authority'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -29,7 +29,7 @@ import { InputSuggestion } from '../../../../input-suggestions/input-suggestions
|
|||||||
import { SearchOptions } from '../../../models/search-options.model';
|
import { SearchOptions } from '../../../models/search-options.model';
|
||||||
import { SEARCH_CONFIG_SERVICE } from '../../../../../my-dspace-page/my-dspace-page.component';
|
import { SEARCH_CONFIG_SERVICE } from '../../../../../my-dspace-page/my-dspace-page.component';
|
||||||
import { currentPath } from '../../../../utils/route.utils';
|
import { currentPath } from '../../../../utils/route.utils';
|
||||||
import { addOperatorToFilterValue, getFacetValueForType, stripOperatorFromFilterValue } from '../../../search.utils';
|
import { getFacetValueForType, stripOperatorFromFilterValue } from '../../../search.utils';
|
||||||
import { createPendingRemoteDataObject } from '../../../../remote-data.utils';
|
import { createPendingRemoteDataObject } from '../../../../remote-data.utils';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -239,11 +239,11 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Submits a selected filter value to the filter
|
* Submits a selected filter value to the filter
|
||||||
* Adds the "equals" operator to the received data before passing it on
|
* Take the query from the InputSuggestion object
|
||||||
* @param data The string selected from input suggestions
|
* @param data The input suggestion selected
|
||||||
*/
|
*/
|
||||||
onClick(data: any) {
|
onClick(data: InputSuggestion) {
|
||||||
this.applyFilterValue(addOperatorToFilterValue(data, 'equals'));
|
this.applyFilterValue(data.query);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -279,6 +279,7 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
|
|||||||
return rd.payload.page.map((facet) => {
|
return rd.payload.page.map((facet) => {
|
||||||
return {
|
return {
|
||||||
displayValue: this.getDisplayValue(facet, data),
|
displayValue: this.getDisplayValue(facet, data),
|
||||||
|
query: this.getFacetValue(facet),
|
||||||
value: stripOperatorFromFilterValue(this.getFacetValue(facet))
|
value: stripOperatorFromFilterValue(this.getFacetValue(facet))
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user