Update ObjectQL components to support all v3.0.1 field types#95
Update ObjectQL components to support all v3.0.1 field types#95
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…v3.0.1 field types Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
…atting Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the ObjectForm and ObjectTable components to fully support all 27 field types defined in ObjectQL v3.0.1, enhancing field property handling and adding type-aware formatting for better data representation.
Changes:
- Extended ObjectForm field type mapping from basic types to comprehensive coverage of all 27 ObjectQL field types
- Enhanced field property handling with proper support for min_length, max_length, multiple, accept, and other field-specific attributes
- Added type-aware column formatting in ObjectTable for dates, booleans, numbers, files, lookups, and URLs
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/plugin-object/src/ObjectForm.tsx | Expanded field type mappings to cover all 27 ObjectQL v3.0.1 types, added property handling for file uploads, contact fields, and computed fields, and introduced formatFileSize helper |
| packages/plugin-object/src/ObjectTable.tsx | Added type-specific column formatters for dates, booleans, numbers, files, relationships, and URLs to improve data display |
| column.cell = (value: any) => { | ||
| if (!value) return '-'; | ||
| if (Array.isArray(value)) { | ||
| const count = value.length; |
There was a problem hiding this comment.
The pluralization logic is incorrect. When value.length is 1, it will display 'file(s)' instead of 'file'. Consider using conditional logic: ${value.length} ${field.type}${value.length !== 1 ? 's' : ''}
| const count = value.length; | |
| return `${value.length} ${field.type}${value.length !== 1 ? 's' : ''}`; |
| formField.accept = field.accept?.join(','); | ||
| // Add validation hints for file size and dimensions | ||
| if (field.max_size) { | ||
| const sizeHint = `Max size: ${formatFileSize(field.max_size)}`; |
There was a problem hiding this comment.
String concatenation for description updates could lead to duplicate size hints if this logic runs multiple times. Consider checking if the description already contains the size hint before appending, or use a more structured approach to store metadata separately from user-facing descriptions.
| const sizeHint = `Max size: ${formatFileSize(field.max_size)}`; | |
| const sizeHint = `(Max size: ${formatFileSize(field.max_size)})`; | |
| const currentDescription = formField.description || ''; | |
| if (!currentDescription.includes(sizeHint)) { | |
| formField.description = currentDescription | |
| ? `${currentDescription} ${sizeHint}` | |
| : sizeHint; | |
| } |
| return '0 B'; | ||
| } |
There was a problem hiding this comment.
The formatFileSize function uses toFixed() which returns a string, then interpolates it into another string. This can result in trailing zeros (e.g., '5.0 MB'). Consider using Number(size.toFixed(...)) or format the number differently to avoid unnecessary decimal points for whole numbers.
| return '0 B'; | |
| } | |
| const decimals = unitIndex > 0 ? 1 : 0; | |
| const formattedSize = Number(size.toFixed(decimals)); | |
| return `${formattedSize} ${units[unitIndex]}`; |
📦 Bundle Size Report
Size Limits
|
…backs Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
📦 Bundle Size Report
Size Limits
|
|
✅ All checks passed!
|
|
✅ All checks passed!
|
📦 Bundle Size Report
Size Limits
|
| // For relationship fields, display the name property if available | ||
| column.cell = (value: any) => { | ||
| if (!value) return '-'; | ||
| if (typeof value === 'object' && value !== null) { |
Check warning
Code scanning / CodeQL
Comparison between inconvertible types Warning
|
✅ All checks passed!
|
The ObjectForm and ObjectTable components only supported a subset of ObjectQL field types, missing newly added types like
markdown,html,time,phone,image,file,location,formula,summary,auto_number,object,vector, andgrid.Changes
ObjectForm
formula,summary,auto_number) to read-onlyinputTypeattributes foremail,phone,url,password,timemaxLength→max_length,minLength→min_lengthfile/imagefieldsObjectTable
date,boolean,number)file/imagefields showing count with proper pluralizationlookup/master_detailfields with safe object fallbackExample
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.