Skip to content
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

Ensure product category error message is shown when creating new product [OFN-12591] #12671

Merged
merged 2 commits into from
Aug 6, 2024

Conversation

wandji20
Copy link
Contributor

@wandji20 wandji20 commented Jul 15, 2024

What? Why?

What should we test?

Creating a product without a category will display the proper error message
Creating a product without a producer will display the proper error message

Release notes

Add an error message when creating a new product without a product category or without producer

Changelog Category (reviewers may add a label for the release notes):

  • User facing changes
  • Technical changes only

The title of the pull request will be included in the release notes.

Add an error message when creating a new product without a product category

Dependencies

@wandji20 wandji20 force-pushed the wb-OFN-12591 branch 8 times, most recently from c8956d7 to 4f5bce1 Compare July 19, 2024 13:12
@dacook dacook self-requested a review July 22, 2024 01:37
Copy link
Member

@dacook dacook left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, apart from one query for Gaetan. Thank you!

app/models/product_import/entry_processor.rb Outdated Show resolved Hide resolved
app/models/spree/product.rb Show resolved Hide resolved
@rioug rioug added the user facing changes Thes pull requests affect the user experience label Jul 22, 2024
Copy link
Collaborator

@rioug rioug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good effort ! I think it needs a few tweaks to clean it up, see comments below. We are also missing a spec for creating a product without a producer (supplier), could you add that?

Thanks !

app/controllers/spree/admin/products_controller.rb Outdated Show resolved Hide resolved
config/locales/en.yml Show resolved Hide resolved
app/models/spree/product.rb Show resolved Hide resolved
app/models/product_import/entry_processor.rb Outdated Show resolved Hide resolved
@wandji20 wandji20 force-pushed the wb-OFN-12591 branch 3 times, most recently from 11d66d7 to 4f0130e Compare July 22, 2024 14:10
Copy link
Collaborator

@rioug rioug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick turn around. There are still a couple things to iron out see my comments. Sorry about the translations, I somehow missed it was still used 🙏

app/models/product_import/entry_processor.rb Outdated Show resolved Hide resolved
config/locales/en.yml Show resolved Hide resolved
@wandji20 wandji20 force-pushed the wb-OFN-12591 branch 3 times, most recently from 75e095e to 3be0502 Compare July 23, 2024 12:02
Copy link
Collaborator

@rioug rioug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now, Thanks 🙏

@filipefurtad0 filipefurtad0 self-assigned this Jul 25, 2024
@filipefurtad0 filipefurtad0 added pr-staged-fr staging.coopcircuits.fr and removed pr-staged-fr staging.coopcircuits.fr labels Jul 25, 2024
@filipefurtad0
Copy link
Contributor

Hey @wandji20 ,
I see there are conflicts on the .rubocop_todo.yml file. Are you able to fix these?

Moving to In progress, for the time being.

@wandji20
Copy link
Contributor Author

wandji20 commented Aug 1, 2024

Hey @wandji20 , I see there are conflicts on the .rubocop_todo.yml file. Are you able to fix these?

Moving to In progress, for the time being.

For this, I rebased and regenerated .rubocop_todo.yml with bundle exec rubocop --regenerate-todo --no-auto-gen-timestamp

@drummer83 drummer83 self-assigned this Aug 5, 2024
@drummer83 drummer83 added the pr-staged-au staging.openfoodnetwork.org.au label Aug 5, 2024
@drummer83 drummer83 removed their assignment Aug 6, 2024
@drummer83 drummer83 removed the pr-staged-au staging.openfoodnetwork.org.au label Aug 6, 2024
@drummer83 drummer83 self-assigned this Aug 6, 2024
@drummer83 drummer83 added the pr-staged-au staging.openfoodnetwork.org.au label Aug 6, 2024
@drummer83
Copy link
Contributor

Hi @wandji20,
Thank you for yet another PR! Before staging I also couldn't reproduce the error 500 but found that products could be created without variants - just like you mentioned.

I tested this in detail while I was working on it anyway, so you will thing below, which are out of scope for this PR, but I found it worth mentioning for completeness.

Comparison before and after staging the PR

Field Before After
Supplier No error when empty ❌ ❗ Error when empty ✔️ 💪
Product can be created when empty, but no variant created ❌ ❗ Product can't be created ✔️ 💪
No red highlighting at all on error ❌ No red color of field's label on error ❌
Product name Error when empty ✔️ Error when empty ✔️
Unit size Error when empty ✔️ Error when empty ✔️
No red border on error ❌ No red border on error ❌
Value (if variant unit == item) No error when empty (set to '1') ✔️ No error when empty (set to '1') ✔️
Unit name (if variant unit == item) Error when empty ✔️ Error when empty ✔️
Unit name is not kept after error messages ❌ Unit name is not kept after error messages ❌
No red highlighting at all on error ❌ No red highlighting at all on error ❌
Value (if variant unit != item) Error when not a number ✔️ Error when not a number ✔️
No red border on error ❌ No red border on error ❌
Display as (if variant unit != item) No error when empty ✔️ No error when empty ✔️
Product category No error when empty ❌ ❗ Error when empty ✔️ 💪
Product can be created when empty, but no variant created ❌ ❗ Product can't be created ✔️ 💪
No red highlighting at all on error ❌ No red border on error ❌
Price Error when not a number ✔️ Error when not a number ✔️
Unit price Auto-filled ✔️ Auto-filled ✔️
Tax category Pre-selected ✔️ Pre-selected ✔️
Shipping category Pre-selected ✔️ Pre-selected ✔️
Shipping category is not kept after error message ❌ Shipping category is not kept after error message ❌
On hand No error when empty (set to 0) ✔️ No error when empty (set to 0) ✔️
On demand Checkbox only ✔️ Checkbox only ✔️
Image No error when empty ✔️ No error when empty ✔️

Further ideas for improvement

  • Use same 'can't be blank' string for supplier and product category as for e.g. product name.
  • Unify the three different types of drop down menus:
    • Modern design wth pre-filled 'Select a supplier'
    • Modern design without pre-filled information (completely empty)
    • Legacy design (smaller line heights, no highlighting on hover)

General remark

  • Unit value (if variant unit == item) can only be edited on /products, not on the /edit page.

Conclusion

The issue in #12591 is resolved. 💪
There was no regression found within this PR. 🥳
Anything else I found was out of scope of this PR.
We can merge and address the other bits in separate PRs. 🪨

Thanks again for your work!

@drummer83 drummer83 merged commit cb42e7e into openfoodfoundation:master Aug 6, 2024
54 checks passed
@drummer83 drummer83 removed the pr-staged-au staging.openfoodnetwork.org.au label Aug 6, 2024
@drummer83
Copy link
Contributor

@wandji20 I've created #12744 just in case you would like to tackle some of those. No need to address them all at once.
Thanks again!

@wandji20
Copy link
Contributor Author

wandji20 commented Aug 6, 2024

Sure @drummer83
That is fine by me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
user facing changes Thes pull requests affect the user experience
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Error 500 when product category left blank
5 participants