-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
fix(nc-gui): form view elements over the attachment/pdf viewer #9867
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
fix(nc-gui): form view elements over the attachment/pdf viewer #9867
Conversation
📝 WalkthroughWalkthroughThe changes in this pull request focus on enhancing the form handling functionality within the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
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: 2
🧹 Outside diff range and nitpick comments (3)
packages/nc-gui/components/smartsheet/Form.vue (3)
Line range hint
1-39
: Consider organizing imports and dependencies more efficientlyThe component has quite a few dependencies which could impact load time and maintainability. Consider:
- Lazy loading non-critical dependencies
- Grouping related imports together (e.g., all UI components, all types, all utilities)
<script setup lang="ts"> + // UI Components import Draggable from 'vuedraggable' import { Pane, Splitpanes } from 'splitpanes' import 'splitpanes/dist/splitpanes.css' + // Utilities import tinycolor from 'tinycolor2' + // Types import { type AttachmentResType, type ColumnType, // ... rest of types } from 'nocodb-sdk'
Line range hint
365-404
: Improve error handling in form submissionThe current error handling has several issues:
- Errors are logged but the function continues execution
- Generic error message doesn't help users understand what's wrong
- No proper error propagation to the UI
Consider this improved implementation:
async function submitForm() { if (!isUIAllowed('dataInsert')) return try { for (const col of localColumns.value) { if (col.show && col.title && isRequired(col, col.required) && formState.value[col.title] === undefined) { formState.value[col.title] = null } if ((!col.visible || !col.show) && col.title) { delete formState.value[col.title] delete state.value[col.title] } } await validate( Object.keys(formState.value) .map((title) => fieldMappings.value[title]) .filter((v) => v !== undefined), ) - } catch (e: any) { - console.error(e) - if (e?.errorFields?.length) { - message.error(t('msg.error.someOfTheRequiredFieldsAreEmpty')) - return - } + } catch (e: any) { + console.error('Form validation failed:', e) + if (e?.errorFields?.length) { + const fieldErrors = e.errorFields.map(f => f.name).join(', ') + message.error(t('msg.error.validationFailed', { fields: fieldErrors })) + return + } + message.error(t('msg.error.submissionFailed')) + return } const res = await insertRow({ row: { ...formState.value, ...state.value }, oldRow: {}, rowMeta: { new: true }, }) if (res) { submitted.value = true } + else { + message.error(t('msg.error.submissionFailed')) + } }
Line range hint
509-512
: Refactor field visibility logic for better maintainabilityThe
shouldSkipColumn
function mixes multiple concerns and has hardcoded field types. This could make maintenance difficult as new field types are added.-function shouldSkipColumn(col: Record<string, any>) { - return ( - isDbRequired(col) || !!col.required || (!!col.rqd && !col.cdf) || col.uidt === UITypes.QrCode || col.uidt === UITypes.Barcode - ) +} + +const IMMUTABLE_FIELD_TYPES = [UITypes.QrCode, UITypes.Barcode] as const + +function isImmutableFieldType(fieldType: string): boolean { + return IMMUTABLE_FIELD_TYPES.includes(fieldType as typeof IMMUTABLE_FIELD_TYPES[number]) +} + +function shouldSkipColumn(col: Record<string, any>) { + return ( + isDbRequired(col) || + !!col.required || + (!!col.rqd && !col.cdf) || + isImmutableFieldType(col.uidt) + ) }
Change Summary
Provide summary of changes with issue number if any.
Change type
Test/ Verification
Provide summary of changes.
Additional information / screenshots (optional)
Anything for maintainers to be made aware of