@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,3802 @@
1
+ import { DatasourceFactory, MemoryDatasource, URL, Utils, RestDatasource, Metadata, DateHelper, I18n, Messages, Config, Accessor, Loader, Http } from '@zeedhi/core';
2
+ import { ComponentRender, GridColumnEditable, Button, ModalService, NonInitializedError, ViewNavigator, GridEditableEvents, DataSelector, Iterable, TableActionBuilder, IterableTable, DataNavigator, DataEditorWithAdd, KeyMapMerger, KeyMapNavigation, KeyMapEditing, IterableColumnsButtonController, IterableColumnsButton, List } from '@zeedhi/common';
3
+ import debounce from 'lodash.debounce';
4
+ import clonedeep from 'lodash.clonedeep';
5
+ import { UserInfo } from '@zeedhi/zd-user-info-common';
6
+
7
+ /**
8
+ * BreadcrumbHeader join breadcrumb and title
9
+ */
10
+ class BreadcrumbHeader extends ComponentRender {
11
+ breadcrumb;
12
+ title = '';
13
+ rightSlot = [];
14
+ constructor(props) {
15
+ super(props);
16
+ this.breadcrumb = this.getBreadcrumbProperties(props.breadcrumb);
17
+ this.title = this.getInitValue('title', props.title, this.title);
18
+ this.rightSlot = props.rightSlot || this.rightSlot;
19
+ }
20
+ getBreadcrumbProperties(breadcrumb) {
21
+ return {
22
+ ...breadcrumb,
23
+ name: breadcrumb.name,
24
+ component: 'ZdBreadcrumb',
25
+ divider: '>',
26
+ };
27
+ }
28
+ }
29
+
30
+ const DynamicFilterOperations = {
31
+ CONTAINS: true,
32
+ NOT_CONTAINS: true,
33
+ EQUALS: true,
34
+ NOT_EQUALS: true,
35
+ GREATER_THAN: true,
36
+ LESS_THAN: true,
37
+ GREATER_THAN_EQUALS: true,
38
+ LESS_THAN_EQUALS: true,
39
+ IN: true,
40
+ NOT_IN: true,
41
+ BETWEEN: true,
42
+ };
43
+ const DynamicFilterRelations = {
44
+ AND: true,
45
+ OR: true,
46
+ };
47
+
48
+ class TekMemoryDatasource extends MemoryDatasource {
49
+ /** Dynamic filter data */
50
+ dynamicFilter;
51
+ /** Search Join data */
52
+ searchJoin;
53
+ /**
54
+ * Dynamic Filter Operations
55
+ */
56
+ dynamicFilterOperations = DynamicFilterOperations;
57
+ /**
58
+ * Dynamic Filter Relations
59
+ */
60
+ dynamicFilterRelations = DynamicFilterRelations;
61
+ /**
62
+ * Dynamic Filter applied flag
63
+ */
64
+ dynamicFilterApplied = '';
65
+ /**
66
+ * Create new datasource
67
+ * @param props Datasource properties
68
+ */
69
+ constructor(props) {
70
+ super(props);
71
+ if (!this.watchUrl) {
72
+ this.dynamicFilter = this.getInitValue('dynamicFilter', props.dynamicFilter, {});
73
+ this.searchJoin = this.getInitValue('searchJoin', props.searchJoin, {});
74
+ }
75
+ this.createAccessors();
76
+ this.createObjAccessors(this.dynamicFilter, 'dynamicFilter');
77
+ this.createObjAccessors(this.searchJoin, 'searchJoin');
78
+ }
79
+ updateReservedKeys() {
80
+ this.reservedKeys.dynamic_filter = true;
81
+ this.reservedKeys.search_join = true;
82
+ }
83
+ updateInternalProperties(datasource = {}) {
84
+ if (!this.watchUrl)
85
+ return;
86
+ this.updateReservedKeys();
87
+ super.updateInternalProperties(datasource);
88
+ const queryString = URL.getParsedQueryStringFromUrl();
89
+ this.dynamicFilter = this.getEncodedParam(queryString.dynamic_filter, datasource.dynamicFilter);
90
+ this.searchJoin = this.getEncodedParam(queryString.search_join, datasource.searchJoin);
91
+ }
92
+ getEncodedParam(urlParam, datasourceParam = {}) {
93
+ return urlParam ? JSON.parse(atob(urlParam)) : datasourceParam;
94
+ }
95
+ getQueryStringValues() {
96
+ const values = super.getQueryStringValues();
97
+ if (this.dynamicFilter && Object.keys(this.dynamicFilter).length) {
98
+ values.dynamic_filter = btoa(JSON.stringify(this.dynamicFilter));
99
+ }
100
+ if (this.searchJoin && Object.keys(this.searchJoin).length) {
101
+ values.search_join = btoa(JSON.stringify(this.searchJoin));
102
+ }
103
+ return values;
104
+ }
105
+ getUrlQueryString() {
106
+ const superQueryString = super.getUrlQueryString();
107
+ const query = URL.getParsedQueryStringFromUrl();
108
+ let dynamicFilterQuerystring = '';
109
+ if (query.dynamic_filter) {
110
+ dynamicFilterQuerystring = `&${URL.getFormattedQueryString({
111
+ dynamic_filter: query.dynamic_filter,
112
+ })}`;
113
+ }
114
+ let searchJoinQuerystring = '';
115
+ if (query.search_join) {
116
+ searchJoinQuerystring = `&${URL.getFormattedQueryString({
117
+ search_join: query.search_join,
118
+ })}`;
119
+ }
120
+ return superQueryString + dynamicFilterQuerystring + searchJoinQuerystring;
121
+ }
122
+ /**
123
+ * Adds a new dynamic filter position or replace if exists
124
+ * @param column Dynamic Filter column name
125
+ * @param value Dynamic Filter value
126
+ * @returns Promise with data collection
127
+ */
128
+ addDynamicFilter(column, value) {
129
+ if (this.isValidDynamicFilterValue(column, value)) {
130
+ this.dynamicFilter[column] = value;
131
+ return this.updateDynamicFilter();
132
+ }
133
+ return this.removeDynamicFilter(column);
134
+ }
135
+ /**
136
+ * Removes a dynamic filter position
137
+ * @param column Dynamic Filter column name
138
+ * @returns Promise with data collection
139
+ */
140
+ removeDynamicFilter(column) {
141
+ delete this.dynamicFilter[column];
142
+ return this.updateDynamicFilter();
143
+ }
144
+ /**
145
+ * Sets new dynamic filter value
146
+ * @param filter Dynamic Filter value
147
+ * @returns Promise with data collection
148
+ */
149
+ setDynamicFilter(filter) {
150
+ this.dynamicFilter = {};
151
+ Object.keys(filter).forEach((column) => {
152
+ if (this.isValidDynamicFilterValue(column, filter[column])) {
153
+ this.dynamicFilter[column] = filter[column];
154
+ }
155
+ else {
156
+ delete this.dynamicFilter[column];
157
+ }
158
+ });
159
+ return this.updateDynamicFilter();
160
+ }
161
+ /**
162
+ * Clears Dynamic filter value
163
+ * @returns Promise with data collection
164
+ */
165
+ clearDynamicFilter() {
166
+ this.dynamicFilter = {};
167
+ return this.updateDynamicFilter();
168
+ }
169
+ /**
170
+ * Resets page and selected rows and tries to update the url
171
+ * @returns Promise with data collection
172
+ */
173
+ async updateDynamicFilter() {
174
+ this.page = this.firstPage;
175
+ this.selectedRows = [];
176
+ this.visibleSelectedRows = [];
177
+ if (this.watchUrl) {
178
+ if (this.dynamicFilter && Object.keys(this.dynamicFilter).length) {
179
+ URL.updateQueryString({
180
+ dynamic_filter: btoa(JSON.stringify(this.dynamicFilter)),
181
+ });
182
+ }
183
+ else {
184
+ URL.updateQueryString({
185
+ dynamic_filter: undefined,
186
+ });
187
+ }
188
+ }
189
+ return this.get();
190
+ }
191
+ /**
192
+ * Checks if a filter value is valid
193
+ * @param value Filter value
194
+ * @returns Is valid filter value
195
+ */
196
+ isValidDynamicFilterValue(column, value) {
197
+ return (!this.reservedKeys[column] &&
198
+ value &&
199
+ value.length > 0 &&
200
+ value.every((filterValue) => this.dynamicFilterOperations[filterValue.operation] &&
201
+ this.dynamicFilterRelations[filterValue.relation] &&
202
+ filterValue.value !== '' &&
203
+ filterValue.value !== null));
204
+ }
205
+ clone() {
206
+ return {
207
+ ...super.clone(),
208
+ dynamicFilter: this.dynamicFilter,
209
+ searchJoin: this.searchJoin,
210
+ type: 'tek-memory',
211
+ };
212
+ }
213
+ /**
214
+ * Updates filtered data
215
+ */
216
+ updateFilteredData() {
217
+ // first apply filters (simple and dynamic)
218
+ this.filteredData = Object.keys(this.filter).length
219
+ ? this.allData.filter((row) => this.getRowByFilter(row))
220
+ : Array.from(this.allData);
221
+ if (this.dynamicFilter && Object.keys(this.dynamicFilter).length) {
222
+ this.filteredData = this.filteredData.filter((row) => this.getRowByDynamicFilter(row));
223
+ }
224
+ const searchWithoutSearchJoin = (row) => {
225
+ const searchRow = { ...row };
226
+ if (this.searchJoin) {
227
+ // do not search on columns with searchJoin
228
+ Object.keys(this.searchJoin).forEach((key) => delete searchRow[key]);
229
+ }
230
+ return this.getRowBySearch(searchRow);
231
+ };
232
+ // only after do the search
233
+ const searchData = this.search ? this.filteredData.filter(searchWithoutSearchJoin) : this.filteredData;
234
+ let searchIds = searchData.map((row) => row[this.uniqueKey]);
235
+ if (this.searchJoin && Object.keys(this.searchJoin).length) {
236
+ const searchJoinData = this.filteredData.filter((row) => this.getRowBySearchJoin(row));
237
+ // get the ids from search and searchJoin
238
+ searchIds = searchIds.concat(searchJoinData.map((row) => row[this.uniqueKey])).sort();
239
+ }
240
+ // filter filteredData using searchIds
241
+ this.filteredData = this.allData.filter((row) => searchIds.indexOf(row[this.uniqueKey]) !== -1);
242
+ }
243
+ getRowByDynamicFilter(row) {
244
+ let filtered;
245
+ try {
246
+ Object.keys(this.dynamicFilter).forEach((key) => {
247
+ const filterItems = this.dynamicFilter[key];
248
+ filterItems.forEach((item) => {
249
+ if (filtered === false && item.relation === 'AND')
250
+ return;
251
+ if (filtered === true && item.relation === 'OR')
252
+ return;
253
+ const columnValue = Utils.normalize(row[key].toString());
254
+ let value = '';
255
+ if (Array.isArray(item.value)) {
256
+ value = item.value.map((val) => Utils.normalize(val.toString()));
257
+ switch (item.operation) {
258
+ case 'IN':
259
+ filtered = value.includes(columnValue);
260
+ break;
261
+ case 'NOT_IN':
262
+ filtered = !value.includes(columnValue);
263
+ break;
264
+ case 'BETWEEN':
265
+ filtered =
266
+ (Number(columnValue) || columnValue) >= (Number(value[0]) || value[0]) &&
267
+ (Number(columnValue) || columnValue) <= (Number(value[1]) || value[1]);
268
+ break;
269
+ default:
270
+ break;
271
+ }
272
+ }
273
+ else {
274
+ value = Utils.normalize(item.value.toString());
275
+ switch (item.operation) {
276
+ case 'CONTAINS':
277
+ filtered = columnValue.indexOf(value) !== -1;
278
+ break;
279
+ case 'NOT_CONTAINS':
280
+ filtered = columnValue.indexOf(value) === -1;
281
+ break;
282
+ case 'EQUALS':
283
+ filtered = columnValue === value;
284
+ break;
285
+ case 'NOT_EQUALS':
286
+ filtered = columnValue !== value;
287
+ break;
288
+ case 'GREATER_THAN':
289
+ filtered = (Number(columnValue) || columnValue) > (Number(value) || value);
290
+ break;
291
+ case 'LESS_THAN':
292
+ filtered = (Number(columnValue) || columnValue) < (Number(value) || value);
293
+ break;
294
+ case 'GREATER_THAN_EQUALS':
295
+ filtered = (Number(columnValue) || columnValue) >= (Number(value) || value);
296
+ break;
297
+ case 'LESS_THAN_EQUALS':
298
+ filtered = (Number(columnValue) || columnValue) <= (Number(value) || value);
299
+ break;
300
+ default:
301
+ break;
302
+ }
303
+ }
304
+ });
305
+ });
306
+ }
307
+ catch {
308
+ // do nothing
309
+ }
310
+ return filtered;
311
+ }
312
+ getRowBySearchJoin(row) {
313
+ return Object.keys(this.searchJoin).some((key) => this.searchJoin[key].includes(row[key]));
314
+ }
315
+ hasFilter(columnName) {
316
+ return this.dynamicFilter[columnName] && this.dynamicFilter[columnName].length > 0;
317
+ }
318
+ }
319
+ DatasourceFactory.register('tek-memory', TekMemoryDatasource);
320
+
321
+ class TekRestDatasource extends RestDatasource {
322
+ /** Dynamic filter data */
323
+ dynamicFilter;
324
+ /** Search Join data */
325
+ searchJoin;
326
+ /**
327
+ * Dynamic Filter Operations
328
+ */
329
+ dynamicFilterOperations = DynamicFilterOperations;
330
+ /**
331
+ * Dynamic Filter Relations
332
+ */
333
+ dynamicFilterRelations = DynamicFilterRelations;
334
+ /**
335
+ * Dynamic Filter applied flag
336
+ */
337
+ dynamicFilterApplied = '';
338
+ /**
339
+ * Create new datasource
340
+ * @param props Datasource properties
341
+ */
342
+ constructor(props) {
343
+ super({ ...props, lazyLoad: true });
344
+ if (!this.watchUrl) {
345
+ this.dynamicFilter = this.getInitValue('dynamicFilter', props.dynamicFilter, {});
346
+ this.searchJoin = this.getInitValue('searchJoin', props.searchJoin, {});
347
+ }
348
+ this.lazyLoad = this.getInitValue('lazyLoad', props.lazyLoad, this.lazyLoad);
349
+ this.createAccessors();
350
+ this.createObjAccessors(this.dynamicFilter, 'dynamicFilter');
351
+ this.createObjAccessors(this.searchJoin, 'searchJoin');
352
+ }
353
+ updateReservedKeys() {
354
+ this.reservedKeys.dynamic_filter = true;
355
+ this.reservedKeys.search_join = true;
356
+ }
357
+ updateInternalProperties(datasource = {}) {
358
+ if (!this.watchUrl)
359
+ return;
360
+ this.updateReservedKeys();
361
+ super.updateInternalProperties(datasource);
362
+ const queryString = URL.getParsedQueryStringFromUrl();
363
+ this.dynamicFilter = this.getEncodedParam(queryString.dynamic_filter, datasource.dynamicFilter);
364
+ this.searchJoin = this.getEncodedParam(queryString.search_join, datasource.searchJoin);
365
+ }
366
+ getEncodedParam(urlParam, datasourceParam = {}) {
367
+ return urlParam ? JSON.parse(atob(urlParam)) : datasourceParam;
368
+ }
369
+ getQueryStringValues() {
370
+ const values = super.getQueryStringValues();
371
+ if (this.dynamicFilter && Object.keys(this.dynamicFilter).length) {
372
+ values.dynamic_filter = btoa(JSON.stringify(this.dynamicFilter));
373
+ }
374
+ if (this.searchJoin && Object.keys(this.searchJoin).length) {
375
+ values.search_join = btoa(JSON.stringify(this.searchJoin));
376
+ }
377
+ return values;
378
+ }
379
+ getUrlQueryString() {
380
+ const superQueryString = super.getUrlQueryString();
381
+ const query = URL.getParsedQueryStringFromUrl();
382
+ let dynamicFilterQuerystring = '';
383
+ if (query.dynamic_filter) {
384
+ dynamicFilterQuerystring = `&${URL.getFormattedQueryString({
385
+ dynamic_filter: query.dynamic_filter,
386
+ })}`;
387
+ }
388
+ let searchJoinQuerystring = '';
389
+ if (query.search_join) {
390
+ searchJoinQuerystring = `&${URL.getFormattedQueryString({
391
+ search_join: query.search_join,
392
+ })}`;
393
+ }
394
+ return superQueryString + dynamicFilterQuerystring + searchJoinQuerystring;
395
+ }
396
+ /**
397
+ * Adds a new dynamic filter position or replace if exists
398
+ * @param column Dynamic Filter column name
399
+ * @param value Dynamic Filter value
400
+ * @returns Promise with data collection
401
+ */
402
+ addDynamicFilter(column, value) {
403
+ if (this.isValidDynamicFilterValue(column, value)) {
404
+ this.dynamicFilter[column] = value;
405
+ return this.updateDynamicFilter();
406
+ }
407
+ return this.removeDynamicFilter(column);
408
+ }
409
+ /**
410
+ * Removes a dynamic filter position
411
+ * @param column Dynamic Filter column name
412
+ * @returns Promise with data collection
413
+ */
414
+ removeDynamicFilter(column) {
415
+ delete this.dynamicFilter[column];
416
+ return this.updateDynamicFilter();
417
+ }
418
+ /**
419
+ * Sets new dynamic filter value
420
+ * @param filter Dynamic Filter value
421
+ * @returns Promise with data collection
422
+ */
423
+ setDynamicFilter(filter) {
424
+ this.dynamicFilter = {};
425
+ Object.keys(filter).forEach((column) => {
426
+ if (this.isValidDynamicFilterValue(column, filter[column])) {
427
+ this.dynamicFilter[column] = filter[column];
428
+ }
429
+ else {
430
+ delete this.dynamicFilter[column];
431
+ }
432
+ });
433
+ return this.updateDynamicFilter();
434
+ }
435
+ /**
436
+ * Clears Dynamic filter value
437
+ * @returns Promise with data collection
438
+ */
439
+ clearDynamicFilter() {
440
+ this.dynamicFilter = {};
441
+ return this.updateDynamicFilter();
442
+ }
443
+ /**
444
+ * Resets page and selected rows and tries to update the url
445
+ * @returns Promise with data collection
446
+ */
447
+ async updateDynamicFilter() {
448
+ this.page = this.firstPage;
449
+ this.selectedRows = [];
450
+ this.visibleSelectedRows = [];
451
+ if (this.watchUrl) {
452
+ if (this.dynamicFilter && Object.keys(this.dynamicFilter).length) {
453
+ URL.updateQueryString({
454
+ dynamic_filter: btoa(JSON.stringify(this.dynamicFilter)),
455
+ });
456
+ }
457
+ else {
458
+ URL.updateQueryString({
459
+ dynamic_filter: undefined,
460
+ });
461
+ }
462
+ }
463
+ return this.get();
464
+ }
465
+ /**
466
+ * Checks if a filter value is valid
467
+ * @param value Filter value
468
+ * @returns Is valid filter value
469
+ */
470
+ isValidDynamicFilterValue(column, value) {
471
+ return (!this.reservedKeys[column] &&
472
+ value &&
473
+ value.length > 0 &&
474
+ value.every((filterValue) => this.dynamicFilterOperations[filterValue.operation] &&
475
+ this.dynamicFilterRelations[filterValue.relation] &&
476
+ filterValue.value !== '' &&
477
+ filterValue.value !== null));
478
+ }
479
+ /**
480
+ * Retrieves request params
481
+ */
482
+ getRequestParams() {
483
+ const requestParams = super.getRequestParams();
484
+ const isNotEmptyObj = (obj) => !!(obj && Object.keys(obj).length);
485
+ const isValid = this.dynamicFilter &&
486
+ Object.keys(this.dynamicFilter).every((column) => {
487
+ const value = this.dynamicFilter[column];
488
+ return value && value.length > 0 && this.isValidDynamicFilterValue(column, value);
489
+ });
490
+ if (isNotEmptyObj(this.dynamicFilter) && isValid) {
491
+ requestParams.dynamic_filter = btoa(JSON.stringify(this.dynamicFilter));
492
+ }
493
+ if (isNotEmptyObj(this.searchJoin)) {
494
+ requestParams.search_join = btoa(JSON.stringify(this.searchJoin));
495
+ }
496
+ return requestParams;
497
+ }
498
+ hasFilter(columnName) {
499
+ return this.dynamicFilter[columnName] && this.dynamicFilter[columnName].length > 0;
500
+ }
501
+ clone() {
502
+ return {
503
+ ...super.clone(),
504
+ dynamicFilter: this.dynamicFilter,
505
+ searchJoin: this.searchJoin,
506
+ type: 'tek-rest',
507
+ };
508
+ }
509
+ }
510
+ DatasourceFactory.register('tek-rest', TekRestDatasource);
511
+
512
+ class ButtonOption {
513
+ config;
514
+ constructor(config) {
515
+ this.config = config;
516
+ }
517
+ buildComponent(grid) {
518
+ const { type, label, portrait = true, iconName } = this.config;
519
+ const orientation = portrait ? 'portrait' : 'landscape';
520
+ return {
521
+ label,
522
+ iconName,
523
+ name: `${grid.name}_export_${type}_${orientation}`,
524
+ component: 'ZdButton',
525
+ flat: true,
526
+ events: {
527
+ click: () => grid.getReport(type, portrait),
528
+ },
529
+ };
530
+ }
531
+ }
532
+
533
+ class MultiOption {
534
+ config;
535
+ constructor(config) {
536
+ this.config = config;
537
+ }
538
+ formatName(id, type, grid) {
539
+ return `${grid.name}_export_${type}_${id}`;
540
+ }
541
+ buildTooltip(option, type, grid) {
542
+ const { label } = option;
543
+ return {
544
+ name: this.formatName(`tooltip_${label}`, type, grid),
545
+ component: 'ZdTooltip',
546
+ bottom: true,
547
+ label,
548
+ children: [],
549
+ };
550
+ }
551
+ buildButton(option, type, grid) {
552
+ const { cssClass, label, iconName, reportParams } = option;
553
+ const { portrait: optionPortrait, rowObj } = reportParams || {};
554
+ return {
555
+ name: this.formatName(`button_${label}`, type, grid),
556
+ component: 'ZdButton',
557
+ cssClass,
558
+ icon: true,
559
+ iconName,
560
+ events: {
561
+ click: () => grid.getReport(type, optionPortrait, rowObj),
562
+ },
563
+ };
564
+ }
565
+ buildDivider(option, type, grid) {
566
+ const { label } = option;
567
+ return {
568
+ name: this.formatName(`divider_${label}`, type, grid),
569
+ component: 'ZdDivider',
570
+ cssClass: 'zd-my-1',
571
+ vertical: true,
572
+ };
573
+ }
574
+ buildComponent(grid) {
575
+ const { type, label, multiOption } = this.config;
576
+ const optionComponents = multiOption.flatMap((option) => [
577
+ {
578
+ ...this.buildTooltip(option, type, grid),
579
+ children: [this.buildButton(option, type, grid)],
580
+ },
581
+ this.buildDivider(option, type, grid),
582
+ ]);
583
+ optionComponents.pop();
584
+ const text = {
585
+ name: this.formatName('text', type, grid),
586
+ component: 'ZdText',
587
+ cssClass: 'zd-display-flex zd-align-center zd-flex-grow-1 tek-grid-export-multioption-text',
588
+ events: {
589
+ click: ({ event }) => event?.stopPropagation(),
590
+ },
591
+ text: label || '',
592
+ };
593
+ const result = {
594
+ name: this.formatName('row', type, grid),
595
+ component: 'ZdRow',
596
+ cssClass: 'zd-display-flex zd-ma-0 zd-py-0 zd-gap-x-1 tek-grid-export-multioption-row',
597
+ children: [text, ...optionComponents],
598
+ };
599
+ return result;
600
+ }
601
+ }
602
+
603
+ /**
604
+ * Base Teknisa error
605
+ */
606
+ class TeknisaCommonError extends Error {
607
+ constructor(message) {
608
+ super(`[Teknisa Common err]: ${message}`);
609
+ }
610
+ }
611
+
612
+ /**
613
+ * TekGridDelete rows error
614
+ */
615
+ class TekGridDeleteRowsError extends TeknisaCommonError {
616
+ constructor() {
617
+ super("TekGrid can't automatically delete rows when selectAllPages property is true." +
618
+ ' You should delete them manually using the beforeDelete event and preventing' +
619
+ ' the default execution');
620
+ this.name = 'TekGridDeleteRowsError';
621
+ }
622
+ }
623
+
624
+ class TekGridToolbarProvider {
625
+ grid;
626
+ groupsVisibility;
627
+ constructor(grid, groupsVisibility) {
628
+ this.grid = grid;
629
+ this.groupsVisibility = groupsVisibility;
630
+ }
631
+ atoms = {
632
+ TITLE: '_gridTitle',
633
+ HIDE_BUTTON: '_hideButton',
634
+ ADD_BUTTON: '_addButton',
635
+ DELETE_BUTTON: '_deleteButton',
636
+ REFRESH_BUTTON: '_refreshButton',
637
+ COLUMNS_BUTTON: '_columnsButton',
638
+ LAYOUT_BUTTON: '_layout_options',
639
+ EXPORT_BUTTON: '_exportButton',
640
+ ACTIONS_BUTTON: '_actionsButton',
641
+ SAVE_BUTTON: '_saveButton',
642
+ CANCEL_BUTTON: '_cancelButton',
643
+ SEARCH: '_gridSearch',
644
+ FILTER_BUTTON: '_filterButton',
645
+ FILTER_MODAL: '-filter-modal',
646
+ FILTER_FORM: '-filter-form',
647
+ EXPORT_DROPDOWN: '_export_dropdown',
648
+ ACTIONS_DROPDOWN: '_actions_dropdown',
649
+ HIDE_TOOLTIP: '_hideTooltip',
650
+ TOOLBAR_DIV: '_toolbarDiv',
651
+ NOT_EDITING_SPAN: '_notEditingSpan',
652
+ ADD_TOOLTIP: '_add_tooltip',
653
+ DELETE_TOOLTIP: '_delete_tooltip',
654
+ DIVIDER1: '_divider1',
655
+ REFRESH_TOOLTIP: '_refresh_tooltip',
656
+ DIVIDER2: '_divider2',
657
+ COLUMNS_TOOLTIP: '_columns_button_tooltip',
658
+ DIVIDER_ACTIONS: '_dividerActions',
659
+ DIVIDER3: '_divider3',
660
+ FILTER_TOOLTIP: '_filter_tooltip',
661
+ };
662
+ getAtomName(key) {
663
+ return `${this.grid.name}${this.atoms[key]}`;
664
+ }
665
+ getAtomInstance(key) {
666
+ return Metadata.getInstance(`${this.grid.name}${this.atoms[key]}`);
667
+ }
668
+ getOption(config) {
669
+ if (config.multiOption)
670
+ return new MultiOption(config);
671
+ return new ButtonOption(config);
672
+ }
673
+ getExportConfigButtons() {
674
+ return this.grid.exportConfig.map((config) => {
675
+ const option = this.getOption(config);
676
+ return option.buildComponent(this.grid);
677
+ });
678
+ }
679
+ hideButtonClick({ event }) {
680
+ if (!event.defaultPrevented) {
681
+ const instance = Metadata.getInstance(`${this.grid.name}_toolbarDiv`);
682
+ if (instance) {
683
+ instance.isVisible = !instance.isVisible;
684
+ }
685
+ }
686
+ }
687
+ cancelChanges({ event }) {
688
+ this.grid.callEvent('beforeCancel', { component: this.grid, event });
689
+ if (!event.defaultPrevented) {
690
+ const cancel = async () => {
691
+ await this.grid.cancelEditedRows();
692
+ this.grid.editingNewRows = false;
693
+ };
694
+ cancel();
695
+ this.grid.callEvent('afterCancel', { component: this.grid });
696
+ }
697
+ }
698
+ saveChanges({ event }) {
699
+ this.grid.callEvent('beforeSave', { component: this.grid, event });
700
+ if (!event.defaultPrevented) {
701
+ const save = async () => {
702
+ await this.grid.saveEditedRows();
703
+ this.grid.editingNewRows = false;
704
+ };
705
+ save();
706
+ this.grid.callEvent('afterSave', { component: this.grid });
707
+ }
708
+ }
709
+ addButtonClick({ event }) {
710
+ if (this.grid.editNewRowsOnly) {
711
+ this.grid.editingNewRows = true;
712
+ }
713
+ this.grid.callEvent('addClick', { component: this.grid, event });
714
+ }
715
+ deleteButtonClick({ event }) {
716
+ this.grid.callEvent('beforeDelete', { component: this.grid, event });
717
+ if (!event.defaultPrevented) {
718
+ if (this.grid.selectAllPages) {
719
+ throw new TekGridDeleteRowsError();
720
+ }
721
+ this.grid.deleteRows();
722
+ this.grid.callEvent('afterDelete', { component: this.grid });
723
+ }
724
+ }
725
+ reloadGrid({ event }) {
726
+ this.grid.callEvent('beforeReload', { component: this.grid, event });
727
+ if (event?.defaultPrevented)
728
+ return;
729
+ this.grid.reload();
730
+ }
731
+ getProperties() {
732
+ const exportConfigButtons = this.getExportConfigButtons();
733
+ return [
734
+ {
735
+ name: this.getAtomName('TITLE'),
736
+ component: 'ZdText',
737
+ cssClass: 'toolbar-title',
738
+ tag: 'h2',
739
+ text: this.grid.title,
740
+ title: this.grid.title,
741
+ },
742
+ {
743
+ name: `${this.grid.name}_spacer`,
744
+ component: 'VSpacer',
745
+ },
746
+ {
747
+ name: this.getAtomName('HIDE_TOOLTIP'),
748
+ component: 'ZdTooltip',
749
+ label: `{{GridController_${this.grid.name}.tooltipName}}`,
750
+ bottom: true,
751
+ children: [
752
+ {
753
+ name: this.getAtomName('HIDE_BUTTON'),
754
+ component: 'ZdButton',
755
+ flat: true,
756
+ icon: true,
757
+ iconName: 'mdi-chevron-right',
758
+ color: 'grey',
759
+ isVisible: `{{GridController_${this.grid.name}.isNotEditing}}`,
760
+ cssClass: `{{GridController_${this.grid.name}.toolbarClass}}`,
761
+ events: {
762
+ click: this.hideButtonClick.bind(this),
763
+ },
764
+ },
765
+ ],
766
+ },
767
+ {
768
+ name: this.getAtomName('TOOLBAR_DIV'),
769
+ component: 'ZdTag',
770
+ tag: 'div',
771
+ cssStyle: 'display: flex; align-items: center',
772
+ isVisible: `{{GridController_${this.grid.name}.showToolbar}}`,
773
+ children: [
774
+ {
775
+ name: this.getAtomName('NOT_EDITING_SPAN'),
776
+ component: 'ZdTag',
777
+ tag: 'span',
778
+ cssStyle: 'display: flex',
779
+ isVisible: `{{GridController_${this.grid.name}.isNotEditing}}`,
780
+ children: [
781
+ {
782
+ name: this.getAtomName('ADD_TOOLTIP'),
783
+ component: 'ZdTooltip',
784
+ label: 'TEKGRID_ADD',
785
+ bottom: true,
786
+ children: [
787
+ {
788
+ name: this.getAtomName('ADD_BUTTON'),
789
+ component: 'ZdButton',
790
+ icon: true,
791
+ iconName: 'mdi-plus-box',
792
+ isVisible: `{{GridController_${this.grid.name}.showAddButton}}`,
793
+ events: {
794
+ click: this.addButtonClick.bind(this),
795
+ },
796
+ },
797
+ ],
798
+ },
799
+ {
800
+ name: this.getAtomName('DELETE_TOOLTIP'),
801
+ component: 'ZdTooltip',
802
+ label: 'TEKGRID_DELETE',
803
+ bottom: true,
804
+ children: [
805
+ {
806
+ name: this.getAtomName('DELETE_BUTTON'),
807
+ component: 'ZdButton',
808
+ icon: true,
809
+ iconName: 'mdi-trash-can-outline',
810
+ isVisible: `{{GridController_${this.grid.name}.showDeleteButton}}`,
811
+ disabled: `{{GridController_${this.grid.name}.disableDeleteButton}}`,
812
+ events: {
813
+ click: this.deleteButtonClick.bind(this),
814
+ },
815
+ },
816
+ ],
817
+ },
818
+ {
819
+ name: this.getAtomName('DIVIDER1'),
820
+ component: 'ZdDivider',
821
+ cssClass: 'toolbar-divider',
822
+ vertical: true,
823
+ isVisible: `{{GridController_${this.grid.name}.showDivider1}}`,
824
+ },
825
+ {
826
+ name: this.getAtomName('REFRESH_TOOLTIP'),
827
+ component: 'ZdTooltip',
828
+ label: 'TEKGRID_REFRESH',
829
+ bottom: true,
830
+ children: [
831
+ {
832
+ name: this.getAtomName('REFRESH_BUTTON'),
833
+ component: 'ZdButton',
834
+ icon: true,
835
+ iconName: 'refresh',
836
+ isVisible: `{{GridController_${this.grid.name}.showReloadButton}}`,
837
+ events: {
838
+ click: this.reloadGrid.bind(this),
839
+ },
840
+ },
841
+ ],
842
+ },
843
+ {
844
+ name: this.getAtomName('DIVIDER2'),
845
+ component: 'ZdDivider',
846
+ cssClass: 'toolbar-divider',
847
+ vertical: true,
848
+ isVisible: `{{GridController_${this.grid.name}.showDivider2}}`,
849
+ },
850
+ {
851
+ name: this.getAtomName('COLUMNS_BUTTON'),
852
+ component: 'TekGridColumnsButton',
853
+ isVisible: `{{GridController_${this.grid.name}.showColumnsButton}}`,
854
+ iterableComponentName: this.grid.name,
855
+ hideGroups: this.groupsVisibility === 'hide',
856
+ ignoreColumns: `{{GridController_${this.grid.name}.columnsButtonIgnore}}`,
857
+ },
858
+ {
859
+ name: this.getAtomName('LAYOUT_BUTTON'),
860
+ component: 'TekGridLayoutOptions',
861
+ isVisible: `{{GridController_${this.grid.name}.showLayoutOptionsButton}}`,
862
+ },
863
+ {
864
+ name: this.getAtomName('DIVIDER_ACTIONS'),
865
+ component: 'ZdDivider',
866
+ cssClass: 'toolbar-divider',
867
+ vertical: true,
868
+ isVisible: `{{GridController_${this.grid.name}.showActionAndExportButton}}`,
869
+ },
870
+ {
871
+ name: this.getAtomName('EXPORT_DROPDOWN'),
872
+ component: 'ZdDropdown',
873
+ cssClass: 'tekgrid-actions-dropdown',
874
+ offsetY: true,
875
+ activator: {
876
+ name: this.getAtomName('EXPORT_BUTTON'),
877
+ component: 'ZdButton',
878
+ icon: true,
879
+ iconName: 'mdi-file-download-outline',
880
+ isVisible: `{{GridController_${this.grid.name}.showExportButton}}`,
881
+ },
882
+ children: this.grid.exportActions || exportConfigButtons,
883
+ },
884
+ {
885
+ name: this.getAtomName('ACTIONS_DROPDOWN'),
886
+ component: 'ZdDropdown',
887
+ cssClass: 'tekgrid-actions-dropdown',
888
+ offsetY: true,
889
+ activator: {
890
+ name: this.getAtomName('ACTIONS_BUTTON'),
891
+ component: 'ZdButton',
892
+ icon: true,
893
+ iconName: 'mdi-dots-vertical',
894
+ isVisible: `{{GridController_${this.grid.name}.showActionsButton}}`,
895
+ },
896
+ children: this.grid.actions,
897
+ },
898
+ {
899
+ name: this.getAtomName('DIVIDER3'),
900
+ component: 'ZdDivider',
901
+ cssClass: 'toolbar-divider',
902
+ vertical: true,
903
+ isVisible: `{{GridController_${this.grid.name}.showDivider3}}`,
904
+ },
905
+ ],
906
+ },
907
+ {
908
+ name: this.getAtomName('SAVE_BUTTON'),
909
+ component: 'ZdButton',
910
+ label: 'TEKGRID_SAVE',
911
+ isVisible: `{{GridController_${this.grid.name}.showEditButtons}}`,
912
+ small: true,
913
+ events: {
914
+ click: this.saveChanges.bind(this),
915
+ },
916
+ },
917
+ {
918
+ name: this.getAtomName('CANCEL_BUTTON'),
919
+ component: 'ZdButton',
920
+ label: 'TEKGRID_CANCEL',
921
+ outline: true,
922
+ cssClass: 'zd-mx-2',
923
+ isVisible: `{{GridController_${this.grid.name}.showEditButtons}}`,
924
+ small: true,
925
+ events: {
926
+ click: this.cancelChanges.bind(this),
927
+ },
928
+ },
929
+ {
930
+ name: this.getAtomName('SEARCH'),
931
+ component: 'ZdSearch',
932
+ cssClass: 'zd-grid-search',
933
+ iterableComponentName: `${this.grid.name}`,
934
+ isVisible: `{{GridController_${this.grid.name}.showSearchInput}}`,
935
+ },
936
+ {
937
+ name: this.getAtomName('FILTER_TOOLTIP'),
938
+ component: 'ZdTooltip',
939
+ label: 'TEKGRID_FILTER',
940
+ bottom: true,
941
+ children: [
942
+ {
943
+ name: this.getAtomName('FILTER_BUTTON'),
944
+ component: 'TekGridFilterButton',
945
+ grid: this.grid,
946
+ gridName: this.grid.name,
947
+ showCheckboxAll: this.grid.showCheckboxAllFilter,
948
+ isVisible: `{{GridController_${this.grid.name}.showFilterButton}}`,
949
+ },
950
+ ],
951
+ },
952
+ ],
953
+ },
954
+ ];
955
+ }
956
+ }
957
+
958
+ class ColumnsSearcher {
959
+ async searchColumn(columns, search) {
960
+ const lookupColumns = columns.filter((column) => !!column.componentProps?.datasource && !column.skipLookupSearch);
961
+ const searchJoin = {};
962
+ if (search) {
963
+ const promises = lookupColumns.map(async (column) => {
964
+ const searchData = await column.memorySearch(search);
965
+ const lookupId = column.componentProps.datasource.uniqueKey;
966
+ searchJoin[column.name] = searchData.map((row) => row[lookupId]);
967
+ });
968
+ await Promise.all(promises);
969
+ }
970
+ return searchJoin;
971
+ }
972
+ }
973
+
974
+ class DynamicFilterDatasourceFactory {
975
+ factory(options) {
976
+ return DatasourceFactory.factory({
977
+ data: this.getFilterOptionsData(options),
978
+ loadAll: true,
979
+ translate: ['text'],
980
+ });
981
+ }
982
+ getFilterOptionsData(options) {
983
+ const optionsKeys = Object.keys(options);
984
+ return optionsKeys.map((item) => ({
985
+ text: `TEKGRID_${item}`,
986
+ value: item,
987
+ }));
988
+ }
989
+ }
990
+
991
+ class TekFilterHelper {
992
+ static getLabel(name) {
993
+ return DateHelper.getLabel(name);
994
+ }
995
+ static getValue(name, column) {
996
+ return DateHelper.getValue(name, column.componentProps.dateFormat);
997
+ }
998
+ static register(name, label, fn) {
999
+ DateHelper.register(name, label, fn);
1000
+ }
1001
+ static unregister(name) {
1002
+ DateHelper.unregister(name);
1003
+ }
1004
+ }
1005
+
1006
+ /**
1007
+ * Base class for TekGrid column
1008
+ */
1009
+ class TekGridColumn extends GridColumnEditable {
1010
+ /* filter component props */
1011
+ filterProps = [];
1012
+ /* column can be use to filter */
1013
+ filterable = true;
1014
+ /* Index of the column inside filter modal */
1015
+ filterIndex;
1016
+ /* should not consider lookup column on search */
1017
+ skipLookupSearch = false;
1018
+ /* column is grouped */
1019
+ groupedValue = false;
1020
+ /* column group is opened */
1021
+ groupOpenedValue = false;
1022
+ /* Value to show when grouped value is empty */
1023
+ groupLabelForEmptyValue = '';
1024
+ /* column has aggregation */
1025
+ aggregationValue;
1026
+ /* column is visible */
1027
+ isVisibleValue = true;
1028
+ /**
1029
+ * Defines if the column should store the componentProps datasource.data in memory
1030
+ */
1031
+ storeData = true;
1032
+ grid;
1033
+ /* istanbul ignore next */
1034
+ /**
1035
+ * Creates a new TekGrid Column.
1036
+ * @param props TekGrid column properties
1037
+ */
1038
+ constructor(props, grid) {
1039
+ super(props);
1040
+ this.grid = grid;
1041
+ this.isVisible = this.getInitValue('isVisible', props.isVisible, this.isVisible);
1042
+ this.filterProps = this.getInitValue('filterProps', props.filterProps, this.filterProps);
1043
+ this.filterable = this.getInitValue('filterable', props.filterable, this.filterable);
1044
+ this.filterIndex = this.getInitValue('filterIndex', props.filterIndex, this.filterIndex);
1045
+ this.skipLookupSearch = this.getInitValue('skipLookupSearch', props.skipLookupSearch, this.skipLookupSearch);
1046
+ this.grouped = this.getInitValue('grouped', props.grouped, this.grouped);
1047
+ this.groupOpened = this.getInitValue('groupOpened', props.groupOpened, this.groupOpened);
1048
+ this.aggregation = this.getInitValue('aggregation', props.aggregation, this.aggregation);
1049
+ this.groupLabelForEmptyValue = this.getInitValue('groupLabelForEmptyValue', props.groupLabelForEmptyValue, this.groupLabelForEmptyValue);
1050
+ this.storeData = this.getInitValue('storeData', props.storeData, this.storeData);
1051
+ this.createAccessors();
1052
+ }
1053
+ async getBatchLookupData(lookupColumn, values) {
1054
+ const batch = [];
1055
+ const dataToLookup = [];
1056
+ values.forEach((value) => {
1057
+ if (this.lookupData[value]) {
1058
+ batch.push(this.lookupData[value]);
1059
+ return;
1060
+ }
1061
+ const dataIndex = this.lookupDatasource.data.findIndex((row) => row[lookupColumn] === value);
1062
+ if (dataIndex !== -1) {
1063
+ this.lookupData[value] = this.lookupDatasource.data[dataIndex];
1064
+ batch.push(this.lookupData[value]);
1065
+ return;
1066
+ }
1067
+ dataToLookup.push(value);
1068
+ });
1069
+ if (dataToLookup.length > 0) {
1070
+ await this.lookupFn(lookupColumn, dataToLookup);
1071
+ dataToLookup.forEach((value) => {
1072
+ const row = this.lookupData[value];
1073
+ if (row)
1074
+ batch.push(row);
1075
+ });
1076
+ }
1077
+ return batch;
1078
+ }
1079
+ /**
1080
+ * Memory search, without changing lookupDatasource
1081
+ */
1082
+ async memorySearch(search) {
1083
+ if (!this.lookupDatasource) {
1084
+ throw new Error("Can't search in a column that doesn't have a datasource");
1085
+ }
1086
+ let { data } = this.lookupDatasource;
1087
+ if (this.storeData) {
1088
+ if (!data.length) {
1089
+ data = await this.lookupDatasource.get();
1090
+ }
1091
+ }
1092
+ else {
1093
+ // datasource without the lookup filters
1094
+ const defaultDs = DatasourceFactory.factory({
1095
+ ...this.componentProps.datasource,
1096
+ lazyLoad: true,
1097
+ loadAll: true,
1098
+ });
1099
+ defaultDs.initialize();
1100
+ data = await defaultDs.get();
1101
+ }
1102
+ const { dataText } = this.componentProps;
1103
+ const searchIn = Array.isArray(dataText) ? dataText : [dataText];
1104
+ // get datasource as memory
1105
+ const datasource = DatasourceFactory.factory({
1106
+ searchIn,
1107
+ data,
1108
+ type: 'memory',
1109
+ loadAll: true,
1110
+ });
1111
+ datasource.initialize();
1112
+ return datasource.setSearch(search);
1113
+ }
1114
+ get grouped() {
1115
+ return this.groupedValue;
1116
+ }
1117
+ set grouped(value) {
1118
+ const changed = value !== this.groupedValue;
1119
+ this.groupedValue = value;
1120
+ if (changed) {
1121
+ this.changeGrouping();
1122
+ }
1123
+ }
1124
+ get aggregation() {
1125
+ return this.aggregationValue;
1126
+ }
1127
+ set aggregation(value) {
1128
+ const changed = value !== this.aggregationValue;
1129
+ this.aggregationValue = value;
1130
+ if (changed) {
1131
+ this.changeGrouping();
1132
+ }
1133
+ }
1134
+ get groupOpened() {
1135
+ return this.groupOpenedValue;
1136
+ }
1137
+ set groupOpened(value) {
1138
+ const changed = value !== this.groupOpenedValue;
1139
+ this.groupOpenedValue = value;
1140
+ if (changed) {
1141
+ this.changeGrouping();
1142
+ }
1143
+ }
1144
+ /* istanbul ignore next */
1145
+ // @ts-ignore
1146
+ get isVisible() {
1147
+ return this.isVisibleValue && !this.grouped;
1148
+ }
1149
+ /* istanbul ignore next */
1150
+ set isVisible(value) {
1151
+ this.isVisibleValue = value;
1152
+ }
1153
+ changeGrouping() {
1154
+ // wait for grid.constructor to be fully executed
1155
+ setTimeout(() => {
1156
+ this.grid.updateGrouping();
1157
+ });
1158
+ }
1159
+ }
1160
+
1161
+ /**
1162
+ * Base class for TekGrid Filter Button component
1163
+ */
1164
+ class TekGridFilterButton extends Button {
1165
+ gridName;
1166
+ grid;
1167
+ showCheckboxAll = false;
1168
+ filterModal;
1169
+ filterFormInputs = {};
1170
+ constructor(props) {
1171
+ super(props);
1172
+ this.gridName = this.getInitValue('gridName', props.gridName, this.gridName);
1173
+ this.grid = this.getInitValue('grid', props.grid, undefined);
1174
+ this.showCheckboxAll = this.getInitValue('showCheckboxAll', props.showCheckboxAll, this.showCheckboxAll);
1175
+ this.createAccessors();
1176
+ if (!this.grid)
1177
+ this.loadGrid();
1178
+ }
1179
+ loadGrid(gridName) {
1180
+ if (gridName)
1181
+ this.gridName = gridName;
1182
+ if (!this.gridName)
1183
+ return;
1184
+ this.grid = Metadata.getInstances(this.gridName)[0];
1185
+ }
1186
+ click(event) {
1187
+ this.callEvent('click', { component: this, event });
1188
+ this.grid.callEvent('filterClick', { component: this.grid, event });
1189
+ if (!event?.defaultPrevented) {
1190
+ this.createFilterFromColumns.call(this);
1191
+ }
1192
+ }
1193
+ loadFilterValues({ component }) {
1194
+ const changedCompNames = [];
1195
+ const { datasource } = this.grid;
1196
+ if (datasource instanceof TekRestDatasource || datasource instanceof TekMemoryDatasource) {
1197
+ const { dynamicFilter } = datasource;
1198
+ const newDynamicFilter = { ...this.grid.defaultFilter, ...dynamicFilter };
1199
+ Object.keys(newDynamicFilter).forEach((column) => {
1200
+ if (newDynamicFilter[column] && newDynamicFilter[column].length > 0) {
1201
+ newDynamicFilter[column].forEach((filterItem, index) => {
1202
+ const relation = filterItem.relation || 'AND';
1203
+ const operation = filterItem.operation || 'CONTAINS';
1204
+ const compName = `${this.grid.name}-filter-${relation}-${operation}-${column}-${index}`;
1205
+ changedCompNames.push(compName);
1206
+ component.value[compName] = filterItem.value;
1207
+ let helperValue = '';
1208
+ const columnObj = this.grid.getColumn(column);
1209
+ if (columnObj instanceof TekGridColumn) {
1210
+ const { filterProps } = columnObj;
1211
+ if (!Array.isArray(filterProps)) {
1212
+ helperValue = filterProps.helperValue || '';
1213
+ }
1214
+ else {
1215
+ filterProps.forEach((prop) => {
1216
+ if ((prop.relation || 'AND') === relation && (prop.operation || 'CONTAINS') === operation) {
1217
+ helperValue = prop.helperValue || '';
1218
+ }
1219
+ });
1220
+ }
1221
+ const inputObj = Metadata.getInstances(compName);
1222
+ if (helperValue && inputObj.length && inputObj[0]) {
1223
+ inputObj[0].hint = TekFilterHelper.getLabel(helperValue);
1224
+ }
1225
+ }
1226
+ });
1227
+ }
1228
+ });
1229
+ }
1230
+ else {
1231
+ const { filter } = datasource;
1232
+ const newFilter = { ...this.grid.defaultFilter, ...filter };
1233
+ Object.keys(newFilter).forEach((item) => {
1234
+ if (newFilter[item]) {
1235
+ const compName = `${this.grid.name}-filter-AND-CONTAINS-${item}-0`;
1236
+ changedCompNames.push(compName);
1237
+ component.value[compName] = newFilter[item];
1238
+ }
1239
+ });
1240
+ }
1241
+ Object.keys(component.value).forEach((compName) => {
1242
+ if (changedCompNames.indexOf(compName) === -1) {
1243
+ component.value[compName] = null;
1244
+ }
1245
+ });
1246
+ }
1247
+ hideFilterModal() {
1248
+ this.filterModal.hide();
1249
+ }
1250
+ destroyFilterModal() {
1251
+ if (this.filterModal)
1252
+ this.filterModal.destroy();
1253
+ }
1254
+ createFilterFromColumns() {
1255
+ if (!this.filterModal) {
1256
+ const originalProps = {
1257
+ height: 'auto',
1258
+ maxHeight: '18.75rem',
1259
+ persistent: true,
1260
+ title: 'FILTER',
1261
+ };
1262
+ const mergeModalFilterProps = Object.assign(originalProps, this.grid.modalFilterProps);
1263
+ const filterModalDef = {
1264
+ name: `${this.grid.name}-filter-modal`,
1265
+ persistent: mergeModalFilterProps.persistent,
1266
+ grid: mergeModalFilterProps.grid,
1267
+ cssClass: mergeModalFilterProps.cssClass,
1268
+ cssStyle: mergeModalFilterProps.cssStyle,
1269
+ draggable: mergeModalFilterProps.draggable,
1270
+ dragHandle: mergeModalFilterProps.dragHandle,
1271
+ fullscreen: mergeModalFilterProps.fullscreen,
1272
+ light: mergeModalFilterProps.light,
1273
+ dark: mergeModalFilterProps.dark,
1274
+ escKeydownStop: false,
1275
+ children: [
1276
+ {
1277
+ name: `${this.grid.name}-filter-header-container`,
1278
+ component: 'ZdContainer',
1279
+ cssClass: 'zd-pa-0 zd-display-flex',
1280
+ children: [
1281
+ {
1282
+ name: `${this.grid.name}-filter-title`,
1283
+ component: 'ZdText',
1284
+ cssStyle: `color: ${'var(--v-primary-base);'}`,
1285
+ text: mergeModalFilterProps.title,
1286
+ tag: 'h3',
1287
+ },
1288
+ {
1289
+ name: `${this.grid.name}-filter-spacer`,
1290
+ component: 'VSpacer',
1291
+ },
1292
+ {
1293
+ name: `${this.grid.name}-filter-close-button`,
1294
+ component: 'ZdModalCloseButton',
1295
+ small: true,
1296
+ modalName: `${this.grid.name}-filter-modal`,
1297
+ },
1298
+ ],
1299
+ },
1300
+ {
1301
+ name: `${this.grid.name}-filter-content-container`,
1302
+ component: 'ZdContainer',
1303
+ scrollView: true,
1304
+ cssClass: 'zd-my-2 zd-pa-0 tek-grid-filter-content-container',
1305
+ maxHeight: mergeModalFilterProps.maxHeight,
1306
+ height: mergeModalFilterProps.height,
1307
+ children: [
1308
+ {
1309
+ name: `${this.grid.name}-filter-form`,
1310
+ component: 'ZdForm',
1311
+ cssClass: 'zd-my-2 zd-pa-0',
1312
+ children: this.getFilterModalComponents(),
1313
+ events: {
1314
+ onMounted: this.loadFilterValues.bind(this),
1315
+ },
1316
+ },
1317
+ ],
1318
+ },
1319
+ {
1320
+ name: `${this.grid.name}-filter-footer-container`,
1321
+ component: 'ZdContainer',
1322
+ cssClass: 'zd-pa-0',
1323
+ children: [
1324
+ {
1325
+ name: `${this.grid.name}-filter-footer`,
1326
+ component: 'ZdFooter',
1327
+ color: 'transparent',
1328
+ padless: true,
1329
+ leftSlot: [
1330
+ {
1331
+ name: `${this.grid.name}-filter-clearButton`,
1332
+ component: 'ZdButton',
1333
+ label: 'CLEAR',
1334
+ outline: true,
1335
+ events: {
1336
+ click: this.clearFilter.bind(this),
1337
+ },
1338
+ },
1339
+ ],
1340
+ rightSlot: [
1341
+ {
1342
+ name: `${this.grid.name}-filter-cancelButton`,
1343
+ component: 'ZdButton',
1344
+ label: 'CANCEL',
1345
+ keyMap: {
1346
+ esc: {
1347
+ event: this.hideFilterModal.bind(this),
1348
+ focus: true,
1349
+ visible: true,
1350
+ input: true,
1351
+ stop: true,
1352
+ },
1353
+ },
1354
+ outline: true,
1355
+ events: {
1356
+ click: this.hideFilterModal.bind(this),
1357
+ },
1358
+ },
1359
+ {
1360
+ name: `${this.grid.name}-filter-okButton`,
1361
+ component: 'ZdButton',
1362
+ label: 'OK',
1363
+ events: {
1364
+ click: this.applyFilter.bind(this),
1365
+ },
1366
+ keyMap: {
1367
+ 'mod+enter': {
1368
+ event: this.applyFilter.bind(this),
1369
+ focus: true,
1370
+ input: true,
1371
+ stop: true,
1372
+ visible: true,
1373
+ },
1374
+ },
1375
+ },
1376
+ ],
1377
+ },
1378
+ ],
1379
+ },
1380
+ ],
1381
+ };
1382
+ this.filterModal = ModalService.create(filterModalDef);
1383
+ }
1384
+ else {
1385
+ this.loadFilterValues({ component: Metadata.getInstance(`${this.grid.name}-filter-form`) });
1386
+ }
1387
+ this.filterModal.show();
1388
+ }
1389
+ onBeforeDestroy() {
1390
+ super.onBeforeDestroy();
1391
+ this.destroyFilterModal();
1392
+ }
1393
+ formatFormValue(filterForm) {
1394
+ // TODO: add this logic when SelectMultiple is implemented
1395
+ // return Object.keys(filterForm.value).reduce((result, item) => {
1396
+ // try {
1397
+ // const itemInstance = filterForm.getChildInstance<Input>(item);
1398
+ // if (!(itemInstance instanceof SelectMultiple) || !itemInstance.checkboxAll) return result;
1399
+ // // when selectmultiple with checkboxAll, should either remove it from the filter or
1400
+ // // change the value to T, depending on selectAllCompatibilityMode
1401
+ // if ((Config as ITekConfig).selectAllCompatibilityMode) {
1402
+ // result[item] = 'T';
1403
+ // return result;
1404
+ // }
1405
+ // delete result[item];
1406
+ // return result;
1407
+ // } catch (e) {
1408
+ // return result;
1409
+ // }
1410
+ // }, { ...filterForm.value });
1411
+ return filterForm.value;
1412
+ }
1413
+ async applyFilter({ event }) {
1414
+ const filterForm = Metadata.getInstance(`${this.grid.name}-filter-form`);
1415
+ const isFormValid = await filterForm.validate();
1416
+ if (isFormValid.valid) {
1417
+ const { datasource } = this.grid;
1418
+ const filter = {};
1419
+ const formValue = this.formatFormValue(filterForm);
1420
+ if (datasource instanceof TekRestDatasource || datasource instanceof TekMemoryDatasource) {
1421
+ Object.keys(formValue).forEach((item) => {
1422
+ const itemValue = formValue[item];
1423
+ if (itemValue && !(Array.isArray(itemValue) && !itemValue.length)) {
1424
+ const relationAndOperationAndName = item.split(`${this.grid.name}-filter-`)[1];
1425
+ const [relation, operation] = relationAndOperationAndName.split('-');
1426
+ let columnName = relationAndOperationAndName.split(`${relation}-${operation}-`)[1];
1427
+ columnName = columnName.split('-').slice(0, -1).join('-'); // remove index
1428
+ if (!filter[columnName]) {
1429
+ filter[columnName] = [];
1430
+ }
1431
+ const value = itemValue;
1432
+ filter[columnName].push({
1433
+ relation,
1434
+ operation,
1435
+ value,
1436
+ });
1437
+ }
1438
+ });
1439
+ datasource.dynamicFilter = filter;
1440
+ this.setFilter(filter, event, datasource.setDynamicFilter.bind(datasource));
1441
+ }
1442
+ else {
1443
+ Object.keys(formValue).forEach((item) => {
1444
+ let columnName = item.split(`${this.grid.name}-filter-AND-CONTAINS-`)[1];
1445
+ columnName = columnName.split('-').slice(0, -1).join('-'); // remove index
1446
+ if (formValue[item]) {
1447
+ filter[columnName] = formValue[item];
1448
+ }
1449
+ });
1450
+ datasource.filter = filter;
1451
+ this.setFilter(filter, event, datasource.setFilter.bind(datasource));
1452
+ }
1453
+ this.grid.changeLayout(event);
1454
+ }
1455
+ }
1456
+ setFilter(filter, event, filterFn) {
1457
+ this.grid.callEvent('beforeApplyFilter', { component: this.grid, event });
1458
+ if (event.defaultPrevented)
1459
+ return;
1460
+ filterFn(filter);
1461
+ this.hideFilterModal();
1462
+ }
1463
+ clearFilter() {
1464
+ const filterForm = Metadata.getInstance(`${this.grid.name}-filter-form`);
1465
+ Object.keys(filterForm.value).forEach((item) => {
1466
+ filterForm.value[item] = null;
1467
+ });
1468
+ }
1469
+ sortFilterIndex(col1, col2) {
1470
+ const index1 = col1.filterIndex !== undefined ? col1.filterIndex : Number.MAX_SAFE_INTEGER;
1471
+ const index2 = col2.filterIndex !== undefined ? col2.filterIndex : Number.MAX_SAFE_INTEGER;
1472
+ return index1 - index2;
1473
+ }
1474
+ getFilterModalComponents() {
1475
+ const filterColumns = [];
1476
+ let columnComponentName;
1477
+ [...this.grid.columns].sort(this.sortFilterIndex).forEach((column) => {
1478
+ const filterProps = Array.isArray(column.filterProps) ? column.filterProps : [column.filterProps];
1479
+ if (column.filterable && filterProps && filterProps.length > 0) {
1480
+ this.filterFormInputs[column.name] = [];
1481
+ filterProps.forEach((filterItem, index) => {
1482
+ const { datasource } = this.grid;
1483
+ if (datasource instanceof TekRestDatasource || datasource instanceof TekMemoryDatasource) {
1484
+ const relation = filterItem.relation || 'AND';
1485
+ const operation = filterItem.operation || 'CONTAINS';
1486
+ columnComponentName = `${this.grid.name}-filter-${relation}-${operation}-${column.name}-${index}`;
1487
+ }
1488
+ else {
1489
+ columnComponentName = `${this.grid.name}-filter-AND-CONTAINS-${column.name}-${index}`;
1490
+ }
1491
+ this.filterFormInputs[column.name].push(columnComponentName);
1492
+ const newColumnComponent = {
1493
+ label: column.label,
1494
+ ...column.componentProps,
1495
+ ...filterItem,
1496
+ name: columnComponentName,
1497
+ };
1498
+ if (filterItem.helperOptions) {
1499
+ if (!newColumnComponent.events)
1500
+ newColumnComponent.events = {};
1501
+ newColumnComponent.events.change = this.changeHelperEvent.bind(this, column);
1502
+ }
1503
+ if (newColumnComponent.component === 'ZdSelectMultiple') {
1504
+ newColumnComponent.showCheckboxAll = newColumnComponent.showCheckboxAll ?? this.showCheckboxAll;
1505
+ }
1506
+ filterColumns.push(newColumnComponent);
1507
+ });
1508
+ }
1509
+ });
1510
+ return filterColumns;
1511
+ }
1512
+ changeHelperEvent(column, { component }) {
1513
+ const { helperValue } = component;
1514
+ const componentName = component.name;
1515
+ if (!Array.isArray(column.filterProps)) {
1516
+ column.filterProps.helperValue = helperValue;
1517
+ }
1518
+ else {
1519
+ column.filterProps.forEach((prop) => {
1520
+ const relationAndOperationAndName = componentName.split(`${this.grid.name}-filter-`)[1];
1521
+ const [relation, operation] = relationAndOperationAndName.split('-');
1522
+ if ((prop.relation || 'AND') === relation && (prop.operation || 'CONTAINS') === operation) {
1523
+ prop.helperValue = helperValue;
1524
+ }
1525
+ });
1526
+ }
1527
+ }
1528
+ }
1529
+
1530
+ const isFilledObject = (obj) => {
1531
+ return !!obj && typeof obj === 'object' && !Array.isArray(obj) && !!Object.keys(obj).length;
1532
+ };
1533
+
1534
+ function isNil(value) {
1535
+ return value === null || value === undefined;
1536
+ }
1537
+
1538
+ class GroupedDataManager {
1539
+ grid;
1540
+ summaryColumns = [];
1541
+ groups = [];
1542
+ summary = {};
1543
+ groupedData = [];
1544
+ groupColumnNames = [];
1545
+ groupColumns = [];
1546
+ originalDatasourceLoadAll;
1547
+ originalDatasourceLimit;
1548
+ viewUpdateScrollData;
1549
+ viewUpdateFixedColumns;
1550
+ constructor(grid) {
1551
+ this.grid = grid;
1552
+ }
1553
+ setViewUpdateFixedColumns(fn) {
1554
+ this.viewUpdateFixedColumns = fn;
1555
+ }
1556
+ setViewUpdateScrollData(fn) {
1557
+ this.viewUpdateScrollData = fn;
1558
+ }
1559
+ /**
1560
+ * Tasks that should be finished before loading the grid data
1561
+ */
1562
+ tasksBeforeLoad = [];
1563
+ registerTask(task) {
1564
+ this.tasksBeforeLoad.push(task);
1565
+ }
1566
+ request = () => {
1567
+ throw new NonInitializedError(this.constructor.name);
1568
+ };
1569
+ debounceUpdateGrouping = () => {
1570
+ throw new NonInitializedError(this.constructor.name);
1571
+ };
1572
+ /**
1573
+ * Loads grid data after resolving all tasks
1574
+ */
1575
+ async loadAfterTasks() {
1576
+ Promise.all(this.tasksBeforeLoad.map((promise) => promise.catch(() => undefined)));
1577
+ this.tasksBeforeLoad = [];
1578
+ return this.request();
1579
+ }
1580
+ initializeDebounceFunctions() {
1581
+ this.request = debounce(() => {
1582
+ this.grid.reload();
1583
+ }, 500);
1584
+ this.debounceUpdateGrouping = debounce((lazyLoad = false) => {
1585
+ this.updateGroupedData(lazyLoad);
1586
+ }, 100);
1587
+ }
1588
+ /**
1589
+ * Initializes grid groups, summary columns and registers the grid datasource callback
1590
+ * @param lazyLoad defines if the grid should automatically load data after updating the datasource
1591
+ */
1592
+ initializeGrouping(lazyLoad) {
1593
+ this.initializeDebounceFunctions();
1594
+ this.initGroups();
1595
+ this.initSummaryColumns();
1596
+ this.originalDatasourceLoadAll = this.grid.datasource.loadAll;
1597
+ this.originalDatasourceLimit = this.grid.datasource.limit;
1598
+ this.grid.datasource.registerGetCallback((data) => this.onGet(data));
1599
+ this.updateGrouping(lazyLoad);
1600
+ }
1601
+ onGet(data) {
1602
+ if (this.isGrouped()) {
1603
+ this.buildGroupedData();
1604
+ }
1605
+ return data;
1606
+ }
1607
+ resetFooterVariables(group) {
1608
+ this.summaryColumns.forEach((column) => {
1609
+ group.footer[column.name] = {
1610
+ count: 0,
1611
+ sum: undefined,
1612
+ avg: undefined,
1613
+ min: undefined,
1614
+ max: undefined,
1615
+ };
1616
+ });
1617
+ }
1618
+ initGroups() {
1619
+ this.groups = [];
1620
+ this.groupColumns.forEach((column) => {
1621
+ const newGroup = {
1622
+ column,
1623
+ name: column.name,
1624
+ label: column.label,
1625
+ lastValue: undefined,
1626
+ initialized: false,
1627
+ footer: {},
1628
+ };
1629
+ this.resetFooterVariables(newGroup);
1630
+ this.groups.push(newGroup);
1631
+ });
1632
+ }
1633
+ getGroupedData() {
1634
+ return this.groupedData;
1635
+ }
1636
+ initSummaryColumns() {
1637
+ this.summaryColumns = this.grid.columns.filter((column) => !!column.aggregation && !column.grouped);
1638
+ this.summary = {};
1639
+ }
1640
+ /**
1641
+ * Calls updateGroupedData with debounce
1642
+ */
1643
+ updateGrouping(lazyLoad) {
1644
+ this.debounceUpdateGrouping(lazyLoad);
1645
+ }
1646
+ /**
1647
+ * Inits summary columns, updates the grid datasource and, if needed, reloads the grid data
1648
+ */
1649
+ async updateGroupedData(lazyLoad) {
1650
+ this.initSummaryColumns();
1651
+ this.updateGridDatasource();
1652
+ if (!lazyLoad) {
1653
+ await this.loadAfterTasks();
1654
+ }
1655
+ if (this.grid.virtualScroll && this.viewUpdateScrollData) {
1656
+ this.viewUpdateScrollData();
1657
+ }
1658
+ if (this.viewUpdateFixedColumns) {
1659
+ this.viewUpdateFixedColumns();
1660
+ }
1661
+ }
1662
+ /**
1663
+ * When using groups, should update the grid datasource order to reflect the group order
1664
+ * If the grid is not grouped, should not update the datasource order
1665
+ */
1666
+ updateGridDatasource() {
1667
+ this.groupedData = [];
1668
+ this.groupColumns = this.grid.columns.filter((column) => column.grouped);
1669
+ this.groupColumnNames = this.groupColumns.map((column) => column.name);
1670
+ if (this.isGrouped()) {
1671
+ if (this.groupColumns.length) {
1672
+ const order = this.getOrder(this.groupColumnNames, this.grid.datasource.order);
1673
+ this.grid.datasource.order = order;
1674
+ }
1675
+ this.grid.datasource.loadAll = true;
1676
+ return;
1677
+ }
1678
+ this.grid.datasource.loadAll = this.originalDatasourceLoadAll;
1679
+ this.grid.datasource.limit = this.originalDatasourceLimit;
1680
+ }
1681
+ /**
1682
+ * Returns the order to be used in the grid datasource based on the group column names and the grid order
1683
+ */
1684
+ getOrder(groupColumnNames, gridOrder) {
1685
+ const groupOrderColumns = groupColumnNames.map((column) => `${column}.asc`);
1686
+ const otherOrderColumns = gridOrder.filter((column) => groupColumnNames.indexOf(column.split('.')[0]) === -1);
1687
+ return [...groupOrderColumns, ...otherOrderColumns];
1688
+ }
1689
+ /**
1690
+ * Returns the summary data for the group
1691
+ */
1692
+ getSummaryData(group) {
1693
+ const summaryData = {};
1694
+ this.summaryColumns.forEach((column) => {
1695
+ const { aggregation } = column;
1696
+ const currentGroup = group[column.name];
1697
+ if (!currentGroup) {
1698
+ summaryData[column.name] = 0;
1699
+ return;
1700
+ }
1701
+ if (aggregation === 'COUNT') {
1702
+ summaryData[column.name] = currentGroup.count;
1703
+ }
1704
+ else if (aggregation === 'SUM') {
1705
+ summaryData[column.name] = currentGroup.sum;
1706
+ }
1707
+ else if (aggregation === 'AVG') {
1708
+ if (currentGroup.avg) {
1709
+ summaryData[column.name] = currentGroup.avg;
1710
+ }
1711
+ else if (typeof currentGroup.sum === 'number') {
1712
+ summaryData[column.name] = currentGroup.sum / currentGroup.count;
1713
+ }
1714
+ }
1715
+ else if (aggregation === 'MIN') {
1716
+ summaryData[column.name] = currentGroup.min;
1717
+ }
1718
+ else {
1719
+ // if (aggregation === 'MAX') {
1720
+ summaryData[column.name] = currentGroup.max;
1721
+ }
1722
+ });
1723
+ return summaryData;
1724
+ }
1725
+ /**
1726
+ * Adds group footers to the grouped data
1727
+ */
1728
+ addGroupFooters(groupIndex) {
1729
+ if (this.summaryColumns.length === 0) {
1730
+ return;
1731
+ }
1732
+ for (let i = this.groups.length - 1; i >= groupIndex; i -= 1) {
1733
+ if (this.groups[i].initialized) {
1734
+ const groupFooterRow = {
1735
+ groupFooter: true,
1736
+ groupIndex: i,
1737
+ groupHeaders: [],
1738
+ groupLabel: this.groups[i].lastGroupHeaderRow.groupLabel,
1739
+ groupValue: this.groups[i].lastGroupHeaderRow.groupValue,
1740
+ ...this.getSummaryData(this.groups[i].footer),
1741
+ };
1742
+ // add header for outer groups
1743
+ for (let g = 0; g < i; g += 1) {
1744
+ const { lastGroupHeaderRow } = this.groups[g];
1745
+ if (lastGroupHeaderRow) {
1746
+ groupFooterRow.groupHeaders.push(lastGroupHeaderRow);
1747
+ }
1748
+ }
1749
+ this.groupedData.push(groupFooterRow);
1750
+ }
1751
+ }
1752
+ }
1753
+ getGroupValue(group, row) {
1754
+ const groupColumn = this.grid.getColumn(group.column.name);
1755
+ const cellsApplied = this.grid.getAppliedConditions({ row, column: groupColumn });
1756
+ if (!isFilledObject(cellsApplied)) {
1757
+ this.grid.reapplyConditions(row);
1758
+ }
1759
+ const groupValue = groupColumn.formatterByRow(row, cellsApplied);
1760
+ return groupValue;
1761
+ }
1762
+ addGroupHeader(row, group, index) {
1763
+ const groupValue = this.getGroupValue(group, row) || group.column.groupLabelForEmptyValue;
1764
+ const groupHeaderRow = {
1765
+ group: true,
1766
+ groupRow: row,
1767
+ groupColumnName: group.column.name,
1768
+ groupHeader: true,
1769
+ groupIndex: index,
1770
+ groupLabel: I18n.translate(group.label),
1771
+ groupValue,
1772
+ groupOpened: group.column.groupOpened || this.grid.groupsOpened,
1773
+ groupHeaders: [],
1774
+ children: [],
1775
+ };
1776
+ // add header for outer groups to the added row
1777
+ for (let i = 0; i < index; i += 1) {
1778
+ groupHeaderRow.groupHeaders.push(this.groups[i].lastGroupHeaderRow);
1779
+ }
1780
+ group.lastGroupHeaderRow = groupHeaderRow;
1781
+ group.initialized = true;
1782
+ this.groupedData.push(groupHeaderRow);
1783
+ }
1784
+ calcSummaryValues(column, summary, row) {
1785
+ const rowValue = row[column.name];
1786
+ if (isNil(rowValue))
1787
+ return;
1788
+ summary.count += 1;
1789
+ if (this.grid.events.calcSummary) {
1790
+ this.grid.calcSummary(column, summary, row);
1791
+ return;
1792
+ }
1793
+ if (summary.min === undefined)
1794
+ summary.min = rowValue;
1795
+ if (summary.max === undefined)
1796
+ summary.max = rowValue;
1797
+ summary.min = rowValue < summary.min ? rowValue : summary.min;
1798
+ summary.max = rowValue > summary.max ? rowValue : summary.max;
1799
+ if (typeof rowValue === 'number') {
1800
+ summary.sum = (summary.sum || 0) + rowValue;
1801
+ }
1802
+ }
1803
+ calcSummary(row) {
1804
+ if (this.summaryColumns.length === 0)
1805
+ return;
1806
+ this.summaryColumns.forEach((column) => {
1807
+ const columnName = column.name;
1808
+ if (isNil(this.summary[columnName])) {
1809
+ this.summary[columnName] = {
1810
+ count: 0,
1811
+ sum: undefined,
1812
+ avg: undefined,
1813
+ min: undefined,
1814
+ max: undefined,
1815
+ };
1816
+ }
1817
+ this.calcSummaryValues(column, this.summary[columnName], row);
1818
+ this.groups.forEach((group) => {
1819
+ this.calcSummaryValues(column, group.footer[columnName], row);
1820
+ });
1821
+ });
1822
+ }
1823
+ addSummary() {
1824
+ if (this.summaryColumns.length === 0)
1825
+ return;
1826
+ const summaryRow = {
1827
+ groupFooter: true,
1828
+ groupSummary: true,
1829
+ ...this.getSummaryData(this.summary),
1830
+ };
1831
+ this.groupedData.push(summaryRow);
1832
+ }
1833
+ /**
1834
+ * It takes a flat array of data and groups it by the group columns specified in
1835
+ * the grid.
1836
+ */
1837
+ buildGroupedData() {
1838
+ this.initGroups();
1839
+ this.initSummaryColumns();
1840
+ this.groupedData = [];
1841
+ const data = this.grid.getData();
1842
+ data.forEach((row) => {
1843
+ let groupBreak = false;
1844
+ this.groups.forEach((group, index) => {
1845
+ const groupValue = row[group.name];
1846
+ if (group.lastValue !== groupValue || groupBreak) {
1847
+ if (!groupBreak) {
1848
+ this.addGroupFooters(index);
1849
+ }
1850
+ group.lastValue = groupValue;
1851
+ this.resetFooterVariables(group);
1852
+ this.addGroupHeader(row, group, index);
1853
+ groupBreak = true;
1854
+ }
1855
+ });
1856
+ this.groups.forEach((group) => {
1857
+ group.lastGroupHeaderRow.children.push(row);
1858
+ });
1859
+ this.groupedData.push({
1860
+ ...row,
1861
+ groupHeaders: this.groups.map((group) => group.lastGroupHeaderRow).filter(Boolean),
1862
+ });
1863
+ this.calcSummary(row);
1864
+ });
1865
+ if (this.groupedData.length > 0) {
1866
+ this.addGroupFooters(0);
1867
+ if (this.grid.showSummaryTotal) {
1868
+ this.addSummary();
1869
+ }
1870
+ }
1871
+ }
1872
+ openGroup(group) {
1873
+ group.groupOpened = !group.groupOpened;
1874
+ if (this.grid.virtualScroll && this.viewUpdateScrollData)
1875
+ this.viewUpdateScrollData();
1876
+ }
1877
+ isItemVisible(row) {
1878
+ return !row.groupHeaders || !row.groupHeaders.length || row.groupHeaders.every((group) => group.groupOpened);
1879
+ }
1880
+ isGrouped() {
1881
+ return !!this.groupColumnNames.length || (this.grid.showSummaryTotal && !!this.summaryColumns.length);
1882
+ }
1883
+ isColumnSearchable(column) {
1884
+ return !this.grid.searchVisibleOnly || column.isVisible || column.grouped;
1885
+ }
1886
+ directionalLeft() {
1887
+ const { currentRow } = this.grid.datasource;
1888
+ if (currentRow.group && currentRow.groupOpened) {
1889
+ currentRow.groupOpened = false;
1890
+ return;
1891
+ }
1892
+ if (this.grid.cellSelection || !currentRow.groupHeaders?.length)
1893
+ return;
1894
+ const newCurrentRow = currentRow.groupHeaders[currentRow.groupHeaders.length - 1];
1895
+ this.grid.setCurrentRow(newCurrentRow);
1896
+ }
1897
+ directionalRight() {
1898
+ const { currentRow } = this.grid.datasource;
1899
+ if (!currentRow.group || currentRow.groupOpened)
1900
+ return;
1901
+ currentRow.groupOpened = true;
1902
+ }
1903
+ }
1904
+
1905
+ class GroupedViewNavigator {
1906
+ viewNavigator;
1907
+ grid;
1908
+ constructor(iterable) {
1909
+ this.viewNavigator = new ViewNavigator();
1910
+ this.grid = iterable;
1911
+ }
1912
+ navigateLeft(param) {
1913
+ this.viewNavigator.navigateLeft(param);
1914
+ }
1915
+ navigateRight(param) {
1916
+ this.viewNavigator.navigateRight(param);
1917
+ }
1918
+ setViewNavigate(viewNavigate) {
1919
+ this.viewNavigator.setViewNavigate(viewNavigate);
1920
+ }
1921
+ getRowIndex(groupedData, index) {
1922
+ if (index)
1923
+ return index;
1924
+ const { currentRow } = this.grid.datasource;
1925
+ return groupedData.findIndex((row) => {
1926
+ if (currentRow.group) {
1927
+ return row.group && row.groupValue === currentRow.groupValue;
1928
+ }
1929
+ const rowKey = this.grid.getRowKey(row);
1930
+ const currentRowKey = this.grid.getRowKey(currentRow);
1931
+ return rowKey && rowKey === currentRowKey;
1932
+ });
1933
+ }
1934
+ navigateUp(index) {
1935
+ if (!this.grid.isGrouped() || this.grid.cellSelection) {
1936
+ this.viewNavigator.navigateUp();
1937
+ return;
1938
+ }
1939
+ const groupedData = this.grid.getGroupedData();
1940
+ if (!groupedData.length || index === -1)
1941
+ return;
1942
+ let rowIndex = this.getRowIndex(groupedData, index);
1943
+ if (rowIndex === -1)
1944
+ rowIndex = groupedData.length;
1945
+ const newRow = groupedData[rowIndex - 1];
1946
+ if (!newRow || !this.grid.isItemVisible(newRow) || newRow.groupFooter) {
1947
+ this.navigateUp(rowIndex - 1);
1948
+ return;
1949
+ }
1950
+ this.grid.setCurrentRow(newRow);
1951
+ }
1952
+ navigateDown(index) {
1953
+ if (!this.grid.isGrouped() || this.grid.cellSelection) {
1954
+ this.viewNavigator.navigateDown();
1955
+ return;
1956
+ }
1957
+ const groupedData = this.grid.getGroupedData();
1958
+ if (!groupedData.length || index === groupedData.length)
1959
+ return;
1960
+ const rowIndex = this.getRowIndex(groupedData, index);
1961
+ const newRow = groupedData[rowIndex + 1];
1962
+ if (!newRow || !this.grid.isItemVisible(newRow) || newRow.groupFooter) {
1963
+ this.navigateDown(rowIndex + 1);
1964
+ return;
1965
+ }
1966
+ this.grid.setCurrentRow(newRow);
1967
+ }
1968
+ }
1969
+
1970
+ const tuple = (...args) => args;
1971
+ const columnAggregationValues = tuple('SUM', 'MIN', 'MAX', 'AVG', 'COUNT', undefined);
1972
+
1973
+ class KeyMapGrouped {
1974
+ getMap(instance) {
1975
+ return {
1976
+ left: {
1977
+ event: instance.directionalLeft.bind(instance),
1978
+ stop: true,
1979
+ active: true,
1980
+ },
1981
+ right: {
1982
+ event: instance.directionalRight.bind(instance),
1983
+ stop: true,
1984
+ active: true,
1985
+ },
1986
+ };
1987
+ }
1988
+ }
1989
+
1990
+ class TekGridController {
1991
+ grid;
1992
+ openToolbar = true;
1993
+ constructor(grid) {
1994
+ this.grid = grid;
1995
+ this.openToolbar = this.grid.toolbarOpened;
1996
+ }
1997
+ get gridTitle() {
1998
+ return this.grid.title;
1999
+ }
2000
+ get showAddButton() {
2001
+ return this.grid.addButton;
2002
+ }
2003
+ get showDeleteButton() {
2004
+ return this.grid.deleteButton !== 'none';
2005
+ }
2006
+ get showFilterButton() {
2007
+ return this.grid.filterButton;
2008
+ }
2009
+ get showModalFilterProps() {
2010
+ return this.grid.modalFilterProps;
2011
+ }
2012
+ get showSearchInput() {
2013
+ return this.grid.showSearch;
2014
+ }
2015
+ get showToolbar() {
2016
+ return this.openToolbar;
2017
+ }
2018
+ set showToolbar(value) {
2019
+ this.openToolbar = value;
2020
+ }
2021
+ get toolbarClass() {
2022
+ return !this.openToolbar ? 'is-rotated' : '';
2023
+ }
2024
+ get tooltipName() {
2025
+ return !this.openToolbar ? 'TEKGRID_SHOW' : 'TEKGRID_HIDE';
2026
+ }
2027
+ get showReloadButton() {
2028
+ return this.grid.showReload;
2029
+ }
2030
+ get showDivider2() {
2031
+ return (this.showReloadButton &&
2032
+ (this.showLayoutOptionsButton ||
2033
+ this.showColumnsButton ||
2034
+ this.showActionsButton ||
2035
+ this.showExportButton ||
2036
+ this.showSearchInput));
2037
+ }
2038
+ get showColumnsButton() {
2039
+ return this.grid.columnsButton;
2040
+ }
2041
+ get columnsButtonIgnore() {
2042
+ return this.grid.columnsButtonIgnore;
2043
+ }
2044
+ get showLayoutOptionsButton() {
2045
+ return this.grid.showLayoutOptions;
2046
+ }
2047
+ get showDivider1() {
2048
+ return ((this.showAddButton || this.showDeleteButton) &&
2049
+ (this.showReloadButton ||
2050
+ this.showLayoutOptionsButton ||
2051
+ this.showColumnsButton ||
2052
+ this.showActionsButton ||
2053
+ this.showExportButton ||
2054
+ this.showSearchInput));
2055
+ }
2056
+ get showActionsButton() {
2057
+ return this.grid.actions.length > 0;
2058
+ }
2059
+ get showExportButton() {
2060
+ return this.grid.showExport;
2061
+ }
2062
+ get showActionAndExportButton() {
2063
+ return ((this.showLayoutOptionsButton || this.showColumnsButton) &&
2064
+ (this.showActionsButton || this.showExportButton || this.showSearchInput));
2065
+ }
2066
+ get showDivider3() {
2067
+ return (this.showActionsButton || this.showExportButton) && this.showSearchInput;
2068
+ }
2069
+ get isEditing() {
2070
+ return this.grid.editing;
2071
+ }
2072
+ get showEditButtons() {
2073
+ return this.isEditing && this.grid.showEditButtons;
2074
+ }
2075
+ get isNotEditing() {
2076
+ return !this.isEditing;
2077
+ }
2078
+ get disableDeleteButton() {
2079
+ if (this.grid.deleteButton === 'selection') {
2080
+ if (this.grid.selectAllPages) {
2081
+ const { allSelected, except } = this.grid.selectionState;
2082
+ return (allSelected && except.length === this.grid.datasource.total) || (!allSelected && except.length === 0);
2083
+ }
2084
+ return this.grid.selectedRows.length === 0;
2085
+ }
2086
+ if (this.grid.deleteButton === 'currentRow') {
2087
+ return !this.grid.datasource.currentRow[this.grid.datasource.uniqueKey];
2088
+ }
2089
+ return false;
2090
+ }
2091
+ }
2092
+
2093
+ class TekGridEvents extends GridEditableEvents {
2094
+ tekGrid;
2095
+ /**
2096
+ * Flag to prevent row click
2097
+ */
2098
+ preventRowClick = false;
2099
+ preventRowDoubleClick = false;
2100
+ constructor(tekGrid) {
2101
+ super(tekGrid);
2102
+ this.tekGrid = tekGrid;
2103
+ }
2104
+ calcSummary(column, summary, row) {
2105
+ this.tekGrid.callEvent('calcSummary', {
2106
+ component: this.tekGrid,
2107
+ column,
2108
+ columnName: column.name,
2109
+ summary,
2110
+ row,
2111
+ rowValue: row[column.name],
2112
+ });
2113
+ }
2114
+ rowDoubleClick(row, event, element) {
2115
+ if (!this.preventRowDoubleClick) {
2116
+ this.tekGrid.datasource.currentRow = row;
2117
+ this.tekGrid.callEvent('rowDoubleClick', {
2118
+ event,
2119
+ element,
2120
+ row,
2121
+ component: this.tekGrid,
2122
+ column: undefined,
2123
+ });
2124
+ }
2125
+ this.preventRowDoubleClick = false;
2126
+ }
2127
+ /**
2128
+ * Dispatches group row click event
2129
+ * @param row Grid row
2130
+ * @param event DOM event
2131
+ * @param element DOM Element
2132
+ */
2133
+ groupRowClick(row, event, element) {
2134
+ if (!this.preventRowClick) {
2135
+ this.tekGrid.callEvent('groupRowClick', {
2136
+ event,
2137
+ element,
2138
+ row,
2139
+ component: this.tekGrid,
2140
+ column: undefined,
2141
+ });
2142
+ }
2143
+ this.preventRowClick = false;
2144
+ }
2145
+ groupRowDoubleClick(row, event, element) {
2146
+ if (!this.preventRowDoubleClick) {
2147
+ this.tekGrid.callEvent('groupRowDoubleClick', {
2148
+ event,
2149
+ element,
2150
+ row,
2151
+ component: this.tekGrid,
2152
+ column: undefined,
2153
+ });
2154
+ }
2155
+ this.preventRowDoubleClick = false;
2156
+ }
2157
+ /**
2158
+ * Dispatches group select/unselect event
2159
+ * @param row Group row
2160
+ * @param isSelected Row is selected
2161
+ * @param event DOM event
2162
+ * @param element DOM Element
2163
+ */
2164
+ selectGroupClick(row, isSelected, event, element) {
2165
+ if (isSelected) {
2166
+ this.tekGrid.callEvent('groupSelected', {
2167
+ event,
2168
+ element,
2169
+ row,
2170
+ component: this.tekGrid,
2171
+ column: undefined,
2172
+ });
2173
+ }
2174
+ else {
2175
+ this.tekGrid.callEvent('groupUnselected', {
2176
+ event,
2177
+ element,
2178
+ row,
2179
+ component: this.tekGrid,
2180
+ column: undefined,
2181
+ });
2182
+ }
2183
+ }
2184
+ }
2185
+
2186
+ class GroupedDataSelector extends DataSelector {
2187
+ selectAll(isSelected) {
2188
+ if (!this.iterable.selectable)
2189
+ return;
2190
+ this.iterable.selectionState = { allSelected: isSelected, except: [] };
2191
+ const data = this.getData();
2192
+ if (!isSelected) {
2193
+ data.forEach((row) => {
2194
+ const index = this.iterable.selectedRows.indexOf(row);
2195
+ if (index > -1) {
2196
+ this.iterable.selectedRows.splice(index, 1);
2197
+ }
2198
+ });
2199
+ return;
2200
+ }
2201
+ data.forEach((row) => {
2202
+ if (this.callDisableSelection(row))
2203
+ return;
2204
+ const key = this.iterable.getRowKey(row);
2205
+ if (key && this.iterable.selectedRows.indexOf(row) === -1) {
2206
+ this.iterable.selectedRows.push(row);
2207
+ }
2208
+ });
2209
+ }
2210
+ getData() {
2211
+ if (this.iterable.isGrouped()) {
2212
+ return this.iterable.getGroupedData();
2213
+ }
2214
+ return this.iterable.getData();
2215
+ }
2216
+ }
2217
+
2218
+ /* TekGrid Class */
2219
+ class TekGrid extends Iterable {
2220
+ tableActionBuilder;
2221
+ iterableTable;
2222
+ dataSelector;
2223
+ tekGridEvents;
2224
+ dataNavigator;
2225
+ groupedViewNavigator;
2226
+ keyMapMerger;
2227
+ dataEditor;
2228
+ columnsSearcher;
2229
+ groupedDataManager;
2230
+ tekGridToolbarProvider;
2231
+ /* Grid Title */
2232
+ title = '';
2233
+ /* Show Add button */
2234
+ addButton = false;
2235
+ /* Show Delete button */
2236
+ deleteButton = 'none';
2237
+ /* Show Delete button */
2238
+ actions = [];
2239
+ /* Show edit button */
2240
+ showEditButtons = true;
2241
+ /* Show Filter button */
2242
+ filterButton = false;
2243
+ /* Show SearchInput */
2244
+ showSearch = true;
2245
+ /* Show Column Filter button */
2246
+ columnFilterButton = false;
2247
+ /* Show Columns button */
2248
+ columnsButton = false;
2249
+ /* Defines if the grid is the unique grid on screen */
2250
+ mainGrid = true;
2251
+ /* Columns to be ignored on columns button */
2252
+ columnsButtonIgnore = [];
2253
+ /**
2254
+ * Enables column dragging
2255
+ * @public
2256
+ */
2257
+ dragColumns = true;
2258
+ /**
2259
+ * Enables column resizing
2260
+ * @public
2261
+ */
2262
+ resizeColumns = true;
2263
+ /**
2264
+ * Enables layout saving
2265
+ * @public
2266
+ */
2267
+ showLayoutOptions = true;
2268
+ xlsDefaultType;
2269
+ modalFilterProps = {
2270
+ name: this.name,
2271
+ height: 'auto',
2272
+ persistent: true,
2273
+ cssClass: '',
2274
+ cssStyle: '',
2275
+ dark: false,
2276
+ draggable: false,
2277
+ fullscreen: false,
2278
+ dragHandle: '',
2279
+ title: 'FILTER',
2280
+ };
2281
+ /**
2282
+ * Show export button
2283
+ */
2284
+ showExport = false;
2285
+ /**
2286
+ * Show refresh button
2287
+ */
2288
+ showReload = true;
2289
+ /**
2290
+ * Export config
2291
+ */
2292
+ exportConfig = [
2293
+ {
2294
+ type: 'pdf',
2295
+ label: I18n.translate('TEKGRID_EXPORT_AS', { type: 'PDF' }),
2296
+ multiOption: [
2297
+ { label: I18n.translate('TEKGRID_PORTRAIT'), iconName: 'mdi-file-outline' },
2298
+ {
2299
+ label: I18n.translate('TEKGRID_LANDSCAPE'),
2300
+ iconName: 'mdi-file-outline',
2301
+ cssClass: 'tek-grid-export-landscape',
2302
+ reportParams: { portrait: false },
2303
+ },
2304
+ ],
2305
+ },
2306
+ {
2307
+ type: 'xls',
2308
+ label: I18n.translate('TEKGRID_EXPORT_AS', {
2309
+ type: 'XLS',
2310
+ }),
2311
+ },
2312
+ {
2313
+ type: 'xls2',
2314
+ label: I18n.translate('TEKGRID_EXPORT_AS', {
2315
+ type: `XLS ${I18n.translate('TEKGRID_WITH_GROUPS')}`,
2316
+ }),
2317
+ },
2318
+ {
2319
+ type: 'xls3',
2320
+ label: I18n.translate('TEKGRID_EXPORT_AS', {
2321
+ type: `XLS ${I18n.translate('TEKGRID_GRID_MIRROR')}`,
2322
+ }),
2323
+ },
2324
+ {
2325
+ type: 'csv',
2326
+ label: I18n.translate('TEKGRID_EXPORT_AS', { type: 'CSV' }),
2327
+ },
2328
+ ];
2329
+ /**
2330
+ * Actions to overwrite the default export config
2331
+ */
2332
+ exportActions;
2333
+ /**
2334
+ * Groups should be opened by default after building
2335
+ */
2336
+ groupsOpened = false;
2337
+ /**
2338
+ * Show Total summary
2339
+ */
2340
+ showSummaryTotal = true;
2341
+ editNewRowsOnly = false;
2342
+ keyShortcutKeyMapping;
2343
+ showCheckboxAllFilter = Config.gridShowCheckboxAllFilter || false;
2344
+ defaultFilter = {};
2345
+ toolbarOpened = true;
2346
+ reportTitle = '';
2347
+ editing = false;
2348
+ currentColumn = null;
2349
+ selectedRows = [];
2350
+ selectionState = {
2351
+ allSelected: false,
2352
+ except: [],
2353
+ };
2354
+ rowStyleConditions;
2355
+ selectAllPages = Config.gridSelectAllPages;
2356
+ selectable = false;
2357
+ disableSelection;
2358
+ cellSelection = false;
2359
+ toolbarSlot = [{ name: '<<NAME>>_gridSearch', component: 'ZdSearch' }];
2360
+ footerSlot = [
2361
+ { name: '<<NAME>>_iterablePagination', component: 'ZdIterablePagination' },
2362
+ {
2363
+ name: '<<NAME>>_iterableInfoDiv',
2364
+ component: 'ZdTag',
2365
+ cssClass: 'zd-grid-div-footer',
2366
+ tag: 'div',
2367
+ children: [
2368
+ {
2369
+ name: '<<NAME>>_iterablePageSize',
2370
+ component: 'ZdIterablePageSize',
2371
+ iterableComponentName: '<<NAME>>',
2372
+ },
2373
+ {
2374
+ name: '<<NAME>>_iterablePageInfo',
2375
+ component: 'ZdIterablePageInfo',
2376
+ iterableComponentName: '<<NAME>>',
2377
+ },
2378
+ ],
2379
+ },
2380
+ ];
2381
+ noResultsText = 'NO_RESULT';
2382
+ noResultSlot = [
2383
+ {
2384
+ name: '<<NAME>>_no-result',
2385
+ component: 'ZdText',
2386
+ cssClass: 'no-result',
2387
+ text: this.noResultsText,
2388
+ },
2389
+ ];
2390
+ errorSlot = [];
2391
+ dense = true;
2392
+ headerBackground = '';
2393
+ headerCellTextColor = '';
2394
+ height = 'auto';
2395
+ loadingText = 'LOADING';
2396
+ maxHeight = 'none';
2397
+ maxWidth = 'none';
2398
+ minHeight = 'auto';
2399
+ minWidth = 'auto';
2400
+ noDataText = 'NO_DATA';
2401
+ noDataSlot = [
2402
+ {
2403
+ name: '<<NAME>>_no-data',
2404
+ component: 'ZdText',
2405
+ cssClass: 'no-data',
2406
+ text: this.noDataText,
2407
+ },
2408
+ ];
2409
+ showFooter = true;
2410
+ showHeader = true;
2411
+ showSelectAll = true;
2412
+ width = '100%';
2413
+ backgroundColor = 'transparent';
2414
+ canEditRow;
2415
+ showCancelColumn = false;
2416
+ doubleClickEdit = false;
2417
+ singleEdit = false;
2418
+ editingNewRows = false;
2419
+ defaultLazy = false;
2420
+ toolbarSlotProps = false;
2421
+ filterRelationsDatasource;
2422
+ filterOperationsDatasource;
2423
+ /**
2424
+ * TekGrid class constructor
2425
+ * @param props TekGrid properties
2426
+ */
2427
+ constructor(props) {
2428
+ super(props);
2429
+ this.title = this.getInitValue('title', props.title, this.title);
2430
+ this.addButton = this.getInitValue('addButton', props.addButton, this.addButton);
2431
+ this.deleteButton = this.getInitValue('deleteButton', props.deleteButton, this.deleteButton);
2432
+ this.filterButton = this.getInitValue('filterButton', props.filterButton, this.filterButton);
2433
+ this.showSearch = this.getInitValue('showSearch', props.showSearch, this.showSearch);
2434
+ this.columnFilterButton = this.getInitValue('columnFilterButton', props.columnFilterButton, this.columnFilterButton);
2435
+ this.columnsButton = this.getInitValue('columnsButton', props.columnsButton, this.columnsButton);
2436
+ this.columnsButtonIgnore = this.getInitValue('columnsButtonIgnore', props.columnsButtonIgnore, this.columnsButtonIgnore);
2437
+ this.showEditButtons = this.getInitValue('showEditButtons', props.showEditButtons, this.showEditButtons);
2438
+ this.dragColumns = this.getInitValue('dragColumns', props.dragColumns, this.dragColumns);
2439
+ this.resizeColumns = this.getInitValue('resizeColumns', props.resizeColumns, this.resizeColumns);
2440
+ this.showLayoutOptions = this.getInitValue('showLayoutOptions', props.showLayoutOptions, this.showLayoutOptions);
2441
+ this.xlsDefaultType = this.getInitValue('xlsDefaultType', props.xlsDefaultType, this.xlsDefaultType);
2442
+ this.showExport = this.getInitValue('showExport', props.showExport, this.showExport);
2443
+ this.showReload = this.getInitValue('showReload', props.showReload, this.showReload);
2444
+ this.exportConfig = this.getInitValue('exportConfig', props.exportConfig, this.exportConfig);
2445
+ this.modalFilterProps = this.getInitValue('modalFilterProps', props.modalFilterProps, this.modalFilterProps);
2446
+ this.exportActions = props.exportActions || this.exportActions;
2447
+ this.groupsOpened = this.getInitValue('groupsOpened', props.groupsOpened, this.groupsOpened);
2448
+ this.showSummaryTotal = this.getInitValue('showSummaryTotal', props.showSummaryTotal, this.showSummaryTotal);
2449
+ this.showCheckboxAllFilter = this.getInitValue('showCheckboxAllFilter', props.showCheckboxAllFilter, this.showCheckboxAllFilter);
2450
+ this.defaultFilter = this.getInitValue('defaultFilter', props.defaultFilter, this.defaultFilter);
2451
+ this.toolbarOpened = this.getInitValue('toolbarOpened', props.toolbarOpened, this.toolbarOpened);
2452
+ this.editNewRowsOnly = this.getInitValue('editNewRowsOnly', props.editNewRowsOnly, this.editNewRowsOnly);
2453
+ this.mainGrid = this.getInitValue('mainGrid', props.mainGrid, this.mainGrid);
2454
+ this.reportTitle = this.getInitValue('reportTitle', props.reportTitle, this.reportTitle);
2455
+ this.actions = props.actions || this.actions;
2456
+ this.toolbarSlotProps = props.toolbarSlot !== undefined;
2457
+ this.cellSelection = this.getInitValue('cellSelection', props.cellSelection, this.cellSelection);
2458
+ this.dense = this.getInitValue('dense', props.dense, this.dense);
2459
+ this.disableSelection = this.getInitValue('disableSelection', props.disableSelection, this.disableSelection);
2460
+ this.dragColumns = this.getInitValue('dragColumns', props.dragColumns, this.dragColumns);
2461
+ this.fillHeight = this.getInitValue('fillHeight', props.fillHeight, this.fillHeight);
2462
+ this.headerCellTextColor = this.getInitValue('headerCellTextColor', props.headerCellTextColor, this.headerCellTextColor);
2463
+ this.height = this.getInitValue('height', props.height, this.height);
2464
+ this.loadingText = this.getInitValue('loadingText', props.loadingText, this.loadingText);
2465
+ this.maxHeight = this.getInitValue('maxHeight', props.maxHeight, this.maxHeight);
2466
+ this.maxWidth = this.getInitValue('maxWidth', props.maxWidth, this.maxWidth);
2467
+ this.minHeight = this.getInitValue('minHeight', props.minHeight, this.minHeight);
2468
+ this.minWidth = this.getInitValue('minWidth', props.minWidth, this.minWidth);
2469
+ this.noDataText = this.getInitValue('noDataText', props.noDataText, this.noDataText);
2470
+ this.noResultsText = this.getInitValue('noResultsText', props.noResultsText, this.noResultsText);
2471
+ this.resizeColumns = this.getInitValue('resizeColumns', props.resizeColumns, this.resizeColumns);
2472
+ this.rowStyleConditions = this.getInitValue('rowStyleConditions', props.rowStyleConditions, this.rowStyleConditions);
2473
+ this.selectable = this.getInitValue('selectable', props.selectable, this.selectable);
2474
+ this.selectAllPages = this.getInitValue('selectAllPages', props.selectAllPages, this.selectAllPages);
2475
+ this.showFooter = this.getInitValue('showFooter', props.showFooter, this.showFooter);
2476
+ this.showHeader = this.getInitValue('showHeader', props.showHeader, this.showHeader);
2477
+ this.showSelectAll = this.getInitValue('showSelectAll', props.showSelectAll, this.showSelectAll);
2478
+ this.width = this.getInitValue('width', props.width, this.width);
2479
+ this.backgroundColor = this.getInitValue('backgroundColor', props.backgroundColor, this.backgroundColor);
2480
+ // headerBackground defaults to the backgroundColor, unless backgroundColor is transparent
2481
+ const defaultHeaderBackground = this.backgroundColor === 'transparent' ? '' : this.backgroundColor;
2482
+ this.headerBackground = this.getInitValue('headerBackground', props.headerBackground, defaultHeaderBackground);
2483
+ this.doubleClickEdit = this.getInitValue('doubleClickEdit', props.doubleClickEdit, this.doubleClickEdit);
2484
+ this.singleEdit = this.getInitValue('singleEdit', props.singleEdit, this.singleEdit);
2485
+ this.showCancelColumn = this.getInitValue('showCancelColumn', props.showCancelColumn, this.showCancelColumn);
2486
+ this.canEditRow = this.getInitValue('canEditRow', props.canEditRow, this.canEditRow);
2487
+ this.editingNewRows = this.getInitValue('editingNewRows', props.editingNewRows, this.editingNewRows);
2488
+ this.toolbarSlot = props.toolbarSlot || this.toolbarSlot;
2489
+ this.footerSlot = props.footerSlot || this.footerSlot;
2490
+ this.noDataSlot = props.noDataSlot || this.noDataSlot;
2491
+ this.noResultSlot = props.noResultSlot || this.noResultSlot;
2492
+ this.errorSlot = props.errorSlot || this.errorSlot;
2493
+ this.noDataSlot = this.changeDefaultSlotNames(this.noDataSlot);
2494
+ this.footerSlot = this.changeDefaultSlotNames(this.footerSlot);
2495
+ this.toolbarSlot = this.changeDefaultSlotNames(this.toolbarSlot);
2496
+ this.noResultSlot = this.changeDefaultSlotNames(this.noResultSlot);
2497
+ this.errorSlot = this.changeDefaultSlotNames(this.errorSlot);
2498
+ this.defaultLazy = this.getDefaultLazy(props);
2499
+ if (this.deleteButton === 'selection') {
2500
+ this.selectable = true;
2501
+ }
2502
+ this.tableActionBuilder = new TableActionBuilder(this);
2503
+ this.iterableTable = new IterableTable(this);
2504
+ this.dataSelector = new GroupedDataSelector(this);
2505
+ this.tekGridEvents = new TekGridEvents(this);
2506
+ this.dataNavigator = new DataNavigator(this);
2507
+ this.groupedViewNavigator = new GroupedViewNavigator(this);
2508
+ this.dataEditor = new DataEditorWithAdd(this);
2509
+ this.columnsSearcher = new ColumnsSearcher();
2510
+ this.groupedDataManager = new GroupedDataManager(this);
2511
+ this.tekGridToolbarProvider = new TekGridToolbarProvider(this, 'show');
2512
+ }
2513
+ initializeDatasource(props) {
2514
+ let datasourceProps = clonedeep(props.datasource);
2515
+ // if using accessor, get props from the controller
2516
+ if (typeof props.datasource === 'string' && Accessor.isAccessorDefinition(props.datasource)) {
2517
+ const [controller, accessor] = Accessor.getAccessor(props.datasource);
2518
+ const instance = Loader.getInstance(controller);
2519
+ datasourceProps = instance[accessor];
2520
+ }
2521
+ this.datasource = DatasourceFactory.factory({
2522
+ ...datasourceProps,
2523
+ searchIn: props.datasource?.searchIn || `{{IterableController_${this.name}.searchIn}}`,
2524
+ lazyLoad: true,
2525
+ });
2526
+ }
2527
+ columnHasFilter(columnName) {
2528
+ return this.datasource.hasFilter(columnName);
2529
+ }
2530
+ registerTask(task) {
2531
+ this.groupedDataManager.registerTask(task);
2532
+ }
2533
+ async loadAfterTasks() {
2534
+ return this.groupedDataManager.loadAfterTasks();
2535
+ }
2536
+ calcSummary(column, columnNamesummary, row) {
2537
+ this.tekGridEvents.calcSummary(column, columnNamesummary, row);
2538
+ }
2539
+ getDefaultLazy(props) {
2540
+ if (typeof props.datasource === 'object') {
2541
+ return props.datasource.lazyLoad;
2542
+ }
2543
+ if (typeof props.datasource === 'string' && Accessor.isAccessorDefinition(props.datasource)) {
2544
+ const [controller, accessor] = Accessor.getAccessor(props.datasource);
2545
+ const instance = Loader.getInstance(controller);
2546
+ return instance[accessor].lazyLoad || false;
2547
+ }
2548
+ return false;
2549
+ }
2550
+ initializeGrouping(lazyLoad) {
2551
+ this.groupedDataManager.initializeGrouping(lazyLoad);
2552
+ }
2553
+ updateGrouping() {
2554
+ return this.groupedDataManager.updateGrouping();
2555
+ }
2556
+ updateGroupedData(lazyLoad) {
2557
+ return this.groupedDataManager.updateGroupedData(lazyLoad);
2558
+ }
2559
+ buildGroupedData() {
2560
+ this.groupedDataManager.buildGroupedData();
2561
+ }
2562
+ openGroup(group) {
2563
+ this.groupedDataManager.openGroup(group);
2564
+ }
2565
+ isItemVisible(row) {
2566
+ return this.groupedDataManager.isItemVisible(row);
2567
+ }
2568
+ isGrouped() {
2569
+ return this.groupedDataManager.isGrouped();
2570
+ }
2571
+ isColumnSearchable(column) {
2572
+ return this.groupedDataManager.isColumnSearchable(column);
2573
+ }
2574
+ getGroupedData() {
2575
+ return this.groupedDataManager.getGroupedData();
2576
+ }
2577
+ directionalLeft(param) {
2578
+ this.groupedDataManager.directionalLeft(param);
2579
+ this.groupedViewNavigator.navigateLeft(param);
2580
+ }
2581
+ directionalRight(param) {
2582
+ this.groupedDataManager.directionalRight(param);
2583
+ this.groupedViewNavigator.navigateRight(param);
2584
+ }
2585
+ getReport() {
2586
+ throw new Error('Method not implemented.');
2587
+ }
2588
+ setViewUpdateFixedColumns(fn) {
2589
+ this.groupedDataManager.setViewUpdateFixedColumns(fn);
2590
+ }
2591
+ setViewUpdateScrollData(fn) {
2592
+ this.groupedDataManager.setViewUpdateScrollData(fn);
2593
+ }
2594
+ onCreated() {
2595
+ super.onCreated();
2596
+ Loader.addController(`GridController_${this.name}`, TekGridController, [this]);
2597
+ if (!this.toolbarSlotProps)
2598
+ this.toolbarSlot = this.tekGridToolbarProvider.getProperties();
2599
+ this.createDynamicFilterDatasources();
2600
+ }
2601
+ createDynamicFilterDatasources() {
2602
+ if (!(this.datasource instanceof TekRestDatasource || this.datasource instanceof TekMemoryDatasource))
2603
+ return;
2604
+ const datasourceFactory = new DynamicFilterDatasourceFactory();
2605
+ this.filterRelationsDatasource = datasourceFactory.factory(this.datasource.dynamicFilterRelations);
2606
+ this.filterOperationsDatasource = datasourceFactory.factory(this.datasource.dynamicFilterOperations);
2607
+ }
2608
+ onMounted(element) {
2609
+ super.onMounted(element);
2610
+ this.keyMapMerger = new KeyMapMerger(this, [KeyMapNavigation, KeyMapEditing, KeyMapGrouped]);
2611
+ this.keyMapMerger.bind(element);
2612
+ this.initializeGrouping(this.defaultLazy);
2613
+ }
2614
+ onBeforeDestroy() {
2615
+ super.onBeforeDestroy();
2616
+ this.keyMapMerger.unbind();
2617
+ }
2618
+ createColumn(column) {
2619
+ return new TekGridColumn(column, this);
2620
+ }
2621
+ getConditionalProps({ row, column }) {
2622
+ const rowStyle = this.getRowStyleConditions(row);
2623
+ const cellsApplied = this.getAppliedConditions({ row, column });
2624
+ return { ...rowStyle, ...cellsApplied };
2625
+ }
2626
+ changeOrder(sortBy) {
2627
+ return this.iterableTable.changeOrder(sortBy);
2628
+ }
2629
+ selectCell(row, column) {
2630
+ this.iterableTable.selectCell(row, column);
2631
+ }
2632
+ reapplyRowStyleConditions(row) {
2633
+ return this.iterableTable.reapplyRowStyleConditions(row);
2634
+ }
2635
+ getRowStyleConditions(row) {
2636
+ return this.iterableTable.getRowStyleConditions(row);
2637
+ }
2638
+ deleteRows() {
2639
+ return this.iterableTable.deleteRows();
2640
+ }
2641
+ selectAll(isSelected) {
2642
+ this.dataSelector.selectAll(isSelected);
2643
+ }
2644
+ toggleRow(row) {
2645
+ this.dataSelector.toggleRow(row);
2646
+ }
2647
+ selectRow(row, select) {
2648
+ this.dataSelector.selectRow(row, select);
2649
+ }
2650
+ callDisableSelection(row) {
2651
+ return this.dataSelector.callDisableSelection(row);
2652
+ }
2653
+ selectClick(row, isSelected, event, element) {
2654
+ this.dataSelector.selectClick(row, isSelected, event, element);
2655
+ }
2656
+ selectAllClick(isSelected, event, element) {
2657
+ this.dataSelector.selectAllClick(isSelected, event, element);
2658
+ }
2659
+ navigatePageUp() {
2660
+ this.dataNavigator.navigatePageUp();
2661
+ }
2662
+ navigatePageDown() {
2663
+ this.dataNavigator.navigatePageDown();
2664
+ }
2665
+ setViewNavigate(viewNavigate) {
2666
+ this.groupedViewNavigator.setViewNavigate(viewNavigate);
2667
+ }
2668
+ navigateLeft(params) {
2669
+ if (!this.cellSelection)
2670
+ return;
2671
+ this.groupedViewNavigator.navigateLeft(params);
2672
+ }
2673
+ navigateRight(params) {
2674
+ if (!this.cellSelection)
2675
+ return;
2676
+ this.groupedViewNavigator.navigateRight(params);
2677
+ }
2678
+ navigateUp() {
2679
+ this.groupedViewNavigator.navigateUp();
2680
+ }
2681
+ navigateDown() {
2682
+ this.groupedViewNavigator.navigateDown();
2683
+ }
2684
+ navigateDatasource(direction) {
2685
+ this.dataNavigator.navigateDatasource(direction);
2686
+ }
2687
+ getActionComponent(actionComponent, column, row, parentPath) {
2688
+ return this.tableActionBuilder.getActionComponent(actionComponent, column, row, parentPath);
2689
+ }
2690
+ addCancelColumn() {
2691
+ this.dataEditor.addCancelColumn();
2692
+ }
2693
+ getCancelColumnProps() {
2694
+ return this.dataEditor.getCancelColumnProps();
2695
+ }
2696
+ isAdded(row) {
2697
+ return this.dataEditor.isAdded(row);
2698
+ }
2699
+ cancelAddedRow(key) {
2700
+ return this.dataEditor.cancelAddedRow(key);
2701
+ }
2702
+ cancelAddedRows() {
2703
+ return this.dataEditor.cancelAddedRows();
2704
+ }
2705
+ getAddedRows() {
2706
+ return this.dataEditor.getAddedRows();
2707
+ }
2708
+ addNewRow(row, position) {
2709
+ return this.dataEditor.addNewRow(row, position);
2710
+ }
2711
+ getVisibleValue(row, column) {
2712
+ return this.dataEditor.getVisibleValue(row, column);
2713
+ }
2714
+ getEditableComponent(column, row) {
2715
+ return this.dataEditor.getEditableComponent(column, row);
2716
+ }
2717
+ isEdited(column, row) {
2718
+ return this.dataEditor.isEdited(column, row);
2719
+ }
2720
+ isValid(column, row, revalidate) {
2721
+ return this.dataEditor.isValid(column, row, revalidate);
2722
+ }
2723
+ checkValid(column, row) {
2724
+ return this.dataEditor.checkValid(column, row);
2725
+ }
2726
+ isGridValid(revalidate) {
2727
+ return this.dataEditor.isGridValid(revalidate);
2728
+ }
2729
+ getComponent(key, columnName) {
2730
+ return this.dataEditor.getComponent(key, columnName);
2731
+ }
2732
+ updateRow(newRow) {
2733
+ this.dataEditor.updateRow(newRow);
2734
+ }
2735
+ updateCell(rowKey, columnName, value) {
2736
+ this.dataEditor.updateCell(rowKey, columnName, value);
2737
+ }
2738
+ setViewEnterEdit(fn) {
2739
+ this.dataEditor.setViewEnterEdit(fn);
2740
+ }
2741
+ enterEdit(rowKey, columnName) {
2742
+ this.dataEditor.enterEdit(rowKey, columnName);
2743
+ }
2744
+ cancelEditedRows() {
2745
+ return this.dataEditor.cancelEditedRows();
2746
+ }
2747
+ saveEditedRows(revalidate) {
2748
+ return this.dataEditor.saveEditedRows(revalidate);
2749
+ }
2750
+ reapplyCanEditRow(row) {
2751
+ return this.dataEditor.reapplyCanEditRow(row);
2752
+ }
2753
+ getCanEditRow(row) {
2754
+ return this.dataEditor.getCanEditRow(row);
2755
+ }
2756
+ getEditedRows(revalidate, silent) {
2757
+ return this.dataEditor.getEditedRows(revalidate, silent);
2758
+ }
2759
+ getEditedRow(row) {
2760
+ return this.dataEditor.getEditedRow(row);
2761
+ }
2762
+ rowClick(row, event, element) {
2763
+ this.tekGridEvents.rowClick(row, event, element);
2764
+ }
2765
+ rowDoubleClick(row, event, element) {
2766
+ this.tekGridEvents.rowDoubleClick(row, event, element);
2767
+ }
2768
+ cellDoubleClick(row, column, event, element) {
2769
+ this.tekGridEvents.cellDoubleClick(row, column, event, element);
2770
+ }
2771
+ inlineEdit(row, column, event, element) {
2772
+ this.tekGridEvents.inlineEdit(row, column, event, element);
2773
+ }
2774
+ cellClick(row, column, event, element) {
2775
+ this.tekGridEvents.cellClick(row, column, event, element);
2776
+ }
2777
+ cellClickEvent(row, column, event, element) {
2778
+ this.tekGridEvents.cellClickEvent(row, column, event, element);
2779
+ }
2780
+ groupRowClick(row, event, element) {
2781
+ this.tekGridEvents.groupRowClick(row, event, element);
2782
+ }
2783
+ groupRowDoubleClick(row, event, element) {
2784
+ this.tekGridEvents.groupRowDoubleClick(row, event, element);
2785
+ }
2786
+ selectGroupClick(row, isSelected, event, element) {
2787
+ this.tekGridEvents.selectGroupClick(row, isSelected, event, element);
2788
+ }
2789
+ async setSearch(search) {
2790
+ const { datasource } = this;
2791
+ if (datasource instanceof TekRestDatasource || datasource instanceof TekMemoryDatasource) {
2792
+ datasource.searchJoin = await this.columnsSearcher.searchColumn(this.columns, search);
2793
+ }
2794
+ datasource.page = 1;
2795
+ return datasource.setSearch(search);
2796
+ }
2797
+ getAtomInstance(key) {
2798
+ return this.tekGridToolbarProvider.getAtomInstance(key);
2799
+ }
2800
+ getAtomName(key) {
2801
+ return this.tekGridToolbarProvider.getAtomName(key);
2802
+ }
2803
+ }
2804
+ Messages.add({
2805
+ 'pt-BR': {
2806
+ translation: {
2807
+ TEKGRID_CONTAINS: 'contém',
2808
+ TEKGRID_NOT_CONTAINS: 'não contém',
2809
+ TEKGRID_EQUALS: 'é igual a',
2810
+ TEKGRID_NOT_EQUALS: 'é diferente de',
2811
+ TEKGRID_GREATER_THAN: 'é maior que',
2812
+ TEKGRID_LESS_THAN: 'é menor que',
2813
+ TEKGRID_GREATER_THAN_EQUALS: 'é maior ou igual a',
2814
+ TEKGRID_LESS_THAN_EQUALS: 'é menor ou igual a',
2815
+ TEKGRID_IN: 'um dos valores',
2816
+ TEKGRID_NOT_IN: 'nenhum dos valores',
2817
+ TEKGRID_BETWEEN: 'está entre',
2818
+ TEKGRID_AND: 'e',
2819
+ TEKGRID_OR: 'ou',
2820
+ TEKGRID_HIDE: 'Esconder Ações',
2821
+ TEKGRID_SHOW: 'Mostrar Ações',
2822
+ TEKGRID_ADD: 'Adicionar',
2823
+ TEKGRID_DELETE: 'Excluir',
2824
+ TEKGRID_REFRESH: 'Atualizar',
2825
+ TEKGRID_COLUMNS: 'Colunas',
2826
+ TEKGRID_SAVE: 'Salvar',
2827
+ TEKGRID_CANCEL: 'Cancelar',
2828
+ TEKGRID_APPLY: 'Aplicar',
2829
+ TEKGRID_FILTER: 'Filtro',
2830
+ TEKGRID_MULTIPLE_VALUE_HINT: 'Separe valores usando ";"',
2831
+ TEKGRID_EXPORT: 'Exportar',
2832
+ TEKGRID_EXPORT_AS: 'Exportar como {{ type }}',
2833
+ TEKGRID_PORTRAIT: 'Retrato',
2834
+ TEKGRID_LANDSCAPE: 'Paisagem',
2835
+ TEKGRID_COLUMN_VISIBLE: 'Visível',
2836
+ TEKGRID_COLUMN_GROUPED: 'Grupo',
2837
+ TEKGRID_COLUMN_AGGREGATION: 'Totalização',
2838
+ TEKGRID_COLUMN_LABEL: 'Rótulo',
2839
+ TEKGRID_COLUMN_ALIGNMENT: 'Alinhamento',
2840
+ TEKGRID_COLUMN_GROUP_OPENED: 'Aberto (grupo)',
2841
+ TEKGRID_COLUMN_ORDER: 'Ordem',
2842
+ TEKGRID_COLUMN_ORDER_DIRECTION: 'Direção (ordem)',
2843
+ TEKGRID_AGGREGATION_SUM: 'Soma',
2844
+ TEKGRID_AGGREGATION_AVG: 'Média',
2845
+ TEKGRID_AGGREGATION_MAX: 'Máximo',
2846
+ TEKGRID_AGGREGATION_MIN: 'Mínimo',
2847
+ TEKGRID_AGGREGATION_COUNT: 'Contador',
2848
+ TEKGRID_MORE_OPTIONS: 'Mais opções',
2849
+ TEKGRID_COLUMNS_OPTIONS: 'Configuração de colunas',
2850
+ TEKGRID_CLOSE: 'Fechar',
2851
+ TEKGRID_FIXED_COLUMNS: 'Colunas fixadas',
2852
+ TEKGRID_VISIBLE_COLUMNS: 'Colunas visíveis',
2853
+ TEKGRID_GROUPED_COLUMNS: 'Colunas agrupadas',
2854
+ TEKGRID_ORDER: 'Ordem',
2855
+ TEKGRID_OTHER_COLUMNS: 'Outras colunas',
2856
+ TEKGRID_DROP_COLUMNS: 'Arraste colunas aqui',
2857
+ TEKGRID_DETAILS_FOR: 'Detalhes para:',
2858
+ TEKGRID_LEFT: 'Esquerda',
2859
+ TEKGRID_CENTER: 'Centro',
2860
+ TEKGRID_RIGHT: 'Direita',
2861
+ TEKGRID_ASC: 'Crescente',
2862
+ TEKGRID_DESC: 'Decrescente',
2863
+ TEKGRID_SELECT_COLUMN: '(selecione uma ou mais colunas)',
2864
+ TEKGRID_SELECT_ALL: 'Selecionar todas',
2865
+ TEKGRID_HELPERVALUE_TODAY: 'Hoje',
2866
+ TEKGRID_HELPERVALUE_TOMORROW: 'Amanhã',
2867
+ TEKGRID_HELPERVALUE_YESTERDAY: 'Ontem',
2868
+ TEKGRID_HELPERVALUE_LAST_7_DAYS: 'Últimos 7 Dias',
2869
+ TEKGRID_HELPERVALUE_NEXT_7_DAYS: 'Próximos 7 Dias',
2870
+ TEKGRID_HELPERVALUE_CURRENT_WEEK: 'Semana Atual',
2871
+ TEKGRID_HELPERVALUE_CURRENT_MONTH: 'Mês Atual',
2872
+ TEKGRID_HELPERVALUE_CURRENT_YEAR: 'Ano Atual',
2873
+ TEKGRID_WITH_GROUPS: '(Com grupos)',
2874
+ TEKGRID_GRID_MIRROR: '(Espelho do grid)',
2875
+ TEKGRID_NO_DATA: 'Não há dados para gerar o relatório',
2876
+ },
2877
+ },
2878
+ 'en-US': {
2879
+ translation: {
2880
+ TEKGRID_CONTAINS: 'contains',
2881
+ TEKGRID_NOT_CONTAINS: 'does not contain',
2882
+ TEKGRID_EQUALS: 'is equal to',
2883
+ TEKGRID_NOT_EQUALS: 'is different from',
2884
+ TEKGRID_GREATER_THAN: 'is greater than',
2885
+ TEKGRID_LESS_THAN: 'is less than',
2886
+ TEKGRID_GREATER_THAN_EQUALS: 'is greater or equals to',
2887
+ TEKGRID_LESS_THAN_EQUALS: 'is less or equals to',
2888
+ TEKGRID_IN: 'is in',
2889
+ TEKGRID_NOT_IN: 'is not in',
2890
+ TEKGRID_BETWEEN: 'is between',
2891
+ TEKGRID_AND: 'and',
2892
+ TEKGRID_OR: 'or',
2893
+ TEKGRID_HIDE: 'Hide Actions',
2894
+ TEKGRID_SHOW: 'Show Actions',
2895
+ TEKGRID_ADD: 'Add',
2896
+ TEKGRID_DELETE: 'Delete',
2897
+ TEKGRID_REFRESH: 'Refresh',
2898
+ TEKGRID_COLUMNS: 'Columns',
2899
+ TEKGRID_SAVE: 'Save',
2900
+ TEKGRID_CANCEL: 'Cancel',
2901
+ TEKGRID_APPLY: 'Apply',
2902
+ TEKGRID_FILTER: 'Filter',
2903
+ TEKGRID_MULTIPLE_VALUE_HINT: 'Separate values using ";"',
2904
+ TEKGRID_EXPORT: 'Export',
2905
+ TEKGRID_EXPORT_AS: 'Export as {{ type }}',
2906
+ TEKGRID_PORTRAIT: 'Portrait',
2907
+ TEKGRID_LANDSCAPE: 'Landscape',
2908
+ TEKGRID_COLUMN_VISIBLE: 'Visible',
2909
+ TEKGRID_COLUMN_GROUPED: 'Grouped',
2910
+ TEKGRID_COLUMN_AGGREGATION: 'Aggregation',
2911
+ TEKGRID_COLUMN_LABEL: 'Label',
2912
+ TEKGRID_COLUMN_ALIGNMENT: 'Alignment',
2913
+ TEKGRID_COLUMN_GROUP_OPENED: 'Opened (group)',
2914
+ TEKGRID_COLUMN_ORDER: 'Order',
2915
+ TEKGRID_COLUMN_ORDER_DIRECTION: 'Direction (order)',
2916
+ TEKGRID_AGGREGATION_SUM: 'Sum',
2917
+ TEKGRID_AGGREGATION_AVG: 'Average',
2918
+ TEKGRID_AGGREGATION_MAX: 'Maximum',
2919
+ TEKGRID_AGGREGATION_MIN: 'Minimum',
2920
+ TEKGRID_AGGREGATION_COUNT: 'Count',
2921
+ TEKGRID_MORE_OPTIONS: 'More options',
2922
+ TEKGRID_COLUMNS_OPTIONS: 'Columns configuration',
2923
+ TEKGRID_CLOSE: 'Close',
2924
+ TEKGRID_FIXED_COLUMNS: 'Fixed columns',
2925
+ TEKGRID_VISIBLE_COLUMNS: 'Visible columns',
2926
+ TEKGRID_GROUPED_COLUMNS: 'Grouped columns',
2927
+ TEKGRID_ORDER: 'Order',
2928
+ TEKGRID_OTHER_COLUMNS: 'Other columns',
2929
+ TEKGRID_DROP_COLUMNS: 'Drop columns here',
2930
+ TEKGRID_DETAILS_FOR: 'Details for:',
2931
+ TEKGRID_LEFT: 'Left',
2932
+ TEKGRID_CENTER: 'Center',
2933
+ TEKGRID_RIGHT: 'Right',
2934
+ TEKGRID_ASC: 'Ascending',
2935
+ TEKGRID_DESC: 'Descending',
2936
+ TEKGRID_SELECT_COLUMN: '(select one or more columns)',
2937
+ TEKGRID_SELECT_ALL: 'Select all',
2938
+ TEKGRID_HELPERVALUE_TODAY: 'Today',
2939
+ TEKGRID_HELPERVALUE_TOMORROW: 'Tomorrow',
2940
+ TEKGRID_HELPERVALUE_YESTERDAY: 'Yesterday',
2941
+ TEKGRID_HELPERVALUE_LAST_7_DAYS: 'Last 7 Days',
2942
+ TEKGRID_HELPERVALUE_NEXT_7_DAYS: 'Next 7 Days',
2943
+ TEKGRID_HELPERVALUE_CURRENT_WEEK: 'Current Week',
2944
+ TEKGRID_HELPERVALUE_CURRENT_MONTH: 'Current Month',
2945
+ TEKGRID_HELPERVALUE_CURRENT_YEAR: 'Current Year',
2946
+ TEKGRID_WITH_GROUPS: '(With groups)',
2947
+ TEKGRID_GRID_MIRROR: '(Grid mirror)',
2948
+ TEKGRID_NO_DATA: 'There is no data to generate the report',
2949
+ },
2950
+ },
2951
+ 'es-CL': {
2952
+ translation: {
2953
+ TEKGRID_CONTAINS: 'contiene',
2954
+ TEKGRID_NOT_CONTAINS: 'no contiene',
2955
+ TEKGRID_EQUALS: 'igual',
2956
+ TEKGRID_NOT_EQUALS: 'es diferente de',
2957
+ TEKGRID_GREATER_THAN: 'es mayor que',
2958
+ TEKGRID_LESS_THAN: 'es menor que',
2959
+ TEKGRID_GREATER_THAN_EQUALS: 'es mayor o igual que',
2960
+ TEKGRID_LESS_THAN_EQUALS: 'es menor o igual que',
2961
+ TEKGRID_IN: 'uno de los valores',
2962
+ TEKGRID_NOT_IN: 'ninguno de los valores',
2963
+ TEKGRID_BETWEEN: 'está entre',
2964
+ TEKGRID_AND: 'e',
2965
+ TEKGRID_OR: 'o',
2966
+ TEKGRID_HIDE: 'Ocultar Acciones',
2967
+ TEKGRID_SHOW: 'Mostrar Acciones',
2968
+ TEKGRID_ADD: 'Añadir',
2969
+ TEKGRID_DELETE: 'Eliminar',
2970
+ TEKGRID_REFRESH: 'Actualizar',
2971
+ TEKGRID_COLUMNS: 'Colunas',
2972
+ TEKGRID_SAVE: 'Guardar',
2973
+ TEKGRID_CANCEL: 'Cancelar',
2974
+ TEKGRID_APPLY: 'Aplicar',
2975
+ TEKGRID_FILTER: 'Filtro',
2976
+ TEKGRID_MULTIPLE_VALUE_HINT: 'Separe los valores usando ";"',
2977
+ TEKGRID_EXPORT: 'Exportar',
2978
+ TEKGRID_EXPORT_AS: 'Exportar como {{ type }}',
2979
+ TEKGRID_PORTRAIT: 'Vertical',
2980
+ TEKGRID_LANDSCAPE: 'Horizontal',
2981
+ TEKGRID_COLUMN_VISIBLE: 'Visible',
2982
+ TEKGRID_COLUMN_GROUPED: 'Grupo',
2983
+ TEKGRID_COLUMN_AGGREGATION: 'Totalización',
2984
+ TEKGRID_COLUMN_LABEL: 'Etiqueta',
2985
+ TEKGRID_COLUMN_ALIGNMENT: 'alineación',
2986
+ TEKGRID_COLUMN_GROUP_OPENED: 'Abierto (grupo)',
2987
+ TEKGRID_COLUMN_ORDER: 'Orden',
2988
+ TEKGRID_COLUMN_ORDER_DIRECTION: 'Dirección (orden)',
2989
+ TEKGRID_AGGREGATION_SUM: 'Suma',
2990
+ TEKGRID_AGGREGATION_AVG: 'Media',
2991
+ TEKGRID_AGGREGATION_MAX: 'Máximo',
2992
+ TEKGRID_AGGREGATION_MIN: 'Mínimo',
2993
+ TEKGRID_AGGREGATION_COUNT: 'Contar',
2994
+ TEKGRID_MORE_OPTIONS: 'Mas opciones',
2995
+ TEKGRID_COLUMNS_OPTIONS: 'Configuración de columna',
2996
+ TEKGRID_CLOSE: 'Cerrar',
2997
+ TEKGRID_FIXED_COLUMNS: 'Columnas fijas',
2998
+ TEKGRID_VISIBLE_COLUMNS: 'Columnas visibles',
2999
+ TEKGRID_GROUPED_COLUMNS: 'Columnas agrupadas',
3000
+ TEKGRID_ORDER: 'Orden',
3001
+ TEKGRID_OTHER_COLUMNS: 'Otras columnas',
3002
+ TEKGRID_DROP_COLUMNS: 'Arrastra columnas aquí',
3003
+ TEKGRID_DETAILS_FOR: 'Detalles para',
3004
+ TEKGRID_LEFT: 'Izquierda',
3005
+ TEKGRID_CENTER: 'Centro',
3006
+ TEKGRID_RIGHT: 'Derecha',
3007
+ TEKGRID_ASC: 'Creciente',
3008
+ TEKGRID_DESC: 'Decreciente',
3009
+ TEKGRID_SELECT_COLUMN: '(seleccione una o más columnas)',
3010
+ TEKGRID_SELECT_ALL: 'Seleccionar todas',
3011
+ TEKGRID_HELPERVALUE_TODAY: 'Hoy',
3012
+ TEKGRID_HELPERVALUE_TOMORROW: 'Mañana',
3013
+ TEKGRID_HELPERVALUE_YESTERDAY: 'Ayer',
3014
+ TEKGRID_HELPERVALUE_LAST_7_DAYS: 'Últimos 7 días',
3015
+ TEKGRID_HELPERVALUE_NEXT_7_DAYS: 'Próximos 7 días',
3016
+ TEKGRID_HELPERVALUE_CURRENT_WEEK: 'Semana actual',
3017
+ TEKGRID_HELPERVALUE_CURRENT_MONTH: 'Mes actual',
3018
+ TEKGRID_HELPERVALUE_CURRENT_YEAR: 'Año actual',
3019
+ TEKGRID_WITH_GROUPS: '(Con grupos)',
3020
+ TEKGRID_GRID_MIRROR: '(Espejo de grid)',
3021
+ TEKGRID_NO_DATA: 'No hay datos para generar el reporte',
3022
+ },
3023
+ },
3024
+ });
3025
+ Messages.add({
3026
+ 'pt-BR': {
3027
+ translation: {
3028
+ NO_NOTIFICATIONS: 'Nenhuma Notificação',
3029
+ MARK_ALL_AS_READ: 'Marcar todas como lidas',
3030
+ NOTIFICATIONS: 'Notificações',
3031
+ SEE_ALL_NOTIFICATIONS: 'Ver todas notificações',
3032
+ UNAVAILABLE_IMAGE: 'Imagem indisponível',
3033
+ REFRESH: 'Atualizar',
3034
+ ACTIONS: 'Ações',
3035
+ FILTER: 'Filtro',
3036
+ LAYOUT: 'Layout: ',
3037
+ NEW_LAYOUT: 'Novo layout',
3038
+ DEFAULT_LAYOUT: 'Padrão',
3039
+ LAYOUT_MODIFIED: 'O layout atual foi modificado. Crie um novo layout, sobrescreva um existente ou descarte as alterações',
3040
+ LAYOUT_NOT_MODIFIED: 'Crie um novo layout ou aplique um dos layouts já existentes',
3041
+ LAYOUT_DISCART_CHANGES: 'Descartar alterações',
3042
+ },
3043
+ },
3044
+ 'en-US': {
3045
+ translation: {
3046
+ NO_NOTIFICATIONS: 'No Notifications',
3047
+ MARK_ALL_AS_READ: 'Mark all as read',
3048
+ NOTIFICATIONS: 'Notifications',
3049
+ SEE_ALL_NOTIFICATIONS: 'See all notifications',
3050
+ UNAVAILABLE_IMAGE: 'Unavailable image',
3051
+ REFRESH: 'Refresh',
3052
+ ACTIONS: 'Actions',
3053
+ FILTER: 'Filter',
3054
+ LAYOUT: 'Layout: ',
3055
+ NEW_LAYOUT: 'New layout',
3056
+ DEFAULT_LAYOUT: 'Default',
3057
+ LAYOUT_MODIFIED: 'The current layout has been modified. Create a new layout, overwrite an existing one or discard changes',
3058
+ LAYOUT_NOT_MODIFIED: 'Create a new layout or apply one of the existing layouts',
3059
+ LAYOUT_DISCART_CHANGES: 'Discard changes',
3060
+ },
3061
+ },
3062
+ 'es-CL': {
3063
+ translation: {
3064
+ NO_NOTIFICATIONS: 'Sin Notificación',
3065
+ MARK_ALL_AS_READ: 'Marcar todo como leído',
3066
+ NOTIFICATIONS: 'Notificaciones',
3067
+ SEE_ALL_NOTIFICATIONS: 'Ver todas las notificaciones',
3068
+ UNAVAILABLE_IMAGE: 'Imagen no disponible',
3069
+ REFRESH: 'Actualizar',
3070
+ ACTIONS: 'Acciones',
3071
+ FILTER: 'Filtro',
3072
+ LAYOUT: 'Disposición: ',
3073
+ NEW_LAYOUT: 'Nueva disposición',
3074
+ DEFAULT_LAYOUT: 'Default',
3075
+ LAYOUT_MODIFIED: 'La disposición actual ha sido modificada. Cree una nueva disposición, sobrescriba una existente o descarte los cambios',
3076
+ LAYOUT_NOT_MODIFIED: 'Cree una nueva disposición o aplique una de las disposiciones existentes',
3077
+ LAYOUT_DISCART_CHANGES: 'Descartar los cambios',
3078
+ },
3079
+ },
3080
+ });
3081
+
3082
+ class TekGridLayoutOptions extends ComponentRender {
3083
+ currentLayoutName = '';
3084
+ layoutEdited = false;
3085
+ layouts = {};
3086
+ layoutNames = [];
3087
+ viewApplyLayout;
3088
+ viewGetCurrentLayout;
3089
+ originalColumnProps = [];
3090
+ originalDatasourceOrder = [];
3091
+ originalDatasourceDynamicFilter = {};
3092
+ originalDatasourceFilter = {};
3093
+ grid;
3094
+ getParentGrid() {
3095
+ let { parent } = this;
3096
+ while (parent && !(parent.constructor === Iterable || parent.constructor.prototype instanceof Iterable)) {
3097
+ parent = parent.parent;
3098
+ }
3099
+ return parent;
3100
+ }
3101
+ async onMounted(element) {
3102
+ super.onMounted(element);
3103
+ this.grid = this.getParentGrid();
3104
+ this.originalDatasourceOrder = [...this.grid.datasource.order];
3105
+ this.originalDatasourceDynamicFilter = {
3106
+ ...this.grid.datasource.dynamicFilter,
3107
+ };
3108
+ this.originalDatasourceFilter = { ...this.grid.datasource.filter };
3109
+ this.originalColumnProps = this.grid.columns.map((column) => ({
3110
+ name: column.name,
3111
+ label: column.label,
3112
+ align: column.align,
3113
+ isVisible: column.isVisible,
3114
+ minWidth: column.minWidth,
3115
+ maxWidth: column.maxWidth,
3116
+ width: column.width,
3117
+ fixed: column.fixed,
3118
+ grouped: column.grouped,
3119
+ groupOpened: column.groupOpened,
3120
+ aggregation: column.aggregation,
3121
+ filterHelperValue: this.getHelperValue(column),
3122
+ }));
3123
+ let layoutsInfo = {};
3124
+ const promise = this.loadLayoutsInfo();
3125
+ if (this.grid instanceof TekGrid) {
3126
+ this.grid.registerTask(promise);
3127
+ }
3128
+ layoutsInfo = await promise;
3129
+ if (layoutsInfo.layouts) {
3130
+ this.layouts = layoutsInfo.layouts;
3131
+ this.layoutNames = Object.keys(this.layouts);
3132
+ if (layoutsInfo.currentLayoutName) {
3133
+ this.currentLayoutName = layoutsInfo.currentLayoutName;
3134
+ this.applyLayout(this.currentLayoutName, false);
3135
+ }
3136
+ }
3137
+ }
3138
+ async loadLayoutsInfo() {
3139
+ const eventFunction = this.events.loadLayouts || this.grid.events.loadLayouts;
3140
+ if (eventFunction && typeof eventFunction === 'function') {
3141
+ return eventFunction({ component: this.grid });
3142
+ }
3143
+ if (Config.loadGridLayoutsEndPoint) {
3144
+ const route = Config.loadGridLayoutsEndPoint;
3145
+ const response = await Http.get(`${route}?id=${this.grid.name}`);
3146
+ const responseData = response.data.data;
3147
+ return responseData.length && responseData[0] ? responseData[0].layouts : responseData.layouts || {};
3148
+ }
3149
+ return JSON.parse(localStorage.getItem(this.grid.name) || '{}');
3150
+ }
3151
+ getHelperValue(column) {
3152
+ if (column instanceof TekGridColumn) {
3153
+ if (!Array.isArray(column.filterProps))
3154
+ return column.filterProps.helperValue;
3155
+ return column.filterProps.map((prop) => prop.helperValue);
3156
+ }
3157
+ return '';
3158
+ }
3159
+ newLayout(layout) {
3160
+ this.fixColumns(layout);
3161
+ this.currentLayoutName = layout.name;
3162
+ this.addLayout(layout);
3163
+ this.layoutEdited = false;
3164
+ }
3165
+ addLayout(layout) {
3166
+ this.fixColumns(layout);
3167
+ this.layouts[layout.name] = layout;
3168
+ this.saveLayouts();
3169
+ }
3170
+ discardChanges() {
3171
+ const layoutSelected = this.layouts[this.currentLayoutName];
3172
+ if (this.viewApplyLayout) {
3173
+ this.viewApplyLayout(layoutSelected);
3174
+ }
3175
+ this.layoutEdited = false;
3176
+ }
3177
+ applyLayout(name, save = true) {
3178
+ this.currentLayoutName = name;
3179
+ const layoutSelected = this.layouts[name];
3180
+ if (this.viewApplyLayout) {
3181
+ this.viewApplyLayout(layoutSelected);
3182
+ }
3183
+ if (save) {
3184
+ this.saveLayouts();
3185
+ }
3186
+ this.layoutEdited = false;
3187
+ }
3188
+ saveLayouts() {
3189
+ this.layoutNames = Object.keys(this.layouts);
3190
+ const layoutInfo = {
3191
+ currentLayoutName: this.currentLayoutName,
3192
+ layouts: this.layouts,
3193
+ };
3194
+ const eventFunction = this.events.saveLayouts || this.grid.events.saveLayouts;
3195
+ if (eventFunction && typeof eventFunction === 'function') {
3196
+ eventFunction({ component: this.grid, layouts: layoutInfo });
3197
+ }
3198
+ else if (Config.saveGridLayoutsEndPoint) {
3199
+ const route = Config.saveGridLayoutsEndPoint;
3200
+ Http.post(route, { id: this.grid.name, layouts: layoutInfo });
3201
+ }
3202
+ else {
3203
+ localStorage.setItem(this.grid.name, JSON.stringify(layoutInfo));
3204
+ }
3205
+ }
3206
+ deleteLayout(name) {
3207
+ if (this.currentLayoutName === name) {
3208
+ this.currentLayoutName = '';
3209
+ this.applyLayout(this.currentLayoutName, false);
3210
+ }
3211
+ delete this.layouts[name];
3212
+ this.saveLayouts();
3213
+ }
3214
+ updateLayout(name, layout) {
3215
+ this.fixColumns(layout);
3216
+ this.currentLayoutName = name;
3217
+ layout.name = name;
3218
+ this.layouts[layout.name] = layout;
3219
+ this.saveLayouts();
3220
+ this.layoutEdited = false;
3221
+ }
3222
+ updateDefaultLayout(layout) {
3223
+ this.fixColumns(layout);
3224
+ this.originalDatasourceOrder = layout.order || this.originalDatasourceOrder;
3225
+ this.originalDatasourceDynamicFilter = layout.dynamicFilter || this.originalDatasourceDynamicFilter;
3226
+ this.originalDatasourceFilter = layout.filter || this.originalDatasourceFilter;
3227
+ if (layout.columns) {
3228
+ this.originalColumnProps = layout.columns.map((column) => {
3229
+ const originalColumnIdx = this.originalColumnProps.findIndex((item) => item.name === column.name);
3230
+ const originalColumn = originalColumnIdx !== -1 ? this.originalColumnProps[originalColumnIdx] : {};
3231
+ return {
3232
+ ...originalColumn,
3233
+ ...column,
3234
+ };
3235
+ });
3236
+ }
3237
+ if (this.currentLayoutName === '') {
3238
+ this.applyLayout(this.currentLayoutName, false);
3239
+ }
3240
+ }
3241
+ fixColumns(layout) {
3242
+ const hasLayoutColumns = !!layout.columns;
3243
+ layout.columns = layout.columns || [];
3244
+ const layoutColumnNames = layout.columns.map((layoutColumn) => layoutColumn.name);
3245
+ this.grid.columns.forEach((gridColumn) => {
3246
+ if (!hasLayoutColumns || layoutColumnNames.indexOf(gridColumn.name) === -1) {
3247
+ layout.columns.push({
3248
+ name: gridColumn.name,
3249
+ label: gridColumn.label,
3250
+ align: gridColumn.align,
3251
+ isVisible: !hasLayoutColumns && gridColumn.isVisible,
3252
+ width: gridColumn.width,
3253
+ minWidth: gridColumn.minWidth,
3254
+ maxWidth: gridColumn.maxWidth,
3255
+ fixed: gridColumn.fixed,
3256
+ grouped: gridColumn.grouped,
3257
+ groupOpened: gridColumn.groupOpened,
3258
+ aggregation: gridColumn.aggregation,
3259
+ filterHelperValue: this.getHelperValue(gridColumn),
3260
+ });
3261
+ }
3262
+ });
3263
+ }
3264
+ }
3265
+
3266
+ class TekGridColumnsButtonController extends IterableColumnsButtonController {
3267
+ changeGroupedColumn(column, { component, event, element }) {
3268
+ column.grouped = component.value;
3269
+ if (!column.grouped) {
3270
+ const index = this.iterableComponent.datasource.order.indexOf(`${column.name}.asc`);
3271
+ this.iterableComponent.datasource.order.splice(index, 1);
3272
+ }
3273
+ this.iterableComponent.changeLayout(event, element);
3274
+ }
3275
+ changeAggregationColumn(column, { component, event, element }) {
3276
+ const newValue = component.value || undefined;
3277
+ if (column.aggregation !== newValue) {
3278
+ this.iterableComponent.changeLayout(event, element);
3279
+ }
3280
+ column.aggregation = newValue;
3281
+ }
3282
+ showHideTekColumn(column, { component, event, element }) {
3283
+ if (!component.value && column.grouped)
3284
+ column.grouped = false;
3285
+ column.isVisible = component.value;
3286
+ this.iterableComponent.changeLayout(event, element);
3287
+ }
3288
+ }
3289
+
3290
+ /**
3291
+ * Base class for TekGrid Columns Button component
3292
+ */
3293
+ class TekGridColumnsButton extends IterableColumnsButton {
3294
+ hideGroups = false;
3295
+ constructor(props) {
3296
+ super(props);
3297
+ this.hideGroups = this.getInitValue('hideGroups', props.hideGroups, this.hideGroups);
3298
+ this.createAccessors();
3299
+ }
3300
+ onCreated() {
3301
+ super.onCreated();
3302
+ Loader.addController(`IterableColumnsButtonController_${this.name}`, TekGridColumnsButtonController, [
3303
+ this.iterableComponent,
3304
+ ]);
3305
+ this.controller = Loader.getInstance(`IterableColumnsButtonController_${this.name}`);
3306
+ }
3307
+ aggregationDataSet = [];
3308
+ getAggregationSelectData() {
3309
+ if (!this.aggregationDataSet.length) {
3310
+ this.aggregationDataSet = columnAggregationValues.filter(Boolean).map((value) => ({
3311
+ text: I18n.translate(`TEKGRID_AGGREGATION_${value}`),
3312
+ value,
3313
+ }));
3314
+ }
3315
+ return this.aggregationDataSet;
3316
+ }
3317
+ }
3318
+
3319
+ class TekUserInfoController {
3320
+ component;
3321
+ get versionInfo() {
3322
+ return this.component.versionInfo;
3323
+ }
3324
+ constructor(component) {
3325
+ this.component = component;
3326
+ }
3327
+ get name() {
3328
+ return this.versionInfo?.name || '';
3329
+ }
3330
+ set name(value) {
3331
+ if (!this.versionInfo)
3332
+ return;
3333
+ this.versionInfo.name = value;
3334
+ }
3335
+ get version() {
3336
+ return this.versionInfo?.version || '';
3337
+ }
3338
+ set version(value) {
3339
+ if (!this.versionInfo)
3340
+ return;
3341
+ this.versionInfo.version = value;
3342
+ }
3343
+ get hasDefaultEmail() {
3344
+ return !!this.component.defaultEmail;
3345
+ }
3346
+ get hasAboutImage() {
3347
+ return !!this.component.aboutImage;
3348
+ }
3349
+ mergeText(name, version) {
3350
+ return `<li>${name} - <b>${version}</b></li>`;
3351
+ }
3352
+ get mainVersion() {
3353
+ if (!this.versionInfo?.name || !this.versionInfo.version)
3354
+ return '';
3355
+ return `${this.versionInfo.name} - <b>${this.versionInfo.version}</b>`;
3356
+ }
3357
+ getItems(tab) {
3358
+ if (!this.versionInfo)
3359
+ return [];
3360
+ const tabInfo = this.versionInfo[tab];
3361
+ return `<ul>${tabInfo.map((item) => this.mergeText(item.name, item.version)).join('')}</ul>`;
3362
+ }
3363
+ get frontendItems() {
3364
+ return this.getItems('frontend');
3365
+ }
3366
+ get backendItems() {
3367
+ return this.getItems('backend');
3368
+ }
3369
+ get modulesItems() {
3370
+ return this.getItems('modules');
3371
+ }
3372
+ get showReportError() {
3373
+ const { reportError } = this.component.visibleItems;
3374
+ return reportError || reportError === undefined;
3375
+ }
3376
+ get showVersionInfo() {
3377
+ const { versionInfo } = this.component.visibleItems;
3378
+ return versionInfo || versionInfo === undefined;
3379
+ }
3380
+ get showAbout() {
3381
+ const { about } = this.component.visibleItems;
3382
+ return about || about === undefined;
3383
+ }
3384
+ }
3385
+
3386
+ class TekUserInfo extends UserInfo {
3387
+ aboutModal;
3388
+ reportModal;
3389
+ /**
3390
+ * Data about the application version
3391
+ */
3392
+ versionInfo = null;
3393
+ /**
3394
+ * Default email address to be defined in the Report Bug form
3395
+ */
3396
+ defaultEmail = '';
3397
+ /**
3398
+ * Url from which the version info will be retrieved
3399
+ */
3400
+ versionUrl = '';
3401
+ /**
3402
+ * Path to the image to be shown on about modal
3403
+ */
3404
+ aboutImage = '';
3405
+ propBottomSlot;
3406
+ constructor(props) {
3407
+ super(props);
3408
+ this.versionInfo = this.getInitValue('versionInfo', props.versionInfo, this.versionInfo);
3409
+ this.defaultEmail = this.getInitValue('defaultEmail', props.defaultEmail, this.defaultEmail);
3410
+ this.versionUrl = this.getInitValue('versionUrl', props.versionUrl, this.versionUrl);
3411
+ this.aboutImage = this.getInitValue('aboutImage', props.aboutImage, this.aboutImage);
3412
+ this.createAccessors();
3413
+ this.propBottomSlot = props.bottomSlot;
3414
+ }
3415
+ getBottomSlot() {
3416
+ return [
3417
+ {
3418
+ name: `${this.name}_bottom_list`,
3419
+ component: 'TekUserInfoList',
3420
+ parentName: this.name,
3421
+ },
3422
+ ];
3423
+ }
3424
+ onAboutClick() {
3425
+ if (!this.aboutModal) {
3426
+ this.aboutModal = ModalService.create({
3427
+ name: `${this.name}_about_modal`,
3428
+ cssClass: 'about-modal',
3429
+ grid: { cols: 8, sm: 4, lg: 5 },
3430
+ children: [
3431
+ {
3432
+ name: `${this.name}_about_header`,
3433
+ component: 'ZdHeader',
3434
+ color: 'transparent',
3435
+ padless: true,
3436
+ elevation: 0,
3437
+ rightSlot: [
3438
+ {
3439
+ name: `${this.name}_about_close_button`,
3440
+ component: 'ZdModalCloseButton',
3441
+ small: true,
3442
+ modalName: `${this.name}_about_modal`,
3443
+ },
3444
+ ],
3445
+ },
3446
+ {
3447
+ name: `${this.name}_about_row`,
3448
+ component: 'ZdTag',
3449
+ tag: 'div',
3450
+ cssClass: 'zd-justify-center zd-px-6',
3451
+ isVisible: `{{TekUserInfoController_${this.componentId}.hasAboutImage}}`,
3452
+ children: [
3453
+ {
3454
+ name: `${this.name}_about_image`,
3455
+ component: 'ZdImage',
3456
+ width: '100%',
3457
+ src: this.aboutImage,
3458
+ },
3459
+ ],
3460
+ },
3461
+ {
3462
+ name: `${this.name}_version_tabs`,
3463
+ cssClass: 'zd-pt-3 zd-tekUserInfo-tab',
3464
+ component: 'ZdTabs',
3465
+ tabs: [
3466
+ {
3467
+ name: `${this.name}_version_frontend_tab`,
3468
+ tabTitle: 'Frontend',
3469
+ children: this.getVersionTree('frontend'),
3470
+ },
3471
+ {
3472
+ name: `${this.name}_version_backend_tab`,
3473
+ tabTitle: 'Backend',
3474
+ children: this.getVersionTree('backend'),
3475
+ },
3476
+ {
3477
+ name: `${this.name}_version_modules_tab`,
3478
+ tabTitle: 'Modules',
3479
+ children: this.getVersionTree('modules'),
3480
+ },
3481
+ ],
3482
+ },
3483
+ ],
3484
+ });
3485
+ }
3486
+ this.aboutModal.show();
3487
+ }
3488
+ getVersionTree(tab) {
3489
+ if (!this.versionInfo)
3490
+ return [];
3491
+ const main = {
3492
+ name: `${this.name}_version_${tab}_main`,
3493
+ component: 'ZdText',
3494
+ text: `{{TekUserInfoController_${this.componentId}.mainVersion}}`,
3495
+ };
3496
+ const itemsComponent = {
3497
+ name: `${this.name}_version_${tab}`,
3498
+ component: 'ZdText',
3499
+ cssClass: 'zd-pl-4',
3500
+ text: `{{TekUserInfoController_${this.componentId}.${tab}Items}}`,
3501
+ };
3502
+ return [main, itemsComponent];
3503
+ }
3504
+ onReportClick() {
3505
+ if (!this.reportModal) {
3506
+ this.reportModal = ModalService.create({
3507
+ name: `${this.name}_report_modal`,
3508
+ children: [
3509
+ {
3510
+ name: `${this.name}_report_header`,
3511
+ component: 'ZdHeader',
3512
+ color: 'transparent',
3513
+ padless: true,
3514
+ elevation: 0,
3515
+ leftSlot: [
3516
+ {
3517
+ name: `${this.name}_report_title`,
3518
+ component: 'ZdText',
3519
+ text: 'TEKUSERINFO_REPORT_ERROR',
3520
+ cssClass: 'zd-theme-font-title',
3521
+ },
3522
+ ],
3523
+ rightSlot: [
3524
+ {
3525
+ name: `${this.name}_report_close_button`,
3526
+ component: 'ZdModalCloseButton',
3527
+ small: true,
3528
+ modalName: `${this.name}_report_modal`,
3529
+ },
3530
+ ],
3531
+ },
3532
+ {
3533
+ name: `${this.name}_report_form`,
3534
+ component: 'ZdForm',
3535
+ cssClass: 'zd-pt-4',
3536
+ children: [
3537
+ {
3538
+ name: 'report_email',
3539
+ component: 'ZdTextInput',
3540
+ label: 'E-mail',
3541
+ grid: {
3542
+ cols: '12',
3543
+ },
3544
+ value: this.defaultEmail,
3545
+ readonly: `{{TekUserInfoController_${this.componentId}.hasDefaultEmail}}`,
3546
+ validations: {
3547
+ required: {},
3548
+ email: {},
3549
+ },
3550
+ },
3551
+ {
3552
+ name: 'report_cc',
3553
+ component: 'ZdTextInput',
3554
+ label: 'CC',
3555
+ placeholder: 'TEKUSERINFO_EMAIL_PLACEHOLDER',
3556
+ grid: {
3557
+ cols: '12',
3558
+ },
3559
+ },
3560
+ {
3561
+ name: 'report_type',
3562
+ component: 'ZdSelect',
3563
+ label: 'TEKUSERINFO_TYPE',
3564
+ dataValue: 'value',
3565
+ dataText: 'text',
3566
+ datasource: {
3567
+ uniqueKey: 'value',
3568
+ translate: true,
3569
+ data: [
3570
+ { value: '0', text: 'TEKUSERINFO_ERROR' },
3571
+ { value: '1', text: 'TEKUSERINFO_IMPROVEMENT' },
3572
+ ],
3573
+ },
3574
+ grid: {
3575
+ cols: '12',
3576
+ },
3577
+ validations: {
3578
+ required: {},
3579
+ },
3580
+ },
3581
+ {
3582
+ name: 'report_description',
3583
+ component: 'ZdTextarea',
3584
+ label: 'TEKUSERINFO_DESCRIPTION',
3585
+ grid: {
3586
+ cols: '12',
3587
+ },
3588
+ validations: {
3589
+ required: {},
3590
+ },
3591
+ },
3592
+ ],
3593
+ },
3594
+ {
3595
+ name: `${this.name}_report_footer`,
3596
+ component: 'ZdFooter',
3597
+ color: 'transparent',
3598
+ padless: true,
3599
+ rightSlot: [
3600
+ {
3601
+ name: `${this.name}_report_cancel`,
3602
+ component: 'ZdButton',
3603
+ label: 'TEKUSERINFO_CANCEL',
3604
+ outline: true,
3605
+ events: {
3606
+ click: () => { this.reportModal?.hide(); },
3607
+ },
3608
+ },
3609
+ {
3610
+ name: `${this.name}_report_send`,
3611
+ component: 'ZdButton',
3612
+ label: 'TEKUSERINFO_SEND',
3613
+ events: {
3614
+ click: (args) => this.onSendReport(args),
3615
+ },
3616
+ },
3617
+ ],
3618
+ },
3619
+ ],
3620
+ });
3621
+ }
3622
+ this.reportModal.show();
3623
+ }
3624
+ async onSendReport({ event, element }) {
3625
+ if (!this.reportModal)
3626
+ return;
3627
+ const form = Metadata.getInstance(`${this.name}_report_form`);
3628
+ const validation = await form.validate();
3629
+ if (!validation.valid)
3630
+ return;
3631
+ this.callEvent('onSendReport', {
3632
+ event, element, component: this, form,
3633
+ });
3634
+ this.reportModal.hide();
3635
+ }
3636
+ onCreated() {
3637
+ super.onCreated();
3638
+ Loader.addController(`TekUserInfoController_${this.componentId}`, TekUserInfoController, [this]);
3639
+ this.bottomSlot = this.propBottomSlot ? this.propBottomSlot : this.getBottomSlot();
3640
+ }
3641
+ async onMounted(element) {
3642
+ super.onMounted(element);
3643
+ if (this.versionUrl) {
3644
+ const res = await Http.get(this.versionUrl);
3645
+ this.versionInfo = res.data.versionInfo;
3646
+ }
3647
+ }
3648
+ }
3649
+ Messages.add({
3650
+ 'pt-BR': {
3651
+ translation: {
3652
+ TEKUSERINFO_ABOUT: 'Sobre',
3653
+ TEKUSERINFO_REPORT_ERROR: 'Reportar Erro',
3654
+ TEKUSERINFO_EMAIL_PLACEHOLDER: 'Separe e-mails usando ";"',
3655
+ TEKUSERINFO_TYPE: 'Tipo',
3656
+ TEKUSERINFO_ERROR: 'Erro',
3657
+ TEKUSERINFO_IMPROVEMENT: 'Melhoria',
3658
+ TEKUSERINFO_DESCRIPTION: 'Descrição',
3659
+ TEKUSERINFO_CANCEL: 'Cancelar',
3660
+ TEKUSERINFO_SEND: 'Enviar',
3661
+ },
3662
+ },
3663
+ 'en-US': {
3664
+ translation: {
3665
+ TEKUSERINFO_ABOUT: 'About',
3666
+ TEKUSERINFO_REPORT_ERROR: 'Report Bug',
3667
+ TEKUSERINFO_EMAIL_PLACEHOLDER: 'Separate e-mails using ";"',
3668
+ TEKUSERINFO_TYPE: 'Type',
3669
+ TEKUSERINFO_ERROR: 'Bug',
3670
+ TEKUSERINFO_IMPROVEMENT: 'Improvement',
3671
+ TEKUSERINFO_DESCRIPTION: 'Description',
3672
+ TEKUSERINFO_CANCEL: 'Cancel',
3673
+ TEKUSERINFO_SEND: 'Send',
3674
+ },
3675
+ },
3676
+ 'es-CL': {
3677
+ translation: {
3678
+ TEKUSERINFO_ABOUT: 'Sobre',
3679
+ TEKUSERINFO_REPORT_ERROR: 'Reportar Error',
3680
+ TEKUSERINFO_EMAIL_PLACEHOLDER: 'Separar e-mails usando ";"',
3681
+ TEKUSERINFO_TYPE: 'Tipo',
3682
+ TEKUSERINFO_ERROR: 'Error',
3683
+ TEKUSERINFO_IMPROVEMENT: 'Mejora',
3684
+ TEKUSERINFO_DESCRIPTION: 'Descripción',
3685
+ TEKUSERINFO_CANCEL: 'Cancelar',
3686
+ TEKUSERINFO_SEND: 'Enviar',
3687
+ },
3688
+ },
3689
+ });
3690
+
3691
+ class TekUserInfoList extends List {
3692
+ /**
3693
+ * Name of the user info component
3694
+ */
3695
+ parentName = '';
3696
+ dense = true;
3697
+ constructor(props) {
3698
+ super(props);
3699
+ this.parentName = props.parentName || '';
3700
+ }
3701
+ onCreated() {
3702
+ super.onCreated();
3703
+ this.items = this.getItems();
3704
+ }
3705
+ getItems() {
3706
+ const parent = this.parentName ? Metadata.getInstance(this.parentName) : this.parent;
3707
+ if (!(parent instanceof TekUserInfo)) {
3708
+ throw Error(`Could not find the TekUserInfo component associated with ${this.name} TekUserInfoList`);
3709
+ }
3710
+ return [
3711
+ {
3712
+ name: `${parent.name}_version`,
3713
+ component: 'ZdListItem',
3714
+ title: `{{TekUserInfoController_${parent.componentId}.name}}`,
3715
+ subtitle: `{{TekUserInfoController_${parent.componentId}.version}}`,
3716
+ isVisible: `{{TekUserInfoController_${parent.componentId}.showVersionInfo}}`,
3717
+ cssClass: 'zd-px-2',
3718
+ },
3719
+ {
3720
+ name: `${parent.name}_about`,
3721
+ component: 'ZdListItem',
3722
+ title: 'TEKUSERINFO_ABOUT',
3723
+ prependIcon: 'infoOutline',
3724
+ cssClass: 'zd-px-2',
3725
+ isVisible: `{{TekUserInfoController_${parent.componentId}.showAbout}}`,
3726
+ events: {
3727
+ click: () => parent.onAboutClick(),
3728
+ },
3729
+ },
3730
+ {
3731
+ name: `${parent.name}_report`,
3732
+ component: 'ZdListItem',
3733
+ title: 'TEKUSERINFO_REPORT_ERROR',
3734
+ prependIcon: 'mdi-ladybug',
3735
+ cssClass: 'zd-px-2',
3736
+ isVisible: `{{TekUserInfoController_${parent.componentId}.showReportError}}`,
3737
+ events: {
3738
+ click: () => parent.onReportClick(),
3739
+ },
3740
+ },
3741
+ ];
3742
+ }
3743
+ }
3744
+
3745
+ Messages.add({
3746
+ 'pt-BR': {
3747
+ translation: {
3748
+ NO_NOTIFICATIONS: 'Nenhuma Notificação',
3749
+ MARK_ALL_AS_READ: 'Marcar todas como lidas',
3750
+ NOTIFICATIONS: 'Notificações',
3751
+ SEE_ALL_NOTIFICATIONS: 'Ver todas notificações',
3752
+ UNAVAILABLE_IMAGE: 'Imagem indisponível',
3753
+ REFRESH: 'Atualizar',
3754
+ ACTIONS: 'Ações',
3755
+ FILTER: 'Filtro',
3756
+ LAYOUT: 'Layout: ',
3757
+ NEW_LAYOUT: 'Novo layout',
3758
+ DEFAULT_LAYOUT: 'Padrão',
3759
+ LAYOUT_MODIFIED: 'O layout atual foi modificado. Crie um novo layout, sobrescreva um existente ou descarte as alterações',
3760
+ LAYOUT_NOT_MODIFIED: 'Crie um novo layout ou aplique um dos layouts já existentes',
3761
+ LAYOUT_DISCART_CHANGES: 'Descartar alterações',
3762
+ },
3763
+ },
3764
+ 'en-US': {
3765
+ translation: {
3766
+ NO_NOTIFICATIONS: 'No Notifications',
3767
+ MARK_ALL_AS_READ: 'Mark all as read',
3768
+ NOTIFICATIONS: 'Notifications',
3769
+ SEE_ALL_NOTIFICATIONS: 'See all notifications',
3770
+ UNAVAILABLE_IMAGE: 'Unavailable image',
3771
+ REFRESH: 'Refresh',
3772
+ ACTIONS: 'Actions',
3773
+ FILTER: 'Filter',
3774
+ LAYOUT: 'Layout: ',
3775
+ NEW_LAYOUT: 'New layout',
3776
+ DEFAULT_LAYOUT: 'Default',
3777
+ LAYOUT_MODIFIED: 'The current layout has been modified. Create a new layout, overwrite an existing one or discard changes',
3778
+ LAYOUT_NOT_MODIFIED: 'Create a new layout or apply one of the existing layouts',
3779
+ LAYOUT_DISCART_CHANGES: 'Discard changes',
3780
+ },
3781
+ },
3782
+ 'es-CL': {
3783
+ translation: {
3784
+ NO_NOTIFICATIONS: 'Sin Notificación',
3785
+ MARK_ALL_AS_READ: 'Marcar todo como leído',
3786
+ NOTIFICATIONS: 'Notificaciones',
3787
+ SEE_ALL_NOTIFICATIONS: 'Ver todas las notificaciones',
3788
+ UNAVAILABLE_IMAGE: 'Imagen no disponible',
3789
+ REFRESH: 'Actualizar',
3790
+ ACTIONS: 'Acciones',
3791
+ FILTER: 'Filtro',
3792
+ LAYOUT: 'Disposición: ',
3793
+ NEW_LAYOUT: 'Nueva disposición',
3794
+ DEFAULT_LAYOUT: 'Default',
3795
+ LAYOUT_MODIFIED: 'La disposición actual ha sido modificada. Cree una nueva disposición, sobrescriba una existente o descarte los cambios',
3796
+ LAYOUT_NOT_MODIFIED: 'Cree una nueva disposición o aplique una de las disposiciones existentes',
3797
+ LAYOUT_DISCART_CHANGES: 'Descartar los cambios',
3798
+ },
3799
+ },
3800
+ });
3801
+
3802
+ export { BreadcrumbHeader, ButtonOption, ColumnsSearcher, DynamicFilterDatasourceFactory, DynamicFilterOperations, DynamicFilterRelations, GroupedDataManager, GroupedDataSelector, GroupedViewNavigator, KeyMapGrouped, MultiOption, TekFilterHelper, TekGrid, TekGridColumn, TekGridColumnsButton, TekGridColumnsButtonController, TekGridController, TekGridEvents, TekGridFilterButton, TekGridLayoutOptions, TekGridToolbarProvider, TekMemoryDatasource, TekRestDatasource, TekUserInfo, TekUserInfoList, columnAggregationValues, isFilledObject, isNil };