-
-
Notifications
You must be signed in to change notification settings - Fork 226
feat(dataTable): improve repeat group responses handling DEV-2400 #7226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
magicznyleszek
merged 11 commits into
main
from
leszek/dev-2400-repeat-group-blank-table
Jul 14, 2026
Merged
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
419f0e2
fix repeat groups answers displaying
magicznyleszek 009391e
improve repeat group handling in data table
magicznyleszek e0e0cd1
cr fixes
magicznyleszek 0da88f2
Potential fix for pull request finding
magicznyleszek c75bf01
Potential fix for pull request finding
magicznyleszek ee98951
Potential fix for pull request finding
magicznyleszek 4b1f015
cr fix
magicznyleszek 6b215a8
cr fix
magicznyleszek 1a3da20
undo UI improvements
magicznyleszek 43c14e6
bring back print styles
magicznyleszek c488ca5
Merge branch 'main' into leszek/dev-2400-repeat-group-blank-table
magicznyleszek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
20 changes: 0 additions & 20 deletions
20
jsapp/js/components/submissions/DataTableCell/RepeatGroupCell.module.scss
This file was deleted.
Oops, something went wrong.
67 changes: 55 additions & 12 deletions
67
jsapp/js/components/submissions/DataTableCell/RepeatGroupCell.tsx
This file contains hidden or 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 |
|---|---|---|
| @@ -1,27 +1,70 @@ | ||
| import { List } from '@mantine/core' | ||
| import type { SubmissionResponse } from '#/dataInterface' | ||
| import { getRepeatGroupAnswers } from '../submissionUtils' | ||
| import styles from './RepeatGroupCell.module.scss' | ||
| import { | ||
| type RepeatGroupAnswerTreeNode, | ||
| formatRepeatGroupAnswerValueToText, | ||
| getRepeatGroupAnswerTree, | ||
| } from '../repeatGroupUtils' | ||
| import TextModalCell from './TextModalCell' | ||
|
|
||
| interface RepeatGroupCellProps { | ||
| submissionData: SubmissionResponse | ||
| rowName: string | ||
| columnName: string | ||
| submissionIndex: number | ||
| submissionTotal: number | ||
| } | ||
|
|
||
| function formatIndexPath(indexPath: number[]): string { | ||
| return `${indexPath.join('.')}.` | ||
| } | ||
|
|
||
| function formatInlineAnswer(answerNode: RepeatGroupAnswerTreeNode, indexPath: number[]): string { | ||
| if (!Array.isArray(answerNode)) { | ||
| return `${formatIndexPath(indexPath)} ${formatRepeatGroupAnswerValueToText(answerNode)}` | ||
| } | ||
|
|
||
| return answerNode | ||
| .map((childNode, childIndex) => formatInlineAnswer(childNode, [...indexPath, childIndex + 1])) | ||
| .join('; ') | ||
| } | ||
|
|
||
| function collectIndexedLeafAnswers(answerNode: RepeatGroupAnswerTreeNode, indexPath: number[]): string[] { | ||
| if (!Array.isArray(answerNode)) { | ||
| return [`${formatIndexPath(indexPath)} ${formatRepeatGroupAnswerValueToText(answerNode)}`] | ||
| } | ||
|
|
||
| return answerNode.flatMap((childNode, childIndex) => | ||
| collectIndexedLeafAnswers(childNode, [...indexPath, childIndex + 1]), | ||
| ) | ||
| } | ||
|
|
||
| /** | ||
| * Displays a list of answers from a repeat group question. | ||
| */ | ||
| export default function RepeatGroupCell(props: RepeatGroupCellProps) { | ||
| const repeatGroupAnswers = getRepeatGroupAnswers(props.submissionData, props.rowName) | ||
| if (!repeatGroupAnswers) return null | ||
| const repeatGroupAnswers = getRepeatGroupAnswerTree(props.submissionData, props.rowName) | ||
| if (!repeatGroupAnswers || repeatGroupAnswers.length <= 0) return null | ||
|
|
||
| return ( | ||
| <div className={styles.repeatGroupCell} dir='auto'> | ||
| {repeatGroupAnswers.map((answer, i) => ( | ||
| <span key={i}> | ||
| {i > 0 && ', '} | ||
| {answer} | ||
| </span> | ||
| const inlineText = repeatGroupAnswers.map((answer, i) => formatInlineAnswer(answer, [i + 1])).join('; ') | ||
|
|
||
| const modalRows = repeatGroupAnswers.flatMap((answer, i) => collectIndexedLeafAnswers(answer, [i + 1])) | ||
|
|
||
| const modalContent = ( | ||
| <List pl={0}> | ||
| {modalRows.map((rowText, i) => ( | ||
| <List.Item key={i}>{rowText}</List.Item> | ||
| ))} | ||
| </div> | ||
| </List> | ||
| ) | ||
|
|
||
| return ( | ||
| <TextModalCell | ||
| text={inlineText} | ||
| modalContent={modalContent} | ||
| columnName={props.columnName} | ||
| submissionIndex={props.submissionIndex} | ||
| submissionTotal={props.submissionTotal} | ||
| /> | ||
| ) | ||
| } |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.