diff --git a/src/app/core/data/search-response-parsing.service.ts b/src/app/core/data/search-response-parsing.service.ts index 707875911d..c7456aa2f9 100644 --- a/src/app/core/data/search-response-parsing.service.ts +++ b/src/app/core/data/search-response-parsing.service.ts @@ -26,7 +26,7 @@ export class SearchResponseParsingService implements ResponseParsingService { value: hhObject[key].join('...') })) } else { - return undefined; + return []; } }); diff --git a/src/app/shared/object-list/search-result-list-element/search-result-list-element.component.ts b/src/app/shared/object-list/search-result-list-element/search-result-list-element.component.ts index 31e31c72a8..fd821997ad 100644 --- a/src/app/shared/object-list/search-result-list-element/search-result-list-element.component.ts +++ b/src/app/shared/object-list/search-result-list-element/search-result-list-element.component.ts @@ -1,12 +1,12 @@ import { Component, Inject } from '@angular/core'; +import { Observable } from 'rxjs/Observable'; import { SearchResult } from '../../../+search-page/search-result.model'; import { DSpaceObject } from '../../../core/shared/dspace-object.model'; import { Metadatum } from '../../../core/shared/metadatum.model'; -import { isEmpty, hasNoValue, isNotEmpty } from '../../empty.util'; +import { hasNoValue, isEmpty } from '../../empty.util'; import { ListableObject } from '../../object-collection/shared/listable-object.model'; import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component'; -import { Observable } from 'rxjs/Observable'; import { TruncatableService } from '../../truncatable/truncatable.service'; @Component({ @@ -24,15 +24,13 @@ export class SearchResultListElementComponent, K exten getValues(keys: string[]): string[] { const results: string[] = new Array(); - if (isNotEmpty(this.object.hitHighlights)) { - this.object.hitHighlights.forEach( - (md: Metadatum) => { - if (keys.indexOf(md.key) > -1) { - results.push(md.value); - } + this.object.hitHighlights.forEach( + (md: Metadatum) => { + if (keys.indexOf(md.key) > -1) { + results.push(md.value); } - ); - } + } + ); if (isEmpty(results)) { this.dso.filterMetadata(keys).forEach( (md: Metadatum) => { @@ -45,16 +43,14 @@ export class SearchResultListElementComponent, K exten getFirstValue(key: string): string { let result: string; - if (isNotEmpty(this.object.hitHighlights)) { - this.object.hitHighlights.some( - (md: Metadatum) => { - if (key === md.key) { - result = md.value; - return true; - } + this.object.hitHighlights.some( + (md: Metadatum) => { + if (key === md.key) { + result = md.value; + return true; } - ); - } + } + ); if (hasNoValue(result)) { result = this.dso.findMetadata(key); }