From b0a4665bf47c20c56a1f0ea1d67ca6896f74565d Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Thu, 31 Oct 2019 13:29:11 +1100 Subject: [PATCH] set the dollar amount --- assets/javascripts/discourse/models/plan.js.es6 | 14 ++++++++++---- ...-discourse-patrons-products-show-plans-show.hbs | 2 +- test/javascripts/models/plan-test.js.es6 | 14 ++++++++++++-- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/assets/javascripts/discourse/models/plan.js.es6 b/assets/javascripts/discourse/models/plan.js.es6 index de04a99..952a540 100644 --- a/assets/javascripts/discourse/models/plan.js.es6 +++ b/assets/javascripts/discourse/models/plan.js.es6 @@ -2,10 +2,16 @@ import computed from "ember-addons/ember-computed-decorators"; import { ajax } from "discourse/lib/ajax"; const Plan = Discourse.Model.extend({ - @computed("amount") - amountDollars(amount) { - return parseFloat(amount / 100).toFixed(2); - }, + amountDollars: Ember.computed("amount", { + get() { + return parseFloat(this.get("amount") / 100).toFixed(2); + }, + set(key, value) { + const decimal = parseFloat(value) * 100; + this.set("amount", decimal); + return value; + } + }), @computed("amountDollars", "currency", "interval") subscriptionRate(amountDollars, currency, interval) { diff --git a/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons-products-show-plans-show.hbs b/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons-products-show-plans-show.hbs index 371404b..c3f583c 100644 --- a/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons-products-show-plans-show.hbs +++ b/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons-products-show-plans-show.hbs @@ -22,7 +22,7 @@

- {{input type="text" name="name" value=model.plan.amount disabled=planFieldDisabled}} + {{input type="text" name="name" value=model.plan.amountDollars disabled=planFieldDisabled}}