From cc95f3b5b557a456d25ea2dd14a676e196a841f9 Mon Sep 17 00:00:00 2001 From: Kukks Date: Mon, 14 Jan 2019 07:53:03 +0100 Subject: [PATCH] fix exponent numbers in contribution amounts --- BTCPayServer/wwwroot/crowdfund/app.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/BTCPayServer/wwwroot/crowdfund/app.js b/BTCPayServer/wwwroot/crowdfund/app.js index 26ff5ac03..9f65be936 100644 --- a/BTCPayServer/wwwroot/crowdfund/app.js +++ b/BTCPayServer/wwwroot/crowdfund/app.js @@ -50,20 +50,31 @@ addLoadEvent(function (ev) { return; } - eventAggregator.$emit("contribute", {amount: this.amount, choiceKey: this.perk.id}); + eventAggregator.$emit("contribute", {amount: parseFloat(this.amount), choiceKey: this.perk.id}); }, expand: function(){ if(this.canExpand){ this.expanded = true; } + }, + setAmount: function (amount) { + this.amount = (amount || 0).noExponents(); + this.expanded = false; } }, - mounted: function(){ - this.amount = this.perk.price.value; - + mounted: function () { + this.setAmount(this.perk.price.value); + }, + watch: { + perk: function (newValue, oldValue) { + if (newValue.price.value != oldValue.price.value) { + this.setAmount(newValue.price.value); + } + } } + }); app = new Vue({