<%= render :partial => 'stock_location_stock_item_template' %> <%= paginate @variants %> <% variants.each do |variant| %> <%- locations_without_items = @stock_item_stock_locations - variant.stock_items.flat_map(&:stock_location) %> <%- display_add_row = locations_without_items.any? && can?(:create, Spree::StockItem) %> <%- row_count = (variant.stock_items.map(&:stock_location) & @stock_item_stock_locations).size %> <%- row_count += display_add_row ? 2 : 1 %> <% variant.stock_items.each do |item| %> <% if @stock_item_stock_locations.include?(item.stock_location) %> <%= render partial: 'spree/admin/shared/number_field_update_cell', locals: { resource_id: item.id, field_tag: :count_on_hand, number_value: item.count_on_hand } %> <% end %> <% end %> <% if display_add_row %> <% end %> <% reset_cycle("stock_locations") %> <% end %>
<%= Spree.t(:item) %> <%= Spree.t(:options) %> <%= Spree.t(:stock_location) %> <%= Spree.t(:backorderable_header) %> <%= Spree.t(:count_on_hand) %>
<%= image_tag(variant.display_image(fallback: false).attachment(:small)) %>
<% @variant_display_attributes.each do |display_attribute| %> <% end %>
<%= Spree.t(display_attribute[:translation_key]) %> <%= variant.send(display_attribute[:attr_name]) %>
<% variant.option_values.sort_by(&:option_type_name).each do |option_value| %> <% end %>
<%= option_value.option_type_presentation %> <%= option_value.presentation %>
<%= item.stock_location.name %> <% if can?(:update, item) %> <%= check_box_tag :backorderable, 'backorderable', item.backorderable?, id: "backorderable-#{item.id}", disabled: "disabled" %> <% end %> <%= render partial: 'spree/admin/shared/number_field_update_actions', locals: { resource: item, update_data: { location_id: item.stock_location_id } } %>
<%= select_tag :stock_location_id, options_from_collection_for_select(locations_without_items, :id, :name), { :include_blank => true, :class => 'select2', "data-placeholder" => Spree.t(:add_to_stock_location), :id => "variant-stock-location-#{variant.id}" } %> <%= check_box_tag :backorderable, 'backorderable', false, id: "variant-backorderable-#{variant.id}" %> <%= number_field_tag :count_on_hand, "", class: 'fullwidth', id: "variant-count-on-hand-#{variant.id}" %> <%= link_to_with_icon 'plus', Spree.t('actions.create'), '#', :no_text => true, :data => {:action => 'green', :variant_id => variant.id } if can?(:create, Spree::StockItem) %>
<%= paginate @variants %>