mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-03 06:59:14 +00:00
Remove unhelpful Helper
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
module ProductsHelper
|
||||
def product_has_variant_unit_option_type?(product)
|
||||
product.option_types.any? { |option_type| variant_unit_option_type? option_type }
|
||||
end
|
||||
|
||||
def variant_unit_option_type?(option_type)
|
||||
Spree::Product.all_variant_unit_option_types.include? option_type
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -362,10 +362,6 @@ module Spree
|
||||
presentation: option_type_presentation)
|
||||
end
|
||||
|
||||
def self.all_variant_unit_option_types
|
||||
Spree::OptionType.where('name LIKE ?', 'unit_%%')
|
||||
end
|
||||
|
||||
def destroy
|
||||
transaction do
|
||||
touch_distributors
|
||||
|
||||
@@ -6,17 +6,16 @@
|
||||
= f.label :display_as, t('.display_as')
|
||||
= f.text_field :display_as, class: "fullwidth", placeholder: t('.display_as_placeholder')
|
||||
|
||||
- if product_has_variant_unit_option_type?(@product)
|
||||
- if @product.variant_unit != 'items'
|
||||
.field
|
||||
= label_tag :unit_value_human, "#{t('admin.'+@product.variant_unit)} ({{unitName(#{@product.variant_unit_scale}, '#{@product.variant_unit}')}})"
|
||||
= hidden_field_tag 'product_variant_unit_scale', @product.variant_unit_scale
|
||||
= number_field_tag :unit_value_human, nil, {class: "fullwidth", step: 0.01, 'ng-model' => 'unit_value_human', 'ng-change' => 'updateValue()'}
|
||||
= f.number_field :unit_value, {hidden: true, 'ng-value' => 'unit_value'}
|
||||
|
||||
- if @product.variant_unit != 'items'
|
||||
.field
|
||||
= f.label :unit_description, t(:spree_admin_unit_description)
|
||||
= f.text_field :unit_description, class: "fullwidth", placeholder: t('admin.products.unit_name_placeholder')
|
||||
= label_tag :unit_value_human, "#{t('admin.'+@product.variant_unit)} ({{unitName(#{@product.variant_unit_scale}, '#{@product.variant_unit}')}})"
|
||||
= hidden_field_tag 'product_variant_unit_scale', @product.variant_unit_scale
|
||||
= number_field_tag :unit_value_human, nil, {class: "fullwidth", step: 0.01, 'ng-model' => 'unit_value_human', 'ng-change' => 'updateValue()'}
|
||||
= f.number_field :unit_value, {hidden: true, 'ng-value' => 'unit_value'}
|
||||
|
||||
.field
|
||||
= f.label :unit_description, t(:spree_admin_unit_description)
|
||||
= f.text_field :unit_description, class: "fullwidth", placeholder: t('admin.products.unit_name_placeholder')
|
||||
|
||||
%div
|
||||
- @product.option_types.each do |option_type|
|
||||
|
||||
@@ -931,15 +931,6 @@ module Spree
|
||||
expect(p.master.option_values.map(&:name).include?("1g")).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
it "finds all variant unit option types" do
|
||||
ot1 = create(:option_type, name: 'unit_weight', presentation: 'Weight')
|
||||
ot2 = create(:option_type, name: 'unit_volume', presentation: 'Volume')
|
||||
ot3 = create(:option_type, name: 'unit_items', presentation: 'Items')
|
||||
ot4 = create(:option_type, name: 'foo_unit_bar', presentation: 'Foo')
|
||||
|
||||
expect(Spree::Product.all_variant_unit_option_types).to match_array [ot1, ot2, ot3]
|
||||
end
|
||||
end
|
||||
|
||||
describe "option types" do
|
||||
|
||||
Reference in New Issue
Block a user