Skip to content

Commit

Permalink
šŸ› fix(Outcomes indicators) P2-903: update references from 'toc_resultā€¦
Browse files Browse the repository at this point in the history
ā€¦_description' to 'toc_result_title' for consistency across components and services
  • Loading branch information
xKeCo committed Dec 2, 2024
1 parent 58ac3c3 commit be825c5
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 21 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 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 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
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export class ExportTablesService {
: 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',
Expand Down Expand Up @@ -269,7 +269,7 @@ export class ExportTablesService {

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',
Expand All @@ -283,7 +283,7 @@ export class ExportTablesService {
} 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',
Expand Down

0 comments on commit be825c5

Please sign in to comment.