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

refs #11973 - remove SKU from products column #12650

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions app/assets/javascripts/admin/bulk_product_update.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,6 @@ filterSubmitProducts = (productsToFilter) ->
variantHasUpdatableProperty = result.hasUpdatableProperty
filteredVariants.push filteredVariant if variantHasUpdatableProperty

if product.hasOwnProperty("sku")
filteredProduct.sku = product.sku
hasUpdatableProperty = true
if product.hasOwnProperty("name")
filteredProduct.name = product.name
hasUpdatableProperty = true
Expand Down
3 changes: 0 additions & 3 deletions app/views/admin/products_v3/_product_row.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
= f.hidden_field :id
= f.text_field :name, 'aria-label': t('admin.products_page.columns.name')
= error_message_on product, :name
%td.col-sku.field.naked_inputs
= f.text_field :sku, 'aria-label': t('admin.products_page.columns.sku')
= error_message_on product, :sku
%td.col-unit_scale.field.naked_inputs{ 'data-controller': 'toggle-control', 'data-toggle-control-match-value': 'items' }
= f.hidden_field :variant_unit
= f.hidden_field :variant_unit_scale
Expand Down
2 changes: 0 additions & 2 deletions app/views/admin/products_v3/_table.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
-# The `min-width` property works in Chrome but not Firefox so is considered progressive enhancement.
%col.col-image{ width:"56px" }= # (image size + padding)
%col.col-name{ style:"min-width: 6em" }= # (grow to fill)
%col.col-sku{ width:"8%", style:"min-width: 6em" }
%col.col-unit_scale{ width:"8%" }
%col.col-unit{ width:"8%" }
%col.col-price{ width:"5%", style:"min-width: 5em" }
Expand Down Expand Up @@ -52,7 +51,6 @@
%th.col-image.align-left= # image
= render partial: 'spree/admin/shared/stimulus_sortable_header',
locals: { column: :name, sorted: params.dig(:q, :s), default: 'name asc' }
%th.align-left.col-sku.with-input= t('admin.products_page.columns.sku')
%th.align-left.col-unit_scale.with-input= t('admin.products_page.columns.unit_scale')
%th.align-left.col-unit.with-input= t('admin.products_page.columns.unit')
%th.align-left.col-price.with-input= t('admin.products_page.columns.price')
Expand Down
3 changes: 0 additions & 3 deletions app/views/admin/products_v3/_variant_row.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
= f.hidden_field :id
= f.text_field :display_name, 'aria-label': t('admin.products_page.columns.name'), placeholder: variant.product.name
= error_message_on variant, :display_name
%td.col-sku.field.naked_inputs
= f.text_field :sku, 'aria-label': t('admin.products_page.columns.sku')
= error_message_on variant, :sku
%td.col-unit_scale
-# empty
%td.col-unit.field.popout{'data-controller': "popout", 'data-popout-update-display-value': "false"}
Expand Down
2 changes: 0 additions & 2 deletions app/views/spree/admin/products/index/_products_head.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
%col.actions
%col.image{ "ng-show": 'columns.image.visible' }
%col.producer{ "ng-show": 'columns.producer.visible' }
%col.sku{ "ng-show": 'columns.sku.visible' }
%col.name{ "ng-show": 'columns.name.visible' }
%col.unit{ "ng-show": 'columns.unit.visible' }
%col.display_as{ "ng-show": 'columns.unit.visible' }
Expand All @@ -24,7 +23,6 @@
= t(:expand_all)
%th.image{ 'ng-show' => 'columns.image.visible' }
%th.producer{ 'ng-show' => 'columns.producer.visible' }=t('admin.producer')
%th.sku{ 'ng-show' => 'columns.sku.visible' }=t('admin.sku')
%th.name{ 'ng-show' => 'columns.name.visible' }
= render partial: 'spree/admin/shared/sortable_header', locals: {column_name: 'name'}
%th.unit{ 'ng-show' => 'columns.unit.visible' }=t('.unit')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
%a{class: 'image-modal'}
%img{'ng-src' => '{{ product.thumb_url }}'}
%td.producer{ 'ng-show' => 'columns.producer.visible' }
%td.sku{ 'ng-show' => 'columns.sku.visible' }
%input{ 'ng-model' => "product.sku", :name => 'product_sku', 'ofn-track-product' => 'sku', :type => 'text' }
%td.name{ 'ng-show' => 'columns.name.visible' }
%input{ 'ng-model' => "product.name", :name => 'product_name', 'ofn-track-product' => 'name', :type => 'text' }
%td.unit{ 'ng-show' => 'columns.unit.visible' }
Expand Down
6 changes: 2 additions & 4 deletions lib/open_food_network/column_preference_defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ def products_index_columns
{
image: { name: I18n.t("admin.image"), visible: true },
producer: { name: I18n.t("admin.producer"), visible: true },
sku: { name: I18n.t("admin.sku"), visible: false },
name: { name: I18n.t("admin.name"), visible: true },
unit: { name: I18n.t("#{node}.unit"), visible: true },
name: { name: I18n.t("admin.name"), visible: true },
unit: { name: I18n.t("#{node}.unit"), visible: true },
price: { name: I18n.t("admin.price"), visible: true },
on_hand: { name: I18n.t("admin.on_hand"), visible: true },
on_demand: { name: I18n.t("admin.on_demand"), visible: true },
Expand All @@ -82,7 +81,6 @@ def products_v3_index_columns
{
image: { name: t(:image), visible: true },
name: { name: t(:name), visible: true },
sku: { name: t(:sku), visible: true },
unit: { name: t(:unit), visible: true },
unit_scale: { name: t(:unit_scale), visible: true },
price: { name: t(:price), visible: true },
Expand Down
9 changes: 2 additions & 7 deletions spec/system/admin/bulk_product_update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -340,23 +340,21 @@
t1 = FactoryBot.create(:taxon)
t2 = FactoryBot.create(:taxon)
p = FactoryBot.create(:product, supplier_id: s1.id, variant_unit: 'volume',
variant_unit_scale: 1, primary_taxon: t2, sku: "OLD SKU")
variant_unit_scale: 1, primary_taxon: t2)

login_as_admin
visit spree.admin_products_path

toggle_columns /^Category?/i, "Inherits Properties?", "SKU"
toggle_columns /^Category?/i, "Inherits Properties?"

within "tr#p_#{p.id}" do
expect(page).to have_field "product_name", with: p.name
expect(page).to have_select "variant_unit_with_scale", selected: "Volume (L)"
expect(page).to have_checked_field "inherits_properties"
expect(page).to have_field "product_sku", with: p.sku

fill_in "product_name", with: "Big Bag Of Potatoes"
select "Weight (kg)", from: "variant_unit_with_scale"
uncheck "inherits_properties"
fill_in "product_sku", with: "NEW SKU"
end

click_button 'Save Changes', match: :first
Expand All @@ -367,7 +365,6 @@
expect(p.variant_unit).to eq "weight"
expect(p.variant_unit_scale).to eq 1000 # Kg
expect(p.inherits_properties).to be false
expect(p.sku).to eq "NEW SKU"
end

it "updating a product with a variant unit of 'items'" do
Expand Down Expand Up @@ -405,8 +402,6 @@
expect(page).to have_selector "a.view-variants", count: 1
find("a.view-variants").click

toggle_columns "SKU"

expect(page).to have_field "variant_sku", with: "VARIANTSKU"
expect(page).to have_field "variant_price", with: "3.0"
expect(page).to have_field "variant_unit_value_with_description", with: "250 (bottle)"
Expand Down
1 change: 0 additions & 1 deletion spec/system/admin/products_v3/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
within ".products" do
# displays table header
expect(page).to have_selector "th", text: "Name"
expect(page).to have_selector "th", text: "SKU"
expect(page).to have_selector "th", text: "Unit scale"
expect(page).to have_selector "th", text: "Unit"
expect(page).to have_selector "th", text: "Price"
Expand Down
Loading