-
-
Notifications
You must be signed in to change notification settings - Fork 729
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,20 +37,24 @@ | |
= f.label :on_demand do | ||
= f.check_box :on_demand, 'data-action': 'change->toggle-control#disableIfPresent change->popout#closeIfChecked' | ||
= t(:on_demand) | ||
%td.col-producer.naked_inputs | ||
%td.col-producer.field.naked_inputs | ||
= render(SearchableDropdownComponent.new(form: f, | ||
name: :supplier_id, | ||
aria_label: t('.producer_field_name'), | ||
options: producer_options, | ||
selected_option: variant.supplier_id, | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Great, thanks for adding |
||
%td.col-category.field.naked_inputs | ||
= render(SearchableDropdownComponent.new(form: f, | ||
name: :primary_taxon_id, | ||
options: category_options, | ||
selected_option: variant.primary_taxon_id, | ||
aria_label: t('.category_field_name'), | ||
placeholder_value: t('admin.products_v3.filters.search_for_categories'))) | ||
include_blank: t('admin.products_v3.filters.select_category'), | ||
placeholder_value: t('admin.products_v3.filters.select_category'))) | ||
= error_message_on variant, :primary_taxon | ||
%td.col-tax_category.field.naked_inputs | ||
= render(SearchableDropdownComponent.new(form: f, | ||
name: :tax_category_id, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,13 @@ | |
include AuthenticationHelper | ||
include WebHelper | ||
|
||
let!(:supplier) { create(:supplier_enterprise) } | ||
let!(:taxon) { create(:taxon) } | ||
|
||
describe "creating a new product" do | ||
let!(:stock_location) { create(:stock_location, backorderable_default: false) } | ||
let!(:supplier) { create(:supplier_enterprise) } | ||
let!(:distributor) { create(:distributor_enterprise) } | ||
let!(:shipping_category) { create(:shipping_category) } | ||
let!(:taxon) { create(:taxon) } | ||
|
||
before { visit_products_page_as_admin } | ||
|
||
|
@@ -81,6 +82,10 @@ | |
find('input[id$="_display_as"]').fill_in with: "2 grams" | ||
find('button[aria-label="On Hand"]').click | ||
find('input[id$="_price"]').fill_in with: "11.1" | ||
|
||
select supplier.name, from: 'Producer' | ||
select taxon.name, from: 'Category' | ||
Comment on lines
+86
to
+87
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changes here were to fix failing specs |
||
|
||
if stock == "on_hand" | ||
find('input[id$="_on_hand"]').fill_in with: "66" | ||
elsif stock == "on_demand" | ||
|
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 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,
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.
Thanks a lot, @dacook and @rioug for identifying this one.
I noticed that the columns preference default for the category column in old screens have
visible: false
Not so sure why we have this by default but I will gladly appreciate your input on this again.
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.
Yeah that's fine, if we get complaint we can always tell them to use the new screen 😉