mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-22 00:57:26 +00:00
Move payment method display logic to helper
So we don't need to convert strings into classes to then only convert it into the same string again.
This commit is contained in:
@@ -138,7 +138,7 @@ module Spree
|
||||
|
||||
providers.delete("Spree::Gateway::StripeSCA") unless show_stripe?
|
||||
|
||||
providers.map(&:constantize)
|
||||
providers
|
||||
end
|
||||
|
||||
# Show Stripe as an option if enabled, or if the
|
||||
|
||||
14
app/helpers/spree/admin/payment_methods_helper.rb
Normal file
14
app/helpers/spree/admin/payment_methods_helper.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
module Admin
|
||||
module PaymentMethodsHelper
|
||||
def payment_method_type_name(class_name)
|
||||
scope = "spree.admin.payment_methods.providers"
|
||||
key = class_name.demodulize.downcase
|
||||
|
||||
I18n.t(key, scope:)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -3,6 +3,6 @@
|
||||
.alpha.four.columns
|
||||
= label :payment_method, :type, t('.provider')
|
||||
.omega.twelve.columns
|
||||
= collection_select(:payment_method, :type, @providers, :to_s, :clean_name, {}, { class: 'select2 fullwidth', 'provider-prefs-for' => "#{@object.id}"})
|
||||
= select(:payment_method, :type, @providers.map { |p| [payment_method_type_name(p), p] }, {}, { class: 'select2 fullwidth', 'provider-prefs-for' => "#{@object.id}"})
|
||||
|
||||
%div{"ng-include" => "include_html" }
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
- method.distributors.each do |distributor|
|
||||
= distributor.name
|
||||
%br/
|
||||
%td= method.class.clean_name
|
||||
%td= payment_method_type_name(method.class.name)
|
||||
- if spree_current_user.admin?
|
||||
%td.align-center= method.environment.to_s.titleize
|
||||
%td.align-center= method.display_on.blank? ? t('.both') : t('.' + method.display_on.to_s)
|
||||
|
||||
Reference in New Issue
Block a user