71 lines
2.2 KiB
TypeScript
71 lines
2.2 KiB
TypeScript
import {Component, Input} from '@angular/core';
|
|
import {ClaimEntity} from '../../claim-utils/claimHelper.class';
|
|
|
|
@Component({
|
|
selector: 'claim-project-metadata',
|
|
template:
|
|
`
|
|
<div *ngIf="entity.type == 'project' && entity.project" class="uk-grid uk-margin-remove-top uk-text-small">
|
|
<div class="uk-width-1-2">
|
|
<div *ngIf="entity.project.funderName">
|
|
<span class="uk-text-muted">Funder </span>{{entity.project.funderName}}
|
|
</div>
|
|
</div>
|
|
<div class="uk-width-1-2">
|
|
<div *ngIf="entity.project.code">
|
|
<span class="uk-text-muted">GrandId </span>{{entity.project.code}}
|
|
</div>
|
|
<div *ngIf=" !shortVersion && (entity.project.startDate || entity.project.endDate)">
|
|
<span
|
|
class="uk-text-muted">Duration </span>{{(entity.project.startDate) ? entity.project.startDate : 'Unknown'}}{{'-' + ((entity.project.endDate) ? entity.project.endDate : 'Unknown')}}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`
|
|
|
|
|
|
})
|
|
export class ClaimEntityProjectMetadataComponent {
|
|
@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;
|
|
// }
|
|
|
|
}
|