mirror of
https://github.com/valitydev/control-center.git
synced 2024-11-06 02:25:17 +00:00
Support pasted "," radix point in Source Cash (Create Deposit) (#333)
This commit is contained in:
parent
4773475e55
commit
7e5ac50b8f
@ -1,7 +1,7 @@
|
||||
<div style="display: flex; gap: 8px">
|
||||
<mat-form-field style="width: 100%">
|
||||
<mat-label>{{ label || 'Amount' }}</mat-label>
|
||||
<span matPrefix>{{ prefix }} </span>
|
||||
<span matPrefix style="padding: 8px">{{ prefix }} </span>
|
||||
<input
|
||||
[formControl]="amountControl"
|
||||
[inputMask]="amountMask$ | async"
|
||||
|
@ -36,6 +36,7 @@ export interface SourceCash {
|
||||
}
|
||||
|
||||
const GROUP_SEPARATOR = ' ';
|
||||
const RADIX_POINT = '.';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
@ -83,9 +84,12 @@ export class SourceCashFieldComponent
|
||||
createMask({
|
||||
alias: 'numeric',
|
||||
groupSeparator: GROUP_SEPARATOR,
|
||||
radixPoint: RADIX_POINT,
|
||||
digits: exponent,
|
||||
digitsOptional: true,
|
||||
placeholder: '',
|
||||
onBeforePaste: (pastedValue: string) =>
|
||||
this.convertPastedToStringNumber(pastedValue),
|
||||
}),
|
||||
),
|
||||
shareReplay({ refCount: true, bufferSize: 1 }),
|
||||
@ -109,6 +113,7 @@ export class SourceCashFieldComponent
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
super.ngOnInit();
|
||||
combineLatest([
|
||||
combineLatest([getValueChanges(this.amountControl), this.currencyExponent$]).pipe(
|
||||
map(([amountStr, exponent]) => {
|
||||
@ -146,6 +151,7 @@ export class SourceCashFieldComponent
|
||||
const { sourceId, amount } = value || {};
|
||||
if (!sourceId) {
|
||||
this.setValues(amount, null);
|
||||
return;
|
||||
}
|
||||
this.options$
|
||||
.pipe(
|
||||
@ -179,4 +185,8 @@ export class SourceCashFieldComponent
|
||||
typeof amount === 'number' ? String(toMajorByExponent(amount, exponent)) : null,
|
||||
);
|
||||
}
|
||||
|
||||
private convertPastedToStringNumber(pastedValue: string) {
|
||||
return pastedValue.replaceAll(',', RADIX_POINT);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user