@zeedhi/common 1.107.3 → 1.108.0

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.
@@ -4449,6 +4449,31 @@ class Report {
4449
4449
  this.iterable = iterable;
4450
4450
  this.title = title;
4451
4451
  }
4452
+ formatToggleable(column, row, result) {
4453
+ const exportValues = ['trueExportValue', 'falseExportValue'];
4454
+ // Verifica se os valores de exportação foram definidos
4455
+ if (exportValues.every((item) => item in column.componentProps)) {
4456
+ const { trueValue, falseValue, trueExportValue, falseExportValue, } = column.componentProps;
4457
+ const trueDefined = isUndefined(trueValue) ? true : trueValue;
4458
+ const falseDefined = isUndefined(falseValue) ? false : falseValue;
4459
+ if (row[column.name] === trueDefined) {
4460
+ result[column.name] = trueExportValue;
4461
+ return result;
4462
+ }
4463
+ if (row[column.name] === falseDefined) {
4464
+ result[column.name] = falseExportValue;
4465
+ return result;
4466
+ }
4467
+ }
4468
+ // Se os valores de exportação não foram definidos, mantém a formatação original
4469
+ const formattedCell = column.formatterByRow(row);
4470
+ result[column.name] = formattedCell;
4471
+ return result;
4472
+ }
4473
+ isToggleableComponent(component) {
4474
+ const toggleableComponents = ['ZdCheckbox', 'ZdSwitch'];
4475
+ return toggleableComponents.includes(component);
4476
+ }
4452
4477
  getData() {
4453
4478
  return __awaiter(this, void 0, void 0, function* () {
4454
4479
  const datasource = DatasourceFactory.factory(Object.assign(Object.assign({}, this.iterable.datasource.clone()), { loadAll: true }));
@@ -4456,12 +4481,16 @@ class Report {
4456
4481
  const formattedData = data.map((row) => {
4457
4482
  const { columns } = this.iterable;
4458
4483
  const formattedRow = columns.reduce((result, column) => {
4459
- if (row[column.name] && typeof row[column.name] !== 'number') {
4484
+ const { component } = column.componentProps;
4485
+ if (this.isToggleableComponent(component)) { // Verificação se o componente é um toggleable
4486
+ return this.formatToggleable(column, row, result);
4487
+ }
4488
+ if (row[column.name] && typeof row[column.name] !== 'number') { // Verifica se o valor não é um número
4460
4489
  const formattedCell = column.formatterByRow(row);
4461
4490
  result[column.name] = formattedCell;
4462
4491
  }
4463
4492
  return result;
4464
- }, row);
4493
+ }, Object.assign({}, row));
4465
4494
  return formattedRow;
4466
4495
  });
4467
4496
  this.data = formattedData;
@@ -4456,6 +4456,31 @@
4456
4456
  this.iterable = iterable;
4457
4457
  this.title = title;
4458
4458
  }
4459
+ formatToggleable(column, row, result) {
4460
+ const exportValues = ['trueExportValue', 'falseExportValue'];
4461
+ // Verifica se os valores de exportação foram definidos
4462
+ if (exportValues.every((item) => item in column.componentProps)) {
4463
+ const { trueValue, falseValue, trueExportValue, falseExportValue, } = column.componentProps;
4464
+ const trueDefined = isUndefined__default["default"](trueValue) ? true : trueValue;
4465
+ const falseDefined = isUndefined__default["default"](falseValue) ? false : falseValue;
4466
+ if (row[column.name] === trueDefined) {
4467
+ result[column.name] = trueExportValue;
4468
+ return result;
4469
+ }
4470
+ if (row[column.name] === falseDefined) {
4471
+ result[column.name] = falseExportValue;
4472
+ return result;
4473
+ }
4474
+ }
4475
+ // Se os valores de exportação não foram definidos, mantém a formatação original
4476
+ const formattedCell = column.formatterByRow(row);
4477
+ result[column.name] = formattedCell;
4478
+ return result;
4479
+ }
4480
+ isToggleableComponent(component) {
4481
+ const toggleableComponents = ['ZdCheckbox', 'ZdSwitch'];
4482
+ return toggleableComponents.includes(component);
4483
+ }
4459
4484
  getData() {
4460
4485
  return __awaiter(this, void 0, void 0, function* () {
4461
4486
  const datasource = core.DatasourceFactory.factory(Object.assign(Object.assign({}, this.iterable.datasource.clone()), { loadAll: true }));
@@ -4463,12 +4488,16 @@
4463
4488
  const formattedData = data.map((row) => {
4464
4489
  const { columns } = this.iterable;
4465
4490
  const formattedRow = columns.reduce((result, column) => {
4466
- if (row[column.name] && typeof row[column.name] !== 'number') {
4491
+ const { component } = column.componentProps;
4492
+ if (this.isToggleableComponent(component)) { // Verificação se o componente é um toggleable
4493
+ return this.formatToggleable(column, row, result);
4494
+ }
4495
+ if (row[column.name] && typeof row[column.name] !== 'number') { // Verifica se o valor não é um número
4467
4496
  const formattedCell = column.formatterByRow(row);
4468
4497
  result[column.name] = formattedCell;
4469
4498
  }
4470
4499
  return result;
4471
- }, row);
4500
+ }, Object.assign({}, row));
4472
4501
  return formattedRow;
4473
4502
  });
4474
4503
  this.data = formattedData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/common",
3
- "version": "1.107.3",
3
+ "version": "1.108.0",
4
4
  "description": "Zeedhi Common",
5
5
  "author": "Zeedhi <zeedhi@teknisa.com>",
6
6
  "license": "ISC",
@@ -43,5 +43,5 @@
43
43
  "lodash.times": "4.3.*",
44
44
  "mockdate": "3.0.*"
45
45
  },
46
- "gitHead": "acf8225d464c1dce096b18c3c4b119b4576759c9"
46
+ "gitHead": "fec5423500f173adcfc49a1c27c5ad0bd6d624ee"
47
47
  }
@@ -8,6 +8,8 @@ export declare class Report implements IReport {
8
8
  endPoint: string;
9
9
  fileEndPoint: string;
10
10
  constructor(iterable: Iterable, title: string);
11
+ private formatToggleable;
12
+ private isToggleableComponent;
11
13
  private getData;
12
14
  private getReportType;
13
15
  getReport(type: string, portrait?: boolean, rowObj?: any, beforeReportEvent?: IBeforeReportEvent): Promise<string>;