Skip to content

Commit 4a608b1

Browse files
oscar-esciregithub-actions[bot]
authored andcommitted
Fix: author search result without co-author
(cherry picked from commit f055ff6)
1 parent 3ab9f6a commit 4a608b1

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<span *ngIf="dso.firstMetadataValue('dc.date.issued')" class="item-list-date" [innerHTML]="firstMetadataValue('dc.date.issued')"></span>)
3030
</ng-container>
3131
<span *ngIf="dso.allMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*']).length > 0" class="item-list-authors">
32-
<span *ngFor="let author of allMetadataValues(['dc.contributor.author', 'dc.creator', 'dc.contributor.*']); let last=last;">
32+
<span *ngFor="let author of allMetadataNoExcludingValues(['dc.contributor.author', 'dc.creator', 'dc.contributor.*']); let last=last;">
3333
<span [innerHTML]="author"><span [innerHTML]="author"></span></span>
3434
<span *ngIf="!last">; </span>
3535
</span>

src/app/shared/object-list/search-result-list-element/search-result-list-element.component.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,28 @@ export class SearchResultListElementComponent<T extends SearchResult<K>, K exten
5555
return Metadata.allValues([this.object.hitHighlights, this.dso.metadata], keyOrKeys);
5656
}
5757

58+
/**
59+
* Gets all matching metadata string values from hitHighlights or dso metadata.
60+
*
61+
* @param {string|string[]} keyOrKeys The metadata key(s) in scope. Wildcards are supported; see [[Metadata]].
62+
* @returns {string[]} the matching string values or an empty array.
63+
*/
64+
allMetadataNoExcludingValues(keyOrKeys: string | string[]): string[] {
65+
let dsoMetadata: string[] = Metadata.allValues([this.dso.metadata], keyOrKeys);
66+
let highlights: string[] = Metadata.allValues([this.object.hitHighlights], keyOrKeys);
67+
let removedHighlights: string[] = highlights.map(str => str.replace(/<\/?em>/g, ''));
68+
for (let i = 0; i < removedHighlights.length; i++) {
69+
let index = dsoMetadata.indexOf(removedHighlights[i]);
70+
if (index !== -1) {
71+
dsoMetadata[index] = highlights[i];
72+
}
73+
}
74+
console.log(dsoMetadata);
75+
console.log(highlights);
76+
console.log(removedHighlights);
77+
return dsoMetadata;
78+
}
79+
5880
/**
5981
* Gets the first matching metadata string value from hitHighlights or dso metadata, preferring hitHighlights.
6082
*

0 commit comments

Comments
 (0)