-
Notifications
You must be signed in to change notification settings - Fork 332
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
Enhance form submissions column management #691
Conversation
Warning Rate limit exceeded@JhumanJ has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 15 minutes and 56 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughThe pull request updates several UI components by introducing a new text wrapping functionality. The Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Modal as FormSubmissionsModal
participant Toggle as ToggleSwitchInput
User->>Modal: Open modal
Modal->>Toggle: Render display and wrap toggles
User->>Toggle: Toggle display/wrap option
Toggle-->>Modal: Update displayColumns/wrapColumns state
Modal->>Modal: Recompute sections for UI update
sequenceDiagram
participant OpenTable
participant TableCell
OpenTable->>TableCell: Check wrapColumns[col.id]
alt wrapColumns[col.id] is true
TableCell-->>OpenTable: Apply text wrap classes
else
TableCell-->>OpenTable: Render normally
end
Possibly Related PRs
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
client/components/open/forms/components/FormSubmissions.vue (1)
279-306
: Initialize and persist wrap column settings.The
wrapColumns
settings should be initialized and persisted similar todisplayColumns
for consistency across sessions.Update the initialization logic:
initFormStructure() { // ... existing code ... // Get display columns from local storage const tmpColumns = window.localStorage.getItem('display-columns-formid-' + this.form.id) if (tmpColumns !== null && tmpColumns) { this.displayColumns = JSON.parse(tmpColumns) this.onChangeDisplayColumns() } else { this.properties.forEach((field) => { this.displayColumns[field.id] = true }) } + // Get wrap columns from local storage + const tmpWrapColumns = window.localStorage.getItem('wrap-columns-formid-' + this.form.id) + if (tmpWrapColumns !== null && tmpWrapColumns) { + this.wrapColumns = JSON.parse(tmpWrapColumns) + } else { + this.properties.forEach((field) => { + this.wrapColumns[field.id] = false + }) + } }Also add a method to persist wrap settings:
+ onChangeWrapColumns() { + if (!import.meta.client) return + window.localStorage.setItem('wrap-columns-formid-' + this.form.id, JSON.stringify(this.wrapColumns)) + }And update the toggle:
<ToggleSwitchInput v-model="wrapColumns[field.id]" wrapper-class="mb-0" label="" :name="`wrap-${field.id}`" + @update:model-value="onChangeWrapColumns" />
🧹 Nitpick comments (3)
client/components/open/tables/OpenTable.vue (1)
77-77
: Add null check for safer access.While the implementation works, it could be made more robust by adding a null check.
- 'whitespace-normal break-words': wrapColumns[col.id] === true, + 'whitespace-normal break-words': wrapColumns && wrapColumns[col.id] === true,client/components/open/forms/components/FormSubmissions.vue (2)
77-84
: Add aria-labels to toggle switches for better accessibility.The toggle switches lack proper aria-labels which are essential for screen readers.
Add aria-labels to both display and wrap toggles:
<ToggleSwitchInput v-model="displayColumns[field.id]" wrapper-class="mb-0" - label="" + label="Toggle display for field" + :aria-label="`Toggle display for ${field.name}`" :name="`display-${field.id}`" @update:model-value="onChangeDisplayColumns" /> <ToggleSwitchInput v-model="wrapColumns[field.id]" wrapper-class="mb-0" - label="" + label="Toggle text wrapping for field" + :aria-label="`Toggle text wrapping for ${field.name}`" :name="`wrap-${field.id}`" />Also applies to: 86-92
43-97
: Consider adding a loading state to the modal content.The modal content might flicker or appear empty momentarily while the sections data is being computed.
Add a loading state:
<div class="px-4"> + <Loader v-if="isModalLoading" class="h-6 w-6 text-nt-blue mx-auto" /> + <template v-else> <template v-for="(section, sectionIndex) in sections" :key="sectionIndex" > <!-- ... existing content ... --> </template> + </template> </div>
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
client/components/open/forms/components/FormSubmissions.vue
(4 hunks)client/components/open/tables/OpenTable.vue
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Build the Nuxt app
🔇 Additional comments (2)
client/components/open/forms/components/FormSubmissions.vue (2)
44-96
: Well-structured grid layout with clear visual hierarchy!The new modal structure with sections and grid layout provides a clear and organized way to manage columns. The use of consistent styling and proper spacing improves the user experience.
246-257
: Clean implementation of sections computed property!The
sections
computed property provides a clear and maintainable way to organize fields into logical groups.
wrapColumns: { | ||
type: Object, | ||
default: () => {}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Enhance prop definition with proper defaults and validation.
The prop definition needs improvements:
- The default value should return an empty object.
- Add prop validation for the object structure.
- Add prop documentation.
wrapColumns: {
type: Object,
- default: () => {},
+ default: () => ({}),
+ validator(value) {
+ return Object.values(value).every(v => typeof v === 'boolean')
+ },
},
Also, consider adding JSDoc documentation above the prop:
/**
* Controls text wrapping for individual columns.
* @type {Object.<string, boolean>}
* @example { column1: true, column2: false }
*/
- Refactor RecordOperations component to use UButtonGroup and UButton - Update FormSubmissions component with Nuxt UI buttons and modal - Improve table cell styling in OpenTable component - Simplify column management and export functionality
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
client/components/open/forms/components/FormSubmissions.vue (1)
222-248
: 🛠️ Refactor suggestionEnhance error handling in CSV export.
While the CSV export implementation is functional, the error handling could be improved:
- The catch block only logs to console
- No user feedback on error
Consider this enhancement:
downloadAsCsv() { if (this.exportLoading) { return } this.exportLoading = true opnFetch(this.exportUrl, { responseType: "blob", method: "POST", body: { columns: this.displayColumns } }).then(blob => { const filename = `${this.form.slug}-${Date.now()}-submissions.csv` const a = document.createElement("a") document.body.appendChild(a) a.style = "display: none" const url = window.URL.createObjectURL(blob) a.href = url a.download = filename a.click() window.URL.revokeObjectURL(url) }).catch((error) => { - console.error(error) + this.useAlert.error('Failed to export CSV. Please try again.') + console.error('CSV export failed:', error) }).finally(() => { this.exportLoading = false }) }
🧹 Nitpick comments (2)
client/components/open/forms/components/FormColumnsSettingsModal.vue (2)
124-132
: Enhance storage key security.The storage key using form ID could be vulnerable to collision. Consider adding a namespace or prefix.
const columnPreferences = useStorage( - computed(() => props.form ? `column-preferences-formid-${props.form.id}` : null), + computed(() => props.form ? `opn-form-columns-${props.form.id}` : null), { display: {}, wrap: {}, widths: {} } )
151-175
: Improve width initialization robustness.The width preservation logic could be more robust by:
- Adding type checking for width values
- Setting reasonable min/max bounds
function preserveColumnWidths(newColumns, existingColumns = []) { if (!columnPreferences.value) { columnPreferences.value = { display: {}, wrap: {}, widths: {} } } if (!columnPreferences.value.widths) { columnPreferences.value.widths = {} } return newColumns.map(col => { // First try to find width in storage const storedWidth = columnPreferences.value?.widths?.[col.id] // Then try current table columns const currentCol = props.columns?.find(c => c.id === col.id) // Then fallback to form properties const existing = existingColumns?.find(e => e.id === col.id) - const width = storedWidth || currentCol?.cell_width || currentCol?.width || existing?.cell_width || existing?.width || col.width || 150 + const MIN_WIDTH = 80 + const MAX_WIDTH = 500 + const DEFAULT_WIDTH = 150 + + let width = parseInt(storedWidth) || + parseInt(currentCol?.cell_width) || + parseInt(currentCol?.width) || + parseInt(existing?.cell_width) || + parseInt(existing?.width) || + parseInt(col.width) || + DEFAULT_WIDTH + + // Ensure width is within bounds + width = Math.max(MIN_WIDTH, Math.min(width, MAX_WIDTH)) return { ...col, width, cell_width: width } }) }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
client/components/open/components/RecordOperations.vue
(1 hunks)client/components/open/forms/components/FormColumnsSettingsModal.vue
(1 hunks)client/components/open/forms/components/FormSubmissions.vue
(9 hunks)client/components/open/tables/OpenTable.vue
(3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- client/components/open/tables/OpenTable.vue
🧰 Additional context used
🪛 GitHub Check: Run client linters
client/components/open/components/RecordOperations.vue
[warning] 2-2:
'orientation' should be on a new line
client/components/open/forms/components/FormSubmissions.vue
[warning] 16-16:
Attribute "v-model:display-columns" should go before ":columns"
[warning] 17-17:
Attribute "v-model:wrap-columns" should go before ":columns"
client/components/open/forms/components/FormColumnsSettingsModal.vue
[warning] 8-8:
'class' should be on a new line
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Build the Nuxt app
🔇 Additional comments (3)
client/components/open/components/RecordOperations.vue (1)
2-17
: LGTM! UI components upgrade improves consistency.The changes effectively migrate from raw HTML buttons to the design system's
UButtonGroup
andUButton
components, maintaining functionality while improving UI consistency.🧰 Tools
🪛 GitHub Check: Run client linters
[warning] 2-2:
'orientation' should be on a new lineclient/components/open/forms/components/FormSubmissions.vue (1)
11-20
: LGTM! Clean modal integration.The FormColumnsSettingsModal integration is well-structured with proper prop bindings and event handling.
🧰 Tools
🪛 GitHub Check: Run client linters
[warning] 16-16:
Attribute "v-model:display-columns" should go before ":columns"
[warning] 17-17:
Attribute "v-model:wrap-columns" should go before ":columns"client/components/open/forms/components/FormColumnsSettingsModal.vue (1)
233-242
: LGTM! Efficient column update handling.The
onChangeDisplayColumns
function effectively preserves column widths while updating visibility.
Summary by CodeRabbit