-
Notifications
You must be signed in to change notification settings - Fork 26
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
[#4019] Mapping file uploads in Object API registration (frontend) #4036
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4036 +/- ##
=======================================
Coverage 96.06% 96.06%
=======================================
Files 728 728
Lines 22847 22854 +7
Branches 2648 2650 +2
=======================================
+ Hits 21947 21954 +7
Misses 637 637
Partials 263 263 ☔ View full report in Codecov by Sentry. |
if (componentDefinition && componentDefinition.type === 'file') { | ||
// If it is, and it has multiple == True, then type is array | ||
if (componentDefinition.multiple) return {type: 'array'}; | ||
// Otherwise it's string (URL of the document) | ||
return {type: 'string', format: 'uri'}; | ||
} |
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.
I made this as a 'special case'. I thought that if in the future we have more special cases we can refactor this.
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.
I'm wondering if this special case should be moved in the ObjectsApiVariableConfigurationEditor
component instead 🤔, as it is purely hardcoding a json schema.
Or maybe instead of passing the array of components
, only pass the relevant component
to this function?
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.
more accurate would also be:
type: array
items:
type: string
format: uri
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.
I think leaving it in here is more appropriate, it fits the idea of providing the json schema for a given variable. The fact that the schema is hard coded doesn't really matter, it's the same how your fallback is a hardcoded type: string
, no?
src/openforms/js/components/admin/form_design/variables/VariablesEditor.stories.js
Show resolved
Hide resolved
src/openforms/js/components/admin/form_design/variables/VariablesEditor.stories.js
Outdated
Show resolved
Hide resolved
The variable for file components has type 'array', but if only one file can be uploaded we want to be able to map it to attributes of type 'string' in the JSON schema. If multiple files can be uploaded, then we map it to 'array' attributes
cb06a67
to
a5a4d5d
Compare
Fixes #4019 (partially)