From 37be0e826f907927170aa58c2a8aa9aebda07f06 Mon Sep 17 00:00:00 2001 From: Alexandre Guerra Marcondes Date: Mon, 1 May 2017 19:27:45 -0400 Subject: [PATCH 1/2] Add support for custom decimal and thousands delimiters --- src/global/money/money.js | 8 ++++++++ src/global/money/money.test.js | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/global/money/money.js b/src/global/money/money.js index 82e01845..e3b44048 100644 --- a/src/global/money/money.js +++ b/src/global/money/money.js @@ -21,6 +21,14 @@ function MoneyMaskDirective($locale, $parse, PreFormatters) { return new StringMask(maskPattern, {reverse: true}); } + if (angular.isDefined(attrs.uiDecimalDelimiter)) { + decimalDelimiter = attrs.uiDecimalDelimiter; + } + + if (angular.isDefined(attrs.uiThousandsDelimiter)) { + thousandsDelimiter = attrs.uiThousandsDelimiter; + } + if (angular.isDefined(attrs.uiHideGroupSep)) { thousandsDelimiter = ''; } diff --git a/src/global/money/money.test.js b/src/global/money/money.test.js index 9db15b9c..a1546f74 100644 --- a/src/global/money/money.test.js +++ b/src/global/money/money.test.js @@ -207,4 +207,22 @@ describe('ui-money-mask', function() { var model = input.controller('ngModel'); expect(model.$viewValue).toBe('345.00'); }); + + it('should employ a custom thousands delimiter', function() { + var input = TestUtil.compile('', { + model: 1234567.00 + }); + + var model = input.controller('ngModel'); + expect(model.$viewValue).toBe('$ 1|234|567.00'); + }); + + it('should employ a custom decimal delimiter', function() { + var input = TestUtil.compile('', { + model: 123.00 + }); + + var model = input.controller('ngModel'); + expect(model.$viewValue).toBe('$ 123|00'); + }); }); From b6a2f53f98155687ba3b6c127c9d0878f2b06e3d Mon Sep 17 00:00:00 2001 From: Igor Rafael Date: Tue, 30 May 2017 09:18:17 -0300 Subject: [PATCH 2/2] style: replace spaces with tabs --- src/global/money/money.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/global/money/money.test.js b/src/global/money/money.test.js index 1a8a88b5..458faaaf 100644 --- a/src/global/money/money.test.js +++ b/src/global/money/money.test.js @@ -224,8 +224,8 @@ describe('ui-money-mask', function() { var model = input.controller('ngModel'); expect(model.$viewValue).toBe('$ 123|00'); - }); - + }); + it('should add currency after value', function() { var input = TestUtil.compile('', { model: 345.00