Skip to content

Commit

Permalink
fix: FORMS-1385 data grid export (bcgov#1433)
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterMoar authored Jul 16, 2024
1 parent ddc0be9 commit 6cce619
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
9 changes: 1 addition & 8 deletions app/src/forms/form/exportService.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,7 @@ const service = {

if (fields) {
return formSchemaheaders.filter((header) => {
// In the 'fields' sent from the caller we'll have something like
// 'datagrid.input', but in the actual submission data in the
// 'formSchemaheaders' we'll have things like 'datagrid.0.input',
// 'datagrid.1.input', etc. Remove the '.0' array index to get
// 'datagrid.input' and then do the comparison.
const flattenedHeader = header.replace(/\.\d+\./gi, '.');

if (Array.isArray(fields) && fields.includes(flattenedHeader)) {
if (Array.isArray(fields) && fields.includes(header)) {
return header;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
"email",
"forWhichBcLakeRegionAreYouCompletingTheseQuestions",
"didYouFishAnyBcLakesThisYear",
"oneRowPerLake.lakeName",
"oneRowPerLake.closestTown",
"oneRowPerLake.numberOfDays",
"oneRowPerLake.dataGrid.fishType",
"oneRowPerLake.dataGrid.numberCaught",
"oneRowPerLake.dataGrid.numberKept"
"oneRowPerLake.0.lakeName",
"oneRowPerLake.0.closestTown",
"oneRowPerLake.0.numberOfDays",
"oneRowPerLake.0.dataGrid.0.fishType",
"oneRowPerLake.0.dataGrid.1.fishType",
"oneRowPerLake.0.dataGrid.0.numberCaught",
"oneRowPerLake.0.dataGrid.1.numberCaught",
"oneRowPerLake.0.dataGrid.0.numberKept",
"oneRowPerLake.0.dataGrid.1.numberKept"
]
5 changes: 3 additions & 2 deletions app/tests/unit/forms/form/exportService.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ describe('export', () => {
'form.username',
'form.email',
'dataGrid',
'dataGrid.simpletextfield',
'dataGrid.0.simpletextfield',
'dataGrid.1.simpletextfield',
],
template: 'singleRowCSVExport',
};
Expand Down Expand Up @@ -515,7 +516,7 @@ describe('_buildCsvHeaders', () => {
// get result columns if we need to filter out the columns
const result = await exportService._buildCsvHeaders(form, submissionsExport, 1, fields, true);

expect(result).toHaveLength(29);
expect(result).toHaveLength(20);
expect(result).toEqual(
expect.arrayContaining([
'form.confirmationId',
Expand Down

0 comments on commit 6cce619

Please sign in to comment.