From 93028b9be08c8d05ecd57ad3bdacb2bc563e4f29 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Fri, 7 Aug 2015 11:23:32 -0300 Subject: [PATCH] Fixes decimal inputs --- public/views/modals/customized-amount.html | 8 ++++---- public/views/walletHome.html | 14 ++++++++++---- src/js/directives/directives.js | 6 +++--- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/public/views/modals/customized-amount.html b/public/views/modals/customized-amount.html index d37f32dd5..8981f5738 100644 --- a/public/views/modals/customized-amount.html +++ b/public/views/modals/customized-amount.html @@ -53,8 +53,8 @@ Amount
- + {{unitName}}
@@ -63,8 +63,8 @@
- + {{ alternativeIsoCode }}
diff --git a/public/views/walletHome.html b/public/views/walletHome.html index a68d4fa86..06a71249e 100644 --- a/public/views/walletHome.html +++ b/public/views/walletHome.html @@ -382,8 +382,11 @@ Amount
- - + + {{home.unitName}}
@@ -391,8 +394,11 @@
- - + + {{ home.alternativeIsoCode }}
diff --git a/src/js/directives/directives.js b/src/js/directives/directives.js index 5696fd116..78376c647 100644 --- a/src/js/directives/directives.js +++ b/src/js/directives/directives.js @@ -87,22 +87,22 @@ angular.module('copayApp.directives') ]) .directive('validAmount', ['configService', '$locale', function(configService, locale) { - var formats = locale.NUMBER_FORMATS; return { require: 'ngModel', link: function(scope, element, attrs, ctrl) { var val = function(value) { + if (value) value = value.replace(/,/g, '.'); var settings = configService.getSync().wallet.settings; var vNum = Number((value * settings.unitToSatoshi).toFixed(0)); - if (typeof value == 'undefined') { + if (typeof value == 'undefined' || value == 0) { ctrl.$pristine = true; } if (typeof vNum == "number" && vNum > 0) { var decimals = Number(settings.unitDecimals); - var sep_index = ('' + value).indexOf(formats.DECIMAL_SEP); + var sep_index = ('' + value).indexOf('.'); var str_value = ('' + value).substring(sep_index + 1); if (sep_index > 0 && str_value.length > decimals) { ctrl.$setValidity('validAmount', false);