@eqproject/eqp-dynamic-module 2.10.83 → 2.10.84

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.
@@ -8237,6 +8237,12 @@ class AddFormRecordComponent {
8237
8237
  this.FormScalarTypeEnum = FormScalarTypeEnum;
8238
8238
  this.FieldTypeEnum = FieldTypeEnum;
8239
8239
  this.visibleActionButtons = new Array();
8240
+ //#region onRecordChange
8241
+ /**
8242
+ * Metodo invocato al cambio del valore di ogni proprietà dell'oggetto record.
8243
+ * Serve ad aggiornare il valore di tutti i campi che hanno una formula.
8244
+ */
8245
+ this._isInRecordChange = false;
8240
8246
  }
8241
8247
  ngOnInit() {
8242
8248
  injectGoogleFontsFromForm(this.form);
@@ -8282,27 +8288,33 @@ class AddFormRecordComponent {
8282
8288
  GlobalService.speechDirective.SpeechToTextToggler();
8283
8289
  }
8284
8290
  }
8285
- //#region onRecordChange
8286
- /**
8287
- * Metodo invocato al cambio del valore di ogni proprietà dell'oggetto record.
8288
- * Serve ad aggiornare il valore di tutti i campi che hanno una formula.
8289
- */
8290
8291
  onRecordChange() {
8291
- if (this.fieldTemplate && this.fieldTemplate.length > 0) {
8292
- this.fieldTemplate.forEach((f) => { if (f != null && typeof f.updateField === 'function') {
8293
- f.updateField();
8294
- } });
8292
+ // Guardia di rientranza: setValue sui FormControl può triggerare writeValue sui ControlValueAccessor
8293
+ // (es. mat-datepicker), che emettono (dateChange)/(ngModelChange) recordChange loop infinito.
8294
+ if (this._isInRecordChange) {
8295
+ return;
8295
8296
  }
8296
- // Le formule aggiornano record[fieldName] direttamente, senza passare dal FormControl.
8297
- // Qui risincronizziamo tutti i FormControl dal record, altrimenti la validazione required
8298
- // non si aggiorna quando un campo viene valorizzato via formula o ActionButton.
8299
- if (this.form?.Fields) {
8300
- this.form.Fields.forEach(field => {
8301
- const ctrl = field.FormFormGroup?.get(field.Name);
8302
- if (ctrl != null) {
8303
- ctrl.setValue(this.record[field.Name], { emitEvent: false });
8304
- }
8305
- });
8297
+ this._isInRecordChange = true;
8298
+ try {
8299
+ if (this.fieldTemplate && this.fieldTemplate.length > 0) {
8300
+ this.fieldTemplate.forEach((f) => { if (f != null && typeof f.updateField === 'function') {
8301
+ f.updateField();
8302
+ } });
8303
+ }
8304
+ // Le formule aggiornano record[fieldName] direttamente, senza passare dal FormControl.
8305
+ // Qui risincronizziamo i FormControl il cui valore è cambiato rispetto al record,
8306
+ // altrimenti la validazione required fallisce sui campi valorizzati via formula/ActionButton.
8307
+ if (this.form?.Fields) {
8308
+ this.form.Fields.forEach(field => {
8309
+ const ctrl = field.FormFormGroup?.get(field.Name);
8310
+ if (ctrl != null && ctrl.value !== this.record[field.Name]) {
8311
+ ctrl.setValue(this.record[field.Name], { emitEvent: false });
8312
+ }
8313
+ });
8314
+ }
8315
+ }
8316
+ finally {
8317
+ this._isInRecordChange = false;
8306
8318
  }
8307
8319
  }
8308
8320
  //#endregion onRecordChange