This repository has been archived by the owner on Dec 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix field sort in excel submission export
- Loading branch information
Showing
2 changed files
with
9 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,9 @@ export const ExportSubmissionAction: React.FC<Props> = (props) => { | |
workbook.created = new Date() | ||
workbook.modified = new Date() | ||
|
||
const orderedFields = form.data.form.fields | ||
.sort((a, b) => (a.idx ?? 0) - (b.idx ?? 0)) | ||
|
||
const sheet = workbook.addWorksheet('Submissions') | ||
sheet.getRow(1).values = [ | ||
'Submission ID', | ||
|
@@ -45,7 +48,7 @@ export const ExportSubmissionAction: React.FC<Props> = (props) => { | |
'City', | ||
'User Agent', | ||
'Device', | ||
...form.data.form.fields.map((field) => `${field.title} (${field.type})`), | ||
...orderedFields.map((field) => `${field.title} (${field.type})`), | ||
] | ||
|
||
const firstPage = await getSubmissions({ | ||
|
@@ -65,7 +68,9 @@ export const ExportSubmissionAction: React.FC<Props> = (props) => { | |
data.device.name, | ||
] | ||
|
||
data.fields.forEach((field) => { | ||
orderedFields.forEach((formField) => { | ||
const field = data.fields.find(field => field.id === formField.id) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
wodka
Author
Contributor
|
||
|
||
try { | ||
fieldTypes[field.type]?.stringifyValue(field.value) | ||
|
||
|
this comparison fails for me, and then all the export fields are empty, because
find
will always return undefined.The problem is, that field.id contains

J7Ngzj
, but formField.id is"45"
.it would probably need to be
field.field.id
, butfield.field
does not currently contain the id, only the title.