Skip to content

Commit

Permalink
Move JS Spree.currencyInfo into erb view
Browse files Browse the repository at this point in the history
This allows us to pick up configuration changes the RubyMoney
currencies.
  • Loading branch information
jhawthorn committed Feb 28, 2017
1 parent ca48229 commit 77f9760
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -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];

Expand Down
18 changes: 17 additions & 1 deletion backend/app/views/spree/admin/shared/_js_locale_data.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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
%>;
</script>
<script data-hook='admin-custom-translations'>
</script>
Expand Down

0 comments on commit 77f9760

Please sign in to comment.