mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
fixed an issue where a search result without hitlighlights would break the grid view
This commit is contained in:
@@ -26,7 +26,7 @@ export class SearchResponseParsingService implements ResponseParsingService {
|
||||
value: hhObject[key].join('...')
|
||||
}))
|
||||
} else {
|
||||
return undefined;
|
||||
return [];
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -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<T extends SearchResult<K>, K exten
|
||||
|
||||
getValues(keys: string[]): string[] {
|
||||
const results: string[] = new Array<string>();
|
||||
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<T extends SearchResult<K>, 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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user