From 77f9760b35f1f1ce955a5ca84c0d439feb341f3d Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Mon, 27 Feb 2017 11:34:34 -0800 Subject: [PATCH] Move JS Spree.currencyInfo into erb view This allows us to pick up configuration changes the RubyMoney currencies. --- .../{format_money.js.erb => format_money.js} | 16 ---------------- .../admin/shared/_js_locale_data.html.erb | 18 +++++++++++++++++- 2 files changed, 17 insertions(+), 17 deletions(-) rename backend/app/assets/javascripts/spree/backend/{format_money.js.erb => format_money.js} (60%) diff --git a/backend/app/assets/javascripts/spree/backend/format_money.js.erb b/backend/app/assets/javascripts/spree/backend/format_money.js similarity index 60% rename from backend/app/assets/javascripts/spree/backend/format_money.js.erb rename to backend/app/assets/javascripts/spree/backend/format_money.js index 640e74fb232..6f327937053 100644 --- a/backend/app/assets/javascripts/spree/backend/format_money.js.erb +++ b/backend/app/assets/javascripts/spree/backend/format_money.js @@ -1,22 +1,6 @@ //= require spree/backend/translation //= require solidus_admin/accounting -Spree.currencyInfo = <%= -Money::Currency.all.map { |c| - format = - if c.symbol == "" || c.symbol_first - "%s%v" - else - "%v %s" - end - [c.id.to_s.upcase, [ - c.symbol || "¤", - c.exponent, - format - ]] -}.to_h.to_json -%>; - Spree.formatMoney = function(amount, currency) { var currencyInfo = Spree.currencyInfo[currency]; diff --git a/backend/app/views/spree/admin/shared/_js_locale_data.html.erb b/backend/app/views/spree/admin/shared/_js_locale_data.html.erb index 9a36b8e2cc3..e973981723c 100644 --- a/backend/app/views/spree/admin/shared/_js_locale_data.html.erb +++ b/backend/app/views/spree/admin/shared/_js_locale_data.html.erb @@ -21,7 +21,23 @@ currency_delimiter: I18n.t('number.currency.format.delimiter'), activerecord: I18n.t('activerecord') }).to_json -%> +%>; + + Spree.currencyInfo = <%== + Money::Currency.all.map { |c| + format = + if c.symbol == "" || c.symbol_first + "%s%v" + else + "%v %s" + end + [c.id.to_s.upcase, [ + c.symbol || "¤", + c.exponent, + format + ]] + }.to_h.to_json +%>;