diff --git a/src/app/search-page/search.component.ts b/src/app/search-page/search.component.ts index 8be21af552..2972175bdf 100644 --- a/src/app/search-page/search.component.ts +++ b/src/app/search-page/search.component.ts @@ -8,7 +8,7 @@ import { pushInOut } from '../shared/animations/push'; import { HostWindowService } from '../shared/host-window.service'; import { SidebarService } from '../shared/sidebar/sidebar.service'; import { hasValue, isEmpty } from '../shared/empty.util'; -import { getFirstSucceededRemoteData } from '../core/shared/operators'; +import { getFirstCompletedRemoteData } from '../core/shared/operators'; import { RouteService } from '../core/services/route.service'; import { SEARCH_CONFIG_SERVICE } from '../my-dspace-page/my-dspace-page.component'; import { PaginatedSearchOptions } from '../shared/search/paginated-search-options.model'; @@ -126,12 +126,12 @@ export class SearchComponent implements OnInit { this.searchOptions$ = this.getSearchOptions(); this.sub = this.searchOptions$.pipe( switchMap((options) => this.service.search( - options, undefined, true, true, followLink('thumbnail', { isOptional: true }) - ).pipe(getFirstSucceededRemoteData(), startWith(undefined)) + options, undefined, false, true, followLink('thumbnail', { isOptional: true }) + ).pipe(getFirstCompletedRemoteData(), startWith(undefined)) ) ).subscribe((results) => { - this.resultsRD$.next(results); - }); + this.resultsRD$.next(results); + }); if (isEmpty(this.configuration$)) { this.configuration$ = this.searchConfigService.getCurrentConfiguration('default'); diff --git a/src/app/shared/search/search-results/search-results.component.html b/src/app/shared/search/search-results/search-results.component.html index 4e6bca094e..23850f50dd 100644 --- a/src/app/shared/search/search-results/search-results.component.html +++ b/src/app/shared/search/search-results/search-results.component.html @@ -16,11 +16,11 @@ + *ngIf="showError()" + message="{{errorMessageLabel() | translate}}">
{{ 'search.results.no-results' | translate }} = new EventEmitter(); + showError(): boolean { + return this.searchResults?.hasFailed && (!this.searchResults?.errorMessage || this.searchResults?.statusCode !== 400); + } + + errorMessageLabel(): string { + return (this.searchResults?.statusCode === 422) ? 'error.invalid-search-query' : 'error.search-results'; + } + /** * Method to change the given string by surrounding it by quotes if not already present. */