@zeedhi/teknisa-components-common 3.0.4 → 3.2.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 (134) hide show
  1. package/dist/teknisa-components-common.es.js +3536 -0
  2. package/dist/types/components/index.d.ts +2 -0
  3. package/dist/types/components/tek-breadcrumb-header/breadcrumb-header.d.ts +2 -2
  4. package/dist/types/components/tek-breadcrumb-header/interfaces.d.ts +1 -1
  5. package/dist/types/components/tek-datasource/tek-memory-datasource.d.ts +1 -21
  6. package/dist/types/components/tek-datasource/tek-rest-datasource.d.ts +6 -30
  7. package/dist/types/components/tek-grid/filter-helper.d.ts +2 -2
  8. package/dist/types/components/tek-grid/grid-filter-button.d.ts +1 -0
  9. package/dist/types/components/tek-grid/grouped-data-manager.d.ts +8 -1
  10. package/dist/types/components/tek-grid/grouped-data-navigator.d.ts +12 -0
  11. package/dist/types/components/tek-grid/index.d.ts +1 -1
  12. package/dist/types/components/tek-grid/interfaces.d.ts +8 -1
  13. package/dist/types/components/tek-grid/tek-grid-controller.d.ts +19 -17
  14. package/dist/types/components/tek-grid/tek-grid-data-editor.d.ts +11 -0
  15. package/dist/types/components/tek-grid/tek-grid-toolbar-provider/export-options/multi-option.d.ts +1 -1
  16. package/dist/types/components/tek-grid/tek-grid-toolbar-provider/tek-grid-toolbar-provider.d.ts +8 -1
  17. package/dist/types/components/tek-grid/tek-grid.d.ts +24 -6
  18. package/dist/types/components/tek-loading/interfaces.d.ts +6 -0
  19. package/dist/types/components/tek-loading/loading.d.ts +16 -0
  20. package/dist/types/components/tek-user-info/TekUserInfoController.d.ts +4 -4
  21. package/dist/types/utils/extract-properties/extract-properties.d.ts +1 -0
  22. package/dist/types/utils/index.d.ts +2 -0
  23. package/dist/types/utils/report-filter/report-filter.d.ts +12 -0
  24. package/package.json +32 -12
  25. package/coverage/clover.xml +0 -6
  26. package/coverage/coverage-final.json +0 -1
  27. package/coverage/lcov-report/base.css +0 -224
  28. package/coverage/lcov-report/block-navigation.js +0 -87
  29. package/coverage/lcov-report/favicon.png +0 -0
  30. package/coverage/lcov-report/index.html +0 -101
  31. package/coverage/lcov-report/prettify.css +0 -1
  32. package/coverage/lcov-report/prettify.js +0 -2
  33. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  34. package/coverage/lcov-report/sorter.js +0 -210
  35. package/coverage/lcov.info +0 -0
  36. package/dist/teknisa-components-common.js +0 -3802
  37. package/dist/teknisa-components-common.min.js +0 -3802
  38. package/dist/types/components/tek-grid/grouped-view-navigator.d.ts +0 -14
  39. package/dist/types/error/delete-rows-error.d.ts +0 -6
  40. package/environments.json +0 -14
  41. package/jest.config.js +0 -1
  42. package/src/components/index.ts +0 -101
  43. package/src/components/tek-breadcrumb-header/breadcrumb-header.ts +0 -29
  44. package/src/components/tek-breadcrumb-header/interfaces.ts +0 -7
  45. package/src/components/tek-datasource/index.ts +0 -3
  46. package/src/components/tek-datasource/interfaces.ts +0 -36
  47. package/src/components/tek-datasource/tek-memory-datasource.ts +0 -314
  48. package/src/components/tek-datasource/tek-rest-datasource.ts +0 -224
  49. package/src/components/tek-grid/columns-searcher.ts +0 -22
  50. package/src/components/tek-grid/dynamic-filter-datasource-factory.ts +0 -20
  51. package/src/components/tek-grid/filter-helper.ts +0 -20
  52. package/src/components/tek-grid/grid-filter-button.ts +0 -419
  53. package/src/components/tek-grid/grouped-data-manager.ts +0 -448
  54. package/src/components/tek-grid/grouped-data-selector.ts +0 -40
  55. package/src/components/tek-grid/grouped-view-navigator.ts +0 -84
  56. package/src/components/tek-grid/index.ts +0 -18
  57. package/src/components/tek-grid/interfaces.ts +0 -329
  58. package/src/components/tek-grid/keymap-grouped.ts +0 -20
  59. package/src/components/tek-grid/layout-options.ts +0 -248
  60. package/src/components/tek-grid/tek-grid-column.ts +0 -193
  61. package/src/components/tek-grid/tek-grid-columns-button/tek-grid-columns-button-controller.ts +0 -28
  62. package/src/components/tek-grid/tek-grid-columns-button/tek-grid-columns-button.ts +0 -38
  63. package/src/components/tek-grid/tek-grid-controller.ts +0 -140
  64. package/src/components/tek-grid/tek-grid-events.ts +0 -105
  65. package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/button-option.ts +0 -26
  66. package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/index.ts +0 -3
  67. package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/interfaces.ts +0 -6
  68. package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/multi-option.ts +0 -85
  69. package/src/components/tek-grid/tek-grid-toolbar-provider/index.ts +0 -2
  70. package/src/components/tek-grid/tek-grid-toolbar-provider/tek-grid-toolbar-provider.ts +0 -365
  71. package/src/components/tek-grid/tek-grid.ts +0 -1118
  72. package/src/components/tek-user-info/TekUserInfoController.ts +0 -87
  73. package/src/components/tek-user-info/interfaces.ts +0 -21
  74. package/src/components/tek-user-info/tek-user-info-list.ts +0 -64
  75. package/src/components/tek-user-info/tek-user-info.ts +0 -337
  76. package/src/error/tek-grid-delete-rows-error.ts +0 -15
  77. package/src/error/teknisa-common-error.ts +0 -8
  78. package/src/utils/config/config.ts +0 -8
  79. package/src/utils/index.ts +0 -3
  80. package/src/utils/is-filled-object/is-filled-object.ts +0 -5
  81. package/src/utils/is-nil.ts +0 -3
  82. package/tests/__helpers__/component-event-helper.ts +0 -5
  83. package/tests/__helpers__/flush-promises-helper.ts +0 -3
  84. package/tests/__helpers__/get-child-helper.ts +0 -27
  85. package/tests/__helpers__/index.ts +0 -3
  86. package/tests/__helpers__/mock-created-helper.ts +0 -12
  87. package/tests/__mocks__/@zeedhi/core/i18n.js +0 -75
  88. package/tests/__mocks__/@zeedhi/core.js +0 -5
  89. package/tests/unit/components/crud/crud-add-button.spec.ts +0 -56
  90. package/tests/unit/components/crud/crud-button.spec.ts +0 -94
  91. package/tests/unit/components/crud/crud-cancel-button.spec.ts +0 -91
  92. package/tests/unit/components/crud/crud-delete-button.spec.ts +0 -122
  93. package/tests/unit/components/crud/crud-form.spec.ts +0 -165
  94. package/tests/unit/components/crud/crud-save-button.spec.ts +0 -118
  95. package/tests/unit/components/tek-breadcrumb-header/tek-breadcrumb-header.spec.ts +0 -42
  96. package/tests/unit/components/tek-card-title/CardTitle.spec.ts +0 -34
  97. package/tests/unit/components/tek-datasource/memory-datasource.spec.ts +0 -460
  98. package/tests/unit/components/tek-datasource/rest-datasource.spec.ts +0 -362
  99. package/tests/unit/components/tek-drag-grid/tek-drag-grid.spec.ts +0 -112
  100. package/tests/unit/components/tek-grid/button-option.spec.ts +0 -49
  101. package/tests/unit/components/tek-grid/columns-searcher.spec.ts +0 -112
  102. package/tests/unit/components/tek-grid/dynamic-filter-datasource-factory.spec.ts +0 -90
  103. package/tests/unit/components/tek-grid/filter-helper.spec.ts +0 -52
  104. package/tests/unit/components/tek-grid/grid-filter-button.spec.ts +0 -842
  105. package/tests/unit/components/tek-grid/grouped-data-manager.spec.ts +0 -593
  106. package/tests/unit/components/tek-grid/grouped-data-selector.spec.ts +0 -136
  107. package/tests/unit/components/tek-grid/grouped-view-navigator.spec.ts +0 -244
  108. package/tests/unit/components/tek-grid/keymap-grouped.spec.ts +0 -20
  109. package/tests/unit/components/tek-grid/layout-options.spec.ts +0 -1020
  110. package/tests/unit/components/tek-grid/multi-option.spec.ts +0 -139
  111. package/tests/unit/components/tek-grid/tek-grid-column.spec.ts +0 -312
  112. package/tests/unit/components/tek-grid/tek-grid-columns-button.spec.ts +0 -228
  113. package/tests/unit/components/tek-grid/tek-grid-controller.spec.ts +0 -253
  114. package/tests/unit/components/tek-grid/tek-grid-events.spec.ts +0 -186
  115. package/tests/unit/components/tek-grid/tek-grid-toolbar-provider.spec.ts +0 -34
  116. package/tests/unit/components/tek-grid/tek-grid.spec.ts +0 -895
  117. package/tests/unit/components/tek-grid/tek-memory-datasource.spec.ts +0 -482
  118. package/tests/unit/components/tek-grid/tek-rest-datasource.spec.ts +0 -422
  119. package/tests/unit/components/tek-image/Image.spec.ts +0 -67
  120. package/tests/unit/components/tek-iterable-carousel/iterable-carousel.spec.ts +0 -37
  121. package/tests/unit/components/tek-iterable-component-render/iterable-component-render.spec.ts +0 -200
  122. package/tests/unit/components/tek-loading/Loading.spec.ts +0 -30
  123. package/tests/unit/components/tek-notifications/notifications.spec.ts +0 -201
  124. package/tests/unit/components/tek-product-card/product-card.spec.ts +0 -61
  125. package/tests/unit/components/tek-user-info/TekUserInfoContoller.spec.ts +0 -220
  126. package/tests/unit/components/tek-user-info/tek-user-info-list.spec.ts +0 -86
  127. package/tests/unit/components/tek-user-info/tek-user-info.spec.ts +0 -430
  128. package/tests/unit/components/tree-grid/tree-grid.spec.ts +0 -776
  129. package/tests/unit/utils/grid-base/export-options/button-option.spec.ts +0 -44
  130. package/tests/unit/utils/grid-base/export-options/multi-option.spec.ts +0 -135
  131. package/tests/unit/utils/grid-base/grid-controller.spec.ts +0 -174
  132. package/tests/unit/utils/report-filter/report-filter.spec.ts +0 -66
  133. package/tsconfig.build.json +0 -7
  134. package/tsconfig.eslint.json +0 -9
@@ -1,448 +0,0 @@
1
- import { I18n, IDictionary } from '@zeedhi/core';
2
- import debounce from 'lodash.debounce';
3
- import { NonInitializedError } from '@zeedhi/common';
4
- import { isFilledObject, isNil } from '../../utils';
5
- import {
6
- IGroupedDataManager,
7
- ITekGrid,
8
- ITekGridGroup,
9
- ITekGridGroupFooter,
10
- ITekGridGroupHeader,
11
- ITekGridSummary,
12
- } from './interfaces';
13
- import { TekGridColumn } from './tek-grid-column';
14
-
15
- export class GroupedDataManager implements IGroupedDataManager {
16
- protected grid: ITekGrid;
17
-
18
- public summaryColumns: TekGridColumn[] = [];
19
-
20
- private groups: ITekGridGroup[] = [];
21
-
22
- private summary: IDictionary<ITekGridSummary> = {};
23
-
24
- private groupedData: IDictionary<any>[] = [];
25
-
26
- private groupColumnNames: string[] = [];
27
-
28
- private groupColumns: TekGridColumn[] = [];
29
-
30
- private originalDatasourceLoadAll?: boolean;
31
-
32
- private originalDatasourceLimit?: number;
33
-
34
- private viewUpdateScrollData?: () => void;
35
-
36
- private viewUpdateFixedColumns?: () => void;
37
-
38
- constructor(grid: ITekGrid) {
39
- this.grid = grid;
40
- }
41
-
42
- setViewUpdateFixedColumns(fn: () => void) {
43
- this.viewUpdateFixedColumns = fn;
44
- }
45
-
46
- setViewUpdateScrollData(fn: () => void) {
47
- this.viewUpdateScrollData = fn;
48
- }
49
-
50
- /**
51
- * Tasks that should be finished before loading the grid data
52
- */
53
- private tasksBeforeLoad: Promise<any>[] = [];
54
-
55
- public registerTask(task: Promise<any>) {
56
- this.tasksBeforeLoad.push(task);
57
- }
58
-
59
- private request: () => void = () => {
60
- throw new NonInitializedError(this.constructor.name);
61
- };
62
-
63
- private debounceUpdateGrouping: (lazyLoad?: boolean) => void = () => {
64
- throw new NonInitializedError(this.constructor.name);
65
- };
66
-
67
- /**
68
- * Loads grid data after resolving all tasks
69
- */
70
- public async loadAfterTasks() {
71
- Promise.all(this.tasksBeforeLoad.map((promise) => promise.catch(() => undefined)));
72
- this.tasksBeforeLoad = [];
73
-
74
- return this.request();
75
- }
76
-
77
- private initializeDebounceFunctions() {
78
- this.request = debounce(() => {
79
- this.grid.reload();
80
- }, 500);
81
- this.debounceUpdateGrouping = debounce((lazyLoad = false) => {
82
- this.updateGroupedData(lazyLoad);
83
- }, 100);
84
- }
85
-
86
- /**
87
- * Initializes grid groups, summary columns and registers the grid datasource callback
88
- * @param lazyLoad defines if the grid should automatically load data after updating the datasource
89
- */
90
- initializeGrouping(lazyLoad: boolean): void {
91
- this.initializeDebounceFunctions();
92
-
93
- this.initGroups();
94
- this.initSummaryColumns();
95
-
96
- this.originalDatasourceLoadAll = this.grid.datasource.loadAll;
97
- this.originalDatasourceLimit = this.grid.datasource.limit;
98
- this.grid.datasource.registerGetCallback((data) => this.onGet(data));
99
- this.updateGrouping(lazyLoad);
100
- }
101
-
102
- private onGet(data: IDictionary) {
103
- if (this.isGrouped()) {
104
- this.buildGroupedData();
105
- }
106
-
107
- return data;
108
- }
109
-
110
- private resetFooterVariables(group: ITekGridGroup) {
111
- this.summaryColumns.forEach((column) => {
112
- group.footer[column.name] = {
113
- count: 0,
114
- sum: undefined,
115
- avg: undefined,
116
- min: undefined,
117
- max: undefined,
118
- };
119
- });
120
- }
121
-
122
- private initGroups() {
123
- this.groups = [];
124
- this.groupColumns.forEach((column) => {
125
- const newGroup = {
126
- column,
127
- name: column.name,
128
- label: column.label,
129
- lastValue: undefined,
130
- initialized: false,
131
- footer: {},
132
- };
133
- this.resetFooterVariables(newGroup);
134
-
135
- this.groups.push(newGroup);
136
- });
137
- }
138
-
139
- getGroupedData(): IDictionary<any>[] {
140
- return this.groupedData;
141
- }
142
-
143
- private initSummaryColumns() {
144
- this.summaryColumns = this.grid.columns.filter((column) => !!column.aggregation && !column.grouped);
145
- this.summary = {};
146
- }
147
-
148
- /**
149
- * Calls updateGroupedData with debounce
150
- */
151
- public updateGrouping(lazyLoad?: boolean) {
152
- this.debounceUpdateGrouping(lazyLoad);
153
- }
154
-
155
- /**
156
- * Inits summary columns, updates the grid datasource and, if needed, reloads the grid data
157
- */
158
- async updateGroupedData(lazyLoad: boolean): Promise<void> {
159
- this.initSummaryColumns();
160
- this.updateGridDatasource();
161
-
162
- if (!lazyLoad) {
163
- await this.loadAfterTasks();
164
- }
165
-
166
- if (this.grid.virtualScroll && this.viewUpdateScrollData) {
167
- this.viewUpdateScrollData();
168
- }
169
- if (this.viewUpdateFixedColumns) {
170
- this.viewUpdateFixedColumns();
171
- }
172
- }
173
-
174
- /**
175
- * When using groups, should update the grid datasource order to reflect the group order
176
- * If the grid is not grouped, should not update the datasource order
177
- */
178
- private updateGridDatasource() {
179
- this.groupedData = [];
180
-
181
- this.groupColumns = this.grid.columns.filter((column) => column.grouped);
182
- this.groupColumnNames = this.groupColumns.map((column) => column.name);
183
- if (this.isGrouped()) {
184
- if (this.groupColumns.length) {
185
- const order = this.getOrder(this.groupColumnNames, this.grid.datasource.order);
186
- this.grid.datasource.order = order;
187
- }
188
-
189
- this.grid.datasource.loadAll = true;
190
- return;
191
- }
192
-
193
- this.grid.datasource.loadAll = this.originalDatasourceLoadAll!;
194
- this.grid.datasource.limit = this.originalDatasourceLimit!;
195
- }
196
-
197
- /**
198
- * Returns the order to be used in the grid datasource based on the group column names and the grid order
199
- */
200
- private getOrder(groupColumnNames: string[], gridOrder: string[]): string[] {
201
- const groupOrderColumns = groupColumnNames.map((column) => `${column}.asc`);
202
- const otherOrderColumns = gridOrder.filter((column) => groupColumnNames.indexOf(column.split('.')[0]) === -1);
203
-
204
- return [...groupOrderColumns, ...otherOrderColumns];
205
- }
206
-
207
- /**
208
- * Returns the summary data for the group
209
- */
210
- public getSummaryData(group: IDictionary<ITekGridSummary>) {
211
- const summaryData: IDictionary = {};
212
- this.summaryColumns.forEach((column) => {
213
- const { aggregation } = column;
214
- const currentGroup = group[column.name];
215
-
216
- if (!currentGroup) {
217
- summaryData[column.name] = 0;
218
- return;
219
- }
220
-
221
- if (aggregation === 'COUNT') {
222
- summaryData[column.name] = currentGroup.count;
223
- } else if (aggregation === 'SUM') {
224
- summaryData[column.name] = currentGroup.sum;
225
- } else if (aggregation === 'AVG') {
226
- if (currentGroup.avg) {
227
- summaryData[column.name] = currentGroup.avg;
228
- } else if (typeof currentGroup.sum === 'number') {
229
- summaryData[column.name] = currentGroup.sum / currentGroup.count;
230
- }
231
- } else if (aggregation === 'MIN') {
232
- summaryData[column.name] = currentGroup.min;
233
- } else {
234
- // if (aggregation === 'MAX') {
235
- summaryData[column.name] = currentGroup.max;
236
- }
237
- });
238
-
239
- return summaryData;
240
- }
241
-
242
- /**
243
- * Adds group footers to the grouped data
244
- */
245
- private addGroupFooters(groupIndex: number) {
246
- if (this.summaryColumns.length === 0) {
247
- return;
248
- }
249
-
250
- for (let i = this.groups.length - 1; i >= groupIndex; i -= 1) {
251
- if (this.groups[i].initialized) {
252
- const groupFooterRow: ITekGridGroupFooter = {
253
- groupFooter: true,
254
- groupIndex: i,
255
- groupHeaders: [],
256
- groupLabel: this.groups[i].lastGroupHeaderRow!.groupLabel,
257
- groupValue: this.groups[i].lastGroupHeaderRow!.groupValue,
258
- ...this.getSummaryData(this.groups[i].footer),
259
- };
260
-
261
- // add header for outer groups
262
- for (let g = 0; g < i; g += 1) {
263
- const { lastGroupHeaderRow } = this.groups[g];
264
- if (lastGroupHeaderRow) {
265
- groupFooterRow.groupHeaders.push(lastGroupHeaderRow);
266
- }
267
- }
268
-
269
- this.groupedData.push(groupFooterRow);
270
- }
271
- }
272
- }
273
-
274
- private getGroupValue(group: IDictionary<any>, row: IDictionary<any>) {
275
- const groupColumn = this.grid.getColumn(group.column.name);
276
- const cellsApplied = this.grid.getAppliedConditions({ row, column: groupColumn });
277
- if (!isFilledObject(cellsApplied)) {
278
- this.grid.reapplyConditions(row);
279
- }
280
- const groupValue = groupColumn.formatterByRow(row, cellsApplied);
281
- return groupValue;
282
- }
283
-
284
- private addGroupHeader(row: IDictionary, group: ITekGridGroup, index: number) {
285
- const groupValue = this.getGroupValue(group, row) || group.column.groupLabelForEmptyValue;
286
- const groupHeaderRow: ITekGridGroupHeader = {
287
- group: true,
288
- groupRow: row,
289
- groupColumnName: group.column.name,
290
- groupHeader: true,
291
- groupIndex: index,
292
- groupLabel: I18n.translate(group.label),
293
- groupValue,
294
- groupOpened: group.column.groupOpened || this.grid.groupsOpened,
295
- groupHeaders: [],
296
- children: [],
297
- };
298
- // add header for outer groups to the added row
299
- for (let i = 0; i < index; i += 1) {
300
- groupHeaderRow.groupHeaders.push(this.groups[i].lastGroupHeaderRow!);
301
- }
302
- group.lastGroupHeaderRow = groupHeaderRow;
303
- group.initialized = true;
304
- this.groupedData.push(groupHeaderRow);
305
- }
306
-
307
- private calcSummaryValues(column: TekGridColumn, summary: ITekGridSummary, row: IDictionary) {
308
- const rowValue = row[column.name];
309
-
310
- if (isNil(rowValue)) return;
311
-
312
- summary.count += 1;
313
-
314
- if (this.grid.events.calcSummary) {
315
- this.grid.calcSummary(column, summary, row);
316
- return;
317
- }
318
-
319
- if (summary.min === undefined) summary.min = rowValue;
320
- if (summary.max === undefined) summary.max = rowValue;
321
- summary.min = rowValue < summary.min ? rowValue : summary.min;
322
- summary.max = rowValue > summary.max ? rowValue : summary.max;
323
-
324
- if (typeof rowValue === 'number') {
325
- summary.sum = (summary.sum || 0) + rowValue;
326
- }
327
- }
328
-
329
- private calcSummary(row: IDictionary<any>) {
330
- if (this.summaryColumns.length === 0) return;
331
-
332
- this.summaryColumns.forEach((column) => {
333
- const columnName = column.name;
334
- if (isNil(this.summary[columnName])) {
335
- this.summary[columnName] = {
336
- count: 0,
337
- sum: undefined,
338
- avg: undefined,
339
- min: undefined,
340
- max: undefined,
341
- };
342
- }
343
-
344
- this.calcSummaryValues(column, this.summary[columnName], row);
345
-
346
- this.groups.forEach((group) => {
347
- this.calcSummaryValues(column, group.footer[columnName], row);
348
- });
349
- });
350
- }
351
-
352
- private addSummary() {
353
- if (this.summaryColumns.length === 0) return;
354
-
355
- const summaryRow = {
356
- groupFooter: true,
357
- groupSummary: true,
358
- ...this.getSummaryData(this.summary),
359
- };
360
-
361
- this.groupedData.push(summaryRow);
362
- }
363
-
364
- /**
365
- * It takes a flat array of data and groups it by the group columns specified in
366
- * the grid.
367
- */
368
- buildGroupedData(): void {
369
- this.initGroups();
370
- this.initSummaryColumns();
371
- this.groupedData = [];
372
- const data = this.grid.getData();
373
-
374
- data.forEach((row) => {
375
- let groupBreak = false;
376
- this.groups.forEach((group, index) => {
377
- const groupValue = row[group.name];
378
- if (group.lastValue !== groupValue || groupBreak) {
379
- if (!groupBreak) {
380
- this.addGroupFooters(index);
381
- }
382
- group.lastValue = groupValue;
383
-
384
- this.resetFooterVariables(group);
385
- this.addGroupHeader(row, group, index);
386
- groupBreak = true;
387
- }
388
- });
389
-
390
- this.groups.forEach((group) => {
391
- group.lastGroupHeaderRow!.children.push(row);
392
- });
393
-
394
- this.groupedData.push({
395
- ...row,
396
- groupHeaders: this.groups.map((group) => group.lastGroupHeaderRow).filter(Boolean),
397
- });
398
-
399
- this.calcSummary(row);
400
- });
401
-
402
- if (this.groupedData.length > 0) {
403
- this.addGroupFooters(0);
404
-
405
- if (this.grid.showSummaryTotal) {
406
- this.addSummary();
407
- }
408
- }
409
- }
410
-
411
- openGroup(group: IDictionary<any>): void {
412
- group.groupOpened = !group.groupOpened;
413
- if (this.grid.virtualScroll && this.viewUpdateScrollData) this.viewUpdateScrollData();
414
- }
415
-
416
- isItemVisible(row: IDictionary<any>) {
417
- return !row.groupHeaders || !row.groupHeaders.length || row.groupHeaders.every((group: any) => group.groupOpened);
418
- }
419
-
420
- isGrouped(): boolean {
421
- return !!this.groupColumnNames.length || (this.grid.showSummaryTotal && !!this.summaryColumns.length);
422
- }
423
-
424
- isColumnSearchable(column: TekGridColumn): boolean {
425
- return !this.grid.searchVisibleOnly || column.isVisible || column.grouped;
426
- }
427
-
428
- directionalLeft(): void {
429
- const { currentRow } = this.grid.datasource;
430
- if (currentRow.group && currentRow.groupOpened) {
431
- currentRow.groupOpened = false;
432
- return;
433
- }
434
-
435
- if (this.grid.cellSelection || !currentRow.groupHeaders?.length) return;
436
-
437
- const newCurrentRow = currentRow.groupHeaders[currentRow.groupHeaders.length - 1];
438
- this.grid.setCurrentRow(newCurrentRow);
439
- }
440
-
441
- directionalRight(): void {
442
- const { currentRow } = this.grid.datasource;
443
-
444
- if (!currentRow.group || currentRow.groupOpened) return;
445
-
446
- currentRow.groupOpened = true;
447
- }
448
- }
@@ -1,40 +0,0 @@
1
- import { IDictionary } from '@zeedhi/core';
2
- import { DataSelector, IDataSelector, IGrid } from '@zeedhi/common';
3
- import { IGroupedDataManager } from './interfaces';
4
-
5
- export class GroupedDataSelector extends DataSelector implements IDataSelector {
6
- protected declare iterable: IGrid & IGroupedDataManager;
7
-
8
- public selectAll(isSelected: boolean) {
9
- if (!this.iterable.selectable) return;
10
-
11
- this.iterable.selectionState = { allSelected: isSelected, except: [] };
12
- const data = this.getData();
13
-
14
- if (!isSelected) {
15
- data.forEach((row: IDictionary) => {
16
- const index = this.iterable.selectedRows.indexOf(row);
17
- if (index > -1) {
18
- this.iterable.selectedRows.splice(index, 1);
19
- }
20
- });
21
- return;
22
- }
23
-
24
- data.forEach((row: IDictionary) => {
25
- if (this.callDisableSelection(row)) return;
26
-
27
- const key = this.iterable.getRowKey(row);
28
- if (key && this.iterable.selectedRows.indexOf(row) === -1) {
29
- this.iterable.selectedRows.push(row);
30
- }
31
- });
32
- }
33
-
34
- private getData() {
35
- if (this.iterable.isGrouped()) {
36
- return this.iterable.getGroupedData();
37
- }
38
- return this.iterable.getData();
39
- }
40
- }
@@ -1,84 +0,0 @@
1
- import { IEventParam, IDictionary } from '@zeedhi/core';
2
- import { Direction, IViewNavigator, ViewNavigator } from '@zeedhi/common';
3
- import { ITekGrid } from './interfaces';
4
-
5
- export class GroupedViewNavigator implements IViewNavigator {
6
- private viewNavigator: ViewNavigator;
7
-
8
- protected grid: ITekGrid;
9
-
10
- constructor(iterable: ITekGrid) {
11
- this.viewNavigator = new ViewNavigator();
12
- this.grid = iterable;
13
- }
14
-
15
- navigateLeft(param: IEventParam<any>): void {
16
- this.viewNavigator.navigateLeft(param);
17
- }
18
-
19
- navigateRight(param: IEventParam<any>): void {
20
- this.viewNavigator.navigateRight(param);
21
- }
22
-
23
- setViewNavigate(viewNavigate: (direction: Direction, event?: Event) => void): void {
24
- this.viewNavigator.setViewNavigate(viewNavigate);
25
- }
26
-
27
- private getRowIndex(groupedData: IDictionary[], index?: number) {
28
- if (index) return index;
29
-
30
- const { currentRow } = this.grid.datasource;
31
- return groupedData.findIndex((row) => {
32
- if (currentRow.group) {
33
- return row.group && row.groupValue === currentRow.groupValue;
34
- }
35
- const rowKey = this.grid.getRowKey(row);
36
- const currentRowKey = this.grid.getRowKey(currentRow);
37
- return rowKey && rowKey === currentRowKey;
38
- });
39
- }
40
-
41
- public navigateUp(index?: number) {
42
- if (!this.grid.isGrouped() || this.grid.cellSelection) {
43
- this.viewNavigator.navigateUp();
44
- return;
45
- }
46
- const groupedData = this.grid.getGroupedData();
47
-
48
- if (!groupedData.length || index === -1) return;
49
-
50
- let rowIndex: number = this.getRowIndex(groupedData, index);
51
-
52
- if (rowIndex === -1) rowIndex = groupedData.length;
53
-
54
- const newRow = groupedData[rowIndex - 1];
55
-
56
- if (!newRow || !this.grid.isItemVisible(newRow) || newRow.groupFooter) {
57
- this.navigateUp(rowIndex - 1);
58
- return;
59
- }
60
-
61
- this.grid.setCurrentRow(newRow);
62
- }
63
-
64
- public navigateDown(index?: number) {
65
- if (!this.grid.isGrouped() || this.grid.cellSelection) {
66
- this.viewNavigator.navigateDown();
67
- return;
68
- }
69
- const groupedData = this.grid.getGroupedData();
70
-
71
- if (!groupedData.length || index === groupedData.length) return;
72
-
73
- const rowIndex = this.getRowIndex(groupedData, index);
74
-
75
- const newRow = groupedData[rowIndex + 1];
76
-
77
- if (!newRow || !this.grid.isItemVisible(newRow) || newRow.groupFooter) {
78
- this.navigateDown(rowIndex + 1);
79
- return;
80
- }
81
-
82
- this.grid.setCurrentRow(newRow);
83
- }
84
- }
@@ -1,18 +0,0 @@
1
- export * from '../tek-datasource';
2
- export * from './tek-grid-toolbar-provider';
3
- export * from './columns-searcher';
4
- export * from './dynamic-filter-datasource-factory';
5
- export * from './filter-helper';
6
- export * from './grid-filter-button';
7
- export * from './grouped-data-manager';
8
- export * from './grouped-view-navigator';
9
- export * from './interfaces';
10
- export * from './keymap-grouped';
11
- export * from './layout-options';
12
- export * from './tek-grid-column';
13
- export * from './tek-grid-controller';
14
- export * from './tek-grid-events';
15
- export * from './tek-grid';
16
- export * from './tek-grid-columns-button/tek-grid-columns-button';
17
- export * from './tek-grid-columns-button/tek-grid-columns-button-controller';
18
- export * from './grouped-data-selector';