kwikid-forms 0.6.14 → 0.6.16

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 updateLanguage = 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, _d, _e, _f;
1195
+ return ((_f = (_e = (_d = (_c = (_b = (_a = localStorage.getItem("lng")) !== null && _a !== void 0 ? _a : localStorage.getItem("lang")) !== null && _b !== void 0 ? _b : localStorage.getItem("Lang")) !== null && _c !== void 0 ? _c : localStorage.getItem("language")) !== null && _d !== void 0 ? _d : localStorage.getItem("currentLang")) !== null && _e !== void 0 ? _e : localStorage.getItem("selectedLang")) !== null && _f !== void 0 ? _f : "en");
1196
+ };
1179
1197
 
1180
1198
  var Converter = /** @class */ (function () {
1181
1199
  function Converter() {
@@ -1745,18 +1763,51 @@
1745
1763
  }
1746
1764
  return fieldGroups;
1747
1765
  };
1766
+ var updateFormLanguage = function (formConfig, language) {
1767
+ if (kwikidToolkit.checkObjectPathExists(formConfig, "properties.header.title.label")) {
1768
+ formConfig.properties.header.title.label = updateLanguage(formConfig.properties.header.title.label, language);
1769
+ }
1770
+ if (kwikidToolkit.checkObjectPathExists(formConfig, "properties.footer.viewFormsButton.label")) {
1771
+ formConfig.properties.footer.viewFormsButton.label = updateLanguage(formConfig.properties.footer.viewFormsButton.label, language);
1772
+ }
1773
+ if (kwikidToolkit.checkObjectPathExists(formConfig, "properties.footer.saveButton.label")) {
1774
+ formConfig.properties.footer.saveButton.label = updateLanguage(formConfig.properties.footer.saveButton.label, language);
1775
+ }
1776
+ return formConfig;
1777
+ };
1778
+ var updateFieldLanguage = function (field, language) {
1779
+ if (kwikidToolkit.checkObjectKeyExists(field, "label")) {
1780
+ field.label = updateLanguage(field.label, language);
1781
+ }
1782
+ if (kwikidToolkit.checkObjectPathExists(field, "properties.placeholder")) {
1783
+ field.properties["placeholder"] = updateLanguage(field.properties["placeholder"], language);
1784
+ }
1785
+ if (field.type == EFieldType.HTML &&
1786
+ kwikidToolkit.checkObjectPathExists(field, "html")) {
1787
+ field["html"] = updateLanguage(field["html"], language);
1788
+ }
1789
+ var updateApiStatus = function (fieldApiStatus) {
1790
+ for (var status in fieldApiStatus) {
1791
+ fieldApiStatus[status] = updateLanguage(fieldApiStatus[status], language);
1792
+ }
1793
+ return fieldApiStatus;
1794
+ };
1795
+ if (field.type == EFieldType.API_CALL &&
1796
+ kwikidToolkit.checkObjectPathExists(field, "api.status")) {
1797
+ field["api"]["status"]["labels"] = updateApiStatus(field["api"]["status"]["labels"]);
1798
+ }
1799
+ return field;
1800
+ };
1748
1801
  var fields = getFormFields(formConfig);
1749
1802
  var fieldGroups = {};
1750
1803
  try {
1751
1804
  for (var fields_1 = __values(fields), fields_1_1 = fields_1.next(); !fields_1_1.done; fields_1_1 = fields_1.next()) {
1752
1805
  var field = fields_1_1.value;
1806
+ field = updateFieldLanguage(field, getLanguage());
1753
1807
  field = formatOnFieldType(field);
1754
1808
  field = updateFieldDisability(field);
1755
1809
  fieldGroups = updateFormFieldGroups(fieldGroups, field);
1756
- console.log("sadssadasdsdda");
1757
- console.log(kwikidToolkit.getObjectDeepCopy(field));
1758
1810
  field = updateFieldDefaultValue(field);
1759
- console.log(kwikidToolkit.getObjectDeepCopy(field));
1760
1811
  field = updateFieldValidators(field);
1761
1812
  field = updateFieldResetButton(field);
1762
1813
  field = updateFieldMessages(field);
@@ -1769,6 +1820,7 @@
1769
1820
  }
1770
1821
  finally { if (e_1) throw e_1.error; }
1771
1822
  }
1823
+ formConfig = updateFormLanguage(formConfig, getLanguage());
1772
1824
  formConfig = setFormFieldGroups(formConfig, fieldGroups);
1773
1825
  formConfig = setFormFields(formConfig, fields);
1774
1826
  return formConfig;
@@ -3225,13 +3277,8 @@
3225
3277
  value = _b.sent();
3226
3278
  _b.label = 4;
3227
3279
  case 4:
3228
- console.log("sdasgdjsgsadaghas");
3229
- console.log("sdasgdjsgsadaghas1");
3230
3280
  if (!kwikidToolkit.checkObjectKeyExists(field, "default")) return [3 /*break*/, 6];
3231
- console.log("sdasgdjsgsadaghas2");
3232
- console.log(kwikidToolkit.getObjectDeepCopy(field));
3233
3281
  if (!kwikidToolkit.checkObjectKeyExists(field.default, "api")) return [3 /*break*/, 6];
3234
- console.log("sdasgdjsgsadaghas3");
3235
3282
  return [4 /*yield*/, defaults.getFormFieldApiValue()];
3236
3283
  case 5:
3237
3284
  _b.sent();
@@ -5936,7 +5983,6 @@
5936
5983
  }
5937
5984
  }, sourceValue);
5938
5985
  object.FIELD_CONFIG = source.object.FIELD_CONFIG;
5939
- console.log("PRINT0", kwikidToolkit.getObjectDeepCopy(source), sourceValue);
5940
5986
  return [2 /*return*/];
5941
5987
  });
5942
5988
  });
@@ -5961,7 +6007,6 @@
5961
6007
  }
5962
6008
  }, sourceValue);
5963
6009
  object.API_CONFIG = source.object.API_CONFIG;
5964
- console.log("PRINT1", kwikidToolkit.getObjectDeepCopy(source), sourceValue);
5965
6010
  return [2 /*return*/];
5966
6011
  }
5967
6012
  });
@@ -5983,7 +6028,6 @@
5983
6028
  }
5984
6029
  }, sourceValue);
5985
6030
  object.API_CONFIG = source.object.API_CONFIG;
5986
- console.log("PRINT2", kwikidToolkit.getObjectDeepCopy(source), sourceValue);
5987
6031
  return [2 /*return*/];
5988
6032
  });
5989
6033
  });
@@ -6008,7 +6052,6 @@
6008
6052
  }
6009
6053
  }, sourceValue);
6010
6054
  object.API_CONFIG = source.object.API_CONFIG;
6011
- console.log("PRINT3", kwikidToolkit.getObjectDeepCopy(source), sourceValue);
6012
6055
  return [2 /*return*/];
6013
6056
  }
6014
6057
  });
@@ -6030,7 +6073,6 @@
6030
6073
  }
6031
6074
  }, sourceValue);
6032
6075
  object.API_CONFIG = source.object.API_CONFIG;
6033
- console.log("PRINT4", kwikidToolkit.getObjectDeepCopy(source), sourceValue);
6034
6076
  return [2 /*return*/];
6035
6077
  });
6036
6078
  });
@@ -6040,7 +6082,6 @@
6040
6082
  var source, sourceValue;
6041
6083
  return __generator(this, function (_k) {
6042
6084
  source = new kwikidToolkit.Source(object);
6043
- console.log(kwikidToolkit.getObjectDeepCopy(object));
6044
6085
  sourceValue = action.props.valid;
6045
6086
  source.setValueToSource({
6046
6087
  key: kwikidToolkit.ESourceKey.OBJECT,
@@ -6052,7 +6093,6 @@
6052
6093
  }
6053
6094
  }, sourceValue);
6054
6095
  object.API_CONFIG = source.object.API_CONFIG;
6055
- console.log("PRINT5", kwikidToolkit.getObjectDeepCopy(source), sourceValue);
6056
6096
  return [2 /*return*/];
6057
6097
  });
6058
6098
  });
@@ -6521,6 +6561,7 @@
6521
6561
  action = kwikidToolkit.setValueToObjectPath(action, "props.message.message", fieldErrorShowSourceValue);
6522
6562
  _l.label = 8;
6523
6563
  case 8:
6564
+ action.props.message.message = updateLanguage(action.props.message.message, getLanguage());
6524
6565
  this.fieldErrorShow(action.props.fieldKey, action.props.message);
6525
6566
  return [3 /*break*/, 63];
6526
6567
  case 9:
@@ -7019,6 +7060,7 @@
7019
7060
  this.setSelectedForm((_b = (_a = this.activeFormConfig) === null || _a === void 0 ? void 0 : _a.key) !== null && _b !== void 0 ? _b : "");
7020
7061
  this.stepConfig = this.formatStepConfig(this.stepConfig);
7021
7062
  this.formsList = this.filterHiddenForms(this.formsList);
7063
+ this.formsList = this.setFormTitles(this.formsList);
7022
7064
  this.formsListLength = this.findFormsListLength(this.formsList);
7023
7065
  this.isAllFormsCompleted = this.checkIsAllFormsCompleted(this.formsList);
7024
7066
  this.loading = false;
@@ -7039,6 +7081,7 @@
7039
7081
  }
7040
7082
  if (verifyChange("formsList")) {
7041
7083
  this.formsList = this.filterHiddenForms(this.formsList);
7084
+ this.formsList = this.setFormTitles(this.formsList);
7042
7085
  this.formsListLength = this.findFormsListLength(this.formsList);
7043
7086
  this.isAllFormsCompleted = this.checkIsAllFormsCompleted(this.formsList);
7044
7087
  }
@@ -7076,6 +7119,8 @@
7076
7119
  stepConfig = kwikidToolkit.setValueToObjectPath(stepConfig, "props", stepConfigProperties);
7077
7120
  }
7078
7121
  }
7122
+ stepConfig.props.formListProperties.footer.submitFormButton.label =
7123
+ updateLanguage(stepConfig.props.formListProperties.footer.submitFormButton.label, getLanguage());
7079
7124
  return stepConfig;
7080
7125
  };
7081
7126
  KwikIDFormsListComponent.prototype.filterHiddenForms = function (formsList) {
@@ -7087,6 +7132,14 @@
7087
7132
  }
7088
7133
  });
7089
7134
  };
7135
+ KwikIDFormsListComponent.prototype.setFormTitles = function (formsList) {
7136
+ return formsList.filter(function (form) {
7137
+ if (kwikidToolkit.checkObjectPathExists(form, "props.title")) {
7138
+ form.props.title = updateLanguage(form.props.title, getLanguage());
7139
+ return form;
7140
+ }
7141
+ });
7142
+ };
7090
7143
  KwikIDFormsListComponent.prototype.findFormsListLength = function (formsList) {
7091
7144
  var _formsList = formsList.filter(function (form) {
7092
7145
  if (kwikidToolkit.checkObjectKeyExists(form, "type")) {