openaire-library/claims/claim-utils/entityFormatter/claimEntityFormatter.compon...

60 lines
2.4 KiB
TypeScript
Raw Normal View History

import {Component, Input} from '@angular/core';
import {EnvProperties} from '../../../utils/properties/env-properties';
import {ClaimDBContext, ClaimDBOrganization, ClaimDBProject, ClaimDBResult} from "../claimHelper.class";
2022-07-05 15:41:11 +02:00
import {OpenaireEntities} from "../../../utils/properties/searchFields";
import {StringUtils} from "../../../utils/string-utils.class";
//Usage Example "<claim-entity [entity]="" [type]="" > </claim-entity>"
//externalUrl
@Component({
selector: 'claim-entity',
template: `
<div *ngIf="type == 'publication' || type == 'dataset' || type == 'software' || type == 'other'"
2022-07-05 15:41:11 +02:00
[attr.uk-tooptip]="getEntityName(type)">
<div *ngIf="source" class="uk-text-small">
{{getEntityName(type)}}
</div>
<div>
<span *ngIf="!source" class="uk-text-meta uk-text-small uk-margin-small-right uk-text-nowrap">Link to:</span>
2022-07-05 15:41:11 +02:00
<publication-title [entity]="entity" param="id"
path="/search/result" [externalPortalUrl]=externalPortalUrl [linkAvailable]="linkAvailable"></publication-title>
2022-07-05 15:41:11 +02:00
</div>
</div>
<div *ngIf="type == 'project'" [attr.uk-tooptip]="getEntityName(type)">
<span class="uk-text-meta uk-text-small uk-margin-small-right uk-text-nowrap">Link to:</span>
<project-title [project]="entity" [searchLink]=properties.searchLinkToProject
[externalPortalUrl]=externalPortalUrl></project-title>
</div>
<div *ngIf="type == 'organization'" [attr.uk-tooptip]="getEntityName(type)">
<span class="uk-text-meta uk-text-small uk-margin-small-right uk-text-nowrap">Link to:</span>
<organization-title [organization]="entity"></organization-title>
</div>
<div *ngIf="type == 'context'">
<span class="uk-text-meta uk-text-small uk-margin-small-right uk-text-nowrap">Link to:</span>
<h6 class="uk-h6 uk-margin-remove">
<span class="uk-text-truncate" uk-tooltip="Concept">{{entity.title}}</span>
</h6>
</div>
`
})
export class ClaimEntityFormatter {
@Input() entity: ClaimDBResult | ClaimDBContext | ClaimDBProject | ClaimDBOrganization;
@Input() type: string;
@Input() properties: EnvProperties;
@Input() externalPortalUrl: string = null;
@Input() source: boolean = true;
@Input() linkAvailable: boolean = true;
2022-07-05 15:41:11 +02:00
public openAIREEntities = OpenaireEntities;
constructor() {
}
2022-07-05 15:41:11 +02:00
public getEntityName(entityType:string) {
return StringUtils.getEntityName(entityType);
}
2022-07-05 15:41:11 +02:00
}