2019-07-23 14:23:12 +02:00
|
|
|
import {Component, Input} from '@angular/core';
|
|
|
|
import {ClaimEntity} from '../../claim-utils/claimHelper.class';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'claim-result-metadata',
|
2022-05-19 12:12:59 +02:00
|
|
|
template: `
|
2023-07-04 09:16:08 +02:00
|
|
|
<div *ngIf="entity.result">
|
|
|
|
<!-- display all existing data similar to entity-metadata -->
|
|
|
|
<div *ngIf="!shortVersion" class="claim-entity-metadata uk-flex-inline uk-flex-wrap uk-text-xsmall uk-text-emphasis uk-margin-xsmall-top">
|
|
|
|
<span class="uk-text-capitalize uk-text-italic">
|
|
|
|
{{(!entity.result) ? entity.type : ((entity.result && entity.result.source == 'openaire') ? entity.type : (entity.result && entity.result.source + ' result'))}}
|
|
|
|
</span>
|
|
|
|
<span *ngIf="entity.result.publisher!=null">
|
|
|
|
{{entity.result.publisher}}
|
2022-05-19 12:12:59 +02:00
|
|
|
</span>
|
2023-07-04 09:16:08 +02:00
|
|
|
<span *ngIf="entity.result.date">
|
2022-05-19 12:12:59 +02:00
|
|
|
<span [class]="(getProjectDurationMessage(entity)?'uk-text-warning':'')">{{entity.result.date}}</span>
|
|
|
|
</span>
|
2023-07-04 09:16:08 +02:00
|
|
|
<span *ngIf="entity.result.journal!=null">
|
|
|
|
{{entity.result.journal}}
|
|
|
|
</span>
|
|
|
|
<div *ngIf="entity.result.editors && entity.result.editors.length > 0">
|
|
|
|
{{sliceArray(entity.result.editors)}}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div *ngIf="entity.result.authors && entity.result.authors.length > 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)}}
|
|
|
|
</div>
|
|
|
|
<div class="uk-text-small uk-margin-top">
|
|
|
|
<span *ngIf="getProjectDurationMessage(entity)" [class]="(getProjectDurationMessage(entity)?'uk-text-warning':'')">
|
|
|
|
{{getProjectDurationMessage(entity)}}
|
|
|
|
</span>
|
2019-07-23 14:23:12 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-07-04 09:16:08 +02:00
|
|
|
`,
|
|
|
|
styleUrls: ['ClaimEntityMetadata.component.less']
|
2019-07-23 14:23:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|