Remove views code that tests for the existence of product variants

A product always has the standard variant, the only case where a product will not have variants is immediatly after creation and before being saved
This commit is contained in:
Luis Ramos
2020-06-01 14:09:14 +01:00
parent e7828e107b
commit 072da7316e
3 changed files with 28 additions and 70 deletions

View File

@@ -15,15 +15,13 @@
%colgroup
%col{ style: "width: 5%" }/
%col{ style: "width: 10%" }/
- if @product.has_variants?
%col{ style: "width: 25%" }/
%col{ style: "width: 25%" }/
%col{ style: "width: 45%" }/
%col{ style: "width: 15%" }/
%thead
%tr
%th{:colspan => "2"}= t('spree.thumbnail')
- if @product.has_variants?
%th= Spree::Variant.model_name.human
%th= Spree::Variant.model_name.human
%th= t('spree.alt_text')
%th.actions
%tbody
@@ -35,8 +33,7 @@
%span.handle
%td
= link_to image_tag(image.attachment.url(:mini)), image.attachment.url(:product)
- if @product.has_variants?
%td= options_text_for(image)
%td= options_text_for(image)
%td= image.alt
%td.actions
= link_to_with_icon 'icon-edit', t('spree.edit'), edit_admin_product_image_url(@product, image), no_text: true, data: { action: 'edit'}

View File

@@ -43,37 +43,6 @@
.clear
- unless @product.has_variants?
= f.field_container :sku do
= f.label :sku, t(:sku)
= f.text_field :sku, :size => 16
.alpha.two.columns
= f.field_container :on_hand do
= f.label :on_hand, t(:on_hand)
= f.number_field :on_hand, :min => 0
.omega.two.columns
= f.field_container :on_demand, :class => ['checkbox'] do
%label
= f.check_box :on_demand
= t(:on_demand)
.clear
%ul#shipping_specs
%li#shipping_specs_weight_field.field.alpha.two.columns
= f.label :weight, t(:weight)
= f.text_field :weight, :size => 4
%li#shipping_specs_height_field.field.omega.two.columns
= f.label :height, t(:height)
= f.text_field :height, :size => 4
%li#shipping_specs_width_field.field.alpha.two.columns
= f.label :width, t(:width)
= f.text_field :width, :size => 4
%li#shipping_specs_depth_field.field.omega.two.columns
= f.label :depth, t(:depth)
= f.text_field :depth, :size => 4
= f.field_container :shipping_categories do
= f.label :shipping_category_id, t(:shipping_categories)
= f.collection_select(:shipping_category_id, @shipping_categories, :id, :name, { :include_blank => 'None' }, { :class => 'select2' })

View File

@@ -3,40 +3,32 @@
= render partial: 'spree/admin/shared/product_tabs', locals: {current: 'Variants'}
#new_variant
- if @variants.any?
%table.index.sortable{"data-sortable-link" => update_positions_admin_product_variants_path(@product)}
%colgroup
%col{style: "width: 5%"}/
%col{style: "width: 25%"}/
%col{style: "width: 20%"}/
%col{style: "width: 20%"}/
%col{style: "width: 15%"}/
%col{style: "width: 15%"}/
%thead
%tr
%th{colspan: "2"}= t('.options')
%th= t('.price')
%th= t('.sku')
%th.actions
%tbody
- @variants.each do |variant|
%tr{id: spree_dom_id(variant), class: cycle('odd', 'even'), style: "#{"color:red;" if variant.deleted? }" }
%td.no-border
%span.handle
%td= variant.full_name
%td.align-center= variant.display_price.to_html
%td.align-center= variant.sku
%td.actions
= link_to_edit(variant, no_text: true) unless variant.deleted?
= link_to_delete(variant, no_text: true) unless variant.deleted?
- unless @product.has_variants?
%tr
%td{colspan: "5"}= t(:none)
- else
.alpha.twelve.columns.no-objects-found
= t('.no_results')
\.
%table.index.sortable{"data-sortable-link" => update_positions_admin_product_variants_path(@product)}
%colgroup
%col{style: "width: 5%"}/
%col{style: "width: 25%"}/
%col{style: "width: 20%"}/
%col{style: "width: 20%"}/
%col{style: "width: 15%"}/
%col{style: "width: 15%"}/
%thead
%tr
%th{colspan: "2"}= t('.options')
%th= t('.price')
%th= t('.sku')
%th.actions
%tbody
- @variants.each do |variant|
%tr{id: spree_dom_id(variant), class: cycle('odd', 'even'), style: "#{"color:red;" if variant.deleted? }" }
%td.no-border
%span.handle
%td= variant.full_name
%td.align-center= variant.display_price.to_html
%td.align-center= variant.sku
%td.actions
= link_to_edit(variant, no_text: true) unless variant.deleted?
= link_to_delete(variant, no_text: true) unless variant.deleted?
- if @product.empty_option_values?
%p.first_add_option_types.no-objects-found