add changes for sdg-selection component

This commit is contained in:
Alex Martzios 2023-03-09 16:29:25 +02:00
parent f6084fbcd4
commit efc2d6c47b
3 changed files with 23 additions and 8 deletions

View File

@ -73,7 +73,7 @@ export class CommunityService {
return this.http.post(url, community, options); 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; let communityInfo: CommunityInfo = this.community.value;
communityInfo.subjects = subjects; communityInfo.subjects = subjects;
communityInfo.fos = fos; communityInfo.fos = fos;
@ -109,7 +109,19 @@ export class CommunityService {
} }
if (resData.subjects != null) { if (resData.subjects != null) {
community.subjects = Array.isArray(resData.subjects)?resData.subjects:[resData.subjects]; 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) { if (resData.advancedConstraint != null) {
community.selectionCriteria = resData.advancedConstraint; community.selectionCriteria = resData.advancedConstraint;
} else { } else {

View File

@ -9,7 +9,7 @@
<label [class.uk-text-bolder]="subjects?.includes(item.id)"> <label [class.uk-text-bolder]="subjects?.includes(item.id)">
<input [(ngModel)]="item.checked" <input [(ngModel)]="item.checked"
type="checkbox" class="uk-checkbox uk-margin-small-right"> type="checkbox" class="uk-checkbox uk-margin-small-right">
<span class="uk-text-uppercase uk-margin-xsmall-right">Goal</span> <span *ngIf="isFeedback" class="uk-text-uppercase uk-margin-xsmall-right">Goal</span>
<span>{{item.id}}</span> <span>{{item.id}}</span>
</label> </label>
</div> </div>
@ -20,7 +20,7 @@
<label [class.uk-text-bolder]="subjects?.includes(item.id)"> <label [class.uk-text-bolder]="subjects?.includes(item.id)">
<input [(ngModel)]="item.checked" <input [(ngModel)]="item.checked"
type="checkbox" class="uk-checkbox uk-margin-small-right"> type="checkbox" class="uk-checkbox uk-margin-small-right">
<span *ngIf="i !== secondColumn.length - 1" <span *ngIf="i !== secondColumn.length - 1 && isFeedback"
class="uk-text-uppercase uk-margin-xsmall-right">Goal</span> class="uk-text-uppercase uk-margin-xsmall-right">Goal</span>
<span>{{item.id}}</span> <span>{{item.id}}</span>
</label> </label>

View File

@ -13,6 +13,7 @@ export class SdgSelectionComponent {
public properties: EnvProperties = properties; public properties: EnvProperties = properties;
@Input() subjects: string[]; @Input() subjects: string[];
@Input() entityType: string; @Input() entityType: string;
@Input() isFeedback: boolean = true;
public loading: boolean; public loading: boolean;
public sdgs: any = []; public sdgs: any = [];
@ -27,17 +28,19 @@ export class SdgSelectionComponent {
data['sdg'].forEach(element => { 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: 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}); if(this.isFeedback) {
this.loading = false; 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() { 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() { 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() { public getSelectedSubjects() {