From 392655ad5cc5a395bb1e810922d20bd9e6917816 Mon Sep 17 00:00:00 2001 From: xKeCo Date: Tue, 3 Dec 2024 11:33:38 -0500 Subject: [PATCH 1/3] :recycle: refactor(outcome indicators) P2-903: update UI narratives and data models for enhanced indicator details --- .../pages/eioi-home/eoio-home.component.html | 4 ++-- .../indicator-details.component.html | 12 ++++++++++++ .../indicator-details/indicator-details.component.ts | 3 +-- .../indicator-details/models/indicator-data.model.ts | 1 + .../pages/wp-home/wp-home.component.html | 6 ++++-- .../contribution-to-indicator-result.repository.ts | 2 +- 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/eioi-home/eoio-home.component.html b/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/eioi-home/eoio-home.component.html index cf8532013..348f005a3 100644 --- a/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/eioi-home/eoio-home.component.html +++ b/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/eioi-home/eoio-home.component.html @@ -2,7 +2,7 @@
arrow_back
-

Indicator list

+

End of Initiative Outcome Indicators List

@@ -27,7 +27,7 @@

Indicator list

[tableStyle]="{ 'min-width': '80rem' }"> - Outcome + EOI Outcome Indicator Indicator Type Expected Target diff --git a/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/indicator-details/indicator-details.component.html b/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/indicator-details/indicator-details.component.html index 0ecec43eb..283e5adfe 100644 --- a/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/indicator-details/indicator-details.component.html +++ b/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/indicator-details/indicator-details.component.html @@ -13,6 +13,18 @@

+
+
+ + +

Work Package

+
+ +

+ {{ this.indicatorData?.workpackage_short_name ? this.indicatorData.workpackage_short_name + ': ' : '' }} + {{ this.indicatorData?.workpackage_name ?? 'Not specified' }} +

+
@for (item of indicatorInfoItems; track $index) {
diff --git a/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/indicator-details/indicator-details.component.ts b/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/indicator-details/indicator-details.component.ts index 7fbf46c34..5d2c78381 100644 --- a/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/indicator-details/indicator-details.component.ts +++ b/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/indicator-details/indicator-details.component.ts @@ -28,8 +28,7 @@ export class IndicatorDetailsComponent implements OnInit { loading = true; indicatorInfoItems = [ - { icon: '', label: 'Work Package', value: 'workpackage_name', iconClass: 'pi pi-box' }, - { icon: 'login', label: 'Outcome', value: 'outcome_description', iconClass: 'material-icons-round' }, + { icon: 'login', label: 'Outcome', value: 'outcome_name', iconClass: 'material-icons-round' }, { icon: 'show_chart', label: 'Unit of measurement', value: 'unit_measurement', iconClass: 'material-icons-round' }, { icon: '', label: 'Baseline', value: 'indicator_baseline', iconClass: 'pi pi-chart-bar' }, { icon: '', label: 'Target', value: 'indicator_target', iconClass: 'pi pi-bullseye' } diff --git a/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/indicator-details/models/indicator-data.model.ts b/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/indicator-details/models/indicator-data.model.ts index 25e77c7d2..262a001a4 100644 --- a/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/indicator-details/models/indicator-data.model.ts +++ b/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/indicator-details/models/indicator-data.model.ts @@ -10,6 +10,7 @@ export class IndicatorData { outcome_name: string; outcome_description: string; workpackage_name: string; + workpackage_short_name: string; submission_status: string; contributing_results: ContributingResult[]; } diff --git a/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/wp-home/wp-home.component.html b/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/wp-home/wp-home.component.html index fdb8c3294..f2c63f680 100644 --- a/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/wp-home/wp-home.component.html +++ b/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/wp-home/wp-home.component.html @@ -2,7 +2,7 @@
arrow_back
-

Indicator list

+

Work Package Outcome Indicators List

@@ -35,7 +35,9 @@

Indicator list

[expandedRowKeys]="this.outcomeIService.expandedRows"> - Outcome + + Work Package Outcome + Indicator Indicator Type Expected Target diff --git a/onecgiar-pr-server/src/api/contribution-to-indicators/repositories/contribution-to-indicator-result.repository.ts b/onecgiar-pr-server/src/api/contribution-to-indicators/repositories/contribution-to-indicator-result.repository.ts index 10b0526b7..f0284a463 100644 --- a/onecgiar-pr-server/src/api/contribution-to-indicators/repositories/contribution-to-indicator-result.repository.ts +++ b/onecgiar-pr-server/src/api/contribution-to-indicators/repositories/contribution-to-indicator-result.repository.ts @@ -28,7 +28,7 @@ export class ContributionToIndicatorResultsRepository extends Repository', ci.short_name, ' - ', ci.name) as indicator_initiative, + wp.acronym as workpackage_short_name, concat(ci.official_code, ' - ', ci.short_name, ' - ', ci.name) as indicator_initiative, ( CASE when indicator_s.result_status_id = 1 then 0 From 17937d899b002035ddc8e0d131c91aab49be0f8f Mon Sep 17 00:00:00 2001 From: xKeCo Date: Tue, 3 Dec 2024 12:19:52 -0500 Subject: [PATCH 2/3] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(indicator=20d?= =?UTF-8?q?etails)=20P2-903:=20enhance=20updateIndicatorData=20logic=20and?= =?UTF-8?q?=20add=20initiative=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/eioi-home/eoio-home.component.ts | 2 +- .../indicator-details.component.spec.ts | 32 ++++++++++++++++++- .../indicator-details.component.ts | 7 ++++ .../models/indicator-data.model.ts | 2 ++ ...ribution-to-indicator-result.repository.ts | 2 +- 5 files changed, 42 insertions(+), 3 deletions(-) diff --git a/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/eioi-home/eoio-home.component.ts b/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/eioi-home/eoio-home.component.ts index e5ab8efdf..e90bf9956 100644 --- a/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/eioi-home/eoio-home.component.ts +++ b/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/eioi-home/eoio-home.component.ts @@ -1,5 +1,5 @@ import { CommonModule } from '@angular/common'; -import { ChangeDetectionStrategy, Component, inject, OnDestroy, OnInit, signal } from '@angular/core'; +import { ChangeDetectionStrategy, Component, inject, OnDestroy } from '@angular/core'; import { TableModule } from 'primeng/table'; import { ApiService } from '../../../../shared/services/api/api.service'; import { ButtonModule } from 'primeng/button'; diff --git a/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/indicator-details/indicator-details.component.spec.ts b/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/indicator-details/indicator-details.component.spec.ts index fd3952da0..62b4a06c4 100644 --- a/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/indicator-details/indicator-details.component.spec.ts +++ b/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/indicator-details/indicator-details.component.spec.ts @@ -20,7 +20,9 @@ describe('IndicatorDetailsComponent', () => { GET_contributionsToIndicators_indicator: jest.fn().mockReturnValue(of({})), POST_contributionsToIndicators: jest.fn().mockReturnValue(of({})), PATCH_contributionsToIndicators: jest.fn().mockReturnValue(of({})), - POST_contributionsToIndicatorsSubmit: jest.fn().mockReturnValue(of({})) + POST_contributionsToIndicatorsSubmit: jest.fn().mockReturnValue(of({})), + GET_contributionsToIndicatorsWPS: jest.fn().mockReturnValue(of({})), + GET_contributionsToIndicatorsEOIS: jest.fn().mockReturnValue(of({})) }, alertsFe: { show: jest.fn().mockImplementationOnce((config, callback) => { @@ -98,6 +100,34 @@ describe('IndicatorDetailsComponent', () => { expect(component.updateIndicatorData).toHaveBeenCalledWith(response); }); + it('should update indicator data and set loading to false in updateIndicatorData', () => { + const response = { contributionToIndicator: { someData: 'data', initiative_official_code: '123' } }; + component.updateIndicatorData(response); + expect(component.indicatorData).toEqual(response.contributionToIndicator); + expect(component.loading).toBe(false); + }); + + it('should call getWorkPackagesData and getEOIsData if initiativeIdFilter is different', () => { + const response = { contributionToIndicator: { someData: 'data', initiative_official_code: '123' } }; + component.outcomeIService.initiativeIdFilter = '456'; + jest.spyOn(component.outcomeIService, 'getWorkPackagesData'); + jest.spyOn(component.outcomeIService, 'getEOIsData'); + component.updateIndicatorData(response); + expect(component.outcomeIService.initiativeIdFilter).toBe('123'); + expect(component.outcomeIService.getWorkPackagesData).toHaveBeenCalled(); + expect(component.outcomeIService.getEOIsData).toHaveBeenCalled(); + }); + + it('should not call getWorkPackagesData and getEOIsData if initiativeIdFilter is the same', () => { + const response = { contributionToIndicator: { someData: 'data', initiative_official_code: '123' } }; + component.outcomeIService.initiativeIdFilter = '123'; + jest.spyOn(component.outcomeIService, 'getWorkPackagesData'); + jest.spyOn(component.outcomeIService, 'getEOIsData'); + component.updateIndicatorData(response); + expect(component.outcomeIService.getWorkPackagesData).not.toHaveBeenCalled(); + expect(component.outcomeIService.getEOIsData).not.toHaveBeenCalled(); + }); + it('should handle 404 response in handleGetIndicatorResponse', () => { component.indicatorId = '123'; const response = { status: 404 }; diff --git a/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/indicator-details/indicator-details.component.ts b/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/indicator-details/indicator-details.component.ts index 5d2c78381..20a59d1e9 100644 --- a/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/indicator-details/indicator-details.component.ts +++ b/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/indicator-details/indicator-details.component.ts @@ -88,6 +88,13 @@ export class IndicatorDetailsComponent implements OnInit { updateIndicatorData(response: any) { this.indicatorData = response?.contributionToIndicator; + + if (this.outcomeIService.initiativeIdFilter !== this.indicatorData.initiative_official_code) { + this.outcomeIService.initiativeIdFilter = this.indicatorData.initiative_official_code; + this.outcomeIService.getWorkPackagesData(); + this.outcomeIService.getEOIsData(); + } + this.loading = false; } diff --git a/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/indicator-details/models/indicator-data.model.ts b/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/indicator-details/models/indicator-data.model.ts index 262a001a4..c11d35bd5 100644 --- a/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/indicator-details/models/indicator-data.model.ts +++ b/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/indicator-details/models/indicator-data.model.ts @@ -12,6 +12,8 @@ export class IndicatorData { workpackage_name: string; workpackage_short_name: string; submission_status: string; + initiative_official_code: string; + indicator_initiative: string; contributing_results: ContributingResult[]; } diff --git a/onecgiar-pr-server/src/api/contribution-to-indicators/repositories/contribution-to-indicator-result.repository.ts b/onecgiar-pr-server/src/api/contribution-to-indicators/repositories/contribution-to-indicator-result.repository.ts index f0284a463..29b263d20 100644 --- a/onecgiar-pr-server/src/api/contribution-to-indicators/repositories/contribution-to-indicator-result.repository.ts +++ b/onecgiar-pr-server/src/api/contribution-to-indicators/repositories/contribution-to-indicator-result.repository.ts @@ -28,7 +28,7 @@ export class ContributionToIndicatorResultsRepository extends Repository', ci.short_name, ' - ', ci.name) as indicator_initiative, + wp.acronym as workpackage_short_name, concat(ci.official_code, ' - ', ci.short_name, ' - ', ci.name) as indicator_initiative, ci.official_code as initiative_official_code, ( CASE when indicator_s.result_status_id = 1 then 0 From 9d8183ce09d7d1ebb726c532e08c6b6e2fc830a3 Mon Sep 17 00:00:00 2001 From: xKeCo Date: Mon, 16 Dec 2024 08:07:09 -0500 Subject: [PATCH 3/3] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(Outcomes=20in?= =?UTF-8?q?dicators=20module)=20P2-903:=20uncomment=20the=20Results=20Indi?= =?UTF-8?q?cator=20Module=20to=20make=20it=20accessible=20in=20production.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/app/shared/routing/routing-data.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/onecgiar-pr-client/src/app/shared/routing/routing-data.ts b/onecgiar-pr-client/src/app/shared/routing/routing-data.ts index 8741c6a90..42aae0a86 100644 --- a/onecgiar-pr-client/src/app/shared/routing/routing-data.ts +++ b/onecgiar-pr-client/src/app/shared/routing/routing-data.ts @@ -42,15 +42,15 @@ export const routingApp: PrRoute[] = [ path: 'init-admin-module', loadChildren: () => import('../../pages/init-admin-section/init-admin-section.module').then(m => m.InitAdminSectionModule) }, - // { - // prName: 'Outcome Indicator Module', - // onlytest: false, - // prHide: false, - // underConstruction: true, - // canActivate: [CheckLoginGuard], - // path: 'outcome-indicator-module', - // loadChildren: () => import('../../pages/outcome-indicator/outcome-indicator.module').then(m => m.OutcomeIndicatorModule) - // }, + { + prName: 'Outcome Indicator Module', + onlytest: false, + prHide: true, + underConstruction: true, + canActivate: [CheckLoginGuard], + path: 'outcome-indicator-module', + loadChildren: () => import('../../pages/outcome-indicator/outcome-indicator.module').then(m => m.OutcomeIndicatorModule) + }, { prName: 'reports', prHide: true,