Skip to content

Commit f649a82

Browse files
authored
Merge pull request DSpace#1691 from 4Science/CST-6056
fix for filter suggestion issue and bitstream description issue
2 parents 815788b + 20314d4 commit f649a82

11 files changed

Lines changed: 58 additions & 36 deletions

File tree

src/app/item-page/edit-item-page/item-bitstreams/item-bitstreams.component.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,7 @@
5050
cursor: grabbing;
5151
}
5252
}
53+
54+
:host ::ng-deep .larger-tooltip .tooltip-inner {
55+
max-width: 500px;
56+
}

src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream/item-edit-bitstream.component.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
</div>
1010
<div class="{{columnSizes.columns[1].buildClasses()}} row-element d-flex align-items-center">
1111
<div class="w-100">
12-
<span class="text-truncate">
13-
{{ bitstream?.firstMetadataValue('dc.description') }}
14-
</span>
12+
<div class="text-truncate" [tooltipClass]="'larger-tooltip'" placement="bottom"
13+
[ngbTooltip]="bitstream?.firstMetadataValue('dc.description')">
14+
{{ bitstream?.firstMetadataValue('dc.description') }}
15+
</div>
1516
</div>
1617
</div>
1718
<div class="{{columnSizes.columns[2].buildClasses()}} row-element d-flex align-items-center">

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.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
[name]="filterConfig.paramName"
2525
[(ngModel)]="filter"
2626
(submitSuggestion)="onSubmit($event)"
27-
(clickSuggestion)="onSubmit($event)"
27+
(clickSuggestion)="onClick($event)"
2828
(findSuggestions)="findSuggestions($event)"
2929
ngDefaultControl></ds-filter-input-suggestions>
3030
</div>

src/app/shared/search/search-filters/search-filter/search-facet-filter-options/search-facet-option/search-facet-option.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
</span>
1010
</label>
1111
<span class="float-right filter-value-count ml-auto">
12-
<span class="badge badge-secondary badge-pill">{{filterValue.count}}</span>
13-
</span>
12+
<span class="badge badge-secondary badge-pill">{{filterValue.count}}</span>
13+
</span>
1414
</a>

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

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -234,33 +234,16 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
234234
* @param data The string from the input field
235235
*/
236236
onSubmit(data: any) {
237-
if (data.match(new RegExp(`^.+,(equals|query|authority)$`))) {
238-
this.selectedValues$.pipe(take(1)).subscribe((selectedValues) => {
239-
if (isNotEmpty(data)) {
240-
this.router.navigate(this.getSearchLinkParts(), {
241-
queryParams:
242-
{
243-
[this.filterConfig.paramName]: [
244-
...selectedValues.map((facet) => this.getFacetValue(facet)),
245-
data
246-
]
247-
},
248-
queryParamsHandling: 'merge'
249-
});
250-
this.filter = '';
251-
}
252-
this.filterSearchResults = observableOf([]);
253-
}
254-
);
255-
}
237+
this.applyFilterValue(data);
256238
}
257239

258240
/**
259-
* On click, set the input's value to the clicked data
260-
* @param data The value of the option that was clicked
241+
* Submits a selected filter value to the filter
242+
* Take the query from the InputSuggestion object
243+
* @param data The input suggestion selected
261244
*/
262-
onClick(data: any) {
263-
this.filter = data;
245+
onClick(data: InputSuggestion) {
246+
this.applyFilterValue(data.query);
264247
}
265248

266249
/**
@@ -296,6 +279,7 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
296279
return rd.payload.page.map((facet) => {
297280
return {
298281
displayValue: this.getDisplayValue(facet, data),
282+
query: this.getFacetValue(facet),
299283
value: stripOperatorFromFilterValue(this.getFacetValue(facet))
300284
};
301285
});
@@ -308,6 +292,31 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
308292
}
309293
}
310294

295+
/**
296+
* Build the filter query using the value given and apply to the search.
297+
* @param data The string from the input field
298+
*/
299+
protected applyFilterValue(data) {
300+
if (data.match(new RegExp(`^.+,(equals|query|authority)$`))) {
301+
this.selectedValues$.pipe(take(1)).subscribe((selectedValues) => {
302+
if (isNotEmpty(data)) {
303+
this.router.navigate(this.getSearchLinkParts(), {
304+
queryParams:
305+
{
306+
[this.filterConfig.paramName]: [
307+
...selectedValues.map((facet) => this.getFacetValue(facet)),
308+
data
309+
]
310+
},
311+
queryParamsHandling: 'merge'
312+
});
313+
this.filter = '';
314+
}
315+
this.filterSearchResults = observableOf([]);
316+
});
317+
}
318+
}
319+
311320
/**
312321
* Retrieve facet value
313322
*/

src/app/shared/search/search.utils.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ describe('Search Utils', () => {
6666

6767
describe('addOperatorToFilterValue', () => {
6868
it('should add the operator to the value', () => {
69-
expect(addOperatorToFilterValue('value', 'operator')).toEqual('value,operator');
69+
expect(addOperatorToFilterValue('value', 'equals')).toEqual('value,equals');
7070
});
7171

7272
it('shouldn\'t add the operator to the value if it already contains the operator', () => {
73-
expect(addOperatorToFilterValue('value,operator', 'operator')).toEqual('value,operator');
73+
expect(addOperatorToFilterValue('value,equals', 'equals')).toEqual('value,equals');
7474
});
7575
});
7676

0 commit comments

Comments
 (0)