-
-
Notifications
You must be signed in to change notification settings - Fork 763
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 improvements #5837
Form improvements #5837
Conversation
✅ Deploy Preview for inventree-web-pui-preview canceled.
|
@SchrodingersGat , @matmair this would be ready to review. I know you have a lot of other things todo with PUI, but this would be the last improvement to CUI to raise the printing options to a next level. |
@wolflu05 an interesting approach! Does this mean that you have to query the server on each field change, to request the new sub-field information? |
Exactly @SchrodingersGat , an OPTIONS request is sent on any field change of a field that is included in the depends_on list. For text fields, a change is you edit and then click outside of the field (I used the onEdit handler for that). That way we can easily create different forms based on other values. |
Ok, that seems reasonable. Will you integrate support for this into PUI too? |
I actually tried, but didn't got my way around. Now after I refactored the forms in #5897 I may understand the logic. If you really wish this should be done now I can see what I can do, otherwise the plan was to finish the machine integration first for what I would need this PR. But that's up to you. |
I'm not expecting the PUI implement straight away - but it should be kept in mind... |
I'm happy to merge this in for now though, thanks! |
const processField = (name, field, optionsField) => { | ||
if (field.type === "nested object") { | ||
for (const [k, v] of Object.entries(field.children)) { | ||
processField(`${name}__${k}`, v, optionsField.children[k]); |
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.
@wolflu05 this has broken existing form handling. e.g. try to edit an existing purchase order:
Please look into this one ASAP
@wolflu05 please see comment above - this PR has broken some forms |
This reverts commit 0d193d8.
Looks like there are some other on-flow issues too. For now I will revert - #5913 - and we will need to re-asssess |
Sorry that this introduced some errors, I really thought I tested with the part form and it worked. I'll definitely take a look and fix that. Good that you reverted the changes. |
This PR adds a few things which improve the form framework. This is hopefully the last PR that is needed to continue #4824.
Specifically the following is changed:
DependentField
is added. To test this new serializer field, the printing plugin code at the end can be used. This is actually a sample implementation of how I imagine the machine printing to work.DependentField
Bildschirmaufnahme.2023-11-02.um.13.23.18.mov
I actually tried to implement the nested serializer field in PUI, but I sadly have not found my way around the PUI form framework code, so this would be another task.
Please let me know what you think of that implementation and if there's anything I should change.
Sample printing plugin code for testing