2022-04-12 14:15:04 +02:00
|
|
|
import {Component, EventEmitter, Input, Output} from "@angular/core";
|
|
|
|
import {RouterHelper} from "../../utils/routerHelper.class";
|
|
|
|
import {properties} from "../../../../environments/environment";
|
2022-06-09 15:45:39 +02:00
|
|
|
import {StringUtils} from "../../utils/string-utils.class";
|
2024-01-08 14:36:27 +01:00
|
|
|
import {SearchFields} from "../../utils/properties/searchFields";
|
2022-04-12 14:15:04 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'fos',
|
|
|
|
template: `
|
2023-01-24 14:32:58 +01:00
|
|
|
<div class="uk-visible@m">
|
2024-01-08 13:04:18 +01:00
|
|
|
<!-- <div class="uk-text-xsmall" style="color: #EEB204">Beta</div>-->
|
2023-01-24 14:32:58 +01:00
|
|
|
<div [class]="'uk-flex uk-flex-between uk-flex-middle uk-margin-'+(viewAll?'':'small-')+'bottom'">
|
|
|
|
<span *ngIf="viewAll" class="clickable uk-h6 uk-flex uk-flex-middle uk-margin-small-right uk-margin-remove-bottom" (click)="viewLessClick()">
|
2023-02-16 11:59:18 +01:00
|
|
|
<icon class="uk-margin-small-right" name="arrow_back" [flex]="true" [ratio]="1.2"></icon>
|
2023-01-24 14:32:58 +01:00
|
|
|
<span class="uk-text-nowrap">{{title}}</span>
|
|
|
|
</span>
|
2023-02-20 15:34:12 +01:00
|
|
|
<span *ngIf="!viewAll" class="uk-text-emphasis uk-text-bolder uk-text-nowrap uk-margin-small-right">
|
|
|
|
{{title}}
|
|
|
|
<span *ngIf="subjects && subjects.length > threshold && !viewAll">({{subjects.length}})</span>
|
|
|
|
</span>
|
2023-04-06 11:06:12 +02:00
|
|
|
<a *ngIf="properties.adminToolsPortalType == 'eosc' && subjects && subjects.length > threshold && !viewAll"
|
|
|
|
(click)="viewAllClick();" class="view-more-less-link uk-link uk-link-text uk-text-truncate">
|
|
|
|
View all
|
2023-03-09 09:54:03 +01:00
|
|
|
</a>
|
2024-08-01 13:06:12 +02:00
|
|
|
<!-- hide L3 & L4 FoS-->
|
|
|
|
<!-- <a *ngIf="viewAll && lessBtn" (click)="viewAll = !viewAll; lessBtn=false;">View less</a> -->
|
2023-04-06 11:06:12 +02:00
|
|
|
<a *ngIf="properties.adminToolsPortalType != 'eosc' && subjects && subjects.length > threshold && !viewAll"
|
2023-02-20 15:34:12 +01:00
|
|
|
(click)="viewAllClick();" class="view-more-less-link uk-link uk-link-text uk-text-truncate">
|
2024-08-01 13:06:12 +02:00
|
|
|
View all<ng-container *ngIf="properties.environment == 'development'"> & suggest</ng-container>
|
2023-01-24 14:32:58 +01:00
|
|
|
</a>
|
2024-08-01 13:06:12 +02:00
|
|
|
<a *ngIf="properties.environment == 'development' && properties.adminToolsPortalType != 'eosc' && (subjects && subjects.length <= threshold || viewAll)" class="uk-link uk-link-text uk-text-truncate"
|
2023-02-20 15:34:12 +01:00
|
|
|
(click)="suggestClick();">Suggest</a>
|
2023-01-24 14:32:58 +01:00
|
|
|
</div>
|
|
|
|
<div class="uk-margin-small-top">
|
|
|
|
<div *ngFor="let subject of subjects.slice(0, viewAll?subjects.length:threshold); let i=index" class="uk-text-truncate">
|
2023-09-04 13:38:51 +02:00
|
|
|
<a *ngIf="properties.adminToolsPortalType != 'eosc'"
|
|
|
|
[routerLink]="properties.searchLinkToResults" [queryParams]="buildFosQueryParam(subject)">
|
2023-04-25 12:02:33 +02:00
|
|
|
{{subject.label}}
|
2023-01-24 14:32:58 +01:00
|
|
|
</a>
|
2023-09-04 13:38:51 +02:00
|
|
|
<a *ngIf="properties.adminToolsPortalType == 'eosc'" class="custom-external" target="_blank"
|
|
|
|
[href]="'https://explore.openaire.eu'+properties.searchLinkToResults+'?fos='+urlEncodeAndQuote(subject.label)">
|
|
|
|
{{subject.label}}
|
|
|
|
</a>
|
2023-01-24 14:32:58 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="uk-hidden@m">
|
2023-07-20 10:50:10 +02:00
|
|
|
<div *ngIf="!viewAll" class="uk-grid uk-grid-small uk-grid-divider" uk-grid>
|
2023-01-24 14:32:58 +01:00
|
|
|
<div class="uk-width-1-4 uk-text-meta">
|
2024-01-08 13:04:18 +01:00
|
|
|
<!-- <div class="uk-text-xsmall" style="color: #EEB204">Beta</div>-->
|
2023-02-21 15:10:21 +01:00
|
|
|
{{title}}
|
2023-01-24 14:32:58 +01:00
|
|
|
</div>
|
|
|
|
<div class="uk-width-expand">
|
|
|
|
<div *ngFor="let subject of subjects.slice(0, viewAll?subjects.length:threshold); let i=index" class="uk-text-truncate">
|
2023-04-06 11:06:12 +02:00
|
|
|
<a *ngIf="properties.adminToolsPortalType != 'eosc'"
|
2023-08-24 17:31:04 +02:00
|
|
|
[routerLink]="properties.searchLinkToResults" [queryParams]="buildFosQueryParam(subject)">
|
2023-04-25 12:02:33 +02:00
|
|
|
{{subject.label}}
|
2023-01-24 14:32:58 +01:00
|
|
|
</a>
|
2023-04-06 11:06:12 +02:00
|
|
|
<a *ngIf="properties.adminToolsPortalType == 'eosc'" class="custom-external" target="_blank"
|
2023-08-24 17:31:04 +02:00
|
|
|
[href]="'https://explore.openaire.eu'+properties.searchLinkToResults+'?'+buildFosHrefParam(subject)">
|
2023-04-25 12:02:33 +02:00
|
|
|
{{subject.label}}
|
2023-04-06 11:06:12 +02:00
|
|
|
</a>
|
2023-01-24 14:32:58 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-07-20 10:50:10 +02:00
|
|
|
<div *ngIf="viewAll">
|
|
|
|
<div *ngFor="let subject of subjects; let i=index" class="uk-text-truncate">
|
|
|
|
<a *ngIf="properties.adminToolsPortalType != 'eosc'"
|
2023-08-24 17:31:04 +02:00
|
|
|
[routerLink]="properties.searchLinkToResults" [queryParams]="buildFosQueryParam(subject)">
|
2023-07-20 10:50:10 +02:00
|
|
|
{{subject.label}}
|
|
|
|
</a>
|
|
|
|
<a *ngIf="properties.adminToolsPortalType == 'eosc'" class="custom-external" target="_blank"
|
2023-08-24 17:31:04 +02:00
|
|
|
[href]="'https://explore.openaire.eu'+properties.searchLinkToResults+'?'+buildFosHrefParam(subject)">
|
2023-07-20 10:50:10 +02:00
|
|
|
{{subject.label}}
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-02-20 16:56:02 +01:00
|
|
|
<div class="uk-text-right uk-margin-small-top">
|
|
|
|
<a *ngIf="subjects && subjects.length > threshold && !viewAll"
|
|
|
|
(click)="viewAllClick();" class="view-more-less-link uk-text-truncate">
|
|
|
|
<span class="">View all</span>
|
|
|
|
<!-- <span class="">View all & suggest</span>-->
|
|
|
|
</a>
|
|
|
|
<!-- <a *ngIf="(subjects && subjects.length <= threshold || viewAll)" class="uk-link uk-text-truncate"-->
|
|
|
|
<!-- (click)="feedbackClick();">Feedback</a>-->
|
|
|
|
</div>
|
2023-01-24 14:32:58 +01:00
|
|
|
</div>
|
2022-04-12 14:15:04 +02:00
|
|
|
`
|
|
|
|
})
|
|
|
|
|
|
|
|
export class FosComponent {
|
2023-04-25 12:02:33 +02:00
|
|
|
@Input() subjects: {"id": string, "label": string}[];
|
2022-04-12 14:15:04 +02:00
|
|
|
@Input() viewAll: boolean = false;
|
|
|
|
@Output() viewAllClicked = new EventEmitter();
|
2023-02-20 15:34:12 +01:00
|
|
|
@Output() suggestClicked = new EventEmitter();
|
2022-04-12 14:15:04 +02:00
|
|
|
public lessBtn: boolean = false;
|
2023-02-20 16:56:02 +01:00
|
|
|
public threshold: number = 2;
|
2022-04-12 14:15:04 +02:00
|
|
|
public routerHelper: RouterHelper = new RouterHelper();
|
|
|
|
public properties = properties;
|
2022-06-09 15:45:39 +02:00
|
|
|
public title: string = "Fields of Science";
|
2024-01-08 14:36:27 +01:00
|
|
|
private searchFieldsHelper: SearchFields = new SearchFields();
|
2022-04-12 14:15:04 +02:00
|
|
|
|
|
|
|
public viewAllClick() {
|
2022-06-09 15:45:39 +02:00
|
|
|
// if(this.subjects.length <= this.threshold*2) {
|
|
|
|
// this.viewAll = true;
|
|
|
|
// this.lessBtn = true;
|
|
|
|
// } else {
|
2023-02-20 15:34:12 +01:00
|
|
|
this.viewAll = true;
|
2022-04-12 14:15:04 +02:00
|
|
|
this.viewAllClicked.emit('fos');
|
2022-06-09 15:45:39 +02:00
|
|
|
// }
|
2022-04-12 14:15:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public viewLessClick() {
|
|
|
|
this.viewAll = false;
|
|
|
|
this.viewAllClicked.emit("");
|
|
|
|
}
|
2022-06-09 15:45:39 +02:00
|
|
|
|
2023-02-20 15:34:12 +01:00
|
|
|
public suggestClick() {
|
|
|
|
this.suggestClicked.emit('fos');
|
2022-06-09 15:45:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public urlEncodeAndQuote(str: string): string {
|
|
|
|
return StringUtils.quote(StringUtils.URIEncode(str));
|
|
|
|
}
|
2023-08-24 17:31:04 +02:00
|
|
|
|
|
|
|
public buildFosQueryParam(fos) {
|
2023-10-02 12:13:22 +02:00
|
|
|
// return {'foslabel': this.urlEncodeAndQuote(fos.id+"||"+fos.label)};
|
2024-01-08 14:36:27 +01:00
|
|
|
return (this.searchFieldsHelper.getFosParameter() == 'foslabel' ? ({'foslabel': this.urlEncodeAndQuote(fos.id+"||"+fos.label)}) : ({'fos': this.urlEncodeAndQuote(fos.id)}));
|
2023-08-24 17:31:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public buildFosHrefParam(fos): string {
|
2023-10-02 12:13:22 +02:00
|
|
|
// return ('foslabel='+this.urlEncodeAndQuote(fos.id+"||"+fos.label));
|
2024-01-08 14:36:27 +01:00
|
|
|
return (this.searchFieldsHelper.getFosParameter() == 'foslabel' ? ('foslabel='+this.urlEncodeAndQuote(fos.id+"||"+fos.label)) : ('fos='+this.urlEncodeAndQuote(fos.id)));
|
2023-08-24 17:31:04 +02:00
|
|
|
}
|
2022-07-17 15:01:39 +02:00
|
|
|
}
|