import {HttpClient} from "@angular/common/http"; import {Component, Input} from "@angular/core"; import {properties} from "../../../../environments/environment"; import {EnvProperties} from "../../utils/properties/env-properties"; @Component({ selector: 'sdg-selection', templateUrl: 'sdg-selection.component.html', styleUrls: ['sdg-selection.component.less'] }) export class SdgSelectionComponent { public properties: EnvProperties = properties; @Input() subjects: string[]; public loading: boolean; public sdgs: any = []; constructor( private httpClient: HttpClient ) {} ngOnInit() { this.loading = true; this.httpClient.get(this.properties.domain+'/assets/common-assets/vocabulary/sdg.json').subscribe(data => { data['sdg'].forEach(element => { this.sdgs.push({code: element.code, id: element.id, label: element.label, html: element.html, checked: this.subjects.includes(element.id)}); }); this.sdgs.push({code: '18', id: 'No SDGs are relevant for this publication', label: 'Not relevant', html: 'Not relevant', checked: false}); }); this.loading = false; } public get firstColumn() { return this.sdgs.slice(0, this.sdgs.length/2); } public get secondColumn() { return this.sdgs.slice(this.sdgs.length/2, this.sdgs.length); } }