mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-14 04:04:23 +00:00
add currency spec file and update some class names
This commit is contained in:
@@ -1,17 +0,0 @@
|
||||
# Convert number to string currency using injected currency localisation settings.
|
||||
#
|
||||
# Injected: currencyLocalisation - see /app/serializers/api/currency_localization_serializer.rb
|
||||
|
||||
Darkswarm.filter "localiseCurrency", (currencyLocalization)->
|
||||
(amount) ->
|
||||
decimals = if currencyLocalization.hide_cents then 0 else 2
|
||||
amount_fixed = amount.toFixed(decimals)
|
||||
currency_str = ""
|
||||
currency_str = " " + currencyLocalization.currency if currencyLocalization.display_currency
|
||||
|
||||
# Return string
|
||||
if currencyLocalization.symbol_position == 'before'
|
||||
currencyLocalization.symbol + amount_fixed + currency_str
|
||||
else
|
||||
amount_fixed + " " + currencyLocalization.symbol + currency_str
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# Convert number to string currency using injected currency localisation settings.
|
||||
#
|
||||
# @requires currencyConfig json - /app/serializers/api/currency_localization_serializer.rb
|
||||
# @return string
|
||||
Darkswarm.filter "localizeCurrency", (currencyConfig)->
|
||||
(amount) ->
|
||||
decimals = if currencyConfig.hide_cents then 0 else 2
|
||||
amount_fixed = amount.toFixed(2)
|
||||
currency_str = ""
|
||||
currency_str = " " + currencyConfig.currency if currencyConfig.display_currency
|
||||
|
||||
# Return: string. Varies with symbol position.
|
||||
if currencyConfig.symbol_position == 'before'
|
||||
currencyConfig.symbol + amount_fixed + currency_str
|
||||
else
|
||||
amount_fixed + " " + currencyConfig.symbol + currency_str
|
||||
|
||||
@@ -10,26 +10,26 @@
|
||||
.expanded{"ng-show" => "expanded"}
|
||||
%ul
|
||||
%li.cost
|
||||
.right {{ variant.price | localiseCurrency }}
|
||||
.right {{ variant.price | localizeCurrency }}
|
||||
Item cost
|
||||
%li{"bo-if" => "variant.fees.admin"}
|
||||
.right {{ variant.fees.admin | localiseCurrency }}
|
||||
.right {{ variant.fees.admin | localizeCurrency }}
|
||||
Admin fee
|
||||
%li{"bo-if" => "variant.fees.sales"}
|
||||
.right {{ variant.fees.sales | localiseCurrency }}
|
||||
.right {{ variant.fees.sales | localizeCurrency }}
|
||||
Sales fee
|
||||
%li{"bo-if" => "variant.fees.packing"}
|
||||
.right {{ variant.fees.packing | localiseCurrency }}
|
||||
.right {{ variant.fees.packing | localizeCurrency }}
|
||||
Packing fee
|
||||
%li{"bo-if" => "variant.fees.transport"}
|
||||
.right {{ variant.fees.transport | localiseCurrency }}
|
||||
.right {{ variant.fees.transport | localizeCurrency }}
|
||||
Transport fee
|
||||
%li{"bo-if" => "variant.fees.fundraising"}
|
||||
.right {{ variant.fees.fundraising | localiseCurrency }}
|
||||
.right {{ variant.fees.fundraising | localizeCurrency }}
|
||||
Fundraising fee
|
||||
%li
|
||||
%strong
|
||||
.right = {{ variant.price | localiseCurrency }}
|
||||
.right = {{ variant.price | localizeCurrency }}
|
||||
|
||||
|
||||
%a{"ng-click" => "expanded = !expanded"}
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
.small-4.medium-2.large-2.columns.variant-price
|
||||
.table-cell.price
|
||||
%i.ofn-i_009-close
|
||||
{{ variant.price | localiseCurrency }}
|
||||
{{ variant.price | localizeCurrency }}
|
||||
|
||||
-# Now in a template in app/assets/javascripts/templates !
|
||||
%price-breakdown{"price-breakdown" => "_", variant: "variant",
|
||||
@@ -59,4 +59,4 @@
|
||||
.small-12.medium-2.large-2.columns.total-price.text-right
|
||||
.table-cell
|
||||
%strong
|
||||
{{ variant.getPrice() | localiseCurrency }}
|
||||
{{ variant.getPrice() | localizeCurrency }}
|
||||
|
||||
Reference in New Issue
Block a user