@seniorsistemas/angular-components 17.17.6 → 17.17.7

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.
@@ -9920,7 +9920,11 @@
9920
9920
  return ((_a = attributeValue === null || attributeValue === void 0 ? void 0 : attributeValue.options) === null || _a === void 0 ? void 0 : _a.numberFormatOptions) ? _this.numericService.instant(attributeValue.value, {
9921
9921
  numberFormatOptions: attributeValue.options.numberFormatOptions,
9922
9922
  })
9923
- : ng2CurrencyMask.applyMask(attributeValue, numberConfigs, _this.isNumber(attributeValue));
9923
+ : column.numberFormatOptions
9924
+ ? _this.numericService.instant(attributeValue, {
9925
+ numberFormatOptions: column.numberFormatOptions,
9926
+ })
9927
+ : ng2CurrencyMask.applyMask(attributeValue, numberConfigs, _this.isNumber(attributeValue));
9924
9928
  case exports.EnumColumnFieldType.DATE:
9925
9929
  var dateFormat = _this.getDateFormat(column, locale);
9926
9930
  return moment$4(attributeValue).format(dateFormat);
@@ -10120,7 +10124,7 @@
10120
10124
  var _a;
10121
10125
  if ((_a = changes.totalRecords) === null || _a === void 0 ? void 0 : _a.currentValue) {
10122
10126
  this.totalRecordsText = this.translate.instant(this.getTranslatePrefix() + "total_records", {
10123
- value: changes.totalRecords.currentValue
10127
+ value: changes.totalRecords.currentValue,
10124
10128
  });
10125
10129
  }
10126
10130
  };
@@ -10137,28 +10141,28 @@
10137
10141
  {
10138
10142
  id: "exportCurrentPage",
10139
10143
  label: this.translate.instant(this.getTranslatePrefix() + "export_current_page"),
10140
- command: function () { return _this.exportCurrentPage(); }
10141
- }
10144
+ command: function () { return _this.exportCurrentPage(); },
10145
+ },
10142
10146
  ];
10143
10147
  if (this.enableExportSelectedRecords) {
10144
10148
  actions.push({
10145
10149
  id: "exportSelected",
10146
10150
  label: this.translate.instant(this.getTranslatePrefix() + "export_selected_records"),
10147
- command: function () { return _this.exportSelectedRecords(); }
10151
+ command: function () { return _this.exportSelectedRecords(); },
10148
10152
  });
10149
10153
  }
10150
10154
  if (this.loadAllRecords) {
10151
10155
  actions.push({
10152
10156
  id: "exportAll",
10153
10157
  label: this.translate.instant(this.getTranslatePrefix() + "export_all_records"),
10154
- command: function () { return _this.exportAllRecords(); }
10158
+ command: function () { return _this.exportAllRecords(); },
10155
10159
  });
10156
10160
  }
10157
10161
  if ((_a = this.customActions) === null || _a === void 0 ? void 0 : _a.length) {
10158
10162
  var customMenus = this.customActions.map(function (p, index) { return ({
10159
10163
  id: "customAction_" + index,
10160
10164
  label: p.label,
10161
- command: p.command
10165
+ command: p.command,
10162
10166
  }); });
10163
10167
  actions.push.apply(actions, __spread(customMenus));
10164
10168
  }
@@ -10178,7 +10182,7 @@
10178
10182
  field: column.field,
10179
10183
  separator: (_a = column.separator) !== null && _a !== void 0 ? _a : " - ",
10180
10184
  enumPrefix: column.enumPrefix,
10181
- customExport: column.customExport
10185
+ customExport: column.customExport,
10182
10186
  };
10183
10187
  if (column.exportable === false) {
10184
10188
  exportColumn.exportable = false;
@@ -10200,6 +10204,7 @@
10200
10204
  tableData = this.loadCurrentPageRecords();
10201
10205
  }
10202
10206
  tableData = this.mapCustomExport(columns, tableData);
10207
+ tableData = this.mapNumberFormatOptionsExport(columns, tableData);
10203
10208
  return this.mapColumnsTranslations(columns, tableData);
10204
10209
  };
10205
10210
  TablePagingComponent.prototype.getSelectedRowsToExport = function (columns) {
@@ -10208,6 +10213,7 @@
10208
10213
  tableData = this.loadSelectedRecords();
10209
10214
  }
10210
10215
  tableData = this.mapCustomExport(columns, tableData);
10216
+ tableData = this.mapNumberFormatOptionsExport(columns, tableData);
10211
10217
  return this.mapColumnsTranslations(columns, tableData);
10212
10218
  };
10213
10219
  TablePagingComponent.prototype.getPropertyValue = function (obj, path) {
@@ -10222,7 +10228,7 @@
10222
10228
  obj[key] = value;
10223
10229
  return obj;
10224
10230
  }
10225
- obj[key] = (this.recursionSetValue((obj === null || obj === void 0 ? void 0 : obj[key]) || {}, keysList.slice(1), value));
10231
+ obj[key] = this.recursionSetValue((obj === null || obj === void 0 ? void 0 : obj[key]) || {}, keysList.slice(1), value);
10226
10232
  return obj;
10227
10233
  };
10228
10234
  TablePagingComponent.prototype.mapColumnsTranslations = function (columns, rows) {
@@ -10247,6 +10253,88 @@
10247
10253
  return newRow;
10248
10254
  });
10249
10255
  };
10256
+ /**
10257
+ * The purpose of this method is to map values
10258
+ * from the TableColumnsComponent, which uses the numberFormatOptions
10259
+ * field, along with rows that have a custom numberFormatOptions,
10260
+ * to ensure the correct values are exported by the TablePagingComponent.
10261
+ *
10262
+ * @returns Returns the correctly mapped tableData.
10263
+ */
10264
+ TablePagingComponent.prototype.mapNumberFormatOptionsExport = function (columns, tableData) {
10265
+ var hasNumberFormatOptionsColumns = columns.some(function (column) { return column.numberFormatOptions; });
10266
+ var hasNumberFormatOptionsRows = tableData.some(function (rowData) {
10267
+ return Object.keys(rowData).some(function (key) { var _a; return (_a = rowData[key].options) === null || _a === void 0 ? void 0 : _a.numberFormatOptions; });
10268
+ });
10269
+ if (!hasNumberFormatOptionsColumns && !hasNumberFormatOptionsRows)
10270
+ return tableData;
10271
+ var mappedTableData = __spread(tableData);
10272
+ if (hasNumberFormatOptionsColumns) {
10273
+ mappedTableData = mappedTableData.map(function (rowData) {
10274
+ var e_1, _a, e_2, _b;
10275
+ var _c;
10276
+ var row = __assign({}, rowData);
10277
+ var columnsWithNumberFormatOptions = columns.filter(function (column) { return column.numberFormatOptions; });
10278
+ try {
10279
+ for (var columnsWithNumberFormatOptions_1 = __values(columnsWithNumberFormatOptions), columnsWithNumberFormatOptions_1_1 = columnsWithNumberFormatOptions_1.next(); !columnsWithNumberFormatOptions_1_1.done; columnsWithNumberFormatOptions_1_1 = columnsWithNumberFormatOptions_1.next()) {
10280
+ var _d = columnsWithNumberFormatOptions_1_1.value, attributes = _d.attributes, numberFormatOptions = _d.numberFormatOptions;
10281
+ try {
10282
+ for (var attributes_1 = (e_2 = void 0, __values(attributes)), attributes_1_1 = attributes_1.next(); !attributes_1_1.done; attributes_1_1 = attributes_1.next()) {
10283
+ var attribute = attributes_1_1.value;
10284
+ if ((_c = row[attribute].options) === null || _c === void 0 ? void 0 : _c.numberFormatOptions)
10285
+ continue;
10286
+ var value = row[attribute];
10287
+ var mappedValue = numberFormatOptions.style === "percent" ? new BigNumber__default(value).times(100) : new BigNumber__default(value);
10288
+ var numberFormat = new Intl.NumberFormat("en-US", __assign(__assign({}, numberFormatOptions), { style: "decimal", useGrouping: false }));
10289
+ row[attribute] = numberFormat.format(mappedValue.toNumber());
10290
+ }
10291
+ }
10292
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
10293
+ finally {
10294
+ try {
10295
+ if (attributes_1_1 && !attributes_1_1.done && (_b = attributes_1.return)) _b.call(attributes_1);
10296
+ }
10297
+ finally { if (e_2) throw e_2.error; }
10298
+ }
10299
+ }
10300
+ }
10301
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
10302
+ finally {
10303
+ try {
10304
+ if (columnsWithNumberFormatOptions_1_1 && !columnsWithNumberFormatOptions_1_1.done && (_a = columnsWithNumberFormatOptions_1.return)) _a.call(columnsWithNumberFormatOptions_1);
10305
+ }
10306
+ finally { if (e_1) throw e_1.error; }
10307
+ }
10308
+ return row;
10309
+ });
10310
+ }
10311
+ if (hasNumberFormatOptionsRows) {
10312
+ mappedTableData = tableData.map(function (rowData) {
10313
+ var e_3, _a;
10314
+ var row = __assign({}, rowData);
10315
+ var keysWithNumberFormatOptions = Object.keys(row).filter(function (key) { var _a; return (_a = row[key].options) === null || _a === void 0 ? void 0 : _a.numberFormatOptions; });
10316
+ try {
10317
+ for (var keysWithNumberFormatOptions_1 = __values(keysWithNumberFormatOptions), keysWithNumberFormatOptions_1_1 = keysWithNumberFormatOptions_1.next(); !keysWithNumberFormatOptions_1_1.done; keysWithNumberFormatOptions_1_1 = keysWithNumberFormatOptions_1.next()) {
10318
+ var key = keysWithNumberFormatOptions_1_1.value;
10319
+ var value = rowData[key].value;
10320
+ var numberFormatOptions = rowData[key].options.numberFormatOptions;
10321
+ var mappedValue = numberFormatOptions.style === "percent" ? new BigNumber__default(value).times(100) : new BigNumber__default(value);
10322
+ var numberFormat = new Intl.NumberFormat("en-US", __assign(__assign({}, numberFormatOptions), { style: "decimal", useGrouping: false }));
10323
+ row[key] = numberFormat.format(mappedValue.toNumber());
10324
+ }
10325
+ }
10326
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
10327
+ finally {
10328
+ try {
10329
+ if (keysWithNumberFormatOptions_1_1 && !keysWithNumberFormatOptions_1_1.done && (_a = keysWithNumberFormatOptions_1.return)) _a.call(keysWithNumberFormatOptions_1);
10330
+ }
10331
+ finally { if (e_3) throw e_3.error; }
10332
+ }
10333
+ return row;
10334
+ });
10335
+ }
10336
+ return mappedTableData;
10337
+ };
10250
10338
  TablePagingComponent.prototype.mapCustomExport = function (columns, rows) {
10251
10339
  var _this = this;
10252
10340
  var customColumns = columns.filter(function (p) { return p.customExport; });
@@ -10288,8 +10376,7 @@
10288
10376
  return translatedValue;
10289
10377
  };
10290
10378
  TablePagingComponent.prototype.convertToSnakeCase = function (str) {
10291
- return str.replace(/([A-Z])/g, function (match, group) { return "_" + group.toLowerCase(); })
10292
- .replace(/^_/, '');
10379
+ return str.replace(/([A-Z])/g, function (match, group) { return "_" + group.toLowerCase(); }).replace(/^_/, "");
10293
10380
  };
10294
10381
  TablePagingComponent.prototype.getExportFileName = function () {
10295
10382
  var _a, _b;
@@ -10324,6 +10411,7 @@
10324
10411
  serverData = _a.sent();
10325
10412
  columns = this.getColumnsToExport();
10326
10413
  serverData = this.mapCustomExport(columns, serverData);
10414
+ serverData = this.mapNumberFormatOptionsExport(columns, serverData);
10327
10415
  dataToExport = this.mapColumnsTranslations(columns, serverData);
10328
10416
  ExportUtils.exportCSV(columns, dataToExport, undefined, this.getExportFileName());
10329
10417
  return [2 /*return*/];