@eqproject/eqp-dynamic-module 2.10.82 → 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.
@@ -8306,6 +8306,12 @@ class AddFormRecordComponent {
8306
8306
  this.FormScalarTypeEnum = FormScalarTypeEnum;
8307
8307
  this.FieldTypeEnum = FieldTypeEnum;
8308
8308
  this.visibleActionButtons = new Array();
8309
+ //#region onRecordChange
8310
+ /**
8311
+ * Metodo invocato al cambio del valore di ogni proprietà dell'oggetto record.
8312
+ * Serve ad aggiornare il valore di tutti i campi che hanno una formula.
8313
+ */
8314
+ this._isInRecordChange = false;
8309
8315
  }
8310
8316
  ngOnInit() {
8311
8317
  injectGoogleFontsFromForm(this.form);
@@ -8351,18 +8357,37 @@ class AddFormRecordComponent {
8351
8357
  GlobalService.speechDirective.SpeechToTextToggler();
8352
8358
  }
8353
8359
  }
8354
- //#region onRecordChange
8355
- /**
8356
- * Metodo invocato al cambio del valore di ogni proprietà dell'oggetto record.
8357
- * Serve ad aggiornare il valore di tutti i campi che hanno una formula.
8358
- */
8359
8360
  onRecordChange() {
8360
- if (this.fieldTemplate && this.fieldTemplate.length > 0) {
8361
- this.fieldTemplate.forEach((f) => {
8362
- if (f != null && typeof f.updateField === 'function') {
8363
- f.updateField();
8364
- }
8365
- });
8361
+ var _a;
8362
+ // Guardia di rientranza: setValue sui FormControl può triggerare writeValue sui ControlValueAccessor
8363
+ // (es. mat-datepicker), che emettono (dateChange)/(ngModelChange) recordChange loop infinito.
8364
+ if (this._isInRecordChange) {
8365
+ return;
8366
+ }
8367
+ this._isInRecordChange = true;
8368
+ try {
8369
+ if (this.fieldTemplate && this.fieldTemplate.length > 0) {
8370
+ this.fieldTemplate.forEach((f) => {
8371
+ if (f != null && typeof f.updateField === 'function') {
8372
+ f.updateField();
8373
+ }
8374
+ });
8375
+ }
8376
+ // Le formule aggiornano record[fieldName] direttamente, senza passare dal FormControl.
8377
+ // Qui risincronizziamo i FormControl il cui valore è cambiato rispetto al record,
8378
+ // altrimenti la validazione required fallisce sui campi valorizzati via formula/ActionButton.
8379
+ if ((_a = this.form) === null || _a === void 0 ? void 0 : _a.Fields) {
8380
+ this.form.Fields.forEach(field => {
8381
+ var _a;
8382
+ const ctrl = (_a = field.FormFormGroup) === null || _a === void 0 ? void 0 : _a.get(field.Name);
8383
+ if (ctrl != null && ctrl.value !== this.record[field.Name]) {
8384
+ ctrl.setValue(this.record[field.Name], { emitEvent: false });
8385
+ }
8386
+ });
8387
+ }
8388
+ }
8389
+ finally {
8390
+ this._isInRecordChange = false;
8366
8391
  }
8367
8392
  }
8368
8393
  //#endregion onRecordChange