kwikid-forms 0.6.14 → 0.6.15

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.
@@ -1176,6 +1176,24 @@
1176
1176
  );
1177
1177
  }
1178
1178
  };
1179
+ var updateDisplayLanguage = function (object, language) {
1180
+ if (isObject(object)) {
1181
+ if (language && kwikidToolkit.checkObjectKeyExists(object, language)) {
1182
+ object = object[language];
1183
+ }
1184
+ else {
1185
+ object = object["en"];
1186
+ }
1187
+ }
1188
+ return object;
1189
+ };
1190
+ var isObject = function (variable) {
1191
+ return typeof variable === "object" && variable !== null;
1192
+ };
1193
+ var getLanguage = function () {
1194
+ var _a, _b, _c;
1195
+ return ((_c = (_b = (_a = localStorage.getItem("lng")) !== null && _a !== void 0 ? _a : localStorage.getItem("lang")) !== null && _b !== void 0 ? _b : localStorage.getItem("language")) !== null && _c !== void 0 ? _c : "en");
1196
+ };
1179
1197
 
1180
1198
  var Converter = /** @class */ (function () {
1181
1199
  function Converter() {
@@ -1745,6 +1763,38 @@
1745
1763
  }
1746
1764
  return fieldGroups;
1747
1765
  };
1766
+ var updateFormDisplayLanguage = function (formConfig, language) {
1767
+ if (kwikidToolkit.checkObjectPathExists(formConfig, "properties.header.title.label")) {
1768
+ formConfig.properties.header.title.label = updateDisplayLanguage(formConfig.properties.header.title.label, language);
1769
+ }
1770
+ if (kwikidToolkit.checkObjectPathExists(formConfig, "properties.footer.viewFormsButton.label")) {
1771
+ formConfig.properties.footer.viewFormsButton.label =
1772
+ updateDisplayLanguage(formConfig.properties.footer.viewFormsButton.label, language);
1773
+ }
1774
+ if (kwikidToolkit.checkObjectPathExists(formConfig, "properties.footer.saveButton.label")) {
1775
+ formConfig.properties.footer.saveButton.label = updateDisplayLanguage(formConfig.properties.footer.saveButton.label, language);
1776
+ }
1777
+ return formConfig;
1778
+ };
1779
+ var updateFieldDisplayLanguage = function (field, language) {
1780
+ if (kwikidToolkit.checkObjectKeyExists(field, "label")) {
1781
+ field.label = updateDisplayLanguage(field.label, language);
1782
+ }
1783
+ if (kwikidToolkit.checkObjectPathExists(field, "properties.placeholder")) {
1784
+ field.properties["placeholder"] = updateDisplayLanguage(field.properties["placeholder"], language);
1785
+ }
1786
+ var updateApiStatus = function (fieldApiStatus) {
1787
+ for (var status in fieldApiStatus) {
1788
+ fieldApiStatus[status] = updateDisplayLanguage(fieldApiStatus[status], language);
1789
+ }
1790
+ return fieldApiStatus;
1791
+ };
1792
+ if (field.type == EFieldType.API_CALL &&
1793
+ kwikidToolkit.checkObjectPathExists(field, "api.status")) {
1794
+ field["api"]["status"]["labels"] = updateApiStatus(field["api"]["status"]["labels"]);
1795
+ }
1796
+ return field;
1797
+ };
1748
1798
  var fields = getFormFields(formConfig);
1749
1799
  var fieldGroups = {};
1750
1800
  try {
@@ -1753,12 +1803,10 @@
1753
1803
  field = formatOnFieldType(field);
1754
1804
  field = updateFieldDisability(field);
1755
1805
  fieldGroups = updateFormFieldGroups(fieldGroups, field);
1756
- console.log("sadssadasdsdda");
1757
- console.log(kwikidToolkit.getObjectDeepCopy(field));
1758
1806
  field = updateFieldDefaultValue(field);
1759
- console.log(kwikidToolkit.getObjectDeepCopy(field));
1760
1807
  field = updateFieldValidators(field);
1761
1808
  field = updateFieldResetButton(field);
1809
+ field = updateFieldDisplayLanguage(field, getLanguage());
1762
1810
  field = updateFieldMessages(field);
1763
1811
  }
1764
1812
  }
@@ -1769,6 +1817,7 @@
1769
1817
  }
1770
1818
  finally { if (e_1) throw e_1.error; }
1771
1819
  }
1820
+ formConfig = updateFormDisplayLanguage(formConfig, getLanguage());
1772
1821
  formConfig = setFormFieldGroups(formConfig, fieldGroups);
1773
1822
  formConfig = setFormFields(formConfig, fields);
1774
1823
  return formConfig;
@@ -3225,13 +3274,8 @@
3225
3274
  value = _b.sent();
3226
3275
  _b.label = 4;
3227
3276
  case 4:
3228
- console.log("sdasgdjsgsadaghas");
3229
- console.log("sdasgdjsgsadaghas1");
3230
3277
  if (!kwikidToolkit.checkObjectKeyExists(field, "default")) return [3 /*break*/, 6];
3231
- console.log("sdasgdjsgsadaghas2");
3232
- console.log(kwikidToolkit.getObjectDeepCopy(field));
3233
3278
  if (!kwikidToolkit.checkObjectKeyExists(field.default, "api")) return [3 /*break*/, 6];
3234
- console.log("sdasgdjsgsadaghas3");
3235
3279
  return [4 /*yield*/, defaults.getFormFieldApiValue()];
3236
3280
  case 5:
3237
3281
  _b.sent();
@@ -5936,7 +5980,6 @@
5936
5980
  }
5937
5981
  }, sourceValue);
5938
5982
  object.FIELD_CONFIG = source.object.FIELD_CONFIG;
5939
- console.log("PRINT0", kwikidToolkit.getObjectDeepCopy(source), sourceValue);
5940
5983
  return [2 /*return*/];
5941
5984
  });
5942
5985
  });
@@ -5961,7 +6004,6 @@
5961
6004
  }
5962
6005
  }, sourceValue);
5963
6006
  object.API_CONFIG = source.object.API_CONFIG;
5964
- console.log("PRINT1", kwikidToolkit.getObjectDeepCopy(source), sourceValue);
5965
6007
  return [2 /*return*/];
5966
6008
  }
5967
6009
  });
@@ -5983,7 +6025,6 @@
5983
6025
  }
5984
6026
  }, sourceValue);
5985
6027
  object.API_CONFIG = source.object.API_CONFIG;
5986
- console.log("PRINT2", kwikidToolkit.getObjectDeepCopy(source), sourceValue);
5987
6028
  return [2 /*return*/];
5988
6029
  });
5989
6030
  });
@@ -6008,7 +6049,6 @@
6008
6049
  }
6009
6050
  }, sourceValue);
6010
6051
  object.API_CONFIG = source.object.API_CONFIG;
6011
- console.log("PRINT3", kwikidToolkit.getObjectDeepCopy(source), sourceValue);
6012
6052
  return [2 /*return*/];
6013
6053
  }
6014
6054
  });
@@ -6030,7 +6070,6 @@
6030
6070
  }
6031
6071
  }, sourceValue);
6032
6072
  object.API_CONFIG = source.object.API_CONFIG;
6033
- console.log("PRINT4", kwikidToolkit.getObjectDeepCopy(source), sourceValue);
6034
6073
  return [2 /*return*/];
6035
6074
  });
6036
6075
  });
@@ -6040,7 +6079,6 @@
6040
6079
  var source, sourceValue;
6041
6080
  return __generator(this, function (_k) {
6042
6081
  source = new kwikidToolkit.Source(object);
6043
- console.log(kwikidToolkit.getObjectDeepCopy(object));
6044
6082
  sourceValue = action.props.valid;
6045
6083
  source.setValueToSource({
6046
6084
  key: kwikidToolkit.ESourceKey.OBJECT,
@@ -6052,7 +6090,6 @@
6052
6090
  }
6053
6091
  }, sourceValue);
6054
6092
  object.API_CONFIG = source.object.API_CONFIG;
6055
- console.log("PRINT5", kwikidToolkit.getObjectDeepCopy(source), sourceValue);
6056
6093
  return [2 /*return*/];
6057
6094
  });
6058
6095
  });
@@ -6521,6 +6558,7 @@
6521
6558
  action = kwikidToolkit.setValueToObjectPath(action, "props.message.message", fieldErrorShowSourceValue);
6522
6559
  _l.label = 8;
6523
6560
  case 8:
6561
+ action.props.message.message = updateDisplayLanguage(action.props.message.message, getLanguage());
6524
6562
  this.fieldErrorShow(action.props.fieldKey, action.props.message);
6525
6563
  return [3 /*break*/, 63];
6526
6564
  case 9:
@@ -7019,6 +7057,7 @@
7019
7057
  this.setSelectedForm((_b = (_a = this.activeFormConfig) === null || _a === void 0 ? void 0 : _a.key) !== null && _b !== void 0 ? _b : "");
7020
7058
  this.stepConfig = this.formatStepConfig(this.stepConfig);
7021
7059
  this.formsList = this.filterHiddenForms(this.formsList);
7060
+ this.formsList = this.setFormTitles(this.formsList);
7022
7061
  this.formsListLength = this.findFormsListLength(this.formsList);
7023
7062
  this.isAllFormsCompleted = this.checkIsAllFormsCompleted(this.formsList);
7024
7063
  this.loading = false;
@@ -7039,6 +7078,7 @@
7039
7078
  }
7040
7079
  if (verifyChange("formsList")) {
7041
7080
  this.formsList = this.filterHiddenForms(this.formsList);
7081
+ this.formsList = this.setFormTitles(this.formsList);
7042
7082
  this.formsListLength = this.findFormsListLength(this.formsList);
7043
7083
  this.isAllFormsCompleted = this.checkIsAllFormsCompleted(this.formsList);
7044
7084
  }
@@ -7076,6 +7116,8 @@
7076
7116
  stepConfig = kwikidToolkit.setValueToObjectPath(stepConfig, "props", stepConfigProperties);
7077
7117
  }
7078
7118
  }
7119
+ stepConfig.props.formListProperties.footer.submitFormButton.label =
7120
+ updateDisplayLanguage(stepConfig.props.formListProperties.footer.submitFormButton.label, getLanguage());
7079
7121
  return stepConfig;
7080
7122
  };
7081
7123
  KwikIDFormsListComponent.prototype.filterHiddenForms = function (formsList) {
@@ -7087,6 +7129,14 @@
7087
7129
  }
7088
7130
  });
7089
7131
  };
7132
+ KwikIDFormsListComponent.prototype.setFormTitles = function (formsList) {
7133
+ return formsList.filter(function (form) {
7134
+ if (kwikidToolkit.checkObjectPathExists(form, "props.title")) {
7135
+ form.props.title = updateDisplayLanguage(form.props.title, getLanguage());
7136
+ return form;
7137
+ }
7138
+ });
7139
+ };
7090
7140
  KwikIDFormsListComponent.prototype.findFormsListLength = function (formsList) {
7091
7141
  var _formsList = formsList.filter(function (form) {
7092
7142
  if (kwikidToolkit.checkObjectKeyExists(form, "type")) {