mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-25 01:13:25 +01:00
Et2Number: Pad number with specific mask to full number of decimals
This commit is contained in:
parent
05b983ab1c
commit
5cfc165f1d
@ -240,7 +240,7 @@ export class Et2Number extends Et2Textbox
|
||||
|
||||
get valueAsNumber() : number
|
||||
{
|
||||
let formattedValue = this._mask?.unmaskedValue ?? this.value;
|
||||
let formattedValue = (this.mask && this._mask?.value ? this.stripFormat(this._mask.value) : this._mask?.unmaskedValue) ?? this.value;
|
||||
if(typeof this.precision !== 'undefined')
|
||||
{
|
||||
formattedValue = parseFloat(parseFloat(<string>formattedValue).toFixed(this.precision));
|
||||
@ -318,7 +318,23 @@ export class Et2Number extends Et2Textbox
|
||||
updateMaskValue()
|
||||
{
|
||||
this._mask.updateValue();
|
||||
this._mask.unmaskedValue = "" + this.value;
|
||||
if(!this.mask)
|
||||
{
|
||||
// Number mask sometimes gets lost with different decimal characters
|
||||
this._mask.unmaskedValue = ("" + this.value);
|
||||
|
||||
// Fill decimals to precision
|
||||
if(this.precision && ("" + this.value).includes("."))
|
||||
{
|
||||
this._mask.unmaskedValue = this._mask.unmaskedValue.padEnd(("" + this.value).length + this.precision, "0");
|
||||
}
|
||||
}
|
||||
else if(this.precision && ("" + this.value).includes("."))
|
||||
{
|
||||
// Fill decimals to precision
|
||||
let v = formatNumber(this.value, this.decimalSeparator, this.thousandsSeparator);
|
||||
this._mask.value = v.padEnd(v.length + this.precision, "0");
|
||||
}
|
||||
this._mask.updateValue();
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ export class Et2Textbox extends Et2InputWidget(SlInput)
|
||||
onkeypress;
|
||||
|
||||
private __validator : any;
|
||||
private _mask : InputMask;
|
||||
protected _mask : InputMask;
|
||||
protected _value : string = "";
|
||||
|
||||
inputMode = "text";
|
||||
|
Loading…
Reference in New Issue
Block a user