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 6ac04380d..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,8 +23,8 @@ 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 }, 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..0348bf6f0 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,13 @@ 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; + }); + console.log(this.eoisData); 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 91543e61c..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 @@ -256,29 +256,44 @@ export class ExportTablesService { 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}`; - } - 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'); - + 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_achieved_narrative: indicator.indicator_achieved_narrative ?? 'Not defined', - indicator_supporting_results: supportingResults + 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' }); - }); + } }); } @@ -345,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) => {