fixed an issue where a search result without hitlighlights would break the grid view

This commit is contained in:
Art Lowel
2018-04-20 16:01:59 +02:00
parent 2317f1f3a3
commit 545145a759
2 changed files with 16 additions and 20 deletions

View File

@@ -26,7 +26,7 @@ export class SearchResponseParsingService implements ResponseParsingService {
value: hhObject[key].join('...') value: hhObject[key].join('...')
})) }))
} else { } else {
return undefined; return [];
} }
}); });

View File

@@ -1,12 +1,12 @@
import { Component, Inject } from '@angular/core'; import { Component, Inject } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { SearchResult } from '../../../+search-page/search-result.model'; import { SearchResult } from '../../../+search-page/search-result.model';
import { DSpaceObject } from '../../../core/shared/dspace-object.model'; import { DSpaceObject } from '../../../core/shared/dspace-object.model';
import { Metadatum } from '../../../core/shared/metadatum.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 { ListableObject } from '../../object-collection/shared/listable-object.model';
import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component'; import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component';
import { Observable } from 'rxjs/Observable';
import { TruncatableService } from '../../truncatable/truncatable.service'; import { TruncatableService } from '../../truncatable/truncatable.service';
@Component({ @Component({
@@ -24,7 +24,6 @@ export class SearchResultListElementComponent<T extends SearchResult<K>, K exten
getValues(keys: string[]): string[] { getValues(keys: string[]): string[] {
const results: string[] = new Array<string>(); const results: string[] = new Array<string>();
if (isNotEmpty(this.object.hitHighlights)) {
this.object.hitHighlights.forEach( this.object.hitHighlights.forEach(
(md: Metadatum) => { (md: Metadatum) => {
if (keys.indexOf(md.key) > -1) { if (keys.indexOf(md.key) > -1) {
@@ -32,7 +31,6 @@ export class SearchResultListElementComponent<T extends SearchResult<K>, K exten
} }
} }
); );
}
if (isEmpty(results)) { if (isEmpty(results)) {
this.dso.filterMetadata(keys).forEach( this.dso.filterMetadata(keys).forEach(
(md: Metadatum) => { (md: Metadatum) => {
@@ -45,7 +43,6 @@ export class SearchResultListElementComponent<T extends SearchResult<K>, K exten
getFirstValue(key: string): string { getFirstValue(key: string): string {
let result: string; let result: string;
if (isNotEmpty(this.object.hitHighlights)) {
this.object.hitHighlights.some( this.object.hitHighlights.some(
(md: Metadatum) => { (md: Metadatum) => {
if (key === md.key) { if (key === md.key) {
@@ -54,7 +51,6 @@ export class SearchResultListElementComponent<T extends SearchResult<K>, K exten
} }
} }
); );
}
if (hasNoValue(result)) { if (hasNoValue(result)) {
result = this.dso.findMetadata(key); result = this.dso.findMetadata(key);
} }