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 5b22b057c..974ad936c 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 @@ -29,8 +29,9 @@

diff --git a/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/outcome-indicator-home/outcome-indicator-home.component.ts b/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/outcome-indicator-home/outcome-indicator-home.component.ts index d77801886..451e5a7eb 100644 --- a/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/outcome-indicator-home/outcome-indicator-home.component.ts +++ b/onecgiar-pr-client/src/app/pages/outcome-indicator/pages/outcome-indicator-home/outcome-indicator-home.component.ts @@ -23,13 +23,15 @@ export class OutcomeIndicatorHomeComponent { exportIndicatorsToExcel() { const wscolsEOIs = [ - { header: 'Outcome name', key: 'toc_result_title', width: 50 }, - { header: 'Indicator name', key: 'indicator_name', width: 50 }, + { header: 'Outcome', key: 'toc_result_title', width: 50 }, + { header: 'Indicator', key: 'indicator_name', width: 50 }, { header: 'Indicator Type', key: 'indicator_type', width: 50 }, { header: 'Expected target', key: 'expected_target', width: 22 }, { header: 'Actual target achieved', key: 'actual_target_achieved', width: 30 }, { header: 'Achieved status', key: 'achieved_status', width: 22 }, - { header: 'Reporting status', key: 'reporting_status', width: 22 } + { header: 'Reporting status', key: 'reporting_status', width: 22 }, + { header: 'Narrative', key: 'indicator_achieved_narrative', width: 50 }, + { header: 'Supporting results', key: 'indicator_supporting_results', width: 60 } ]; const wscolsWPs = [ @@ -40,7 +42,9 @@ export class OutcomeIndicatorHomeComponent { { header: 'Expected target', key: 'expected_target', width: 22 }, { header: 'Actual target achieved', key: 'actual_target_achieved', width: 30 }, { header: 'Achieved status', key: 'achieved_status', width: 22 }, - { header: 'Reporting status', key: 'reporting_status', width: 22 } + { header: 'Reporting status', key: 'reporting_status', width: 22 }, + { header: 'Narrative', key: 'indicator_achieved_narrative', width: 50 }, + { header: 'Supporting results', key: 'indicator_supporting_results', width: 60 } ]; this.exportTablesSE.exportOutcomesIndicatorsToExcel( diff --git a/onecgiar-pr-client/src/app/pages/outcome-indicator/services/outcome-indicator.service.ts b/onecgiar-pr-client/src/app/pages/outcome-indicator/services/outcome-indicator.service.ts index e3700043d..07ac53f66 100644 --- a/onecgiar-pr-client/src/app/pages/outcome-indicator/services/outcome-indicator.service.ts +++ b/onecgiar-pr-client/src/app/pages/outcome-indicator/services/outcome-indicator.service.ts @@ -46,7 +46,12 @@ export class OutcomeIndicatorService { this.loading.set(true); this.api.resultsSE.GET_contributionsToIndicatorsEOIS(this.initiativeIdFilter).subscribe({ next: res => { - this.eoisData = res?.data; + this.eoisData = res?.data.map(item => { + if (item.indicators === null) { + item.indicators = []; + } + return item; + }); this.loading.set(false); }, error: error => { diff --git a/onecgiar-pr-client/src/app/shared/services/export-tables.service.spec.ts b/onecgiar-pr-client/src/app/shared/services/export-tables.service.spec.ts index 7ef6a758c..5104963f2 100644 --- a/onecgiar-pr-client/src/app/shared/services/export-tables.service.spec.ts +++ b/onecgiar-pr-client/src/app/shared/services/export-tables.service.spec.ts @@ -161,7 +161,7 @@ describe('ExportTablesService', () => { month = '0' + month; } - const dateCET = month + day + year; + const dateCET = year + month + day; const timeCET = dateCETTime.split(',')[1].trim().replace(':', '').slice(0, 4); diff --git a/onecgiar-pr-client/src/app/shared/services/export-tables.service.ts b/onecgiar-pr-client/src/app/shared/services/export-tables.service.ts index 88938bd54..d4f0246e8 100644 --- a/onecgiar-pr-client/src/app/shared/services/export-tables.service.ts +++ b/onecgiar-pr-client/src/app/shared/services/export-tables.service.ts @@ -235,6 +235,10 @@ export class ExportTablesService { indicatorType = `${prefix} ${data.indicators[0]?.indicator_name}`; } + const supportingResults = !data.indicators[0]?.indicator_supporting_results + ? 'Not defined' + : data.indicators[0]?.indicator_supporting_results.map(item => `• ${item.result_type} ${item.result_code} - ${item.result_title}`).join('\n'); + worksheet.addRow({ toc_result_title: data.toc_result_description ?? 'Not defined', indicator_name: data.indicators[0]?.indicator_description ?? 'Not defined', @@ -244,30 +248,52 @@ export class ExportTablesService { achieved_status: this.outcomeIService.achievedStatus(data.indicators[0]?.indicator_target_value, data.indicators[0]?.indicator_achieved_value) ? 'Yes' : 'No', - reporting_status: data.indicators[0]?.indicator_submission_status ? 'Submitted' : 'Editing' + reporting_status: data.indicators[0]?.indicator_submission_status ? 'Submitted' : 'Editing', + indicator_achieved_narrative: data.indicators[0]?.indicator_achieved_narrative ?? 'Not defined', + indicator_supporting_results: supportingResults }); } private addWPSRow(worksheet: ExcelJS.Worksheet, data: any) { data.toc_results.forEach(result => { - result.indicators.forEach(indicator => { - let indicatorType = 'Not defined'; - if (indicator.indicator_name) { - const prefix = indicator.is_indicator_custom ? 'Custom - ' : 'Standard - '; - indicatorType = `${prefix} ${indicator.indicator_name}`; - } - + if (result.indicators.length > 0) { + result.indicators.forEach(indicator => { + let indicatorType = 'Not defined'; + if (indicator.indicator_name) { + const prefix = indicator.is_indicator_custom ? 'Custom - ' : 'Standard - '; + indicatorType = `${prefix} ${indicator.indicator_name}`; + } + const supportingResults = !indicator.indicator_supporting_results + ? 'Not defined' + : indicator.indicator_supporting_results.map(item => `• ${item.result_type} ${item.result_code} - ${item.result_title}`).join('\n'); + + worksheet.addRow({ + workpackage_name: `${data.workpackage_short_name}: ${data.workpackage_name}`, + toc_result_description: result.toc_result_description ?? 'Not defined', + indicator_name: indicator.indicator_description ?? 'Not defined', + indicator_type: indicatorType, + expected_target: indicator.indicator_target_value ?? 'Not defined', + actual_target_achieved: indicator.indicator_achieved_value ?? 'Not defined', + achieved_status: this.outcomeIService.achievedStatus(indicator.indicator_target_value, indicator.indicator_achieved_value) ? 'Yes' : 'No', + reporting_status: indicator.indicator_submission_status ? 'Submitted' : 'Editing', + indicator_achieved_narrative: indicator.indicator_achieved_narrative ?? 'Not defined', + indicator_supporting_results: supportingResults + }); + }); + } else { worksheet.addRow({ workpackage_name: `${data.workpackage_short_name}: ${data.workpackage_name}`, toc_result_description: result.toc_result_description ?? 'Not defined', - indicator_name: indicator.indicator_description ?? 'Not defined', - indicator_type: indicatorType, - expected_target: indicator.indicator_target_value ?? 'Not defined', - actual_target_achieved: indicator.indicator_achieved_value ?? 'Not defined', - achieved_status: this.outcomeIService.achievedStatus(indicator.indicator_target_value, indicator.indicator_achieved_value) ? 'Yes' : 'No', - reporting_status: indicator.indicator_submission_status ? 'Submitted' : 'Editing' + indicator_name: 'Not defined', + indicator_type: 'Not defined', + expected_target: 'Not defined', + actual_target_achieved: 'Not defined', + achieved_status: 'No', + reporting_status: 'Editing', + indicator_achieved_narrative: 'Not defined', + indicator_supporting_results: 'Not defined' }); - }); + } }); } @@ -334,8 +360,12 @@ export class ExportTablesService { day: '2-digit', ...(includeTime && { hour: '2-digit', minute: '2-digit' }) }; - const formatted = date.toLocaleString('en-US', options).replace(/[/,:\s]/g, ''); - return includeTime ? formatted.slice(0, 8) + '_' + formatted.slice(8, 12) + 'cet' : formatted.slice(0, 8); + const formatted = date.toLocaleString('en-GB', options).replace(/[/,:\s]/g, ''); + let formattedDate = formatted.slice(4, 8) + formatted.slice(2, 4) + formatted.slice(0, 2); + if (includeTime) { + formattedDate += '_' + formatted.slice(8, 12) + (isIPSR ? 'cet' : ''); + } + return formattedDate; }; const saveFile = (suffix: string) => {