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/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.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.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 7fbf46c34..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 @@ -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' } @@ -89,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 25e77c7d2..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 @@ -10,7 +10,10 @@ export class IndicatorData { outcome_name: string; outcome_description: string; 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-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-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, 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..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