@zeedhi/teknisa-components-common 1.90.1 → 1.92.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.
Files changed (100) hide show
  1. package/coverage/clover.xml +718 -677
  2. package/coverage/coverage-final.json +45 -42
  3. package/coverage/lcov-report/components/crud/crud-add-button.ts.html +250 -0
  4. package/coverage/lcov-report/components/crud/crud-button.ts.html +292 -0
  5. package/coverage/lcov-report/components/crud/crud-cancel-button.ts.html +259 -0
  6. package/coverage/lcov-report/components/crud/crud-delete-button.ts.html +322 -0
  7. package/coverage/lcov-report/components/crud/crud-form.ts.html +382 -0
  8. package/coverage/lcov-report/components/crud/crud-save-button.ts.html +253 -0
  9. package/coverage/lcov-report/components/crud/index.html +191 -0
  10. package/coverage/lcov-report/components/index.html +116 -0
  11. package/coverage/lcov-report/components/index.ts.html +394 -0
  12. package/coverage/lcov-report/components/tek-breadcrumb-header/breadcrumb-header.ts.html +172 -0
  13. package/coverage/lcov-report/components/tek-breadcrumb-header/index.html +116 -0
  14. package/coverage/lcov-report/components/tek-card-title/card-title.ts.html +175 -0
  15. package/coverage/lcov-report/components/tek-card-title/index.html +116 -0
  16. package/coverage/lcov-report/components/tek-datasource/index.html +146 -0
  17. package/coverage/lcov-report/components/tek-datasource/interfaces.ts.html +193 -0
  18. package/coverage/lcov-report/components/tek-datasource/memory-datasource.ts.html +1015 -0
  19. package/coverage/lcov-report/components/tek-datasource/rest-datasource.ts.html +751 -0
  20. package/coverage/lcov-report/components/tek-drag-grid/index.html +116 -0
  21. package/coverage/lcov-report/components/tek-drag-grid/tek-drag-grid.ts.html +409 -0
  22. package/coverage/lcov-report/components/tek-grid/filter-helper.ts.html +145 -0
  23. package/coverage/lcov-report/components/tek-grid/grid-column.ts.html +775 -0
  24. package/coverage/lcov-report/components/tek-grid/grid-columns-button-controller.ts.html +169 -0
  25. package/coverage/lcov-report/components/tek-grid/grid-columns-button.ts.html +190 -0
  26. package/coverage/lcov-report/components/tek-grid/grid-filter-button.ts.html +1282 -0
  27. package/coverage/lcov-report/components/tek-grid/grid.ts.html +3157 -0
  28. package/coverage/lcov-report/components/tek-grid/index.html +221 -0
  29. package/coverage/lcov-report/components/tek-grid/interfaces.ts.html +733 -0
  30. package/coverage/lcov-report/components/tek-grid/layout-options.ts.html +826 -0
  31. package/coverage/lcov-report/components/tek-image/image.ts.html +313 -0
  32. package/coverage/lcov-report/components/tek-image/index.html +116 -0
  33. package/coverage/lcov-report/components/tek-iterable-carousel/index.html +116 -0
  34. package/coverage/lcov-report/components/tek-iterable-carousel/iterable-carousel.ts.html +175 -0
  35. package/coverage/lcov-report/components/tek-iterable-component-render/index.html +116 -0
  36. package/coverage/lcov-report/components/tek-iterable-component-render/iterable-component-render.ts.html +118 -0
  37. package/coverage/lcov-report/components/tek-loading/index.html +116 -0
  38. package/coverage/lcov-report/components/tek-loading/loading.ts.html +196 -0
  39. package/coverage/lcov-report/components/tek-notifications/index.html +116 -0
  40. package/coverage/lcov-report/components/tek-notifications/notifications.ts.html +271 -0
  41. package/coverage/lcov-report/components/tek-product-card/index.html +116 -0
  42. package/coverage/lcov-report/components/tek-product-card/product-card.ts.html +391 -0
  43. package/coverage/lcov-report/components/tek-tree-grid/index.html +116 -0
  44. package/coverage/lcov-report/components/tek-tree-grid/tree-grid.ts.html +1255 -0
  45. package/coverage/lcov-report/components/tek-user-info/TekUserInfoController.ts.html +367 -0
  46. package/coverage/lcov-report/components/tek-user-info/index.html +146 -0
  47. package/coverage/lcov-report/components/tek-user-info/tek-user-info-list.ts.html +268 -0
  48. package/coverage/lcov-report/components/tek-user-info/tek-user-info.ts.html +1096 -0
  49. package/coverage/lcov-report/error/delete-rows-error.ts.html +118 -0
  50. package/coverage/lcov-report/error/index.html +116 -0
  51. package/coverage/lcov-report/index.html +27 -12
  52. package/coverage/lcov-report/tests/__helpers__/component-event-helper.ts.html +2 -2
  53. package/coverage/lcov-report/tests/__helpers__/flush-promises-helper.ts.html +2 -2
  54. package/coverage/lcov-report/tests/__helpers__/get-child-helper.ts.html +8 -8
  55. package/coverage/lcov-report/tests/__helpers__/index.html +2 -2
  56. package/coverage/lcov-report/tests/__helpers__/index.ts.html +2 -2
  57. package/coverage/lcov-report/tests/__helpers__/mock-created-helper.ts.html +2 -2
  58. package/coverage/lcov-report/utils/grid-base/export-options/button-option.ts.html +166 -0
  59. package/coverage/lcov-report/utils/grid-base/export-options/index.html +146 -0
  60. package/coverage/lcov-report/utils/grid-base/export-options/index.ts.html +94 -0
  61. package/coverage/lcov-report/utils/grid-base/export-options/multi-option.ts.html +355 -0
  62. package/coverage/lcov-report/utils/grid-base/grid-base.ts.html +1960 -0
  63. package/coverage/lcov-report/utils/grid-base/grid-controller.ts.html +457 -0
  64. package/coverage/lcov-report/utils/grid-base/index.html +131 -0
  65. package/coverage/lcov-report/utils/index.html +116 -0
  66. package/coverage/lcov-report/utils/index.ts.html +100 -0
  67. package/coverage/lcov-report/utils/report-filter/index.html +116 -0
  68. package/coverage/lcov-report/utils/report-filter/report-filter.ts.html +256 -0
  69. package/coverage/lcov.info +1055 -972
  70. package/dist/tek-components-common.esm.js +164 -34
  71. package/dist/tek-components-common.umd.js +164 -34
  72. package/package.json +2 -2
  73. package/tests/unit/components/tek-grid/grid.spec.ts +87 -77
  74. package/tests/unit/components/tek-user-info/TekUserInfoContoller.spec.ts +0 -14
  75. package/tests/unit/components/tek-user-info/tek-user-info.spec.ts +1 -1
  76. package/tests/unit/components/tree-grid/tree-grid.spec.ts +28 -19
  77. package/tests/unit/utils/grid-base/export-options/button-option.spec.ts +44 -0
  78. package/tests/unit/utils/grid-base/export-options/multi-option.spec.ts +135 -0
  79. package/types/components/tek-grid/interfaces.d.ts +19 -2
  80. package/types/components/tek-user-info/TekUserInfoController.d.ts +0 -2
  81. package/types/utils/grid-base/export-options/button-option.d.ts +16 -0
  82. package/types/utils/grid-base/export-options/index.d.ts +3 -0
  83. package/types/utils/grid-base/export-options/interfaces.d.ts +5 -0
  84. package/types/utils/grid-base/export-options/multi-option.d.ts +12 -0
  85. package/types/utils/grid-base/grid-base.d.ts +3 -2
  86. package/types/utils/index.d.ts +5 -5
  87. package/types/components/tek-ag-grid/default-icons.d.ts +0 -53
  88. package/types/components/tek-ag-grid/interfaces.d.ts +0 -9
  89. package/types/components/tek-ag-grid/tek-ag-grid.d.ts +0 -35
  90. package/types/components/tek-datasource/datasource.d.ts +0 -94
  91. package/types/components/tek-grid/default-icons.d.ts +0 -53
  92. package/types/components/tek-grid/filter-dynamic-values.d.ts +0 -9
  93. package/types/components/tek-grid/grid-controller.d.ts +0 -19
  94. package/types/components/tek-grid/grid_column.d.ts +0 -14
  95. package/types/components/tek-grid/grid_controller.d.ts +0 -15
  96. package/types/components/tek-grid/tek-grid.d.ts +0 -35
  97. package/types/components/tek-login/interfaces.d.ts +0 -3
  98. package/types/components/tek-login/login-children.d.ts +0 -3
  99. package/types/components/tek-login/login.d.ts +0 -58
  100. package/types/components/tek-login/login_children.d.ts +0 -3
@@ -1,10 +1,10 @@
1
1
  /* eslint-disable no-underscore-dangle */
2
2
 
3
3
  import {
4
- Button, Dropdown, IButton, IModal, Modal, ModalService, Search, TextInput, Text, Report,
4
+ Button, Dropdown, IModal, Modal, ModalService, Search, TextInput, Text, Report,
5
5
  } from '@zeedhi/common';
6
6
  import {
7
- KeyMap, Http, Metadata, IDictionary,
7
+ KeyMap, Http, Metadata, IDictionary, IEventParam,
8
8
  } from '@zeedhi/core';
9
9
  import {
10
10
  ITekGrid,
@@ -157,48 +157,6 @@ describe('TekGrid', () => {
157
157
  expect(instance.toolbarSlot.length).toBe(0);
158
158
  });
159
159
 
160
- it('should create default export buttons from exportConfig', () => {
161
- const instance = new TekGrid({
162
- name: 'grid',
163
- component: 'TekGrid',
164
- });
165
-
166
- expect((instance as any).gridBase.exportConfigButtons[0].label).toBe('Export as PDF');
167
- expect((instance as any).gridBase.exportConfigButtons[0].iconName).toBeUndefined();
168
- expect((instance as any).gridBase.exportConfigButtons[0].name).toBe('grid_export_pdf_portrait');
169
- expect((instance as any).gridBase.exportConfigButtons[0].component).toBe('ZdButton');
170
- expect((instance as any).gridBase.exportConfigButtons[0].flat).toBeTruthy();
171
- expect((instance as any).gridBase.exportConfigButtons[0].events).toBeDefined();
172
-
173
- expect((instance as any).gridBase.exportConfigButtons[1].label).toBe('Export as XLS TEKGRID_WITHOUT_GROUPS');
174
- expect((instance as any).gridBase.exportConfigButtons[1].iconName).toBeUndefined();
175
- expect((instance as any).gridBase.exportConfigButtons[1].name).toBe('grid_export_xls_portrait');
176
- expect((instance as any).gridBase.exportConfigButtons[1].component).toBe('ZdButton');
177
- expect((instance as any).gridBase.exportConfigButtons[1].flat).toBeTruthy();
178
- expect((instance as any).gridBase.exportConfigButtons[1].events).toBeDefined();
179
-
180
- expect((instance as any).gridBase.exportConfigButtons[2].label).toBe('Export as XLS TEKGRID_WITH_GROUPS');
181
- expect((instance as any).gridBase.exportConfigButtons[2].iconName).toBeUndefined();
182
- expect((instance as any).gridBase.exportConfigButtons[2].name).toBe('grid_export_xls2_portrait');
183
- expect((instance as any).gridBase.exportConfigButtons[2].component).toBe('ZdButton');
184
- expect((instance as any).gridBase.exportConfigButtons[2].flat).toBeTruthy();
185
- expect((instance as any).gridBase.exportConfigButtons[2].events).toBeDefined();
186
-
187
- expect((instance as any).gridBase.exportConfigButtons[3].label).toBe('Export as XLS TEKGRID_GRID_MIRROR');
188
- expect((instance as any).gridBase.exportConfigButtons[3].iconName).toBeUndefined();
189
- expect((instance as any).gridBase.exportConfigButtons[3].name).toBe('grid_export_xls3_portrait');
190
- expect((instance as any).gridBase.exportConfigButtons[3].component).toBe('ZdButton');
191
- expect((instance as any).gridBase.exportConfigButtons[3].flat).toBeTruthy();
192
- expect((instance as any).gridBase.exportConfigButtons[3].events).toBeDefined();
193
-
194
- expect((instance as any).gridBase.exportConfigButtons[4].label).toBe('Export as CSV');
195
- expect((instance as any).gridBase.exportConfigButtons[4].iconName).toBeUndefined();
196
- expect((instance as any).gridBase.exportConfigButtons[4].name).toBe('grid_export_csv_portrait');
197
- expect((instance as any).gridBase.exportConfigButtons[4].component).toBe('ZdButton');
198
- expect((instance as any).gridBase.exportConfigButtons[4].flat).toBeTruthy();
199
- expect((instance as any).gridBase.exportConfigButtons[4].events).toBeDefined();
200
- });
201
-
202
160
  it('should change export buttons from exportConfig', () => {
203
161
  const instance = new TekGrid({
204
162
  name: 'grid',
@@ -243,44 +201,14 @@ describe('TekGrid', () => {
243
201
  httpReportSpy.mockReset();
244
202
  });
245
203
 
246
- it('should call getReport on export button click', () => {
247
- (window as any).open = jest.fn();
248
-
249
- const instance = new TekGrid({
250
- name: 'grid_getReport',
251
- component: 'TekGrid',
252
- events: {
253
- beforeOpenReport: jest.fn(),
254
- },
255
- });
256
-
257
- instance.onCreated();
258
-
259
- const buttonProps = (instance as any).gridBase.exportConfigButtons[0] as IButton;
260
- const button = new Button(buttonProps);
261
-
262
- const event = new Event('click');
263
- button.click(event, {} as HTMLElement);
264
-
265
- expect(reportSpy).toBeCalledTimes(1);
266
-
267
- (window as any).open.mockClear();
268
- });
269
-
270
204
  it('should call window open on getReport method', async () => {
271
205
  (window as any).open = jest.fn();
272
206
 
273
207
  const instance = new TekGrid({
274
208
  name: 'grid',
275
209
  component: 'TekGrid',
276
- datasource: {
277
- type: 'tek-rest',
278
- uniqueKey: 'id',
279
- route: '/zeedhi',
280
- lazyLoad: true,
281
- data: [
282
- { id: '1', department_id: '1' },
283
- ],
210
+ events: {
211
+ beforeOpenReport: jest.fn(),
284
212
  },
285
213
  columns: [
286
214
  {
@@ -1419,7 +1347,7 @@ describe('TekGrid', () => {
1419
1347
  expect(instance.groupedData[5].salary).toBe(50);
1420
1348
  });
1421
1349
 
1422
- it('should aggregation with different functions', async () => {
1350
+ it('should aggregate with different functions', async () => {
1423
1351
  const instance = createAndMount({
1424
1352
  name: 'grid_aggregate_4',
1425
1353
  component: 'TekGrid',
@@ -1491,6 +1419,88 @@ describe('TekGrid', () => {
1491
1419
  expect(instance.groupedData[6].column_count).toBe(3);
1492
1420
  });
1493
1421
 
1422
+ it('should aggregate using calcSummary event', async () => {
1423
+ const doCalcSummary = ({ summary, rowValue }: IEventParam<any>) => {
1424
+ summary.sum = `${(summary.sum || '')}${rowValue}`;
1425
+ summary.avg = `${summary.sum}/${summary.count}`;
1426
+ summary.max = summary.max === undefined || summary.max < rowValue ? rowValue : summary.max;
1427
+ summary.min = summary.min === undefined || summary.min > rowValue ? rowValue : summary.min;
1428
+ };
1429
+
1430
+ const instance = createAndMount({
1431
+ name: 'grid_aggregate_5',
1432
+ component: 'TekGrid',
1433
+ showSummaryTotal: true,
1434
+ events: {
1435
+ calcSummary: doCalcSummary,
1436
+ },
1437
+ columns: [
1438
+ {
1439
+ name: 'id',
1440
+ label: 'id',
1441
+ },
1442
+ {
1443
+ name: 'column_sum',
1444
+ label: 'sum',
1445
+ aggregation: 'SUM',
1446
+ },
1447
+ {
1448
+ name: 'column_min',
1449
+ label: 'min',
1450
+ aggregation: 'MIN',
1451
+ },
1452
+ {
1453
+ name: 'column_max',
1454
+ label: 'max',
1455
+ aggregation: 'MAX',
1456
+ },
1457
+ {
1458
+ name: 'column_avg',
1459
+ label: 'avg',
1460
+ aggregation: 'AVG',
1461
+ },
1462
+ {
1463
+ name: 'column_count',
1464
+ label: 'count',
1465
+ aggregation: 'COUNT',
1466
+ },
1467
+ {
1468
+ name: 'department',
1469
+ label: 'department',
1470
+ grouped: true,
1471
+ },
1472
+ ],
1473
+ datasource: {
1474
+ uniqueKey: 'id',
1475
+ data: [
1476
+ {
1477
+ id: 1, department: 1, column_sum: 'd', column_min: 'd', column_max: 'd', column_avg: 'd', column_count: 'd',
1478
+ },
1479
+ {
1480
+ id: 2, department: 1, column_sum: 'b', column_min: 'b', column_max: 'b', column_avg: 'b', column_count: 'b',
1481
+ },
1482
+ {
1483
+ id: 3, department: 1, column_sum: 'a', column_min: 'a', column_max: 'a', column_avg: 'a', column_count: 'a',
1484
+ },
1485
+ {
1486
+ id: 4, department: 1, column_sum: 'c', column_min: 'c', column_max: 'c', column_avg: 'c', column_count: 'c',
1487
+ },
1488
+ ],
1489
+ },
1490
+ });
1491
+
1492
+ await flushPromises();
1493
+
1494
+ expect(instance.datasource.data.length).toBe(4);
1495
+ expect(instance.groupedData.length).toBe(7);
1496
+ expect(instance.groupedData[6].groupSummary).toBeTruthy();
1497
+ expect(instance.groupedData[6].column_sum).toBe('dbac');
1498
+ expect(instance.groupedData[6].column_min).toBe('a');
1499
+ expect(instance.groupedData[6].column_max).toBe('d');
1500
+ expect(instance.groupedData[6].column_avg).toBe('dbac/4');
1501
+ expect(instance.groupedData[6].column_count).toBe(4);
1502
+ });
1503
+
1494
1504
  it('should group data on rest datasource with lazyLoad', async () => {
1495
1505
  const httpSpy = jest.spyOn(Http, 'get').mockImplementation(() => Promise.resolve({
1496
1506
  data: {
@@ -133,22 +133,8 @@ describe('TekUserInfoController', () => {
133
133
  });
134
134
  const controller = new TekUserInfoController(component);
135
135
 
136
- expect(controller.defaultEmail).toBe('zeedhi@zd.com');
137
136
  expect(controller.hasDefaultEmail).toBeTruthy();
138
137
  });
139
-
140
- it('when prop is defined, should set the component value', () => {
141
- const component = new TekUserInfo({
142
- name: 'user-info',
143
- component: 'TekUserInfo',
144
- });
145
- const controller = new TekUserInfoController(component);
146
-
147
- controller.defaultEmail = 'teste@email.com';
148
-
149
- expect(controller.defaultEmail).toBe('teste@email.com');
150
- expect(component.defaultEmail).toBe('teste@email.com');
151
- });
152
138
  });
153
139
 
154
140
  describe('mainVersion property', () => {
@@ -192,7 +192,7 @@ describe('TekUserInfo', () => {
192
192
  name: 'report_email',
193
193
  component: 'ZdTextInput',
194
194
  label: 'E-mail',
195
- value: '{{TekUserInfoController_1.defaultEmail}}',
195
+ value: 'zeedhi@zd.com',
196
196
  },
197
197
  {
198
198
  name: 'report_cc',
@@ -477,44 +477,53 @@ describe('TekTreeGrid', () => {
477
477
  httpReportSpy.mockClear();
478
478
  });
479
479
 
480
- it('should call getReport on export button click', () => {
480
+ it('should call window open on getReport method', async () => {
481
481
  (window as any).open = jest.fn();
482
482
 
483
483
  const instance = new TekTreeGrid({
484
- name: 'grid_getReport',
484
+ name: 'grid',
485
485
  component: 'TekTreeGrid',
486
486
  events: {
487
487
  beforeOpenReport: jest.fn(),
488
488
  },
489
+ datasource: {
490
+ type: 'tek-rest',
491
+ uniqueKey: 'id',
492
+ route: '/zeedhi',
493
+ lazyLoad: false,
494
+ data: [
495
+ { id: '1', department_id: '1' },
496
+ ],
497
+ },
498
+ columns: [
499
+ {
500
+ name: 'id',
501
+ label: 'ID',
502
+ },
503
+ {
504
+ name: 'department_id',
505
+ label: 'Department ID',
506
+ },
507
+ ],
489
508
  });
490
509
 
491
- instance.onCreated();
492
-
493
- const buttonProps = (instance as any).gridBase.exportConfigButtons[0] as IButton;
494
- const button = new Button(buttonProps);
495
-
496
- const event = new Event('click');
497
- button.click(event, {} as HTMLElement);
510
+ const spy = jest.spyOn(window, 'open');
511
+ await instance.getReport('pdf');
498
512
 
499
- expect(reportSpy).toBeCalledTimes(1);
513
+ expect(spy).toHaveBeenCalledTimes(1);
500
514
 
501
515
  (window as any).open.mockClear();
516
+ spy.mockClear();
502
517
  });
503
518
 
504
- it('should call window open on getReport method', async () => {
519
+ it('should call window open on getReport method when using tekmemorydatasource', async () => {
505
520
  (window as any).open = jest.fn();
506
521
 
507
522
  const instance = new TekTreeGrid({
508
523
  name: 'grid',
509
524
  component: 'TekTreeGrid',
510
- datasource: {
511
- type: 'tek-rest',
512
- uniqueKey: 'id',
513
- route: '/zeedhi',
514
- lazyLoad: false,
515
- data: [
516
- { id: '1', department_id: '1' },
517
- ],
525
+ events: {
526
+ beforeOpenReport: jest.fn(),
518
527
  },
519
528
  columns: [
520
529
  {
@@ -0,0 +1,44 @@
1
+ import { Button } from '@zeedhi/common';
2
+ import { TekGrid } from '../../../../../src/components';
3
+ import { ButtonOption } from '../../../../../src/utils';
4
+
5
+ describe('ButtonOption', () => {
6
+ describe('buildComponent()', () => {
7
+ it('when called, should build a simple button component', () => {
8
+ const grid = new TekGrid({ name: 'Grid', component: 'TekGrid' });
9
+ const config = {
10
+ type: 'pdf',
11
+ label: 'Exportar PDF',
12
+ };
13
+ const option = new ButtonOption(config);
14
+
15
+ const component = option.buildComponent(grid);
16
+
17
+ expect(component).toEqual(expect.objectContaining({
18
+ label: config.label,
19
+ name: 'Grid_export_pdf_portrait',
20
+ component: 'ZdButton',
21
+ iconName: undefined,
22
+ flat: true,
23
+ }));
24
+ });
25
+
26
+ it('the generated button component should call grid.getReport on click', () => {
27
+ const grid = new TekGrid({ name: 'Grid', component: 'TekGrid' });
28
+ const spy = jest.fn();
29
+ grid.getReport = spy;
30
+ const config = {
31
+ type: 'pdf',
32
+ label: 'Exportar PDF',
33
+ };
34
+ const option = new ButtonOption(config);
35
+
36
+ const component = option.buildComponent(grid);
37
+
38
+ const instance = new Button(component);
39
+ instance.click();
40
+
41
+ expect(spy).toHaveBeenCalledTimes(1);
42
+ });
43
+ });
44
+ });
@@ -0,0 +1,135 @@
1
+ import { Button, IText, Text } from '@zeedhi/common';
2
+ import { ITekGridExportConfig, TekGrid } from '../../../../../src/components';
3
+ import { MultiOption } from '../../../../../src/utils';
4
+
5
+ describe('MultiOption', () => {
6
+ describe('buildComponent()', () => {
7
+ it('when called, should build a row with multiple buttons', () => {
8
+ const grid = new TekGrid({ name: 'Grid', component: 'TekGrid' });
9
+ const config: ITekGridExportConfig = {
10
+ type: 'pdf',
11
+ label: 'Exportar PDF',
12
+ multiOption: [
13
+ { label: 'portrait', iconName: 'icon-portrait' },
14
+ { label: 'landscape', iconName: 'icon-landscape' },
15
+ ],
16
+ };
17
+ const option = new MultiOption(config);
18
+
19
+ const component = option.buildComponent(grid);
20
+
21
+ expect(component).toEqual({
22
+ name: 'Grid_export_pdf_row',
23
+ component: 'ZdRow',
24
+ cssClass: 'zd-display-flex zd-ma-0 zd-py-0 zd-gap-x-1 tek-grid-export-multioption-row',
25
+ children: [
26
+ expect.objectContaining({
27
+ name: 'Grid_export_pdf_text',
28
+ component: 'ZdText',
29
+ text: 'Exportar PDF',
30
+ cssClass: 'zd-display-flex zd-align-center zd-flex-grow-1 tek-grid-export-multioption-text',
31
+ }),
32
+ {
33
+ name: 'Grid_export_pdf_tooltip_portrait',
34
+ component: 'ZdTooltip',
35
+ bottom: true,
36
+ label: 'portrait',
37
+ children: [
38
+ expect.objectContaining({
39
+ name: 'Grid_export_pdf_button_portrait',
40
+ component: 'ZdButton',
41
+ icon: true,
42
+ iconName: 'icon-portrait',
43
+ }),
44
+ ],
45
+ },
46
+ expect.objectContaining({
47
+ name: 'Grid_export_pdf_divider_portrait',
48
+ component: 'ZdDivider',
49
+ cssClass: 'zd-my-1',
50
+ vertical: true,
51
+ }),
52
+ {
53
+ name: 'Grid_export_pdf_tooltip_landscape',
54
+ component: 'ZdTooltip',
55
+ bottom: true,
56
+ label: 'landscape',
57
+ children: [
58
+ expect.objectContaining({
59
+ name: 'Grid_export_pdf_button_landscape',
60
+ component: 'ZdButton',
61
+ icon: true,
62
+ iconName: 'icon-landscape',
63
+ }),
64
+ ],
65
+ },
66
+ ],
67
+ });
68
+ });
69
+
70
+ it('the generated text component should call stopPropagation on click', () => {
71
+ const grid = new TekGrid({ name: 'Grid', component: 'TekGrid' });
72
+ const config: ITekGridExportConfig = {
73
+ type: 'pdf',
74
+ label: 'Exportar PDF',
75
+ multiOption: [
76
+ { label: 'portrait', iconName: 'icon-portrait' },
77
+ { label: 'landscape', iconName: 'icon-landscape' },
78
+ ],
79
+ };
80
+ const option = new MultiOption(config);
81
+
82
+ const component = option.buildComponent(grid);
83
+
84
+ const instance = new Text(component.children![0] as IText);
85
+ const spy = jest.fn();
86
+ const event = { stopPropagation: spy } as unknown as Event;
87
+ instance.click(event);
88
+
89
+ expect(spy).toHaveBeenCalled();
90
+ });
91
+
92
+ it('the generated text component should not throw if event is undefined', () => {
93
+ const grid = new TekGrid({ name: 'Grid', component: 'TekGrid' });
94
+ const config: ITekGridExportConfig = {
95
+ type: 'pdf',
96
+ label: 'Exportar PDF',
97
+ multiOption: [
98
+ { label: 'portrait', iconName: 'icon-portrait' },
99
+ { label: 'landscape', iconName: 'icon-landscape' },
100
+ ],
101
+ };
102
+ const option = new MultiOption(config);
103
+
104
+ const component = option.buildComponent(grid);
105
+
106
+ const instance = new Text(component.children![0] as IText);
107
+
108
+ expect(() => instance.callEvent('click', { event: undefined })).not.toThrow();
109
+ });
110
+
111
+ it('the generated button components should call grid.getReport on click', () => {
112
+ const grid = new TekGrid({ name: 'Grid', component: 'TekGrid' });
113
+ const spy = jest.fn();
114
+ grid.getReport = spy;
115
+ const config: ITekGridExportConfig = {
116
+ type: 'pdf',
117
+ multiOption: [
118
+ { label: 'portrait', iconName: 'icon-portrait' },
119
+ { label: 'landscape', iconName: 'icon-landscape' },
120
+ ],
121
+ };
122
+ const option = new MultiOption(config);
123
+
124
+ const component = option.buildComponent(grid);
125
+
126
+ const instance = new Button(component.children![1].children![0]);
127
+ instance.click();
128
+
129
+ const instance2 = new Button(component.children![3].children![0]);
130
+ instance2.click();
131
+
132
+ expect(spy).toHaveBeenCalledTimes(2);
133
+ });
134
+ });
135
+ });
@@ -4,8 +4,13 @@ import { IDynamicFilterItem, TekGrid, TekGridLayoutOptions, TekTreeGrid } from '
4
4
  export interface ITekGridLayoutEventParams extends IEventParam<ITekGrid> {
5
5
  layouts: ITekGridLayoutInfo;
6
6
  }
7
+ export interface ITekGridCalcSummaryEventParams extends IEventParam<ITekGrid> {
8
+ summary: ITekGridSummary;
9
+ columnName: string;
10
+ rowValue: IDictionary<any>;
11
+ }
7
12
  export declare type ITekGridEvent<T> = (event: T) => Promise<any>;
8
- export interface ITekGridEvents<T = IEventParam<any> | ITekGridLayoutEventParams> extends IComponentEvents<T> {
13
+ export interface ITekGridEvents<T = IEventParam<any> | ITekGridLayoutEventParams | ITekGridCalcSummaryEventParams> extends IComponentEvents<T> {
9
14
  addClick?: EventDef<T>;
10
15
  afterCancel?: EventDef<T>;
11
16
  afterDelete?: EventDef<T>;
@@ -14,6 +19,7 @@ export interface ITekGridEvents<T = IEventParam<any> | ITekGridLayoutEventParams
14
19
  beforeCancel?: EventDef<T>;
15
20
  beforeDelete?: EventDef<T>;
16
21
  beforeSave?: EventDef<T>;
22
+ calcSummary?: EventDef<T>;
17
23
  filterClick?: EventDef<T>;
18
24
  loadLayouts?: EventDef<T, ITekGridEvent<T>>;
19
25
  saveLayouts?: EventDef<T>;
@@ -54,11 +60,21 @@ export interface ITekGrid extends IGridEditable {
54
60
  layoutOptions?: TekGridLayoutOptions;
55
61
  mainGrid?: boolean;
56
62
  }
63
+ export declare type MultiOptionParams = {
64
+ iconName: string;
65
+ label: string;
66
+ cssClass?: string;
67
+ reportParams?: {
68
+ portrait?: boolean;
69
+ rowObj?: any;
70
+ };
71
+ };
57
72
  export interface ITekGridExportConfig {
58
73
  type: string;
59
74
  portrait?: boolean;
60
75
  label?: string;
61
76
  iconName?: string;
77
+ multiOption?: MultiOptionParams[];
62
78
  }
63
79
  export interface ITekGridLayoutInfo {
64
80
  currentLayoutName?: string;
@@ -141,7 +157,8 @@ export interface ITekGridFooter {
141
157
  [key: string]: ITekGridSummary;
142
158
  }
143
159
  export interface ITekGridSummary {
144
- sum: number;
160
+ sum: any;
161
+ avg: any;
145
162
  count: number;
146
163
  min: any;
147
164
  max: any;
@@ -7,8 +7,6 @@ export declare class TekUserInfoController {
7
7
  set name(value: string);
8
8
  get version(): string;
9
9
  set version(value: string);
10
- get defaultEmail(): string;
11
- set defaultEmail(value: string);
12
10
  get hasDefaultEmail(): boolean;
13
11
  get hasAboutImage(): boolean;
14
12
  mergeText(name: string, version: string): string;
@@ -0,0 +1,16 @@
1
+ import { ITekGridExportConfig, TekGrid, TekTreeGrid } from '../../../components';
2
+ import { IExportOption } from './interfaces';
3
+ export declare class ButtonOption implements IExportOption {
4
+ private config;
5
+ constructor(config: ITekGridExportConfig);
6
+ buildComponent(grid: TekGrid | TekTreeGrid): {
7
+ label: string | undefined;
8
+ iconName: string | undefined;
9
+ name: string;
10
+ component: string;
11
+ flat: boolean;
12
+ events: {
13
+ click: () => any;
14
+ };
15
+ };
16
+ }
@@ -0,0 +1,3 @@
1
+ export * from './button-option';
2
+ export * from './multi-option';
3
+ export * from './interfaces';
@@ -0,0 +1,5 @@
1
+ import { IComponentRender } from '@zeedhi/common';
2
+ import { TekGrid, TekTreeGrid } from '../../../components';
3
+ export interface IExportOption {
4
+ buildComponent: (grid: TekGrid | TekTreeGrid) => IComponentRender;
5
+ }
@@ -0,0 +1,12 @@
1
+ import { IRow } from '@zeedhi/common';
2
+ import { ITekGridExportConfig, TekGrid, TekTreeGrid } from '../../../components';
3
+ import { IExportOption } from './interfaces';
4
+ export declare class MultiOption implements IExportOption {
5
+ private config;
6
+ constructor(config: ITekGridExportConfig);
7
+ private formatName;
8
+ private buildTooltip;
9
+ private buildButton;
10
+ private buildDivider;
11
+ buildComponent(grid: TekGrid | TekTreeGrid): IRow;
12
+ }
@@ -1,4 +1,4 @@
1
- import { IButton } from '@zeedhi/common';
1
+ import { IComponentRender } from '@zeedhi/common';
2
2
  import { IEventParam } from '@zeedhi/core';
3
3
  import { TekGrid, TekGridFilterButton, TekTreeGrid } from '../../components';
4
4
  export interface ITekGridAtoms {
@@ -23,6 +23,7 @@ export declare class GridBase {
23
23
  private grid;
24
24
  private exportConfigButtons;
25
25
  constructor(grid: TekGrid | TekTreeGrid);
26
+ private getOption;
26
27
  private getExportConfigButtons;
27
28
  createToolbarProps(): ({
28
29
  name: string;
@@ -153,7 +154,7 @@ export declare class GridBase {
153
154
  iconName: string;
154
155
  isVisible: string;
155
156
  };
156
- children: IButton[] | import("@zeedhi/common").IComponentRender[];
157
+ children: IComponentRender[];
157
158
  label?: undefined;
158
159
  bottom?: undefined;
159
160
  vertical?: undefined;
@@ -1,5 +1,5 @@
1
- import { ReportFilter } from './report-filter/report-filter';
2
- import { GridBase, ITekGridAtoms } from './grid-base/grid-base';
3
- import { GridController } from './grid-base/grid-controller';
4
- import { ITekConfig } from './config/config';
5
- export { ReportFilter, GridBase, ITekGridAtoms, GridController, ITekConfig, };
1
+ export * from './report-filter/report-filter';
2
+ export * from './grid-base/grid-base';
3
+ export * from './grid-base/grid-controller';
4
+ export * from './grid-base/export-options';
5
+ export * from './config/config';