import {Component, Input} from '@angular/core'; import {ClaimEntity} from '../../claim-utils/claimHelper.class'; import {StringUtils} from "../../../utils/string-utils.class"; @Component({ selector: 'claim-result-metadata', template: `
Authors {{sliceArray(entity.result.authors)}}
Editors {{sliceArray(entity.result.editors)}}
Publisher {{entity.result.publisher}} Journal {{entity.result.journal}}
Published in {{entity.result.date}}
{{getProjectDurationMessage(entity)}}
` }) export class ClaimEntityResultMetadataComponent { @Input() entity: ClaimEntity; @Input() slice: boolean = false; @Input() sliceSize: number = 45; @Input() shortVersion: boolean = false; ngOnInit() { } sliceArray(array): string { if (this.slice) { let sliced = array.slice(0, this.sliceSize); return sliced.join("; ") + (array.length>this.sliceSize ? "...":""); } return array.join("; "); } addStringToNumber(str: string, num: number) { return (+str) + num; } getProjectDurationMessage(result: ClaimEntity) { if(!result.warningMessages){ return null; } for (let message of result.warningMessages) { if (message.type == "projectDuration") { return "Should be from " + message.projectInfo.startDate + ((message.projectInfo.endDate) ? (" to " + ((5 + +message.projectInfo.endDate))) : ""); } } return null; } // getEmbargoEndDateMessage(result: ClaimEntity) { // for (var message of result.warningMessages) { // if (message.type == "embargoEndDate") { // return "Embargo end date must be later than published date"; // } // } // return null; // } }