mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-05 22:26:07 +00:00
Make distributor payment method multi-select
This commit is contained in:
@@ -3,18 +3,15 @@ Spree::PaymentMethod.class_eval do
|
||||
|
||||
belongs_to :distributor, :class_name => 'Enterprise'
|
||||
|
||||
validates_presence_of :distributor_id
|
||||
|
||||
attr_accessible :distributor_id
|
||||
attr_accessible :distributor_ids
|
||||
|
||||
# -- Scopes
|
||||
scope :in_distributor, lambda { |distributor| where(:distributor_id => distributor) }
|
||||
|
||||
scope :managed_by, lambda { |user|
|
||||
if user.has_spree_role?('admin')
|
||||
scoped
|
||||
else
|
||||
where('distributor_id IN (?)', user.enterprises)
|
||||
joins(:distributors).
|
||||
where('distributors_payment_methods.distributor_id IN (?)', user.enterprises)
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
/
|
||||
insert_before '[data-hook="environment"]'
|
||||
|
||||
= f.field_container :distributor do
|
||||
= f.label :distributor
|
||||
%br
|
||||
|
||||
= collection_select(:payment_method, :distributor_id, Enterprise.is_distributor.managed_by(spree_current_user), :id, :name, {:include_blank => false}, {:class => "select2 fullwidth"})
|
||||
= f.error_message_on :distributor
|
||||
@@ -0,0 +1,9 @@
|
||||
/
|
||||
insert_before '[data-hook="environment"]'
|
||||
|
||||
= f.field_container :distributors do
|
||||
= f.label :distributors
|
||||
%br
|
||||
- distributors = Enterprise.is_distributor.managed_by(spree_current_user) | f.object.distributors
|
||||
= collection_select(:payment_method, :distributor_ids, distributors, :id, :name, {include_blank: false}, {class: "select2 fullwidth", multiple: true})
|
||||
= f.error_message_on :distributors
|
||||
Reference in New Issue
Block a user