mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-31 21:37:16 +00:00
Fixed the logic and moved the code to a helper file
This commit is contained in:
@@ -11,6 +11,7 @@ module Spree
|
||||
include OrderCyclesHelper
|
||||
include EnterprisesHelper
|
||||
helper ::Admin::ProductsHelper
|
||||
helper Spree::Admin::TaxCategoriesHelper
|
||||
|
||||
before_action :load_data
|
||||
before_action :load_producers, only: [:index, :new]
|
||||
|
||||
8
app/helpers/spree/admin/tax_categories_helper.rb
Normal file
8
app/helpers/spree/admin/tax_categories_helper.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
module Spree::Admin::TaxCategoriesHelper
|
||||
def tax_category_dropdown_options(require_tax_category)
|
||||
{
|
||||
:include_blank => Spree::Config.products_require_tax_category ? false : t(:none),
|
||||
selected: Spree::Config.products_require_tax_category ? Spree::TaxCategory.find_by(is_default: true)&.id : nil
|
||||
}
|
||||
end
|
||||
end
|
||||
@@ -1,5 +1,5 @@
|
||||
= f.field_container :tax_category_id do
|
||||
= f.label :tax_category_id, t(:tax_category)
|
||||
%br
|
||||
= f.collection_select(:tax_category_id, Spree::TaxCategory.all, :id, :name, {:include_blank => Spree::Config.products_require_tax_category ? false : t(:none), selected: Spree::TaxCategory.find_by(is_default: true)&.id}, {:class => "select2 fullwidth"})
|
||||
= f.collection_select(:tax_category_id, Spree::TaxCategory.all, :id, :name, tax_category_dropdown_options(Spree::Config.products_require_tax_category), {:class => "select2 fullwidth"})
|
||||
= f.error_message_on :tax_category_id
|
||||
|
||||
Reference in New Issue
Block a user