Skip to content

Commit

Permalink
Merge branch 'P2-903-Tracking-of-outcomes-achievements-against-target…
Browse files Browse the repository at this point in the history
…s' into dev
  • Loading branch information
xKeCo committed Dec 2, 2024
2 parents 50664a1 + be825c5 commit 25caa44
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h1 class="eoio_header_title">Indicator list</h1>
id="resultListTable"
#table
[value]="this.outcomeIService.eoisData | appFilterIndicatorBySearch: this.outcomeIService.searchText()"
sortField="toc_result_description"
sortField="toc_result_title"
[sortOrder]="1"
styleClass="p-datatable-gridlines p-datatable-sm"
[rows]="8"
Expand All @@ -27,7 +27,7 @@ <h1 class="eoio_header_title">Indicator list</h1>
[tableStyle]="{ 'min-width': '80rem' }">
<ng-template pTemplate="header">
<tr>
<th pSortableColumn="toc_result_description" style="width: 26%" id="outcome-header">Outcome <p-sortIcon field="toc_result_description" /></th>
<th pSortableColumn="toc_result_title" style="width: 26%" id="outcome-header">Outcome <p-sortIcon field="toc_result_title" /></th>
<th style="width: 25%" id="indicator-header">Indicator</th>
<th style="width: 20%" id="indicator-type-header">Indicator Type</th>
<th style="width: 8%" id="expected-target-header">Expected Target</th>
Expand All @@ -40,7 +40,7 @@ <h1 class="eoio_header_title">Indicator list</h1>
<ng-template pTemplate="body" let-item>
@let indicator = item.indicators?.[0];
<tr>
<td>{{ item?.toc_result_description ?? 'No data found.' }}</td>
<td>{{ item?.toc_result_title ?? 'No data found.' }}</td>
@if (!indicator) {
<td colspan="6" style="text-align: center">No indicator data found.</td>
} @else {
Expand All @@ -57,10 +57,10 @@ <h1 class="eoio_header_title">Indicator list</h1>
{{ indicator?.indicator_name ?? 'No data found.' }}
</td>
<td style="text-align: center">{{ indicator?.indicator_target_value ?? 'Not defined' }}</td>
<td style="text-align: center">{{ indicator?.indicator_achieved_value ?? 'Not defined' }}</td>
<td style="text-align: center">{{ indicator?.indicator_achieved_value ?? 'Not provided' }}</td>
<td style="text-align: center">
{{
this.outcomeIService.achievedStatus(indicator?.indicator_target_value, indicator?.indicator_achieved_value) ? 'Achieved' : 'Not Achieved'
this.outcomeIService.achievedStatus(indicator?.indicator_target_value, indicator?.indicator_achieved_value) ? 'Achieved' : 'Not achieved'
}}
</td>
<td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class OutcomeIndicatorHomeComponent {

const wscolsWPs = [
{ header: 'Workpackage name', key: 'workpackage_name', width: 50 },
{ header: 'Outcome', key: 'toc_result_description', 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 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ <h1 class="wp_header_title">Indicator list</h1>
@for (result of item.toc_results; track $index) {
@if (result.indicators.length === 0 && result.isVisible) {
<tr style="height: 50px">
<td>{{ result?.toc_result_description }}</td>
<td>{{ result?.toc_result_title }}</td>
<td colspan="6" style="text-align: center">No indicator data found</td>
</tr>
} @else {
@for (indicator of result.indicators; track $index) {
@if (indicator.isVisible) {
<tr>
@if ($index === 0) {
<td [attr.rowspan]="result.indicators.length">{{ result?.toc_result_description }}</td>
<td [attr.rowspan]="result.indicators.length">{{ result?.toc_result_title }}</td>
}
<td
class="indicator_link"
Expand All @@ -89,12 +89,12 @@ <h1 class="wp_header_title">Indicator list</h1>
{{ indicator?.indicator_name }}
</td>
<td style="text-align: center">{{ indicator?.indicator_target_value ?? 'Not defined' }}</td>
<td style="text-align: center">{{ indicator?.indicator_achieved_value ?? 'Not defined' }}</td>
<td style="text-align: center">{{ indicator?.indicator_achieved_value ?? 'Not provided' }}</td>
<td style="text-align: center">
{{
this.outcomeIService.achievedStatus(indicator?.indicator_target_value, indicator?.indicator_achieved_value)
? 'Achieved'
: 'Not Achieved'
: 'Not achieved'
}}
</td>
<td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('FilterIndicatorBySearchPipe', () => {
describe('Default filtering (non-WPsTable)', () => {
const mockList = [
{
toc_result_description: 'Result 1',
toc_result_title: 'Result 1',
indicators: [
{
indicator_name: 'Indicator 1',
Expand All @@ -29,7 +29,7 @@ describe('FilterIndicatorBySearchPipe', () => {
]
},
{
toc_result_description: 'Result 2',
toc_result_title: 'Result 2',
indicators: [
{
indicator_name: 'Indicator 2',
Expand All @@ -48,13 +48,13 @@ describe('FilterIndicatorBySearchPipe', () => {
it('should filter by result description', () => {
const result = pipe.transform(mockList, 'Result 1', false);
expect(result.length).toBe(1);
expect(result[0].toc_result_description).toBe('Result 1');
expect(result[0].toc_result_title).toBe('Result 1');
});

it('should be case insensitive', () => {
const result = pipe.transform(mockList, 'result 1', false);
expect(result.length).toBe(1);
expect(result[0].toc_result_description).toBe('Result 1');
expect(result[0].toc_result_title).toBe('Result 1');
});
});

Expand All @@ -63,15 +63,15 @@ describe('FilterIndicatorBySearchPipe', () => {
{
toc_results: [
{
toc_result_description: 'WP Result 1',
toc_result_title: 'WP Result 1',
indicators: [{ indicator_description: 'WP Indicator 1' }, { indicator_description: 'WP Indicator 2' }]
}
]
},
{
toc_results: [
{
toc_result_description: 'WP Result 2',
toc_result_title: 'WP Result 2',
indicators: [{ indicator_description: 'WP Indicator 3' }]
}
]
Expand All @@ -86,7 +86,7 @@ describe('FilterIndicatorBySearchPipe', () => {
it('should filter by result description in WPsTable mode', () => {
const result = pipe.transform(mockWPsList, 'WP Result 1', true);
expect(result.length).toBe(1);
expect(result[0].toc_results[0].toc_result_description).toBe('WP Result 1');
expect(result[0].toc_results[0].toc_result_title).toBe('WP Result 1');
});

it('should filter by indicator description in WPsTable mode', () => {
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('FilterIndicatorBySearchPipe', () => {
});

it('should handle undefined search filter', () => {
const mockList = [{ toc_result_description: 'Test' }];
const mockList = [{ toc_result_title: 'Test' }];
expect(() => pipe.transform(mockList, undefined as any, false)).not.toThrow();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ export class FilterIndicatorBySearchPipe implements PipeTransform {
return (
!searchUpper ||
indicator.indicator_description.toUpperCase().includes(searchUpper) ||
result.toc_result_description.toUpperCase().includes(searchUpper)
result.toc_result_title.toUpperCase().includes(searchUpper)
);
}

private isResultVisible(result: any, searchUpper: string): boolean {
return result.toc_result_description.toUpperCase().includes(searchUpper);
return result.toc_result_title.toUpperCase().includes(searchUpper);
}

private resetIndicators(list: any[]): void {
Expand Down Expand Up @@ -83,7 +83,7 @@ export class FilterIndicatorBySearchPipe implements PipeTransform {
}

private createWPsTableString(item: any): string {
return item.toc_results.map(result => result.toc_result_description).join(', ');
return item.toc_results.map(result => result.toc_result_title).join(', ');
}

private createDefaultString(item: any): string {
Expand All @@ -95,6 +95,6 @@ export class FilterIndicatorBySearchPipe implements PipeTransform {
indicatorType = indicator.is_indicator_custom ? 'Custom -' : 'Standard -';
}

return `${item?.toc_result_description || ''} ${indicator.indicator_description || ''} ${indicatorType} ${indicatorName}`;
return `${item?.toc_result_title || ''} ${indicator.indicator_description || ''} ${indicatorType} ${indicatorName}`;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,19 @@ export class OutcomeIndicatorService {
this.api.resultsSE.GET_contributionsToIndicatorsWPS(this.initiativeIdFilter).subscribe({
next: res => {
this.wpsData = res.data.map(item => {
item.toc_results.sort((a, b) => {
return (a.toc_result_title || '').localeCompare(b.toc_result_title || '');
});

item.toc_results.forEach(result => {
if (result.indicators === null) {
result.indicators = [];
}
});
return item;
});
console.log(this.wpsData);

this.loadingWPs.set(false);
this.expandAll();
},
Expand Down
24 changes: 12 additions & 12 deletions onecgiar-pr-client/src/app/shared/services/export-tables.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,20 +236,20 @@ export class ExportTablesService {
}

const supportingResults = !data.indicators[0]?.indicator_supporting_results
? 'Not defined'
? 'Not provided'
: 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',
toc_result_title: data.toc_result_title ?? 'Not defined',
indicator_name: data.indicators[0]?.indicator_description ?? 'Not defined',
indicator_type: indicatorType,
expected_target: data.indicators[0]?.indicator_target_value ?? 'Not defined',
actual_target_achieved: data.indicators[0]?.indicator_achieved_value ?? 'Not defined',
actual_target_achieved: data.indicators[0]?.indicator_achieved_value ?? 'Not provided',
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',
indicator_achieved_narrative: data.indicators[0]?.indicator_achieved_narrative ?? 'Not defined',
indicator_achieved_narrative: data.indicators[0]?.indicator_achieved_narrative ?? 'Not provided',
indicator_supporting_results: supportingResults
});
}
Expand All @@ -264,34 +264,34 @@ export class ExportTablesService {
indicatorType = `${prefix} ${indicator.indicator_name}`;
}
const supportingResults = !indicator.indicator_supporting_results
? 'Not defined'
? 'Not provided'
: 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',
toc_result_title: result.toc_result_title ?? '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',
actual_target_achieved: indicator.indicator_achieved_value ?? 'Not provided',
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_achieved_narrative: indicator.indicator_achieved_narrative ?? 'Not provided',
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',
toc_result_title: result.toc_result_title ?? 'Not defined',
indicator_name: 'Not defined',
indicator_type: 'Not defined',
expected_target: 'Not defined',
actual_target_achieved: 'Not defined',
actual_target_achieved: 'Not provided',
achieved_status: 'No',
reporting_status: 'Editing',
indicator_achieved_narrative: 'Not defined',
indicator_supporting_results: 'Not defined'
indicator_achieved_narrative: 'Not provided',
indicator_supporting_results: 'Not provided'
});
}
});
Expand Down

0 comments on commit 25caa44

Please sign in to comment.