-
Notifications
You must be signed in to change notification settings - Fork 1
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
Form schema update #1937
base: master
Are you sure you want to change the base?
Form schema update #1937
Conversation
adminOnly?: boolean; | ||
ownerOnly?: boolean; | ||
renderFieldOnly?: boolean; |
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.
document these
adminOnly?: boolean; | ||
ownerOnly?: boolean; | ||
renderFieldOnly?: boolean; |
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.
why not re-use the json-schema readOnly
definition?
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.
readOnly
implies that the field should be visible, but not editable. A better fit would be hide
, however that could prevent us from using more advanced forms in the future. Creating our own definition provides a more clear message of the intent of the field, and does not break any future compatibility with ngx-formly
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.
The point of these schema definitions is that they're read from our swagger/openapi document. There is not an equivalent field there - in fact we use readOnly for this purpose.
You haven't explained the difference between renderFieldOnly and readOnly either
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.
renderFieldOnly
completely removes a field from the form, and is only used by the render field component. It should not be rendered in the form, as it can cause issues in the case of associated models. readOnly
would imply that the form contains the field, but the field was disabled.
As for reading these values from swagger/opernapi, as far as I was aware, we had dropped that constraint as it had little progress. However, given how the DetailViewComponent and RenderFieldComponent work, I suspect they will not be fully compatible regardless, and a more major change is required. Especially if the addition of a renderFieldOnly
property is causing these problems
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.
It should not be rendered in the form, as it can cause issues in the case of associated models.
What issues? Seems like a problem for the models.
would imply that the form contains the field, but the field was disabled.
Do you have a scenario where a field that is currently readOnly
in our API is in actuality only temporarily disabled?
As for reading these values from swagger/opernapi, as far as I was aware, we had dropped that constraint as it had little progress
I am not aware, albeit it is not yet sufficient to serve that purpose for the whole API.
What I did say is that if we abandoned the idea we'd remove ngx-formly altogether.
Especially if the addition of a renderFieldOnly property is causing these problems
It's not causing problems, I just don't understand the need.
Redundant. The whole item is only writeable by an owner.
I've thought about this too, waiting on an official change from open API spec for this: OAI/OpenAPI-Specification#1497 |
Form schema update
Made changes to the form schema to allow for custom behaviours specific to our app
Changes
adminOnly
property for fields which can only be enabled by adminsownerOnly
property for fields which can only be enabled by ownersrenderFieldOnly
property to filter out fields which are not to be used by the formProblems
allowOriginalDownload
is an owner only property on the project model? This should be updated to use the new logiccreateOnly
andupdateOnly
properties in the future for more complex modelsFinal Checklist
npm run lint
)npm run test:all
)