@fluxhub/fluxhub-lib 22.0.15 → 22.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15339,10 +15339,32 @@ class FHNumericFieldComponent {
15339
15339
  constructor(uti_s) {
15340
15340
  this.uti_s = uti_s;
15341
15341
  this.modelChangeSubject.pipe(debounceTime(300)).subscribe((value) => {
15342
- this.onChange(value.split(this.suffixSymbol).join(''));
15342
+ // Al modello va sempre un numero (come in chg()), non la stringa formattata ("10.624,66"):
15343
+ // il testo nel campo non viene toccato. Se nel frattempo c'e' stato blur/invio/writeValue
15344
+ // il valore e' gia' stato propagato e questa emissione e' superata. (change) resta invariato.
15345
+ if (this.typingPending) {
15346
+ this.typingPending = false;
15347
+ const num = this.parseFormatted(value);
15348
+ if (num != null)
15349
+ this.onChange(num);
15350
+ }
15343
15351
  this.change.emit(value.split(this.suffixSymbol).join(''));
15344
15352
  });
15345
15353
  }
15354
+ typingPending = false;
15355
+ // Stesso parsing di chg(); null se il testo non e' (ancora) un numero, es. solo "-"
15356
+ parseFormatted(text) {
15357
+ if (text == null || text == '')
15358
+ return this.uti_s.round(0, this.decimal);
15359
+ const num = this.uti_s.round(parseFloat(text
15360
+ .split('.')
15361
+ .join('')
15362
+ .split(',')
15363
+ .join('.')
15364
+ .split(this.suffixSymbol)
15365
+ .join('')), this.decimal);
15366
+ return isNaN(num) ? null : num;
15367
+ }
15346
15368
  keyDownFunctioncl(event) {
15347
15369
  if (event.keyCode == 13) {
15348
15370
  this.chg();
@@ -15350,6 +15372,7 @@ class FHNumericFieldComponent {
15350
15372
  }
15351
15373
  }
15352
15374
  modelch() {
15375
+ this.typingPending = true;
15353
15376
  setTimeout(() => {
15354
15377
  this.modelChangeSubject.next(this.formattedAmount);
15355
15378
  });
@@ -15386,11 +15409,13 @@ class FHNumericFieldComponent {
15386
15409
  this.transform(this.value, this.decimal) + this.suffixSymbol;
15387
15410
  }
15388
15411
  this.chgf = true;
15412
+ this.typingPending = false;
15389
15413
  this.onChange(this.value);
15390
15414
  }
15391
15415
  writeValue(value) {
15392
15416
  if (value == null)
15393
15417
  value = 0.0;
15418
+ this.typingPending = false;
15394
15419
  this.innerValue = value;
15395
15420
  this.value = value;
15396
15421
  this.formattedAmount =