@zeedhi/teknisa-components-common 1.117.1 → 3.0.1

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 (177) hide show
  1. package/.package.json +43 -0
  2. package/dist/teknisa-components-common.js +3802 -0
  3. package/dist/teknisa-components-common.min.js +3802 -0
  4. package/dist/types/components/index.d.ts +7 -0
  5. package/{types → dist/types}/components/tek-breadcrumb-header/breadcrumb-header.d.ts +12 -12
  6. package/{types → dist/types}/components/tek-breadcrumb-header/interfaces.d.ts +6 -6
  7. package/dist/types/components/tek-datasource/index.d.ts +3 -0
  8. package/{types → dist/types}/components/tek-datasource/interfaces.d.ts +16 -16
  9. package/{types/components/tek-datasource/memory-datasource.d.ts → dist/types/components/tek-datasource/tek-memory-datasource.d.ts} +93 -100
  10. package/{types/components/tek-datasource/rest-datasource.d.ts → dist/types/components/tek-datasource/tek-rest-datasource.d.ts} +95 -103
  11. package/dist/types/components/tek-grid/columns-searcher.d.ts +5 -0
  12. package/dist/types/components/tek-grid/dynamic-filter-datasource-factory.d.ts +6 -0
  13. package/{types → dist/types}/components/tek-grid/filter-helper.d.ts +7 -7
  14. package/{types → dist/types}/components/tek-grid/grid-filter-button.d.ts +29 -31
  15. package/dist/types/components/tek-grid/grouped-data-manager.d.ts +82 -0
  16. package/dist/types/components/tek-grid/grouped-data-selector.d.ts +7 -0
  17. package/dist/types/components/tek-grid/grouped-view-navigator.d.ts +14 -0
  18. package/dist/types/components/tek-grid/index.d.ts +18 -0
  19. package/dist/types/components/tek-grid/interfaces.d.ts +259 -0
  20. package/dist/types/components/tek-grid/keymap-grouped.d.ts +6 -0
  21. package/{types → dist/types}/components/tek-grid/layout-options.d.ts +39 -31
  22. package/{types/components/tek-grid/grid-column.d.ts → dist/types/components/tek-grid/tek-grid-column.d.ts} +42 -45
  23. package/{types/components/tek-grid/grid-columns-button-controller.d.ts → dist/types/components/tek-grid/tek-grid-columns-button/tek-grid-columns-button-controller.d.ts} +8 -8
  24. package/{types/components/tek-grid/grid-columns-button.d.ts → dist/types/components/tek-grid/tek-grid-columns-button/tek-grid-columns-button.d.ts} +13 -12
  25. package/dist/types/components/tek-grid/tek-grid-controller.d.ts +31 -0
  26. package/dist/types/components/tek-grid/tek-grid-events.d.ts +31 -0
  27. package/{types/utils/grid-base → dist/types/components/tek-grid/tek-grid-toolbar-provider}/export-options/button-option.d.ts +17 -16
  28. package/{types/utils/grid-base → dist/types/components/tek-grid/tek-grid-toolbar-provider}/export-options/index.d.ts +3 -3
  29. package/dist/types/components/tek-grid/tek-grid-toolbar-provider/export-options/interfaces.d.ts +5 -0
  30. package/{types/utils/grid-base → dist/types/components/tek-grid/tek-grid-toolbar-provider}/export-options/multi-option.d.ts +12 -12
  31. package/dist/types/components/tek-grid/tek-grid-toolbar-provider/index.d.ts +2 -0
  32. package/dist/types/components/tek-grid/tek-grid-toolbar-provider/tek-grid-toolbar-provider.d.ts +22 -0
  33. package/dist/types/components/tek-grid/tek-grid.d.ts +216 -0
  34. package/{types → dist/types}/components/tek-user-info/TekUserInfoController.d.ts +22 -21
  35. package/{types → dist/types}/components/tek-user-info/interfaces.d.ts +27 -28
  36. package/{types → dist/types}/components/tek-user-info/tek-user-info-list.d.ts +32 -31
  37. package/{types → dist/types}/components/tek-user-info/tek-user-info.d.ts +37 -38
  38. package/{types → dist/types}/error/delete-rows-error.d.ts +6 -6
  39. package/dist/types/error/tek-grid-delete-rows-error.d.ts +7 -0
  40. package/dist/types/error/teknisa-common-error.d.ts +6 -0
  41. package/dist/types/index.d.ts +2 -0
  42. package/{types → dist/types}/utils/config/config.d.ts +7 -7
  43. package/dist/types/utils/index.d.ts +3 -0
  44. package/dist/types/utils/is-filled-object/is-filled-object.d.ts +2 -0
  45. package/dist/types/utils/is-nil.d.ts +1 -0
  46. package/environments.json +14 -0
  47. package/package.json +26 -18
  48. package/src/components/index.ts +101 -0
  49. package/src/components/tek-breadcrumb-header/breadcrumb-header.ts +29 -0
  50. package/src/components/tek-breadcrumb-header/interfaces.ts +7 -0
  51. package/src/components/tek-datasource/index.ts +3 -0
  52. package/src/components/tek-datasource/interfaces.ts +36 -0
  53. package/src/components/tek-datasource/tek-memory-datasource.ts +314 -0
  54. package/src/components/tek-datasource/tek-rest-datasource.ts +224 -0
  55. package/src/components/tek-grid/columns-searcher.ts +22 -0
  56. package/src/components/tek-grid/dynamic-filter-datasource-factory.ts +20 -0
  57. package/src/components/tek-grid/filter-helper.ts +20 -0
  58. package/src/components/tek-grid/grid-filter-button.ts +419 -0
  59. package/src/components/tek-grid/grouped-data-manager.ts +448 -0
  60. package/src/components/tek-grid/grouped-data-selector.ts +40 -0
  61. package/src/components/tek-grid/grouped-view-navigator.ts +84 -0
  62. package/src/components/tek-grid/index.ts +18 -0
  63. package/src/components/tek-grid/interfaces.ts +329 -0
  64. package/src/components/tek-grid/keymap-grouped.ts +20 -0
  65. package/src/components/tek-grid/layout-options.ts +248 -0
  66. package/src/components/tek-grid/tek-grid-column.ts +193 -0
  67. package/src/components/tek-grid/tek-grid-columns-button/tek-grid-columns-button-controller.ts +28 -0
  68. package/src/components/tek-grid/tek-grid-columns-button/tek-grid-columns-button.ts +38 -0
  69. package/src/components/tek-grid/tek-grid-controller.ts +140 -0
  70. package/src/components/tek-grid/tek-grid-events.ts +105 -0
  71. package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/button-option.ts +26 -0
  72. package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/index.ts +3 -0
  73. package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/interfaces.ts +6 -0
  74. package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/multi-option.ts +85 -0
  75. package/src/components/tek-grid/tek-grid-toolbar-provider/index.ts +2 -0
  76. package/src/components/tek-grid/tek-grid-toolbar-provider/tek-grid-toolbar-provider.ts +365 -0
  77. package/src/components/tek-grid/tek-grid.ts +1118 -0
  78. package/src/components/tek-user-info/TekUserInfoController.ts +87 -0
  79. package/src/components/tek-user-info/interfaces.ts +21 -0
  80. package/src/components/tek-user-info/tek-user-info-list.ts +64 -0
  81. package/src/components/tek-user-info/tek-user-info.ts +337 -0
  82. package/src/error/tek-grid-delete-rows-error.ts +15 -0
  83. package/src/error/teknisa-common-error.ts +8 -0
  84. package/src/index.ts +2 -0
  85. package/src/utils/config/config.ts +8 -0
  86. package/src/utils/index.ts +3 -0
  87. package/src/utils/is-filled-object/is-filled-object.ts +5 -0
  88. package/src/utils/is-nil.ts +3 -0
  89. package/tests/__helpers__/component-event-helper.ts +1 -1
  90. package/tests/__helpers__/get-child-helper.ts +1 -1
  91. package/tests/__helpers__/mock-created-helper.ts +1 -1
  92. package/tests/unit/components/crud/crud-button.spec.ts +1 -1
  93. package/tests/unit/components/tek-datasource/memory-datasource.spec.ts +1 -11
  94. package/tests/unit/components/tek-datasource/rest-datasource.spec.ts +5 -7
  95. package/tests/unit/components/tek-drag-grid/tek-drag-grid.spec.ts +1 -1
  96. package/tests/unit/components/tek-grid/button-option.spec.ts +49 -0
  97. package/tests/unit/components/tek-grid/columns-searcher.spec.ts +112 -0
  98. package/tests/unit/components/tek-grid/dynamic-filter-datasource-factory.spec.ts +90 -0
  99. package/tests/unit/components/tek-grid/filter-helper.spec.ts +34 -130
  100. package/tests/unit/components/tek-grid/grid-filter-button.spec.ts +114 -239
  101. package/tests/unit/components/tek-grid/grouped-data-manager.spec.ts +593 -0
  102. package/tests/unit/components/tek-grid/grouped-data-selector.spec.ts +136 -0
  103. package/tests/unit/components/tek-grid/grouped-view-navigator.spec.ts +244 -0
  104. package/tests/unit/components/tek-grid/keymap-grouped.spec.ts +20 -0
  105. package/tests/unit/components/tek-grid/{layout_options.spec.ts → layout-options.spec.ts} +70 -30
  106. package/tests/unit/components/tek-grid/multi-option.spec.ts +139 -0
  107. package/tests/unit/components/tek-grid/{grid-column.spec.ts → tek-grid-column.spec.ts} +44 -2
  108. package/tests/unit/components/tek-grid/{grid-columns-button.spec.ts → tek-grid-columns-button.spec.ts} +42 -9
  109. package/tests/unit/components/tek-grid/tek-grid-controller.spec.ts +253 -0
  110. package/tests/unit/components/tek-grid/tek-grid-events.spec.ts +186 -0
  111. package/tests/unit/components/tek-grid/tek-grid-toolbar-provider.spec.ts +34 -0
  112. package/tests/unit/components/tek-grid/tek-grid.spec.ts +895 -0
  113. package/tests/unit/components/tek-grid/tek-memory-datasource.spec.ts +482 -0
  114. package/tests/unit/components/tek-grid/tek-rest-datasource.spec.ts +422 -0
  115. package/tests/unit/components/tek-user-info/tek-user-info-list.spec.ts +1 -1
  116. package/tests/unit/components/tek-user-info/tek-user-info.spec.ts +10 -14
  117. package/tests/unit/components/tree-grid/tree-grid.spec.ts +4 -28
  118. package/tests/unit/utils/grid-base/export-options/multi-option.spec.ts +2 -2
  119. package/tests/unit/utils/grid-base/grid-controller.spec.ts +17 -152
  120. package/tsconfig.build.json +7 -0
  121. package/coverage/clover.xml +0 -2007
  122. package/coverage/coverage-final.json +0 -48
  123. package/coverage/lcov-report/base.css +0 -224
  124. package/coverage/lcov-report/block-navigation.js +0 -87
  125. package/coverage/lcov-report/favicon.png +0 -0
  126. package/coverage/lcov-report/index.html +0 -431
  127. package/coverage/lcov-report/prettify.css +0 -1
  128. package/coverage/lcov-report/prettify.js +0 -2
  129. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  130. package/coverage/lcov-report/sorter.js +0 -210
  131. package/coverage/lcov-report/tests/__helpers__/component-event-helper.ts.html +0 -100
  132. package/coverage/lcov-report/tests/__helpers__/flush-promises-helper.ts.html +0 -94
  133. package/coverage/lcov-report/tests/__helpers__/get-child-helper.ts.html +0 -166
  134. package/coverage/lcov-report/tests/__helpers__/index.html +0 -176
  135. package/coverage/lcov-report/tests/__helpers__/index.ts.html +0 -94
  136. package/coverage/lcov-report/tests/__helpers__/mock-created-helper.ts.html +0 -121
  137. package/coverage/lcov.info +0 -3885
  138. package/dist/tek-components-common.esm.js +0 -4833
  139. package/dist/tek-components-common.umd.js +0 -4870
  140. package/tests/unit/components/tek-grid/grid.spec.ts +0 -3377
  141. package/tests/unit/utils/grid-base/delete-rows-error.spec.ts +0 -24
  142. package/types/components/crud/crud-add-button.d.ts +0 -38
  143. package/types/components/crud/crud-button.d.ts +0 -27
  144. package/types/components/crud/crud-cancel-button.d.ts +0 -28
  145. package/types/components/crud/crud-delete-button.d.ts +0 -42
  146. package/types/components/crud/crud-form.d.ts +0 -46
  147. package/types/components/crud/crud-save-button.d.ts +0 -24
  148. package/types/components/crud/interfaces.d.ts +0 -15
  149. package/types/components/index.d.ts +0 -41
  150. package/types/components/tek-card-title/card-title.d.ts +0 -14
  151. package/types/components/tek-card-title/interfaces.d.ts +0 -9
  152. package/types/components/tek-drag-grid/interfaces.d.ts +0 -7
  153. package/types/components/tek-drag-grid/tek-drag-grid.d.ts +0 -36
  154. package/types/components/tek-grid/grid.d.ts +0 -267
  155. package/types/components/tek-grid/interfaces.d.ts +0 -203
  156. package/types/components/tek-image/image.d.ts +0 -55
  157. package/types/components/tek-image/interfaces.d.ts +0 -12
  158. package/types/components/tek-iterable-carousel/interfaces.d.ts +0 -5
  159. package/types/components/tek-iterable-carousel/iterable-carousel.d.ts +0 -13
  160. package/types/components/tek-iterable-component-render/interfaces.d.ts +0 -3
  161. package/types/components/tek-iterable-component-render/iterable-component-render.d.ts +0 -10
  162. package/types/components/tek-loading/interfaces.d.ts +0 -6
  163. package/types/components/tek-loading/loading.d.ts +0 -24
  164. package/types/components/tek-notifications/interfaces.d.ts +0 -22
  165. package/types/components/tek-notifications/notifications.d.ts +0 -35
  166. package/types/components/tek-product-card/interfaces.d.ts +0 -19
  167. package/types/components/tek-product-card/product-card.d.ts +0 -66
  168. package/types/components/tek-tree-grid/interfaces.d.ts +0 -30
  169. package/types/components/tek-tree-grid/tree-grid.d.ts +0 -102
  170. package/types/error/incomplete-groups-error.d.ts +0 -8
  171. package/types/index.d.ts +0 -2
  172. package/types/utils/extract-properties.d.ts +0 -7
  173. package/types/utils/grid-base/export-options/interfaces.d.ts +0 -5
  174. package/types/utils/grid-base/grid-base.d.ts +0 -59
  175. package/types/utils/grid-base/grid-controller.d.ts +0 -27
  176. package/types/utils/index.d.ts +0 -6
  177. package/types/utils/report-filter/report-filter.d.ts +0 -12
@@ -0,0 +1,193 @@
1
+ import { Datasource, DatasourceFactory, IDictionary } from '@zeedhi/core';
2
+ import { GridColumnEditable } from '@zeedhi/common';
3
+ import { IFilterPropsComponent, ITekGridColumn, ITekGridColumnAggregation } from './interfaces';
4
+ import { TekGrid } from './tek-grid';
5
+
6
+ /**
7
+ * Base class for TekGrid column
8
+ */
9
+ export class TekGridColumn extends GridColumnEditable implements ITekGridColumn {
10
+ /* filter component props */
11
+ public filterProps: IFilterPropsComponent | IFilterPropsComponent[] = [];
12
+
13
+ /* column can be use to filter */
14
+ public filterable = true;
15
+
16
+ /* Index of the column inside filter modal */
17
+ public filterIndex?: number;
18
+
19
+ /* should not consider lookup column on search */
20
+ public skipLookupSearch = false;
21
+
22
+ /* column is grouped */
23
+ private groupedValue = false;
24
+
25
+ /* column group is opened */
26
+ private groupOpenedValue?: boolean = false;
27
+
28
+ /* Value to show when grouped value is empty */
29
+ public groupLabelForEmptyValue = '';
30
+
31
+ /* column has aggregation */
32
+ private aggregationValue?: ITekGridColumnAggregation;
33
+
34
+ /* column is visible */
35
+ private isVisibleValue = true;
36
+
37
+ /**
38
+ * Defines if the column should store the componentProps datasource.data in memory
39
+ */
40
+ public storeData = true;
41
+
42
+ private grid: TekGrid;
43
+
44
+ /* istanbul ignore next */
45
+ /**
46
+ * Creates a new TekGrid Column.
47
+ * @param props TekGrid column properties
48
+ */
49
+ constructor(props: ITekGridColumn, grid: TekGrid) {
50
+ super(props);
51
+ this.grid = grid;
52
+ this.isVisible = this.getInitValue('isVisible', props.isVisible, this.isVisible);
53
+ this.filterProps = this.getInitValue('filterProps', props.filterProps, this.filterProps);
54
+ this.filterable = this.getInitValue('filterable', props.filterable, this.filterable);
55
+ this.filterIndex = this.getInitValue('filterIndex', props.filterIndex, this.filterIndex);
56
+ this.skipLookupSearch = this.getInitValue('skipLookupSearch', props.skipLookupSearch, this.skipLookupSearch);
57
+ this.grouped = this.getInitValue('grouped', props.grouped, this.grouped);
58
+ this.groupOpened = this.getInitValue('groupOpened', props.groupOpened, this.groupOpened);
59
+ this.aggregation = this.getInitValue('aggregation', props.aggregation, this.aggregation);
60
+ this.groupLabelForEmptyValue = this.getInitValue(
61
+ 'groupLabelForEmptyValue',
62
+ props.groupLabelForEmptyValue,
63
+ this.groupLabelForEmptyValue,
64
+ );
65
+ this.storeData = this.getInitValue('storeData', props.storeData, this.storeData);
66
+ this.createAccessors();
67
+ }
68
+
69
+ public async getBatchLookupData(lookupColumn: string, values: any[]): Promise<IDictionary[]> {
70
+ const batch: IDictionary[] = [];
71
+ const dataToLookup: any[] = [];
72
+ values.forEach((value) => {
73
+ if (this.lookupData[value]) {
74
+ batch.push(this.lookupData[value]);
75
+ return;
76
+ }
77
+
78
+ const dataIndex = this.lookupDatasource!.data.findIndex((row) => row[lookupColumn] === value);
79
+ if (dataIndex !== -1) {
80
+ this.lookupData[value] = this.lookupDatasource!.data[dataIndex];
81
+ batch.push(this.lookupData[value]);
82
+ return;
83
+ }
84
+
85
+ dataToLookup.push(value);
86
+ });
87
+
88
+ if (dataToLookup.length > 0) {
89
+ await this.lookupFn(lookupColumn, dataToLookup);
90
+
91
+ dataToLookup.forEach((value) => {
92
+ const row = this.lookupData[value];
93
+ if (row) batch.push(row);
94
+ });
95
+ }
96
+
97
+ return batch;
98
+ }
99
+
100
+ /**
101
+ * Memory search, without changing lookupDatasource
102
+ */
103
+ public async memorySearch(search: string): Promise<any> {
104
+ if (!this.lookupDatasource) {
105
+ throw new Error("Can't search in a column that doesn't have a datasource");
106
+ }
107
+
108
+ let { data } = this.lookupDatasource;
109
+ if (this.storeData) {
110
+ if (!data.length) {
111
+ data = await this.lookupDatasource.get();
112
+ }
113
+ } else {
114
+ // datasource without the lookup filters
115
+ const defaultDs = DatasourceFactory.factory({
116
+ ...this.componentProps.datasource,
117
+ lazyLoad: true,
118
+ loadAll: true,
119
+ });
120
+ defaultDs.initialize();
121
+
122
+ data = await defaultDs.get();
123
+ }
124
+
125
+ const { dataText } = this.componentProps;
126
+ const searchIn = Array.isArray(dataText) ? dataText : [dataText];
127
+
128
+ // get datasource as memory
129
+ const datasource: Datasource = DatasourceFactory.factory({
130
+ searchIn,
131
+ data,
132
+ type: 'memory',
133
+ loadAll: true,
134
+ });
135
+ datasource.initialize();
136
+
137
+ return datasource.setSearch(search);
138
+ }
139
+
140
+ get grouped() {
141
+ return this.groupedValue;
142
+ }
143
+
144
+ set grouped(value: boolean) {
145
+ const changed = value !== this.groupedValue;
146
+ this.groupedValue = value;
147
+ if (changed) {
148
+ this.changeGrouping();
149
+ }
150
+ }
151
+
152
+ get aggregation() {
153
+ return this.aggregationValue;
154
+ }
155
+
156
+ set aggregation(value: ITekGridColumnAggregation) {
157
+ const changed = value !== this.aggregationValue;
158
+ this.aggregationValue = value;
159
+ if (changed) {
160
+ this.changeGrouping();
161
+ }
162
+ }
163
+
164
+ get groupOpened() {
165
+ return this.groupOpenedValue;
166
+ }
167
+
168
+ set groupOpened(value: boolean | undefined) {
169
+ const changed = value !== this.groupOpenedValue;
170
+ this.groupOpenedValue = value;
171
+ if (changed) {
172
+ this.changeGrouping();
173
+ }
174
+ }
175
+
176
+ /* istanbul ignore next */
177
+ // @ts-ignore
178
+ get isVisible() {
179
+ return this.isVisibleValue && !this.grouped;
180
+ }
181
+
182
+ /* istanbul ignore next */
183
+ set isVisible(value: boolean) {
184
+ this.isVisibleValue = value;
185
+ }
186
+
187
+ private changeGrouping() {
188
+ // wait for grid.constructor to be fully executed
189
+ setTimeout(() => {
190
+ this.grid.updateGrouping();
191
+ });
192
+ }
193
+ }
@@ -0,0 +1,28 @@
1
+ import { IEventParam } from '@zeedhi/core';
2
+ import { Checkbox, IterableColumnsButtonController } from '@zeedhi/common';
3
+ import { TekGridColumn } from '../tek-grid-column';
4
+
5
+ export class TekGridColumnsButtonController extends IterableColumnsButtonController {
6
+ public changeGroupedColumn(column: TekGridColumn, { component, event, element }: IEventParam<Checkbox>) {
7
+ column.grouped = component.value;
8
+ if (!column.grouped) {
9
+ const index = this.iterableComponent.datasource.order.indexOf(`${column.name}.asc`);
10
+ this.iterableComponent.datasource.order.splice(index, 1);
11
+ }
12
+ this.iterableComponent.changeLayout(event, element);
13
+ }
14
+
15
+ public changeAggregationColumn(column: TekGridColumn, { component, event, element }: IEventParam<Checkbox>) {
16
+ const newValue = component.value || undefined;
17
+ if (column.aggregation !== newValue) {
18
+ this.iterableComponent.changeLayout(event, element);
19
+ }
20
+ column.aggregation = newValue;
21
+ }
22
+
23
+ public showHideTekColumn(column: TekGridColumn, { component, event, element }: IEventParam<Checkbox>) {
24
+ if (!component.value && column.grouped) column.grouped = false;
25
+ column.isVisible = component.value;
26
+ this.iterableComponent.changeLayout(event, element);
27
+ }
28
+ }
@@ -0,0 +1,38 @@
1
+ import { I18n, Loader } from '@zeedhi/core';
2
+ import { IterableColumnsButton } from '@zeedhi/common';
3
+ import { TekGridColumn } from '../tek-grid-column';
4
+ import { ITekGridColumnsButton, columnAggregationValues } from '../interfaces';
5
+ import { TekGridColumnsButtonController } from './tek-grid-columns-button-controller';
6
+
7
+ /**
8
+ * Base class for TekGrid Columns Button component
9
+ */
10
+ export class TekGridColumnsButton extends IterableColumnsButton<TekGridColumn> implements ITekGridColumnsButton {
11
+ public hideGroups = false;
12
+
13
+ constructor(props: ITekGridColumnsButton) {
14
+ super(props);
15
+ this.hideGroups = this.getInitValue('hideGroups', props.hideGroups, this.hideGroups);
16
+ this.createAccessors();
17
+ }
18
+
19
+ public onCreated() {
20
+ super.onCreated();
21
+ Loader.addController(`IterableColumnsButtonController_${this.name}`, TekGridColumnsButtonController, [
22
+ this.iterableComponent,
23
+ ]);
24
+ this.controller = Loader.getInstance(`IterableColumnsButtonController_${this.name}`);
25
+ }
26
+
27
+ private aggregationDataSet: any[] = [];
28
+
29
+ public getAggregationSelectData() {
30
+ if (!this.aggregationDataSet.length) {
31
+ this.aggregationDataSet = columnAggregationValues.filter(Boolean).map((value) => ({
32
+ text: I18n.translate(`TEKGRID_AGGREGATION_${value}`),
33
+ value,
34
+ }));
35
+ }
36
+ return this.aggregationDataSet;
37
+ }
38
+ }
@@ -0,0 +1,140 @@
1
+ import { IGridEditable } from '@zeedhi/common';
2
+ import { ISupportsToolbar } from './interfaces';
3
+
4
+ export class TekGridController {
5
+ private grid!: IGridEditable & ISupportsToolbar;
6
+
7
+ public openToolbar = true;
8
+
9
+ public constructor(grid: IGridEditable & ISupportsToolbar) {
10
+ this.grid = grid;
11
+ this.openToolbar = this.grid.toolbarOpened;
12
+ }
13
+
14
+ public get gridTitle() {
15
+ return this.grid.title;
16
+ }
17
+
18
+ public get showAddButton() {
19
+ return this.grid.addButton;
20
+ }
21
+
22
+ public get showDeleteButton() {
23
+ return this.grid.deleteButton !== 'none';
24
+ }
25
+
26
+ public get showFilterButton() {
27
+ return this.grid.filterButton;
28
+ }
29
+
30
+ public get showModalFilterProps() {
31
+ return this.grid.modalFilterProps;
32
+ }
33
+
34
+ public get showSearchInput() {
35
+ return this.grid.showSearch;
36
+ }
37
+
38
+ public get showToolbar() {
39
+ return this.openToolbar;
40
+ }
41
+
42
+ public set showToolbar(value: boolean) {
43
+ this.openToolbar = value;
44
+ }
45
+
46
+ public get toolbarClass(): string {
47
+ return !this.openToolbar ? 'is-rotated' : '';
48
+ }
49
+
50
+ public get tooltipName() {
51
+ return !this.openToolbar ? 'TEKGRID_SHOW' : 'TEKGRID_HIDE';
52
+ }
53
+
54
+ public get showReloadButton() {
55
+ return this.grid.showReload;
56
+ }
57
+
58
+ public get showDivider2() {
59
+ return (
60
+ this.showReloadButton &&
61
+ (this.showLayoutOptionsButton ||
62
+ this.showColumnsButton ||
63
+ this.showActionsButton ||
64
+ this.showExportButton ||
65
+ this.showSearchInput)
66
+ );
67
+ }
68
+
69
+ public get showColumnsButton() {
70
+ return this.grid.columnsButton;
71
+ }
72
+
73
+ public get columnsButtonIgnore() {
74
+ return this.grid.columnsButtonIgnore;
75
+ }
76
+
77
+ public get showLayoutOptionsButton() {
78
+ return this.grid.showLayoutOptions;
79
+ }
80
+
81
+ public get showDivider1() {
82
+ return (
83
+ (this.showAddButton || this.showDeleteButton) &&
84
+ (this.showReloadButton ||
85
+ this.showLayoutOptionsButton ||
86
+ this.showColumnsButton ||
87
+ this.showActionsButton ||
88
+ this.showExportButton ||
89
+ this.showSearchInput)
90
+ );
91
+ }
92
+
93
+ public get showActionsButton() {
94
+ return this.grid.actions.length > 0;
95
+ }
96
+
97
+ public get showExportButton() {
98
+ return this.grid.showExport;
99
+ }
100
+
101
+ public get showActionAndExportButton() {
102
+ return (
103
+ (this.showLayoutOptionsButton || this.showColumnsButton) &&
104
+ (this.showActionsButton || this.showExportButton || this.showSearchInput)
105
+ );
106
+ }
107
+
108
+ public get showDivider3() {
109
+ return (this.showActionsButton || this.showExportButton) && this.showSearchInput;
110
+ }
111
+
112
+ public get isEditing() {
113
+ return this.grid.editing;
114
+ }
115
+
116
+ public get showEditButtons() {
117
+ return this.isEditing && this.grid.showEditButtons;
118
+ }
119
+
120
+ public get isNotEditing() {
121
+ return !this.isEditing;
122
+ }
123
+
124
+ public get disableDeleteButton() {
125
+ if (this.grid.deleteButton === 'selection') {
126
+ if (this.grid.selectAllPages) {
127
+ const { allSelected, except } = this.grid.selectionState;
128
+ return (allSelected && except.length === this.grid.datasource.total) || (!allSelected && except.length === 0);
129
+ }
130
+
131
+ return this.grid.selectedRows.length === 0;
132
+ }
133
+
134
+ if (this.grid.deleteButton === 'currentRow') {
135
+ return !this.grid.datasource.currentRow[this.grid.datasource.uniqueKey];
136
+ }
137
+
138
+ return false;
139
+ }
140
+ }
@@ -0,0 +1,105 @@
1
+ import { IDictionary } from '@zeedhi/core';
2
+ import { GridEditableEvents } from '@zeedhi/common';
3
+ import { ITekGrid, ITekGridEvents, ITekGridSummary } from './interfaces';
4
+ import { TekGridColumn } from './tek-grid-column';
5
+
6
+ export class TekGridEvents extends GridEditableEvents implements ITekGridEvents {
7
+ protected tekGrid: ITekGrid;
8
+
9
+ /**
10
+ * Flag to prevent row click
11
+ */
12
+ protected preventRowClick = false;
13
+
14
+ protected preventRowDoubleClick = false;
15
+
16
+ constructor(tekGrid: ITekGrid) {
17
+ super(tekGrid);
18
+ this.tekGrid = tekGrid;
19
+ }
20
+
21
+ calcSummary(column: TekGridColumn, summary: ITekGridSummary, row: IDictionary): void {
22
+ this.tekGrid.callEvent('calcSummary', {
23
+ component: this.tekGrid,
24
+ column,
25
+ columnName: column.name,
26
+ summary,
27
+ row,
28
+ rowValue: row[column.name],
29
+ });
30
+ }
31
+
32
+ public rowDoubleClick(row: IDictionary<any>, event: Event, element: HTMLElement) {
33
+ if (!this.preventRowDoubleClick) {
34
+ this.tekGrid.datasource.currentRow = row;
35
+
36
+ this.tekGrid.callEvent('rowDoubleClick', {
37
+ event,
38
+ element,
39
+ row,
40
+ component: this.tekGrid,
41
+ column: undefined,
42
+ });
43
+ }
44
+ this.preventRowDoubleClick = false;
45
+ }
46
+
47
+ /**
48
+ * Dispatches group row click event
49
+ * @param row Grid row
50
+ * @param event DOM event
51
+ * @param element DOM Element
52
+ */
53
+ public groupRowClick(row: IDictionary<any>, event: Event, element: HTMLElement) {
54
+ if (!this.preventRowClick) {
55
+ this.tekGrid.callEvent('groupRowClick', {
56
+ event,
57
+ element,
58
+ row,
59
+ component: this.tekGrid,
60
+ column: undefined,
61
+ });
62
+ }
63
+ this.preventRowClick = false;
64
+ }
65
+
66
+ public groupRowDoubleClick(row: IDictionary<any>, event: Event, element: HTMLElement) {
67
+ if (!this.preventRowDoubleClick) {
68
+ this.tekGrid.callEvent('groupRowDoubleClick', {
69
+ event,
70
+ element,
71
+ row,
72
+ component: this.tekGrid,
73
+ column: undefined,
74
+ });
75
+ }
76
+ this.preventRowDoubleClick = false;
77
+ }
78
+
79
+ /**
80
+ * Dispatches group select/unselect event
81
+ * @param row Group row
82
+ * @param isSelected Row is selected
83
+ * @param event DOM event
84
+ * @param element DOM Element
85
+ */
86
+ public selectGroupClick(row: IDictionary<any>, isSelected: boolean, event: Event, element: HTMLElement) {
87
+ if (isSelected) {
88
+ this.tekGrid.callEvent('groupSelected', {
89
+ event,
90
+ element,
91
+ row,
92
+ component: this.tekGrid,
93
+ column: undefined,
94
+ });
95
+ } else {
96
+ this.tekGrid.callEvent('groupUnselected', {
97
+ event,
98
+ element,
99
+ row,
100
+ component: this.tekGrid,
101
+ column: undefined,
102
+ });
103
+ }
104
+ }
105
+ }
@@ -0,0 +1,26 @@
1
+ import { IComponent } from '@zeedhi/common';
2
+ import { IExportable, ITekGridExportConfig } from '../../interfaces';
3
+ import { IExportOption } from './interfaces';
4
+
5
+ export class ButtonOption implements IExportOption {
6
+ private config: ITekGridExportConfig;
7
+
8
+ constructor(config: ITekGridExportConfig) {
9
+ this.config = config;
10
+ }
11
+
12
+ buildComponent(grid: IComponent & IExportable) {
13
+ const { type, label, portrait = true, iconName } = this.config;
14
+ const orientation = portrait ? 'portrait' : 'landscape';
15
+ return {
16
+ label,
17
+ iconName,
18
+ name: `${grid.name}_export_${type}_${orientation}`,
19
+ component: 'ZdButton',
20
+ flat: true,
21
+ events: {
22
+ click: () => grid.getReport(type, portrait) as any,
23
+ },
24
+ };
25
+ }
26
+ }
@@ -0,0 +1,3 @@
1
+ export * from './button-option';
2
+ export * from './multi-option';
3
+ export * from './interfaces';
@@ -0,0 +1,6 @@
1
+ import { IComponent, IComponentRender } from '@zeedhi/common';
2
+ import { IExportable } from '../../interfaces';
3
+
4
+ export interface IExportOption {
5
+ buildComponent: (grid: IComponent & IExportable) => IComponentRender;
6
+ }
@@ -0,0 +1,85 @@
1
+ import { IButton, IComponent, IDivider, IRow, IText, ITooltip } from '@zeedhi/common';
2
+ import { IExportable, ITekGridExportConfig, MultiOptionParams } from '../../interfaces';
3
+ import { IExportOption } from './interfaces';
4
+
5
+ export class MultiOption implements IExportOption {
6
+ private config: ITekGridExportConfig;
7
+
8
+ constructor(config: ITekGridExportConfig) {
9
+ this.config = config;
10
+ }
11
+
12
+ private formatName(id: string, type: string, grid: IComponent & IExportable) {
13
+ return `${grid.name}_export_${type}_${id}`;
14
+ }
15
+
16
+ private buildTooltip(option: MultiOptionParams, type: string, grid: IComponent & IExportable): ITooltip {
17
+ const { label } = option;
18
+ return {
19
+ name: this.formatName(`tooltip_${label}`, type, grid),
20
+ component: 'ZdTooltip',
21
+ bottom: true,
22
+ label,
23
+ children: [],
24
+ };
25
+ }
26
+
27
+ private buildButton(option: MultiOptionParams, type: string, grid: IComponent & IExportable): IButton {
28
+ const { cssClass, label, iconName, reportParams } = option;
29
+ const { portrait: optionPortrait, rowObj } = reportParams || {};
30
+
31
+ return {
32
+ name: this.formatName(`button_${label}`, type, grid),
33
+ component: 'ZdButton',
34
+ cssClass,
35
+ icon: true,
36
+ iconName,
37
+ events: {
38
+ click: () => grid.getReport(type, optionPortrait, rowObj) as any,
39
+ },
40
+ };
41
+ }
42
+
43
+ private buildDivider(option: MultiOptionParams, type: string, grid: IComponent & IExportable): IDivider {
44
+ const { label } = option;
45
+
46
+ return {
47
+ name: this.formatName(`divider_${label}`, type, grid),
48
+ component: 'ZdDivider',
49
+ cssClass: 'zd-my-1',
50
+ vertical: true,
51
+ };
52
+ }
53
+
54
+ buildComponent(grid: IComponent & IExportable) {
55
+ const { type, label, multiOption } = this.config;
56
+
57
+ const optionComponents = multiOption!.flatMap((option) => [
58
+ {
59
+ ...this.buildTooltip(option, type, grid),
60
+ children: [this.buildButton(option, type, grid)],
61
+ },
62
+ this.buildDivider(option, type, grid),
63
+ ]);
64
+
65
+ optionComponents.pop();
66
+
67
+ const text: IText = {
68
+ name: this.formatName('text', type, grid),
69
+ component: 'ZdText',
70
+ cssClass: 'zd-display-flex zd-align-center zd-flex-grow-1 tek-grid-export-multioption-text',
71
+ events: {
72
+ click: ({ event }) => event?.stopPropagation(),
73
+ },
74
+ text: label || '',
75
+ };
76
+ const result: IRow = {
77
+ name: this.formatName('row', type, grid),
78
+ component: 'ZdRow',
79
+ cssClass: 'zd-display-flex zd-ma-0 zd-py-0 zd-gap-x-1 tek-grid-export-multioption-row',
80
+ children: [text, ...optionComponents],
81
+ };
82
+
83
+ return result;
84
+ }
85
+ }
@@ -0,0 +1,2 @@
1
+ export * from './export-options';
2
+ export * from './tek-grid-toolbar-provider';