-
-
Notifications
You must be signed in to change notification settings - Fork 724
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
Require variant category and supplier when creating new product variants [OFN-12666] #12690
Require variant category and supplier when creating new product variants [OFN-12666] #12690
Conversation
fb29bb2
to
70a4e06
Compare
@wandji20 hello! can you have a look at rebasing here? Many thanks for one more 🙏 You're on 🔥 |
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.
Thanks for updating this Wandji.
I note that it might have been just as much effort to implement the new requirement in the old admin screen, instead of re-implementing the old behaviour. But I think it's ok 👍
select supplier.name, from: 'Producer' | ||
select taxon.name, from: 'Category' |
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.
This doesn't actually test the newly added requirements, that the producer and category dropdowns were blank at the beginning.
That would have been nice, but I think this is still ok.
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.
Changes here were to fix failing specs
I agree it will be nice to check when the variant category and producer values are blank
placeholder_value: t('admin.products_v3.filters.search_for_producers'))) | ||
include_blank: t('admin.products_v3.filters.select_producer'), | ||
placeholder_value: t('admin.products_v3.filters.select_producer'))) | ||
= error_message_on variant, :supplier |
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.
Great, thanks for adding error_message_on
. It probably should have been added in the beginning.
# Set new variant category to same as last product variant category to keep compactibility with deleted variant callback to set new variant category | ||
newVariantId = $scope.nextVariantId(); | ||
newVariantCategoryId = product.variants[product.variants.length - 1]?.category_id |
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.
I don't understand why we are doing this, It would make more sense to set the category to blank same as the new screen. I am not sure what you are referring to when you say "to keep compactibility with deleted variant callback to set new variant category"
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.
I am not sure what you are referring to when you say "to keep compactibility with deleted variant callback to set new variant category"
I think he means to maintain the existing behaviour on the old screen. So there would be no apparent change when using the old screen. But as you say,
It would make more sense to set the category to blank same as the new screen
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.
In the old screen the supplier is set to blank, I think it would be better to have a consistent behaviour.
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.
😮 Oh, so this change makes it worse than before? In that case we need to do better.
Wandji would it be hard to make the old screen behave like the new one?
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.
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.
Ok, that's a good point Wandji. If the Category column is hidden by default, it's not intuitive for the user to choose it.
I just tried it out and can see what you mean.
If your PR ensures the old screen maintains the existing behaviour, I think it's ok to proceed as it is. It adds a bit of technical debt, but that's ok because we're planning to remove the old screen later, once the transition to the new screen is complete.
Is that ok with you Gaetan?
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.
Is that ok with you Gaetan?
Yeah that's fine, if we get complaint we can always tell them to use the new screen 😉
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.
Looks good ! thanks @wandji20 🙏
Hey @wandji20 , Thanks for another PR 🙏 Before this change, we can see that:
After staging the PR:
Attempting to save a variant without this information correctly triggers the warning, for these fields: Looking great! Merging. |
Use openfoodfoundation/wishlist#520 Flower Farms code in clokify
What? Why?
Closes Creating a new variant is selecting the first producer and first category of the dropdown #12666
Remove callback to set variant category id on create
Add logic to assign a new variant category to the same as the last variant for thesame product from the old products table
Update specs to select variant producer and category
What should we test?
Updating products (variants) from old admin products table should work as before
Updating products (variants) from v3 admin products table should show errors if producer or category is not selected
Visit ... page.
-
Release notes
Require variant category and supplier when creating new product variants
Changelog Category (reviewers may add a label for the release notes):
Require variant category and supplier when creating new product variant
Dependencies
N/A
Documentation updates
N/A