openfoodnetwork
openfoodnetwork copied to clipboard
Product creation: Minor improvements of errors and mandatory information
Description
Note: This issue can be split into several even smaller issues to be solved. Every tiny pull request is welcome!
During testing of #9177 several minor inconsistencies have been found see comment. Here they are:
- Add "unit value" in the content of the red box at the top of the page if it was left blank during product creation. Currently this is only displayed if a 'unit size' had been selected in the first place.
- Add red highlighting and little text 'can't be blank' under the fields
- unit size
- unit value
- product category
- remove red star on Tax category (default value is preselected)
- remove red star on Supplier (first supplier is preselected)
- remove the option to select a blank 'unit size' in the dropdown (in 'product category' dropdown it is not possible to select 'blank')
Expected Behavior
See above.
Actual Behaviour
See above.
Steps to Reproduce
- Start to create a new product on page /admin/products/new.
- Leave fields with mandatory information blank (e.g. the product category).
- Click 'Create'.
- Observe the error messages and red highlighting.
Animated Gif/Screenshot
Workaround
Severity
bug-s4: it's annoying, but you can use it
Your Environment
- Version used:
- Browser name and version:
- Operating System and version (desktop or mobile):
Possible Fix
@drummer83 can I give this a shot?
Hi @uzorjchibuzor, and welcome! Yes, of course, I will assign it to you! Don't hesitate to ask questions here or in our Slack in case you get stuck!
Looking forward to your contributions! 🥳
@drummer83 May I try removing red stars part?
drummer83 May I try removing red stars part?
@vedant-z
That might cause a merge conflict with what I am trying to do.
Ok I will leave this to you @uzorjchibuzor
let me handle this :)
Sure thanks @abdellani , go ahead 🎉 Don't hesitate to ask any questions here if you are stuck 👍
Please also have a look at the previous PR attempt by another contributor here #9317
From the product model, unit_value
is only validated when the variant unit (unit size) is selected.
validates :unit_value, presence: { if: ->(p) { %w(weight volume).include? p.variant_unit } }
So, if we submit an empty form. I believe we should not see an error related to that field. Is that correct?
@abdellani There is some complexity around this because for 'unit value = item' the 'unit size' is not mandatory anymore. Unit size is set to '1' unless you type something else. To be honest, I don't really understand why it is that way. To answer your question: Yes, that's my understanding as well. 👍🏻