@eqproject/eqp-dynamic-module 2.9.23 → 2.9.25

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.
@@ -3346,10 +3346,11 @@ class NumericFieldTemplateComponent {
3346
3346
  this.record[this.field.Name] = null;
3347
3347
  }
3348
3348
  }
3349
- if (this.field.DataGetter.DataGetterType == DataGetterTypeEnum.Manuale && this.record[this.field.Name] == null) {
3350
- this.record[this.field.Name] = this.field.DataGetter.DataGetterValue;
3351
- this.recordChange.emit(this.record);
3352
- }
3349
+ // Non ricordo perchè ho messo questo codice, quindi lo commento, poi ci penseremo (l'attivazione crea un loop, non farlo)
3350
+ /*if (this.field.DataGetter.DataGetterType == DataGetterTypeEnum.Manuale && this.record[this.field.Name] == null) {
3351
+ this.record[this.field.Name] = this.field.DataGetter.DataGetterValue;
3352
+ this.recordChange.emit(this.record);
3353
+ }*/
3353
3354
  }
3354
3355
  /**
3355
3356
  * Metodo per emettere l'evento che il valore del record è cambiato.
@@ -5689,10 +5690,14 @@ class ActionButtonFieldTemplateComponent {
5689
5690
  GlobalService.debugLog("checkTriggers - assigned DMMODULE - id/code ", formula);
5690
5691
  }
5691
5692
  else if (formulaObj.type == TriggerPropertyTypeEnum.DROPDOWN_LIST) {
5692
- temp = formulaObj.selectedAllowedValue.key; // nel caso di dropdown gli assegno solo la chiave
5693
+ // se la proprietà non esiste è assegnato value - modifica di una configurazione dichiarata in precedenza come string
5694
+ temp =
5695
+ formulaObj?.selectedAllowedValue?.key ? formulaObj.selectedAllowedValue.key
5696
+ : (UtilityHelperService.EvaluateFieldFormula(formula, this.record, this.formulaObject));
5693
5697
  GlobalService.debugLog("checkTriggers - assigned DROPDOWN_LIST- selectedAllowedValue ", formulaObj.selectedAllowedValue);
5694
5698
  }
5695
- else { // passo all'eval quando è stringa e assegno il valore calcolato
5699
+ else {
5700
+ // passo all'eval quando è stringa e assegno il valore calcolato
5696
5701
  temp = UtilityHelperService.EvaluateFieldFormula(formula, this.record, this.formulaObject);
5697
5702
  GlobalService.debugLog("checkTriggers - assigned - .value formula ", formula);
5698
5703
  GlobalService.debugLog("checkTriggers - assigned > value formulaObj.type ", formulaObj);
@@ -6841,8 +6846,12 @@ class AddFormRecordComponent {
6841
6846
  temp = formula;
6842
6847
  }
6843
6848
  else if (formulas[key].type == TriggerPropertyTypeEnum.DROPDOWN_LIST) {
6844
- temp = formulas[key].selectedAllowedValue.key; // nel caso di dropdown gli assegno solo la chiave
6849
+ // se la proprietà non esiste è assegnato value - modifica di una configurazione dichiarata in precedenza come string
6850
+ //temp = formulas[key].selectedAllowedValue.key // nel caso di dropdown gli assegno solo la chiave
6845
6851
  GlobalService.debugLog("checkTriggers - assigned DROPDOWN_LIST- selectedAllowedValue ", temp);
6852
+ temp =
6853
+ formulas[key]?.selectedAllowedValue?.key ? formulas[key].selectedAllowedValue.key
6854
+ : (UtilityHelperService.EvaluateFieldFormula(formula, record, this.formulaObject));
6846
6855
  }
6847
6856
  else { // passo all'eval quando è stringa e assegno i lvalore calcolato
6848
6857
  temp = UtilityHelperService.EvaluateFieldFormula(formula, record, this.formulaObject);
@@ -13139,8 +13148,45 @@ class TriggerCreatorComponent {
13139
13148
  Object.keys(this.trigger.formulas).forEach((res) => {
13140
13149
  /**qui devono essere messi i campi con valori da visualizzare nei campi dentro il popup
13141
13150
  * (?) altrimenti se si entra in modifica non si vedono anche se presenti */
13142
- this.formulaFieldsStructure.find(x => x.key == res).value = this.trigger.formulas[res].value;
13143
- this.formulaFieldsStructure.find(x => x.key == res).selectedAllowedValue = this.trigger.formulas[res].selectedAllowedValue;
13151
+ const myFormula = this.formulaFieldsStructure.find(x => x.key == res);
13152
+ myFormula.value = this.trigger.formulas[res].value; // inizializzo valore allo stesso modo per tutti i trigger
13153
+ // se il valore è diverso dalla chiave, il trigger è stato configurato in precedenza come string
13154
+ if (myFormula.type == this.triggerPropertyType.DROPDOWN_LIST && myFormula.value && myFormula?.selectedAllowedValue?.key != myFormula.value) {
13155
+ // questo caso si presenta quando si legge la configurazione di un trigger con triggerPropertyType modificata (string->list)
13156
+ // se è una dropdown ma non è mai stata configurata come tale (es. dichiarata come string) selectedAllowedValue ha il valore di default o è null, quindi va inizializzato
13157
+ if (!myFormula.allowedValues) { // se non è presente una lista di valori di default la creo per inserirci il nuovo elemento che sarà mostrato come selezionato
13158
+ myFormula.allowedValues = new Array;
13159
+ }
13160
+ // controllo se il valore ha una corrispondenza nella lista dei valori ammissibili
13161
+ // toglo gli apici perché le formule per come sono configurate li contengono
13162
+ let cleanValue;
13163
+ if ((myFormula.value.startsWith("'") && myFormula.value.endsWith("'")) ||
13164
+ (myFormula.value.startsWith('"') && myFormula.value.endsWith('"'))) {
13165
+ cleanValue = myFormula.value.slice(1, -1);
13166
+ }
13167
+ else {
13168
+ cleanValue = myFormula.value;
13169
+ }
13170
+ let newValueToShow = new KeyValue;
13171
+ newValueToShow.key = myFormula.value;
13172
+ newValueToShow.value = myFormula.value;
13173
+ const alreadyExist = myFormula.allowedValues.find(item => item.key == cleanValue || item.key == myFormula.value);
13174
+ // - se value è presente e diverso dal selettore nella dropdown lo ricerco tra i valori ammissibili; se non lo trovo lo aggiungo come nuova voce nella select
13175
+ if (alreadyExist) {
13176
+ GlobalService.debugLog("@@ IS found alreadyExist", alreadyExist);
13177
+ myFormula.selectedAllowedValue = alreadyExist;
13178
+ }
13179
+ else {
13180
+ GlobalService.debugLog("@@ NOT found alreadyExist", alreadyExist);
13181
+ let newValueToShow = new KeyValue;
13182
+ newValueToShow.key = newValueToShow.value = cleanValue;
13183
+ myFormula.allowedValues.push(newValueToShow);
13184
+ myFormula.selectedAllowedValue = newValueToShow;
13185
+ }
13186
+ }
13187
+ else {
13188
+ myFormula.selectedAllowedValue = this.trigger.formulas[res].selectedAllowedValue;
13189
+ }
13144
13190
  });
13145
13191
  }
13146
13192
  var executeGetModules = false;
@@ -13155,6 +13201,7 @@ class TriggerCreatorComponent {
13155
13201
  if (executeGetModules) {
13156
13202
  this.getAllModules();
13157
13203
  }
13204
+ GlobalService.debugLog("@@ formulaFieldsStructure", this.formulaFieldsStructure);
13158
13205
  }
13159
13206
  onTriggerChange(outputCondition, TriggerCondition) {
13160
13207
  this.trigger.conditions.find(x => x.CID == TriggerCondition.CID).booleanlogicoperator = outputCondition.booleanlogicoperator;