diff --git a/connect/community/community.service.ts b/connect/community/community.service.ts index 18b85982..acc3b749 100644 --- a/connect/community/community.service.ts +++ b/connect/community/community.service.ts @@ -73,7 +73,7 @@ export class CommunityService { return this.http.post(url, community, options); } - public updateSubjects(subjects: string[], fos: string[], sgd: string[]) { + public updateSubjects(subjects: string[], fos: string[], sdg: string[]) { let communityInfo: CommunityInfo = this.community.value; communityInfo.subjects = subjects; communityInfo.fos = fos; @@ -109,7 +109,19 @@ export class CommunityService { } if (resData.subjects != null) { community.subjects = Array.isArray(resData.subjects)?resData.subjects:[resData.subjects]; - } + } else { + community.subjects = []; + } + if (resData.sdg != null) { + community.sdg = Array.isArray(resData.sdg)?resData.sdg:[resData.sdg]; + } else { + community.sdg = []; + } + if (resData.fos != null) { + community.fos = Array.isArray(resData.fos)?resData.fos:[resData.fos]; + } else { + community.fos = []; + } if (resData.advancedConstraint != null) { community.selectionCriteria = resData.advancedConstraint; } else { diff --git a/sdg/sdg-selection/sdg-selection.component.html b/sdg/sdg-selection/sdg-selection.component.html index 6ebd36f4..f16c6f6c 100644 --- a/sdg/sdg-selection/sdg-selection.component.html +++ b/sdg/sdg-selection/sdg-selection.component.html @@ -9,7 +9,7 @@ @@ -20,7 +20,7 @@ diff --git a/sdg/sdg-selection/sdg-selection.component.ts b/sdg/sdg-selection/sdg-selection.component.ts index 1a9101a2..b82b23e8 100644 --- a/sdg/sdg-selection/sdg-selection.component.ts +++ b/sdg/sdg-selection/sdg-selection.component.ts @@ -13,6 +13,7 @@ export class SdgSelectionComponent { public properties: EnvProperties = properties; @Input() subjects: string[]; @Input() entityType: string; + @Input() isFeedback: boolean = true; public loading: boolean; public sdgs: any = []; @@ -27,17 +28,19 @@ export class SdgSelectionComponent { 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 ' + this.getEntityName(this.entityType), label: 'Not relevant', html: 'Not relevant', checked: false}); - this.loading = false; + if(this.isFeedback) { + this.sdgs.push({code: '18', id: 'No SDGs are relevant for this ' + this.getEntityName(this.entityType), label: 'Not relevant', html: 'Not relevant', checked: false}); + } + this.loading = false; }); } public get firstColumn() { - return this.sdgs.slice(0, this.sdgs.length/2); + return this.sdgs.slice(0, Math.ceil(this.sdgs.length/2)); } public get secondColumn() { - return this.sdgs.slice(this.sdgs.length/2, this.sdgs.length); + return this.sdgs.slice(Math.ceil(this.sdgs.length/2), this.sdgs.length); } public getSelectedSubjects() {