@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.
@@ -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,31 +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
8361
  var _a;
8361
- if (this.fieldTemplate && this.fieldTemplate.length > 0) {
8362
- this.fieldTemplate.forEach((f) => {
8363
- if (f != null && typeof f.updateField === 'function') {
8364
- f.updateField();
8365
- }
8366
- });
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;
8367
8366
  }
8368
- // Le formule aggiornano record[fieldName] direttamente, senza passare dal FormControl.
8369
- // Qui risincronizziamo tutti i FormControl dal record, altrimenti la validazione required
8370
- // non si aggiorna quando un campo viene valorizzato via formula o ActionButton.
8371
- if ((_a = this.form) === null || _a === void 0 ? void 0 : _a.Fields) {
8372
- this.form.Fields.forEach(field => {
8373
- var _a;
8374
- const ctrl = (_a = field.FormFormGroup) === null || _a === void 0 ? void 0 : _a.get(field.Name);
8375
- if (ctrl != null) {
8376
- ctrl.setValue(this.record[field.Name], { emitEvent: false });
8377
- }
8378
- });
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;
8379
8391
  }
8380
8392
  }
8381
8393
  //#endregion onRecordChange