From 978d9f02699ecb0ad4d15b4346de0185b4726125 Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Thu, 9 Mar 2023 16:07:39 +0200 Subject: [PATCH 1/2] Add updateSubjects and advanced criteria in community service. Add margin-top in actions of users and subscribers. --- connect/community/community.service.ts | 75 ++++++++----------- connect/community/communityInfo.ts | 4 + .../role-users/role-users.component.html | 2 +- .../users/role-users/role-users.component.ts | 1 - .../subscribers/subscribers.component.html | 2 +- 5 files changed, 39 insertions(+), 45 deletions(-) diff --git a/connect/community/community.service.ts b/connect/community/community.service.ts index 7bbc5fd5..18b85982 100644 --- a/connect/community/community.service.ts +++ b/connect/community/community.service.ts @@ -5,6 +5,7 @@ import {map} from "rxjs/operators"; import {BehaviorSubject, from, Observable, Subscriber} from "rxjs"; import {properties} from "../../../../environments/environment"; import {StringUtils} from "../../utils/string-utils.class"; +import {SelectionCriteria} from "../../utils/entities/contentProvider"; @Injectable({providedIn: 'root'}) export class CommunityService { @@ -72,57 +73,47 @@ export class CommunityService { return this.http.post(url, community, options); } + public updateSubjects(subjects: string[], fos: string[], sgd: string[]) { + let communityInfo: CommunityInfo = this.community.value; + communityInfo.subjects = subjects; + communityInfo.fos = fos; + communityInfo.sdg = sdg; + this.community.next(communityInfo); + } + + public updateAdvancedCriteria(selectionCriteria: SelectionCriteria) { + let communityInfo: CommunityInfo = this.community.value; + communityInfo.selectionCriteria = selectionCriteria; + this.community.next(communityInfo); + } + public parseCommunity(data: any): CommunityInfo { - const resData = Array.isArray(data) ? data[0] : data; - const community: CommunityInfo = new CommunityInfo(); - community['title'] = resData.name; - community['shortTitle'] = resData.shortName; - community['communityId'] = resData.id; - community['queryId'] = resData.queryId; - community['logoUrl'] = resData.logoUrl; - community['description'] = resData.description; - community['date'] = resData.creationDate; - community['zenodoCommunity'] = resData.zenodoCommunity; - community['status'] = 'all'; + community.title = resData.name; + community.shortTitle = resData.shortName; + community.communityId = resData.id; + community.queryId = resData.queryId; + community.logoUrl = resData.logoUrl; + community.description = resData.description; + community.date = resData.creationDate; + community.zenodoCommunity = resData.zenodoCommunity; + community.status = 'all'; + community.type = resData.type; if (resData.hasOwnProperty('status')) { - community['status'] = resData.status; + community.status = resData.status; const status = ['all', 'hidden', 'manager']; if (status.indexOf(community['status']) === -1) { - community['status'] = 'hidden'; + community.status = 'hidden'; } } - if (resData.type != null) { - community['type'] = resData.type; - } - - if (resData.managers != null) { - if (community['managers'] === undefined) { - community['managers'] = new Array(); - } - - const managers = resData.managers; - const length = Array.isArray(managers) ? managers.length : 1; - - for (let i = 0; i < length; i++) { - const manager = Array.isArray(managers) ? managers[i] : managers; - community.managers[i] = manager; - } - } - if (resData.subjects != null) { - if (community['subjects'] === undefined) { - community['subjects'] = new Array(); - } - - const subjects = resData.subjects; - const length = Array.isArray(subjects) ? subjects.length : 1; - - for (let i = 0; i < length; i++) { - const subject = Array.isArray(subjects) ? subjects[i] : subjects; - community.subjects[i] = subject; - } + community.subjects = Array.isArray(resData.subjects)?resData.subjects:[resData.subjects]; + } + if (resData.advancedConstraint != null) { + community.selectionCriteria = resData.advancedConstraint; + } else { + community.selectionCriteria = new SelectionCriteria(); } return CommunityInfo.checkIsUpload(community); } diff --git a/connect/community/communityInfo.ts b/connect/community/communityInfo.ts index 065572ec..231a642d 100644 --- a/connect/community/communityInfo.ts +++ b/connect/community/communityInfo.ts @@ -1,5 +1,6 @@ import {StringUtils} from "../../utils/string-utils.class"; import {properties} from "../../../../environments/environment"; +import {SelectionCriteria} from "../../utils/entities/contentProvider"; export class CommunityInfo { title: string; @@ -18,6 +19,9 @@ export class CommunityInfo { isUpload: boolean; isSubscribed: boolean; isManager: boolean; + fos: string[] = []; + sdg: string[] = [] + selectionCriteria: SelectionCriteria; public static checkIsUpload(response: CommunityInfo | CommunityInfo[]): any | any[] { if (Array.isArray(response)) { diff --git a/dashboard/users/role-users/role-users.component.html b/dashboard/users/role-users/role-users.component.html index f9f2e444..cdf80b45 100644 --- a/dashboard/users/role-users/role-users.component.html +++ b/dashboard/users/role-users/role-users.component.html @@ -3,7 +3,7 @@
-
+
    diff --git a/dashboard/users/role-users/role-users.component.ts b/dashboard/users/role-users/role-users.component.ts index 2acc7edc..0e3e17c7 100644 --- a/dashboard/users/role-users/role-users.component.ts +++ b/dashboard/users/role-users/role-users.component.ts @@ -77,7 +77,6 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges { this.updateLists(); this.userManagementService.getUserInfo().subscribe(user => { this.user = user; - console.log(this.canDelete) }); } diff --git a/dashboard/users/subscribers/subscribers.component.html b/dashboard/users/subscribers/subscribers.component.html index c78773e6..46582cfd 100644 --- a/dashboard/users/subscribers/subscribers.component.html +++ b/dashboard/users/subscribers/subscribers.component.html @@ -3,7 +3,7 @@
-
+
From efc2d6c47b1c8e81150274589550b26c25b6eb8f Mon Sep 17 00:00:00 2001 From: Alex Martzios Date: Thu, 9 Mar 2023 16:29:25 +0200 Subject: [PATCH 2/2] add changes for sdg-selection component --- connect/community/community.service.ts | 16 ++++++++++++++-- sdg/sdg-selection/sdg-selection.component.html | 4 ++-- sdg/sdg-selection/sdg-selection.component.ts | 11 +++++++---- 3 files changed, 23 insertions(+), 8 deletions(-) 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() {