91 lines
2.9 KiB
TypeScript
91 lines
2.9 KiB
TypeScript
import {Component, Input} from '@angular/core';
|
|
import {ClaimEntity} from '../../claim-utils/claimHelper.class';
|
|
import {StringUtils} from "../../../utils/string-utils.class";
|
|
|
|
@Component({
|
|
selector: 'claim-title',
|
|
template:
|
|
`
|
|
<span class="uk-text-bold">
|
|
<a *ngIf="entity.result && entity.result.url" target="_blank" [href]="entity.result.url"
|
|
class="uk-link">{{entity.title ? sliceString(entity.title) : '[No title available]'}}</a>
|
|
<span
|
|
*ngIf="(entity.result && !entity.result.url)">{{entity.title ? sliceString(entity.title) : '[No title available]'}}</span>
|
|
<span *ngIf="entity.type=='project' && entity.project">
|
|
<a *ngIf="entity.project && entity.project.url" target="_blank" [href]="entity.project.url"
|
|
class="uk-link">
|
|
<span *ngIf="!shortVersion">
|
|
{{(entity.project.acronym ? '[' + entity.project.acronym + '] ' : '') + entity.title}}
|
|
</span>
|
|
<span *ngIf="shortVersion">
|
|
{{(entity.project.acronym ? sliceString(entity.project.acronym):sliceString(entity.title))}}
|
|
</span>
|
|
</a>
|
|
<span
|
|
*ngIf="(entity.project && !entity.project.url)">
|
|
<span *ngIf="!shortVersion">
|
|
{{(entity.project.acronym ? '[' + entity.project.acronym + '] ' : '') + entity.title}}
|
|
</span>
|
|
<span *ngIf="shortVersion">
|
|
{{(entity.project.acronym ? sliceString(entity.project.acronym):sliceString(entity.title))}}
|
|
</span>
|
|
</span>
|
|
|
|
|
|
</span>
|
|
<span *ngIf="entity.type=='community' && entity.context">
|
|
<span *ngIf=" entity.context.community != entity.context.concept.label">
|
|
{{entity.context.community }} > {{entity.context.category}} >
|
|
</span>
|
|
<span> {{entity.context.concept.label}}</span>
|
|
</span>
|
|
</span>
|
|
`
|
|
|
|
|
|
})
|
|
export class ClaimEntityTitleComponent {
|
|
|
|
|
|
@Input() entity: ClaimEntity;
|
|
@Input() slice:boolean = false;
|
|
@Input() sliceSize:number = 45;
|
|
@Input() shortVersion: boolean = false;
|
|
|
|
ngOnInit() {
|
|
|
|
|
|
}
|
|
sliceString(mystr:string): string {
|
|
if(this.slice){
|
|
return StringUtils.sliceString(mystr,this.sliceSize);
|
|
}
|
|
return mystr;
|
|
}
|
|
|
|
|
|
addStringToNumber(str: string, num: number) {
|
|
return (+str) + num;
|
|
}
|
|
|
|
getProjectDurationMessage(result: ClaimEntity) {
|
|
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;
|
|
}
|
|
|
|
|
|
}
|