@eqproject/eqp-dynamic-module 2.9.24 → 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.
@@ -5690,10 +5690,14 @@ class ActionButtonFieldTemplateComponent {
5690
5690
  GlobalService.debugLog("checkTriggers - assigned DMMODULE - id/code ", formula);
5691
5691
  }
5692
5692
  else if (formulaObj.type == TriggerPropertyTypeEnum.DROPDOWN_LIST) {
5693
- 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));
5694
5697
  GlobalService.debugLog("checkTriggers - assigned DROPDOWN_LIST- selectedAllowedValue ", formulaObj.selectedAllowedValue);
5695
5698
  }
5696
- else { // passo all'eval quando è stringa e assegno il valore calcolato
5699
+ else {
5700
+ // passo all'eval quando è stringa e assegno il valore calcolato
5697
5701
  temp = UtilityHelperService.EvaluateFieldFormula(formula, this.record, this.formulaObject);
5698
5702
  GlobalService.debugLog("checkTriggers - assigned - .value formula ", formula);
5699
5703
  GlobalService.debugLog("checkTriggers - assigned > value formulaObj.type ", formulaObj);
@@ -6842,8 +6846,12 @@ class AddFormRecordComponent {
6842
6846
  temp = formula;
6843
6847
  }
6844
6848
  else if (formulas[key].type == TriggerPropertyTypeEnum.DROPDOWN_LIST) {
6845
- 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
6846
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));
6847
6855
  }
6848
6856
  else { // passo all'eval quando è stringa e assegno i lvalore calcolato
6849
6857
  temp = UtilityHelperService.EvaluateFieldFormula(formula, record, this.formulaObject);
@@ -13140,8 +13148,45 @@ class TriggerCreatorComponent {
13140
13148
  Object.keys(this.trigger.formulas).forEach((res) => {
13141
13149
  /**qui devono essere messi i campi con valori da visualizzare nei campi dentro il popup
13142
13150
  * (?) altrimenti se si entra in modifica non si vedono anche se presenti */
13143
- this.formulaFieldsStructure.find(x => x.key == res).value = this.trigger.formulas[res].value;
13144
- 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
+ }
13145
13190
  });
13146
13191
  }
13147
13192
  var executeGetModules = false;
@@ -13156,6 +13201,7 @@ class TriggerCreatorComponent {
13156
13201
  if (executeGetModules) {
13157
13202
  this.getAllModules();
13158
13203
  }
13204
+ GlobalService.debugLog("@@ formulaFieldsStructure", this.formulaFieldsStructure);
13159
13205
  }
13160
13206
  onTriggerChange(outputCondition, TriggerCondition) {
13161
13207
  this.trigger.conditions.find(x => x.CID == TriggerCondition.CID).booleanlogicoperator = outputCondition.booleanlogicoperator;