Added keep open boolean field to Stock Location modal form#11074
Added keep open boolean field to Stock Location modal form#11074SchrodingersGat merged 24 commits intoinventree:masterfrom
Conversation
✅ Deploy Preview for inventree-web-pui-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
| }, | ||
| location_type: {} | ||
| location_type: {}, | ||
| keep_form_open: keepFormOpenField(create) |
There was a problem hiding this comment.
I do not really like this method here, I would prefer a generic approach here. What do you mean @SchrodingersGat ?
There was a problem hiding this comment.
It does seem out of step with how are pass other parameters. It could be a simple keep_form_open attribute
There was a problem hiding this comment.
Can't we have this parameter for all forms on InvenTree (if it's not disabled for that form) and then don't mix the form fields with the keep open toggle we render independently at the bottom of keep open is available for that form?
… field definitions
|
Ok, I've rewrited it a little. What about now? Calling method is gone. I had to still leave there some parameter passing because I didn't figured out how to hide this field in edit forms in some other way. |
|
Ok, I now rewritted it as a form property, enabled on create forms. |
matmair
left a comment
There was a problem hiding this comment.
LGTM; thanks for the contribution
|
@spamik it looks like your current implementation does not actually use the "keep open" feature in any forms yet - is this intentional? |
|
@SchrodingersGat It shouldn't be; I added keepFormOpenOption=true to CreateApiModalForm so this option should be visible on all create forms (and at least it looks like that when I was testing it). But it's for sure possible to change this option on create form and enable it only on specific forms. |
|
Please address this issue: |
|
@spamik I have pulled this code branch down to test, and I notice a real performance hit when toggling the "keep form open" switch. When compared to a normal boolean input within the form (which toggles very quickly) there is a significant slow-down / lag which is introduced into the browser - especially when quickly toggling the "keep form open" input multiple times. I have not had a chance to try to profile this yet, but this will need to be addressed before we can merge. |
|
I'll try to look on both of the issues. Regarding the performance hit - any idea from experienced react developers what can cause it? Because I've just used mantis switch component and on onchange event it's changing boolean property so I'm really wondering what can be wrong with this part :-) |
…d it's enabled on selected forms.
|
@spamik very nice, happy with this now! Just some very small changes to request: Changelog
Docs
|
|
Done :-) |
|
@spamik thanks! One last thing (sorry!) - I note that there are no test added for this new feature - can you please add a playwright test to ensure that it is functioning as expected: https://docs.inventree.org/en/stable/develop/react-frontend/#testing |
|
Please add a test, fix conflicts, and I'm happy to merge this in! |
|
Yep, I'll try that. Maybe it will take a little time - playwright is another technology I didn't used so far :-) |
|
I've added new test case to pui_forms_spec.ts. Seem it's working as I was testing it by playing with test code. But look if it make sense; I was little fithing with it :-) |
|
@spamik thanks, the test looks good! Please merge in master / fix conflicts here |
|
Conflict should be resolved now |
|
@spamik thanks - just looks like the added test is broken! |
|
@SchrodingersGat It's weird, I was running playwright test locally in devcontainer and it was running fine (I even played with commenting parts of test to be sure it will fail if miss some step). I lookend in logs in QC / Tests and it's failing on start when clicking on switch. It seems that for some reason this switch is missing when it's running in CI/CD pipeline. Is there some way how can I build the same image like what is used in CI/CD pipeline so I can look how app is really looking in it? |
|
Without exact: true it was failing even on my setup... I thought that it was because of duplicity with the description. If I look on your screenshot - I guess that if I use getByRole('switch', ...) selector as it is described here it should be working and it's better than generic getByText, right? |
|
Worth a try at least! |
|
@spamik thanks for this contribution! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #11074 +/- ##
=======================================
Coverage 91.43% 91.43%
=======================================
Files 962 962
Lines 49762 49762
=======================================
Hits 45500 45500
Misses 4262 4262
🚀 New features to boost your workflow:
|
- Following inventree#11074 - Option to keep allocation forms open
- Following #11074 - Option to keep allocation forms open





Added new boolean form field to Stock Location modal form which allows to keep form open after submitting instead closing it and redirecting browser to new stock location. This was discussed in this FR: #10412