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";
|
2022-04-12 14:15:04 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'sdg',
|
|
|
|
template: `
|
2022-06-09 15:45:39 +02:00
|
|
|
<div class="uk-text-xsmall" style="color: #EEB204">Beta</div>
|
|
|
|
<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()">
|
2022-04-12 14:15:04 +02:00
|
|
|
<icon class="uk-margin-small-right" name="arrow_back" flex="true" ratio="1.2"></icon>
|
2022-06-09 15:45:39 +02:00
|
|
|
<span uk-tooltip="Sustainable Development Goals">{{title}}</span>
|
2022-04-12 14:15:04 +02:00
|
|
|
</span>
|
2022-06-09 15:45:39 +02:00
|
|
|
<span *ngIf="!viewAll" class="uk-text-light-grey uk-text-nowrap uk-margin-small-right" uk-tooltip="Sustainable Development Goals">{{title}}</span>
|
|
|
|
<!-- <a *ngIf="viewAll && lessBtn" (click)="viewAll = !viewAll; lessBtn=false;">View less</a>-->
|
2022-04-12 14:15:04 +02:00
|
|
|
<a *ngIf="subjects && subjects.length > threshold && !viewAll"
|
2022-06-09 15:45:39 +02:00
|
|
|
(click)="viewAllClick();" class="view-more-less-link uk-text-truncate" uk-tooltip="View all & feedback">
|
|
|
|
View all & feedback</a>
|
|
|
|
<a *ngIf="(subjects && subjects.length <= threshold || viewAll)" class="uk-link uk-text-truncate"
|
|
|
|
(click)="feedbackClick();">Feedback</a>
|
2022-04-12 14:15:04 +02:00
|
|
|
</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">
|
2022-06-09 15:45:39 +02:00
|
|
|
<a [routerLink]=" properties.searchLinkToResults"
|
|
|
|
[queryParams]="{'sdg': urlEncodeAndQuote(subject)}">
|
2022-04-12 14:15:04 +02:00
|
|
|
{{subject}}
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
`
|
|
|
|
})
|
|
|
|
|
|
|
|
export class SdgComponent {
|
|
|
|
@Input() subjects: string[];
|
|
|
|
@Input() viewAll: boolean = false;
|
|
|
|
@Output() viewAllClicked = new EventEmitter();
|
2022-06-09 15:45:39 +02:00
|
|
|
@Output() feedbackClicked = new EventEmitter();
|
2022-04-12 14:15:04 +02:00
|
|
|
public lessBtn: boolean = false;
|
|
|
|
public threshold: number = 4;
|
|
|
|
public routerHelper: RouterHelper = new RouterHelper();
|
|
|
|
public properties = properties;
|
2022-06-09 15:45:39 +02:00
|
|
|
public title: string = "SDGs";
|
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 {
|
2022-04-12 14:15:04 +02:00
|
|
|
this.viewAll = true;
|
|
|
|
this.viewAllClicked.emit('sdg');
|
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
|
|
|
|
|
|
|
public feedbackClick() {
|
|
|
|
this.feedbackClicked.emit("");
|
|
|
|
}
|
|
|
|
|
|
|
|
public urlEncodeAndQuote(str: string): string {
|
|
|
|
return StringUtils.quote(StringUtils.URIEncode(str));
|
|
|
|
}
|
2022-04-12 14:15:04 +02:00
|
|
|
}
|