import {Component, Input} from '@angular/core';
import {ClaimEntity} from '../../claim-utils/claimHelper.class';
@Component({
selector: 'claim-result-metadata',
template: `
{{(!entity.result) ? entity.type : ((entity.result && entity.result.source == 'openaire') ? entity.type : (entity.result && entity.result.source + ' result'))}}
{{entity.result.publisher}}
{{entity.result.date}}
{{entity.result.journal}}
0">
{{sliceArray(entity.result.editors)}}
0" class="uk-flex uk-flex-wrap uk-text-small uk-text-emphasis uk-text-italic"
[class.uk-margin-small-top]="!shortVersion">
{{sliceArray(entity.result.authors)}}
{{getProjectDurationMessage(entity)}}
`,
styleUrls: ['ClaimEntityMetadata.component.less']
})
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("; ");
}
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;
}
}