Skip to content

Commit 353b574

Browse files
mohas22mohas22
authored andcommitted
updated variable names for better understanding
1 parent 32eee15 commit 353b574

File tree

6 files changed

+46
-55
lines changed

6 files changed

+46
-55
lines changed

packages/angular-sdk-components/src/lib/_components/field/currency/currency.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
matInput
1414
currencyMask
1515
[options]="{
16-
prefix: currSym,
17-
thousands: currSep,
18-
decimal: currDec,
16+
prefix: currencySymbol,
17+
thousands: thousandSeparator,
18+
decimal: decimalSeparator,
1919
align: 'left',
2020
nullable: true,
2121
precision: decimalPrecision,

packages/angular-sdk-components/src/lib/_components/field/currency/currency.component.ts

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ export class CurrencyComponent implements OnInit, OnDestroy {
5252
currencyOptions: Object = {};
5353

5454
fieldControl = new FormControl<number | null>(null, { updateOn: 'blur' });
55-
currSym: string;
56-
currSep: string;
57-
currDec: string;
55+
currencySymbol: string;
56+
thousandSeparator: string;
57+
decimalSeparator: string;
5858
inputMode: any;
5959
decimalPrecision: number | undefined;
6060
formattedValue: string;
@@ -136,9 +136,9 @@ export class CurrencyComponent implements OnInit, OnDestroy {
136136
const currencyISOCode = this.configProps$?.currencyISOCode ?? '';
137137

138138
const theSymbols = getCurrencyCharacters(currencyISOCode);
139-
this.currSym = theSymbols.theCurrencySymbol;
140-
this.currSep = theSymbols.theDigitGroupSeparator;
141-
this.currDec = theSymbols.theDecimalIndicator;
139+
this.currencySymbol = theSymbols.theCurrencySymbol;
140+
this.thousandSeparator = theSymbols.theDigitGroupSeparator;
141+
this.decimalSeparator = theSymbols.theDecimalIndicator;
142142
this.formatter = this.configProps$.formatter;
143143

144144
if (this.displayMode$ === 'DISPLAY_ONLY' || this.displayMode$ === 'STACKED_LARGE_VAL') {
@@ -201,16 +201,13 @@ export class CurrencyComponent implements OnInit, OnDestroy {
201201
const propName = this.pConn$?.getStateProps().value;
202202
let value = event?.target?.value;
203203
value = value?.substring(1);
204-
// replacing thousand seperator with empty string as not required in api call
205-
if (this.currSep === '.') {
206-
value = value?.replace(/\./g, '');
207-
} else {
208-
const regExp = new RegExp(String.raw`${this.currSep}`, 'g');
209-
value = value.replace(regExp, '');
210-
}
211-
// replacing decimal seperator with '.'
212-
if (this.currDec !== '.') {
213-
const regExp = new RegExp(String.raw`${this.currDec}`, 'g');
204+
// replacing thousand separator with empty string as not required in api call
205+
const thousandSep = this.thousandSeparator === '.' ? '\\.' : this.thousandSeparator;
206+
let regExp = new RegExp(String.raw`${thousandSep}`, 'g');
207+
value = value?.replace(regExp, '');
208+
// replacing decimal separator with '.'
209+
if (this.decimalSeparator !== '.') {
210+
regExp = new RegExp(String.raw`${this.decimalSeparator}`, 'g');
214211
value = value.replace(regExp, '.');
215212
}
216213
handleEvent(actionsApi, 'changeNblur', propName, value);

packages/angular-sdk-components/src/lib/_components/field/decimal/decimal.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
matInput
1212
currencyMask
1313
[options]="{
14-
prefix: bReadonly$ && formatter === 'Currency' ? currSym : '',
15-
thousands: currSep,
16-
decimal: currDec,
14+
prefix: bReadonly$ && formatter === 'Currency' ? currencySymbol : '',
15+
thousands: thousandSeparator,
16+
decimal: decimalSeparator,
1717
align: 'left',
1818
nullable: true,
1919
precision: decimalPrecision,

packages/angular-sdk-components/src/lib/_components/field/decimal/decimal.component.ts

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ export class DecimalComponent implements OnInit, OnDestroy {
5858
placeholder: string;
5959

6060
fieldControl = new FormControl<number | null>(null, null);
61-
currDec: string;
62-
currSep: string;
63-
currSym: string;
61+
decimalSeparator: string;
62+
thousandSeparator: string;
63+
currencySymbol: string;
6464
decimalPrecision: number | undefined;
6565
formatter;
6666
formattedValue: any;
@@ -143,8 +143,8 @@ export class DecimalComponent implements OnInit, OnDestroy {
143143
const currencyISOCode = this.configProps$?.currencyISOCode ?? '';
144144

145145
const theSymbols = getCurrencyCharacters(currencyISOCode);
146-
this.currDec = theSymbols.theDecimalIndicator;
147-
this.currSep = showGroupSeparators ? theSymbols.theDigitGroupSeparator : '';
146+
this.decimalSeparator = theSymbols.theDecimalIndicator;
147+
this.thousandSeparator = showGroupSeparators ? theSymbols.theDigitGroupSeparator : '';
148148

149149
const theCurrencyOptions = getCurrencyOptions(currencyISOCode);
150150
this.formatter = this.configProps$.formatter;
@@ -183,9 +183,9 @@ export class DecimalComponent implements OnInit, OnDestroy {
183183
}
184184

185185
if (this.bReadonly$ && this.formatter === 'Currency') {
186-
this.currSym = theSymbols.theCurrencySymbol;
186+
this.currencySymbol = theSymbols.theCurrencySymbol;
187187
} else {
188-
this.currSym = '';
188+
this.currencySymbol = '';
189189
}
190190
this.decimalPrecision = this.configProps$?.decimalPrecision ?? 2;
191191

@@ -196,18 +196,15 @@ export class DecimalComponent implements OnInit, OnDestroy {
196196
const actionsApi = this.pConn$?.getActionsApi();
197197
const propName = this.pConn$?.getStateProps().value;
198198
let value = event?.target?.value;
199-
// replacing thousand seperator with empty string as not required in api call
199+
// replacing thousand separator with empty string as not required in api call
200200
if (this.configProps$.showGroupSeparators) {
201-
if (this.currSep === '.') {
202-
value = value?.replace(/\./g, '');
203-
} else {
204-
const regExp = new RegExp(String.raw`${this.currSep}`, 'g');
205-
value = value.replace(regExp, '');
206-
}
201+
const thousandSep = this.thousandSeparator === '.' ? '\\.' : this.thousandSeparator;
202+
const regExp = new RegExp(String.raw`${thousandSep}`, 'g');
203+
value = value?.replace(regExp, '');
207204
}
208-
// replacing decimal seperator with '.'
209-
if (this.currDec !== '.') {
210-
const regExp = new RegExp(String.raw`${this.currDec}`, 'g');
205+
// replacing decimal separator with '.'
206+
if (this.decimalSeparator !== '.') {
207+
const regExp = new RegExp(String.raw`${this.decimalSeparator}`, 'g');
211208
value = value.replace(regExp, '.');
212209
}
213210
handleEvent(actionsApi, 'changeNblur', propName, value);

packages/angular-sdk-components/src/lib/_components/field/percentage/percentage.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
[options]="{
1414
prefix: '',
1515
suffix: '%',
16-
thousands: currSep,
17-
decimal: currDec,
16+
thousands: thousandSeparator,
17+
decimal: decimalSeparator,
1818
align: 'left',
1919
nullable: true,
2020
precision: decimalPrecision,

packages/angular-sdk-components/src/lib/_components/field/percentage/percentage.component.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ export class PercentageComponent implements OnInit, OnDestroy {
4848
testId: string;
4949
helperText: string;
5050
placeholder: string;
51-
currDec: string;
52-
currSep: string;
51+
decimalSeparator: string;
52+
thousandSeparator: string;
5353
inputMode: any;
5454
decimalPrecision: number | undefined;
5555
fieldControl = new FormControl<number | null>(null, null);
@@ -128,8 +128,8 @@ export class PercentageComponent implements OnInit, OnDestroy {
128128
const showGroupSeparators = this.configProps$.showGroupSeparators;
129129

130130
const theSymbols = getCurrencyCharacters('');
131-
this.currDec = theSymbols.theDecimalIndicator || '2';
132-
this.currSep = showGroupSeparators ? theSymbols.theDigitGroupSeparator : '';
131+
this.decimalSeparator = theSymbols.theDecimalIndicator;
132+
this.thousandSeparator = showGroupSeparators ? theSymbols.theDigitGroupSeparator : '';
133133

134134
this.actionsApi = this.pConn$.getActionsApi();
135135
this.propName = this.pConn$.getStateProps().value;
@@ -188,18 +188,15 @@ export class PercentageComponent implements OnInit, OnDestroy {
188188
fieldOnBlur(event: any) {
189189
let value = event?.target?.value;
190190
value = value ? value.replace(/%/g, '') : '';
191-
// replacing thousand seperator with empty string as not required in api call
191+
// replacing thousand separator with empty string as not required in api call
192192
if (this.configProps$.showGroupSeparators) {
193-
if (this.currSep === '.') {
194-
value = value?.replace(/\./g, '');
195-
} else {
196-
const regExp = new RegExp(String.raw`${this.currSep}`, 'g');
197-
value = value.replace(regExp, '');
198-
}
193+
const thousandSep = this.thousandSeparator === '.' ? '\\.' : this.thousandSeparator;
194+
const regExp = new RegExp(String.raw`${thousandSep}`, 'g');
195+
value = value?.replace(regExp, '');
199196
}
200-
// replacing decimal seperator with '.'
201-
if (this.currDec !== '.') {
202-
const regExp = new RegExp(String.raw`${this.currDec}`, 'g');
197+
// replacing decimal separator with '.'
198+
if (this.decimalSeparator !== '.') {
199+
const regExp = new RegExp(String.raw`${this.decimalSeparator}`, 'g');
203200
value = value.replace(regExp, '.');
204201
}
205202
handleEvent(this.actionsApi, 'changeNblur', this.propName, value);

0 commit comments

Comments
 (0)