From 5fe08c110fc6cd76f7de2f4c0f449be8cbdebd76 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Thu, 31 Oct 2019 14:35:19 +1100 Subject: [PATCH] format some currency --- .../discourse/helpers/format-curency.js.es6 | 2 ++ .../discourse/helpers/format-currency.js.es6 | 19 +++++++++++++++++++ ...lugins-discourse-patrons-products-show.hbs | 2 +- config/locales/client.en.yml | 6 +++--- 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 assets/javascripts/discourse/helpers/format-currency.js.es6 diff --git a/assets/javascripts/discourse/helpers/format-curency.js.es6 b/assets/javascripts/discourse/helpers/format-curency.js.es6 index 268bfc4..fc4f3e5 100644 --- a/assets/javascripts/discourse/helpers/format-curency.js.es6 +++ b/assets/javascripts/discourse/helpers/format-curency.js.es6 @@ -1,3 +1,5 @@ + +// TODO: typo in this helper name: currency not curency. export default Ember.Helper.helper(function(params) { let currencySign; diff --git a/assets/javascripts/discourse/helpers/format-currency.js.es6 b/assets/javascripts/discourse/helpers/format-currency.js.es6 new file mode 100644 index 0000000..ef67ec3 --- /dev/null +++ b/assets/javascripts/discourse/helpers/format-currency.js.es6 @@ -0,0 +1,19 @@ + +export default Ember.Helper.helper(function(params) { + let currencySign; + + switch (Discourse.SiteSettings.discourse_patrons_currency) { + case "EUR": + currencySign = "€"; + break; + case "GBP": + currencySign = "£"; + break; + default: + currencySign = "$"; + } + + + + return currencySign + params.map(p => p.toUpperCase()).join(' '); +}); diff --git a/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons-products-show.hbs b/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons-products-show.hbs index dee5bd5..bf8d666 100644 --- a/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons-products-show.hbs +++ b/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons-products-show.hbs @@ -45,7 +45,7 @@ {{format-date plan.createdFormatted}} {{plan.metadata.group_name}} {{plan.active}} - {{plan.amountDollars}} + {{format-currency plan.currency plan.amountDollars}} {{#link-to "adminPlugins.discourse-patrons.products.show.plans.show" model.product.id plan.id class="btn no-text btn-icon"}} {{d-icon "far-edit"}} diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 5a144b5..2d485fe 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -1,10 +1,10 @@ en: site_settings: discourse_patrons_enabled: "Enable the Discourse Patrons plugin." - discourse_patrons_secret_key: "Stripe Secret Key" - discourse_patrons_public_key: "Stripe Public Key" + discourse_patrons_secret_key: Stripe Secret Key + discourse_patrons_public_key: Stripe Public Key discourse_patrons_subscription_group: The name of the group the user is added to when successfully subscribed - discourse_patrons_currency: "Currency Code" + discourse_patrons_currency: Default Currency Code. This can be overridden when creating a subscription plan discourse_patrons_zip_code: "Show Zip Code" discourse_patrons_billing_address: "Collect billing address" discourse_patrons_payment_page: "Text to be added to enter payments page. Markdown is supported."