openfoodnetwork icon indicating copy to clipboard operation
openfoodnetwork copied to clipboard

Product creation: Minor improvements of errors and mandatory information

Open drummer83 opened this issue 2 years ago • 9 comments

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. grafik
  • Add red highlighting and little text 'can't be blank' under the fields
    • unit size
    • unit value
    • product category grafik
  • remove red star on Tax category (default value is preselected) grafik
  • remove red star on Supplier (first supplier is preselected) grafik
  • remove the option to select a blank 'unit size' in the dropdown (in 'product category' dropdown it is not possible to select 'blank') Peek 2022-06-11 01-46

Expected Behavior

See above.

Actual Behaviour

See above.

Steps to Reproduce

  1. Start to create a new product on page /admin/products/new.
  2. Leave fields with mandatory information blank (e.g. the product category).
  3. Click 'Create'.
  4. Observe the error messages and red highlighting.

Animated Gif/Screenshot

Peek 2022-06-11 01-40

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 avatar Jun 10 '22 23:06 drummer83

@drummer83 can I give this a shot?

uzorjchibuzor avatar Jun 15 '22 14:06 uzorjchibuzor

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 avatar Jun 15 '22 14:06 drummer83

@drummer83 May I try removing red stars part?

vedant-z avatar Jun 15 '22 17:06 vedant-z

drummer83 May I try removing red stars part?

@vedant-z

That might cause a merge conflict with what I am trying to do.

uzorjchibuzor avatar Jun 15 '22 17:06 uzorjchibuzor

Ok I will leave this to you @uzorjchibuzor

vedant-z avatar Jun 15 '22 18:06 vedant-z

let me handle this :)

abdellani avatar Oct 13 '22 08:10 abdellani

Sure thanks @abdellani , go ahead 🎉 Don't hesitate to ask any questions here if you are stuck 👍

sigmundpetersen avatar Oct 13 '22 08:10 sigmundpetersen

Please also have a look at the previous PR attempt by another contributor here #9317

sigmundpetersen avatar Oct 13 '22 08:10 sigmundpetersen

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 avatar Oct 13 '22 11:10 abdellani

@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. 👍🏻

drummer83 avatar Oct 14 '22 07:10 drummer83