@fluxhub/fluxhub-lib 21.0.8 → 21.0.10

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.
@@ -2341,6 +2341,8 @@ class FHComboboxComponent {
2341
2341
  translateValue(val) {
2342
2342
  if (!val)
2343
2343
  return '';
2344
+ // descrizione_valore puo' arrivare numerica dalla query: instant() vuole una stringa
2345
+ val = '' + val;
2344
2346
  if (val == '')
2345
2347
  return '';
2346
2348
  if (!this.disableTranslation)
@@ -2723,6 +2725,8 @@ class FHAutoCompleteComponent {
2723
2725
  translateValue(val) {
2724
2726
  if ((val || '') == '')
2725
2727
  return '';
2728
+ // descrizione_valore puo' arrivare numerica dalla query: instant() vuole una stringa
2729
+ val = '' + val;
2726
2730
  if (!this.disableTranslation && this.only_from_list)
2727
2731
  return this._tsr.instant(val);
2728
2732
  else
@@ -13759,10 +13763,26 @@ class FHNumericFieldComponent {
13759
13763
  constructor(uti_s) {
13760
13764
  this.uti_s = uti_s;
13761
13765
  this.modelChangeSubject.pipe(debounceTime(300)).subscribe(value => {
13762
- this.onChange(value.split(this.suffixSymbol).join(""));
13766
+ // Al modello va sempre un numero (come in chg()), non la stringa formattata ("10.624,66"):
13767
+ // il testo nel campo non viene toccato. Se nel frattempo c'e' stato blur/invio/writeValue
13768
+ // il valore e' gia' stato propagato e questa emissione e' superata. (change) resta invariato.
13769
+ if (this.typingPending) {
13770
+ this.typingPending = false;
13771
+ const num = this.parseFormatted(value);
13772
+ if (num != null)
13773
+ this.onChange(num);
13774
+ }
13763
13775
  this.change.emit(value.split(this.suffixSymbol).join(""));
13764
13776
  });
13765
13777
  }
13778
+ typingPending = false;
13779
+ // Stesso parsing di chg(); null se il testo non e' (ancora) un numero, es. solo "-"
13780
+ parseFormatted(text) {
13781
+ if (text == null || text == "")
13782
+ return this.uti_s.round(0, this.decimal);
13783
+ const num = this.uti_s.round(parseFloat(text.split(".").join("").split(",").join(".").split(this.suffixSymbol).join("")), this.decimal);
13784
+ return isNaN(num) ? null : num;
13785
+ }
13766
13786
  keyDownFunctioncl(event) {
13767
13787
  if (event.keyCode == 13) {
13768
13788
  this.chg();
@@ -13770,6 +13790,7 @@ class FHNumericFieldComponent {
13770
13790
  }
13771
13791
  }
13772
13792
  modelch() {
13793
+ this.typingPending = true;
13773
13794
  setTimeout(() => {
13774
13795
  this.modelChangeSubject.next(this.formattedAmount);
13775
13796
  });
@@ -13798,11 +13819,13 @@ class FHNumericFieldComponent {
13798
13819
  this.formattedAmount = this.transform(this.value, this.decimal) + this.suffixSymbol;
13799
13820
  }
13800
13821
  this.chgf = true;
13822
+ this.typingPending = false;
13801
13823
  this.onChange(this.value);
13802
13824
  }
13803
13825
  writeValue(value) {
13804
13826
  if (value == null)
13805
13827
  value = 0.0;
13828
+ this.typingPending = false;
13806
13829
  this.innerValue = value;
13807
13830
  this.value = value;
13808
13831
  this.formattedAmount = this.transform(this.value, this.decimal) + this.suffixSymbol;