Files
dspace-angular/src/app/shared/object-list/my-dspace-result-list-element/item-list-preview/item-list-preview.component.ts
2019-03-28 19:33:40 +01:00

60 lines
1.9 KiB
TypeScript

import { Component, Input } from '@angular/core';
import { Item } from '../../../../core/shared/item.model';
import { fadeInOut } from '../../../animations/fade';
import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type';
import { Metadata } from '../../../../core/shared/metadata.utils';
/**
* This component show metadata for the given item object in the list view.
*/
@Component({
selector: 'ds-item-list-preview',
styleUrls: ['item-list-preview.component.scss'],
templateUrl: 'item-list-preview.component.html',
animations: [fadeInOut]
})
export class ItemListPreviewComponent {
/**
* The item to display
*/
@Input() item: Item;
/**
* The mydspace result object
*/
@Input() object: any;
/**
* Represent item's status
*/
@Input() status: MyDspaceItemStatusType;
/**
* A boolean representing if to show submitter information
*/
@Input() showSubmitter = false;
/**
* Gets all matching metadata string values from hitHighlights or dso metadata, preferring hitHighlights.
*
* @param {string|string[]} keyOrKeys The metadata key(s) in scope. Wildcards are supported; see [[Metadata]].
* @returns {string[]} the matching string values or an empty array.
*/
allMetadataValues(keyOrKeys: string | string[]): string[] {
return Metadata.allValues([this.object.hitHighlights, this.item.metadata], keyOrKeys);
}
/**
* Gets the first matching metadata string value from hitHighlights or dso metadata, preferring hitHighlights.
*
* @param {string|string[]} keyOrKeys The metadata key(s) in scope. Wildcards are supported; see [[Metadata]].
* @returns {string} the first matching string value, or `undefined`.
*/
firstMetadataValue(keyOrKeys: string | string[]): string {
return Metadata.firstValue([this.object.hitHighlights, this.item.metadata], keyOrKeys);
}
}