From de8d7bd66ef951b308555e2a5115e2870d795183 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Thu, 17 Oct 2013 11:08:25 +1100 Subject: [PATCH] Clean up payment methods form --- app/helpers/enterprises_helper.rb | 4 ++++ .../payment_methods/_form/add_distributors.html.haml.deface | 5 ++--- .../index/add_distributor_td.html.haml.deface | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/helpers/enterprises_helper.rb b/app/helpers/enterprises_helper.rb index e7787c69bc..4b0f2f4a93 100644 --- a/app/helpers/enterprises_helper.rb +++ b/app/helpers/enterprises_helper.rb @@ -7,6 +7,10 @@ module EnterprisesHelper enterprises.map { |enterprise| [enterprise.name + ": " + enterprise.address.address1 + ", " + enterprise.address.city, enterprise.id.to_i] } end + def enterprises_to_names(enterprises) + enterprises.map(&:name).sort.join(', ') + end + def enterprise_confirm_delete_message(enterprise) if enterprise.supplied_products.present? "This will also delete the #{pluralize enterprise.supplied_products.count, 'product'} that this enterprise supplies. Are you sure you want to continue?" diff --git a/app/overrides/spree/admin/payment_methods/_form/add_distributors.html.haml.deface b/app/overrides/spree/admin/payment_methods/_form/add_distributors.html.haml.deface index c299c7dacf..0ed490a94a 100644 --- a/app/overrides/spree/admin/payment_methods/_form/add_distributors.html.haml.deface +++ b/app/overrides/spree/admin/payment_methods/_form/add_distributors.html.haml.deface @@ -1,9 +1,8 @@ -/ - insert_before '[data-hook="environment"]' +/ 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.collection_select(:distributor_ids, distributors, :id, :name, {include_blank: false}, {class: "select2 fullwidth", multiple: true}) = f.error_message_on :distributors diff --git a/app/overrides/spree/admin/payment_methods/index/add_distributor_td.html.haml.deface b/app/overrides/spree/admin/payment_methods/index/add_distributor_td.html.haml.deface index e6ab908889..ac7a69b951 100644 --- a/app/overrides/spree/admin/payment_methods/index/add_distributor_td.html.haml.deface +++ b/app/overrides/spree/admin/payment_methods/index/add_distributor_td.html.haml.deface @@ -1,4 +1,4 @@ / insert_top "[data-hook='admin_payment_methods_index_rows']" %td.align-center - = method.distributors.map(&:name).sort.join(', ') + = enterprises_to_names method.distributors