@seniorsistemas/angular-components 16.3.9 → 16.3.10

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.
@@ -5137,19 +5137,19 @@
5137
5137
  TablePagingComponent.prototype.getSelectedRowsToExport = function (columns) {
5138
5138
  return this.mapColumnsTranslations(columns, this.table.selection);
5139
5139
  };
5140
- TablePagingComponent.prototype.getInnerPropValue = function (obj, path) {
5140
+ TablePagingComponent.prototype.getPropertyValue = function (obj, path) {
5141
5141
  return path.split(".").reduce(function (result, prop) { return (result[prop] === undefined ? undefined : result[prop]); }, obj);
5142
5142
  };
5143
- TablePagingComponent.prototype.setInnerPropValue = function (obj, path, value) {
5144
- this.recursionSet(obj, path.split("."), value);
5143
+ TablePagingComponent.prototype.setPropertyValue = function (obj, path, value) {
5144
+ this.recursionSetValue(obj, path.split("."), value);
5145
5145
  };
5146
- TablePagingComponent.prototype.recursionSet = function (obj, keysList, value) {
5146
+ TablePagingComponent.prototype.recursionSetValue = function (obj, keysList, value) {
5147
5147
  var key = keysList[0];
5148
5148
  if (keysList.length === 1) {
5149
5149
  obj[key] = value;
5150
5150
  return obj;
5151
5151
  }
5152
- obj[key] = (this.recursionSet((obj === null || obj === void 0 ? void 0 : obj[key]) || {}, keysList.slice(1), value));
5152
+ obj[key] = (this.recursionSetValue((obj === null || obj === void 0 ? void 0 : obj[key]) || {}, keysList.slice(1), value));
5153
5153
  return obj;
5154
5154
  };
5155
5155
  TablePagingComponent.prototype.mapColumnsTranslations = function (columns, rows) {
@@ -5160,37 +5160,42 @@
5160
5160
  }
5161
5161
  return __spread(rows).map(function (row) {
5162
5162
  var newRow = __assign({}, row);
5163
- var _loop_1 = function (i) {
5164
- var column = enumColumns[i];
5165
- var fields = column.field;
5166
- if (!Array.isArray(fields)) {
5167
- fields = [fields];
5168
- }
5163
+ enumColumns.forEach(function (column) {
5164
+ var fields = !Array.isArray(column.field) ? [column.field] : column.field;
5169
5165
  fields.forEach(function (fieldName) {
5170
- var columnData = _this.getInnerPropValue(row, fieldName);
5166
+ var columnData = _this.getPropertyValue(row, fieldName);
5171
5167
  if (columnData === null || columnData === undefined) {
5172
5168
  return;
5173
5169
  }
5174
5170
  var newValue = _this.translateValue(column, columnData);
5175
- _this.setInnerPropValue(newRow, fieldName, newValue);
5171
+ _this.setPropertyValue(newRow, fieldName, newValue);
5176
5172
  });
5177
- };
5178
- for (var i = 0; i <= enumColumns.length - 1; i++) {
5179
- _loop_1(i);
5180
- }
5173
+ });
5181
5174
  return newRow;
5182
5175
  });
5183
5176
  };
5184
5177
  TablePagingComponent.prototype.translateValue = function (column, columnData) {
5178
+ // Default usage: ENUM_VALUE -> domain.service.enum_value
5185
5179
  var enumValue = columnData.toString().toLowerCase();
5186
5180
  var translationKey = column.enumPrefix + enumValue;
5187
5181
  var translatedValue = this.translate.instant(translationKey);
5182
+ // Custom usage 1: V9 -> domain.service.v_9
5188
5183
  if (translationKey === translatedValue && enumValue.length > 1) {
5189
5184
  translationKey = "" + column.enumPrefix + enumValue.substring(0, 1) + "_" + enumValue.substr(1);
5190
- return this.translate.instant(translationKey);
5185
+ translatedValue = this.translate.instant(translationKey);
5186
+ }
5187
+ // Custom usage 2: EnumValue -> domain.service.enum_value
5188
+ if (translationKey === translatedValue) {
5189
+ var enumKey = this.convertToSnakeCase(columnData.toString());
5190
+ translationKey = "" + column.enumPrefix + enumKey;
5191
+ translatedValue = this.translate.instant(translationKey);
5191
5192
  }
5192
5193
  return translatedValue;
5193
5194
  };
5195
+ TablePagingComponent.prototype.convertToSnakeCase = function (str) {
5196
+ return str.replace(/([A-Z])/g, function (match, group) { return "_" + group.toLowerCase(); })
5197
+ .replace(/^_/, '');
5198
+ };
5194
5199
  TablePagingComponent.prototype.getExportFileName = function () {
5195
5200
  var _a;
5196
5201
  var fileName = (_a = this.exportFileName) !== null && _a !== void 0 ? _a : "download";