1 |
61381
|
k.triantaf
|
import {Component, Input} from '@angular/core';
|
2 |
|
|
import {ClaimEntity} from '../../claim-utils/claimHelper.class';
|
3 |
|
|
|
4 |
|
|
@Component({
|
5 |
|
|
selector: 'claim-project-metadata',
|
6 |
|
|
template:
|
7 |
|
|
`
|
8 |
|
|
<div *ngIf="entity.type == 'project' && entity.project" class="uk-grid uk-margin-remove-top uk-text-small">
|
9 |
|
|
<div class="uk-width-1-2">
|
10 |
|
|
<div *ngIf="entity.project.funderName">
|
11 |
|
|
<span class="uk-text-muted">Funder </span>{{entity.project.funderName}}
|
12 |
|
|
</div>
|
13 |
|
|
</div>
|
14 |
|
|
<div class="uk-width-1-2">
|
15 |
|
|
<div *ngIf="entity.project.code">
|
16 |
|
|
<span class="uk-text-muted">GrandId </span>{{entity.project.code}}
|
17 |
|
|
</div>
|
18 |
|
|
<div *ngIf=" !shortVersion && (entity.project.startDate || entity.project.endDate)">
|
19 |
|
|
<span
|
20 |
|
|
class="uk-text-muted">Duration </span>{{(entity.project.startDate) ? entity.project.startDate : 'Unknown'}}{{'-' + ((entity.project.endDate) ? entity.project.endDate : 'Unknown')}}
|
21 |
|
|
</div>
|
22 |
|
|
</div>
|
23 |
|
|
</div>
|
24 |
|
|
`
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
})
|
28 |
|
|
export class ClaimEntityProjectMetadataComponent {
|
29 |
|
|
@Input() entity: ClaimEntity;
|
30 |
|
|
@Input() slice: boolean = false;
|
31 |
|
|
@Input() sliceSize: number = 45;
|
32 |
|
|
@Input() shortVersion: boolean = false;
|
33 |
|
|
|
34 |
|
|
ngOnInit() {
|
35 |
|
|
}
|
36 |
|
|
|
37 |
|
|
sliceArray(array): string {
|
38 |
|
|
if (this.slice) {
|
39 |
|
|
let sliced = array.slice(0, this.sliceSize);
|
40 |
|
|
return sliced.join("; ") + (array.length>this.sliceSize ? "...":"");
|
41 |
|
|
}
|
42 |
|
|
return array.join("; ");
|
43 |
|
|
}
|
44 |
|
|
|
45 |
|
|
addStringToNumber(str: string, num: number) {
|
46 |
|
|
return (+str) + num;
|
47 |
|
|
}
|
48 |
|
|
|
49 |
|
|
getProjectDurationMessage(result: ClaimEntity) {
|
50 |
|
|
if(!result.warningMessages){
|
51 |
|
|
return null;
|
52 |
|
|
}
|
53 |
|
|
for (let message of result.warningMessages) {
|
54 |
|
|
if (message.type == "projectDuration") {
|
55 |
|
|
return "Should be from " + message.projectInfo.startDate + ((message.projectInfo.endDate) ? (" to " + ((5 + +message.projectInfo.endDate))) : "");
|
56 |
|
|
}
|
57 |
|
|
}
|
58 |
|
|
return null;
|
59 |
|
|
}
|
60 |
|
|
|
61 |
|
|
// getEmbargoEndDateMessage(result: ClaimEntity) {
|
62 |
|
|
// for (var message of result.warningMessages) {
|
63 |
|
|
// if (message.type == "embargoEndDate") {
|
64 |
|
|
// return "Embargo end date must be later than published date";
|
65 |
|
|
// }
|
66 |
|
|
// }
|
67 |
|
|
// return null;
|
68 |
|
|
// }
|
69 |
|
|
|
70 |
|
|
}
|