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";
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'sdg',
|
|
|
|
template: `
|
|
|
|
<div class="uk-margin-small-bottom uk-flex uk-flex-between">
|
|
|
|
<span *ngIf="viewAll && !lessBtn" class="clickable uk-h6 uk-flex uk-flex-middle" (click)="viewLessClick()">
|
|
|
|
<icon class="uk-margin-small-right" name="arrow_back" flex="true" ratio="1.2"></icon>
|
|
|
|
{{title}}
|
|
|
|
</span>
|
2022-04-16 09:47:30 +02:00
|
|
|
<span *ngIf="!viewAll || lessBtn" class="uk-text-light-grey">{{title}}</span>
|
2022-04-12 14:15:04 +02:00
|
|
|
<a *ngIf="viewAll && lessBtn" (click)="viewAll = !viewAll; lessBtn=false;">View less</a>
|
|
|
|
<a *ngIf="subjects && subjects.length > threshold && !viewAll"
|
|
|
|
(click)="viewAllClick();">View more</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="uk-margin-small-bottom uk-flex">
|
|
|
|
<img src="assets/common-assets/common/The_Global_Goals_Icon_Color.svg"
|
|
|
|
loading="lazy" alt="sdg_colors" style="width:27px; height:27px">
|
|
|
|
<div class="uk-margin-small-left">
|
|
|
|
<div *ngFor="let subject of subjects.slice(0, viewAll?subjects.length:threshold); let i=index" class="uk-text-truncate">
|
|
|
|
<a [routerLink]=" properties.searchLinkToAdvancedResults"
|
|
|
|
[queryParams]="routerHelper.createQueryParams(['f0', 'fv0', 'size'], ['sdg', subject, '50'])">
|
|
|
|
{{subject}}
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
`
|
|
|
|
})
|
|
|
|
|
|
|
|
export class SdgComponent {
|
|
|
|
@Input() subjects: string[];
|
|
|
|
@Input() viewAll: boolean = false;
|
|
|
|
@Output() viewAllClicked = new EventEmitter();
|
|
|
|
public lessBtn: boolean = false;
|
|
|
|
public threshold: number = 4;
|
|
|
|
public routerHelper: RouterHelper = new RouterHelper();
|
|
|
|
public properties = properties;
|
2022-05-30 14:36:33 +02:00
|
|
|
public title: string = "Sustainable Development Goals (SDG) [Beta]";
|
2022-04-12 14:15:04 +02:00
|
|
|
|
|
|
|
public viewAllClick() {
|
|
|
|
if(this.subjects.length <= this.threshold*2) {
|
|
|
|
this.viewAll = true;
|
|
|
|
this.lessBtn = true;
|
|
|
|
} else {
|
|
|
|
this.viewAll = true;
|
|
|
|
this.viewAllClicked.emit('sdg');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public viewLessClick() {
|
|
|
|
this.viewAll = false;
|
|
|
|
this.viewAllClicked.emit("");
|
|
|
|
}
|
|
|
|
}
|