mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Merge pull request #1691 from 4Science/CST-6056
fix for filter suggestion issue and bitstream description issue
This commit is contained in:
@@ -50,3 +50,7 @@
|
||||
cursor: grabbing;
|
||||
}
|
||||
}
|
||||
|
||||
:host ::ng-deep .larger-tooltip .tooltip-inner {
|
||||
max-width: 500px;
|
||||
}
|
||||
|
@@ -9,9 +9,10 @@
|
||||
</div>
|
||||
<div class="{{columnSizes.columns[1].buildClasses()}} row-element d-flex align-items-center">
|
||||
<div class="w-100">
|
||||
<span class="text-truncate">
|
||||
<div class="text-truncate" [tooltipClass]="'larger-tooltip'" placement="bottom"
|
||||
[ngbTooltip]="bitstream?.firstMetadataValue('dc.description')">
|
||||
{{ bitstream?.firstMetadataValue('dc.description') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="{{columnSizes.columns[2].buildClasses()}} row-element d-flex align-items-center">
|
||||
|
@@ -27,7 +27,7 @@
|
||||
<div class="autocomplete dropdown-menu" [ngClass]="{'show': (show | async) && isNotEmpty(suggestions)}">
|
||||
<div class="dropdown-list">
|
||||
<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>
|
||||
</a>
|
||||
</div>
|
||||
|
@@ -51,7 +51,7 @@ describe('FilterInputSuggestionsComponent', () => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
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);
|
||||
}
|
||||
|
||||
onClickSuggestion(data) {
|
||||
this.value = data;
|
||||
onClickSuggestion(data: InputSuggestion) {
|
||||
this.value = data.value;
|
||||
this.clickSuggestion.emit(data);
|
||||
this.close();
|
||||
this.blockReopen = true;
|
||||
|
@@ -7,6 +7,14 @@ export interface InputSuggestion {
|
||||
*/
|
||||
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
|
||||
*/
|
||||
|
@@ -24,7 +24,7 @@
|
||||
[name]="filterConfig.paramName"
|
||||
[(ngModel)]="filter"
|
||||
(submitSuggestion)="onSubmit($event)"
|
||||
(clickSuggestion)="onSubmit($event)"
|
||||
(clickSuggestion)="onClick($event)"
|
||||
(findSuggestions)="findSuggestions($event)"
|
||||
ngDefaultControl></ds-filter-input-suggestions>
|
||||
</div>
|
||||
|
@@ -234,33 +234,16 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
|
||||
* @param data The string from the input field
|
||||
*/
|
||||
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([]);
|
||||
}
|
||||
);
|
||||
}
|
||||
this.applyFilterValue(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* On click, set the input's value to the clicked data
|
||||
* @param data The value of the option that was clicked
|
||||
* Submits a selected filter value to the filter
|
||||
* Take the query from the InputSuggestion object
|
||||
* @param data The input suggestion selected
|
||||
*/
|
||||
onClick(data: any) {
|
||||
this.filter = data;
|
||||
onClick(data: InputSuggestion) {
|
||||
this.applyFilterValue(data.query);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -296,6 +279,7 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
|
||||
return rd.payload.page.map((facet) => {
|
||||
return {
|
||||
displayValue: this.getDisplayValue(facet, data),
|
||||
query: this.getFacetValue(facet),
|
||||
value: stripOperatorFromFilterValue(this.getFacetValue(facet))
|
||||
};
|
||||
});
|
||||
@@ -308,6 +292,31 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the filter query using the value given and apply to the search.
|
||||
* @param data The string from the input field
|
||||
*/
|
||||
protected applyFilterValue(data) {
|
||||
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([]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve facet value
|
||||
*/
|
||||
|
@@ -66,11 +66,11 @@ describe('Search Utils', () => {
|
||||
|
||||
describe('addOperatorToFilterValue', () => {
|
||||
it('should add the operator to the value', () => {
|
||||
expect(addOperatorToFilterValue('value', 'operator')).toEqual('value,operator');
|
||||
expect(addOperatorToFilterValue('value', 'equals')).toEqual('value,equals');
|
||||
});
|
||||
|
||||
it('shouldn\'t add the operator to the value if it already contains the operator', () => {
|
||||
expect(addOperatorToFilterValue('value,operator', 'operator')).toEqual('value,operator');
|
||||
expect(addOperatorToFilterValue('value,equals', 'equals')).toEqual('value,equals');
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -49,7 +49,7 @@ export function stripOperatorFromFilterValue(value: string) {
|
||||
* @param operator
|
||||
*/
|
||||
export function addOperatorToFilterValue(value: string, operator: string) {
|
||||
if (!value.endsWith(`,${operator}`)) {
|
||||
if (!value.match(new RegExp(`^.+,(equals|query|authority)$`))) {
|
||||
return `${value},${operator}`;
|
||||
}
|
||||
return value;
|
||||
|
Reference in New Issue
Block a user