@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
@@ -1,4870 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@zeedhi/core'), require('@zeedhi/common'), require('lodash.debounce'), require('lodash.merge'), require('@zeedhi/zd-user-info-common'), require('@zeedhi/zd-drag-grid-common')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@zeedhi/core', '@zeedhi/common', 'lodash.debounce', 'lodash.merge', '@zeedhi/zd-user-info-common', '@zeedhi/zd-drag-grid-common'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@zeedhi/teknisa-components-common"] = {}, global["@zeedhi/core"], global.common, global.lodash.debounce, global.lodash.merge, global["@zeedhi/zd-user-info-common"], global["@zeedhi/zd-drag-grid-common"]));
5
- })(this, (function (exports, core, common, debounce, merge, zdUserInfoCommon, zdDragGridCommon) { 'use strict';
6
-
7
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
-
9
- var debounce__default = /*#__PURE__*/_interopDefaultLegacy(debounce);
10
- var merge__default = /*#__PURE__*/_interopDefaultLegacy(merge);
11
-
12
- /**
13
- * Form to be used on Crud operations
14
- */
15
- class CrudForm extends common.Form {
16
- /**
17
- * Create new Crud Form
18
- * @param props component properties
19
- */
20
- constructor(props) {
21
- super(props);
22
- /**
23
- * Form edit state
24
- */
25
- this.editing = false;
26
- if (Object.keys(this.value).length > 0) {
27
- this.setValue(this.value);
28
- }
29
- }
30
- setValue(value, autoSave = true) {
31
- this.value = value;
32
- this.unSavedValue = value;
33
- if (autoSave)
34
- this.saveEdit();
35
- }
36
- /**
37
- * Cancel edit and return value to original
38
- */
39
- cancelEdit() {
40
- this.editing = false;
41
- if (this.beforeEditValue) {
42
- this.value = this.beforeEditValue;
43
- }
44
- }
45
- /**
46
- * SaveEdit
47
- */
48
- saveEdit() {
49
- this.editing = false;
50
- this.beforeEditValue = Object.assign({}, this.unSavedValue);
51
- }
52
- /**
53
- * Update value using child input value
54
- * @param child child input
55
- * @param value input value
56
- */
57
- updateChild(child, value) {
58
- const valueKeys = Object.keys(this.value);
59
- const formChanged = valueKeys.some((key) => {
60
- const currValue = this.value[key];
61
- const prevValue = this.beforeEditValue ? this.beforeEditValue[key] : null;
62
- return this.nullCast(currValue) !== this.nullCast(prevValue);
63
- });
64
- if (!formChanged) {
65
- this.editing = false;
66
- return;
67
- }
68
- this.value[child.name] = value;
69
- this.editing = true;
70
- }
71
- nullCast(value) {
72
- return ['', null, undefined].includes(value) ? null : value;
73
- }
74
- onMounted(element) {
75
- this.cancelEdit();
76
- super.onMounted(element);
77
- element.addEventListener('focus', this.focus.bind(this), true);
78
- }
79
- /**
80
- * Form is focused
81
- */
82
- focus() {
83
- if (!this.beforeEditValue) {
84
- this.beforeEditValue = Object.assign({}, this.value);
85
- }
86
- }
87
- }
88
-
89
- /**
90
- * Button to be used on Crud Forms
91
- */
92
- class CrudButton extends common.Button {
93
- /**
94
- * Create new Crud Button
95
- * @param props component properties
96
- */
97
- constructor(props) {
98
- super(props);
99
- this.tooltipDefault = { name: 'crud-button-tooltip', component: 'ZdTooltip', bottom: true };
100
- this.clickShortcutKey = props.clickShortcutKey;
101
- this.tooltip = new common.Tooltip(Object.assign(Object.assign({}, this.tooltipDefault), props.tooltip));
102
- if (this.clickShortcutKey) {
103
- this.keyMap = Object.assign(Object.assign({}, this.keyMap), { [this.clickShortcutKey]: {
104
- event: this.shortcutClick.bind(this),
105
- stop: true,
106
- active: true,
107
- input: true,
108
- } });
109
- }
110
- }
111
- shortcutClick({ event, element }) {
112
- if (!this.disabled) {
113
- this.click(event, element);
114
- }
115
- }
116
- initKeyMap(parentElement) {
117
- core.KeyMap.bind(this.keyMap, this, parentElement);
118
- }
119
- /**
120
- * Return if parent (form or grid) is editing
121
- */
122
- get parentIsEditing() {
123
- if (this.parent instanceof CrudForm) {
124
- return this.parent.editing;
125
- }
126
- if (this.parent instanceof common.GridEditable) {
127
- return this.parent.editing;
128
- }
129
- return false;
130
- }
131
- }
132
-
133
- /**
134
- * Button to be used on Crud Forms
135
- */
136
- class CrudAddButton extends CrudButton {
137
- /**
138
- * Create new Crud Add Button
139
- * @param props component properties
140
- */
141
- constructor(props) {
142
- super(Object.assign(Object.assign({}, props), { clickShortcutKey: props.clickShortcutKey || 'f2' }));
143
- /**
144
- * Button tooltip
145
- */
146
- this.defaultTooltip = 'ADD';
147
- /**
148
- * Button flat
149
- */
150
- this.defaultFlat = true;
151
- /**
152
- * Button icon
153
- */
154
- this.defaultIcon = true;
155
- /**
156
- * Button icon name
157
- */
158
- this.defaultIconName = 'plus';
159
- /**
160
- * Button icon color
161
- */
162
- this.defaultColor = '#666';
163
- this.flat = props.flat !== undefined ? this.flat : this.defaultFlat;
164
- this.icon = props.icon !== undefined ? this.icon : this.defaultIcon;
165
- this.iconName = props.iconName !== undefined ? this.iconName : this.defaultIconName;
166
- this.color = props.color !== undefined ? this.color : this.defaultColor;
167
- this.tooltip.label = this.tooltip.label || `${core.I18n.translate(this.defaultTooltip)} (${props.clickShortcutKey || 'f2'})`;
168
- }
169
- /**
170
- * Triggered when the component is clicked.
171
- * @param event DOM event
172
- * @param element Element clicked
173
- */
174
- click(event, element) {
175
- super.click(event, element);
176
- }
177
- }
178
-
179
- /**
180
- * Button to be used on Crud Forms
181
- */
182
- class CrudCancelButton extends CrudButton {
183
- /**
184
- * Create new Crud Cancel Button
185
- * @param props component properties
186
- */
187
- constructor(props) {
188
- super(Object.assign(Object.assign({}, props), { clickShortcutKey: props.clickShortcutKey || 'esc' }));
189
- /**
190
- * Button label
191
- */
192
- this.defaultLabel = 'CANCEL';
193
- /**
194
- * Button outline
195
- */
196
- this.defaultOutline = true;
197
- this.label = props.label ? this.label : this.defaultLabel;
198
- this.outline = props.outline !== undefined ? this.outline : this.defaultOutline;
199
- this.tooltip.label = this.tooltip.label || `${core.I18n.translate(this.defaultLabel)} (${props.clickShortcutKey || 'esc'})`;
200
- }
201
- /**
202
- * Triggered when the component is clicked.
203
- * @param event DOM event
204
- * @param element Element clicked
205
- */
206
- click(event, element) {
207
- if (this.parent instanceof CrudForm) {
208
- super.click(event, element);
209
- if (!event.defaultPrevented) {
210
- this.parent.cancelEdit();
211
- }
212
- }
213
- else if (this.parent instanceof common.GridEditable) {
214
- super.click(event, element);
215
- if (!event.defaultPrevented) {
216
- this.parent.cancelEditedRows();
217
- }
218
- }
219
- }
220
- get disabled() {
221
- return !this.parentIsEditing;
222
- }
223
- set disabled(_value) {
224
- // do nothing
225
- }
226
- }
227
-
228
- /**
229
- * Button to be used on Crud Forms
230
- */
231
- class CrudDeleteButton extends CrudButton {
232
- /**
233
- * Create new Crud Delete Button
234
- * @param props component properties
235
- */
236
- constructor(props) {
237
- super(Object.assign(Object.assign({}, props), { clickShortcutKey: props.clickShortcutKey || 'ctrl+d' }));
238
- /**
239
- * Button tooltip
240
- */
241
- this.defaultTooltip = 'DELETE';
242
- /**
243
- * Button flat
244
- */
245
- this.defaultFlat = true;
246
- /**
247
- * Button icon
248
- */
249
- this.defaultIcon = true;
250
- /**
251
- * Button icon name
252
- */
253
- this.defaultIconName = 'trashCanOutline';
254
- /**
255
- * Button icon color
256
- */
257
- this.defaultColor = '#666';
258
- this.flat = props.flat !== undefined ? this.flat : this.defaultFlat;
259
- this.icon = props.icon !== undefined ? this.icon : this.defaultIcon;
260
- this.iconName = props.iconName !== undefined ? this.iconName : this.defaultIconName;
261
- this.color = props.color !== undefined ? this.color : this.defaultColor;
262
- const label = `${core.I18n.translate(this.defaultTooltip)} (${props.clickShortcutKey || 'ctrl+d'})`;
263
- this.tooltip.label = this.tooltip.label || label;
264
- }
265
- /**
266
- * Triggered when the component is clicked.
267
- * @param event DOM event
268
- * @param element Element clicked
269
- */
270
- click(event, element) {
271
- super.click(event, element);
272
- }
273
- get parentHasCurrentRow() {
274
- if (!(this.parent instanceof common.Grid))
275
- return false;
276
- const grid = this.parent;
277
- return !grid.selectable && grid.datasource.currentRow[grid.datasource.uniqueKey];
278
- }
279
- get parentHasSelectedRows() {
280
- if (!(this.parent instanceof common.Grid))
281
- return false;
282
- const grid = this.parent;
283
- return grid.selectable && grid.selectedRows.length !== 0;
284
- }
285
- get disabled() {
286
- return this.parentIsEditing || (!this.parentHasCurrentRow && !this.parentHasSelectedRows);
287
- }
288
- set disabled(_value) {
289
- // do nothing
290
- }
291
- }
292
-
293
- /**
294
- * Button to be used on Crud Forms
295
- */
296
- class CrudSaveButton extends CrudButton {
297
- /**
298
- * Create new Crud Save Button
299
- * @param props component properties
300
- */
301
- constructor(props) {
302
- super(Object.assign(Object.assign({}, props), { clickShortcutKey: props.clickShortcutKey || 'ctrl+enter' }));
303
- /**
304
- * Button label
305
- */
306
- this.defaultLabel = 'SAVE';
307
- this.label = this.label || this.defaultLabel;
308
- const label = `${core.I18n.translate(this.defaultLabel)} (${props.clickShortcutKey || 'ctrl+enter'})`;
309
- this.tooltip.label = this.tooltip.label || label;
310
- }
311
- /**
312
- * Triggered when the component is clicked.
313
- * @param event DOM event
314
- * @param element Element clicked
315
- */
316
- click(event, element) {
317
- if (this.parent instanceof CrudForm) {
318
- const form = this.parent;
319
- if (form.validate()) {
320
- super.click(event, element);
321
- if (!event.defaultPrevented) {
322
- form.saveEdit();
323
- }
324
- }
325
- }
326
- else if (this.parent instanceof common.GridEditable) {
327
- super.click(event, element);
328
- if (!event.defaultPrevented) {
329
- this.parent.saveEditedRows();
330
- }
331
- }
332
- }
333
- get disabled() {
334
- return !this.parentIsEditing;
335
- }
336
- set disabled(_value) {
337
- // do nothing
338
- }
339
- }
340
-
341
- /**
342
- * BreadcrumbHeader join breadcrumb and title
343
- */
344
- class BreadcrumbHeader extends common.ComponentRender {
345
- constructor(props) {
346
- super(props);
347
- this.title = '';
348
- this.rightSlot = [];
349
- this.breadcrumb = this.getBreadcrumbProperties(props.breadcrumb);
350
- this.title = this.getInitValue('title', props.title, this.title);
351
- this.rightSlot = props.rightSlot || this.rightSlot;
352
- }
353
- getBreadcrumbProperties(breadcrumb) {
354
- return Object.assign(Object.assign({}, breadcrumb), { name: breadcrumb.name, component: 'ZdBreadcrumb', divider: '>' });
355
- }
356
- }
357
-
358
- /**
359
- * CardTitle component join an icon, title, rightSlot and a divider
360
- */
361
- class CardTitle extends common.ComponentRender {
362
- constructor(props) {
363
- super(props);
364
- this.title = '';
365
- this.subtitle = '';
366
- this.iconName = '';
367
- this.rightSlot = [];
368
- this.showDivider = true;
369
- this.to = '';
370
- this.title = this.getInitValue('title', props.title, this.title);
371
- this.subtitle = this.getInitValue('subtitle', props.subtitle, this.subtitle);
372
- this.iconName = this.getInitValue('iconName', props.iconName, this.iconName);
373
- this.rightSlot = props.rightSlot || this.rightSlot;
374
- this.showDivider = this.getInitValue('showDivider', props.showDivider, this.showDivider);
375
- this.to = this.getInitValue('to', props.to, this.to);
376
- this.createAccessors();
377
- }
378
- }
379
-
380
- /**
381
- * Teknisa component
382
- */
383
- class Image extends common.ComponentRender {
384
- /**
385
- * Creates a new instance of ImgLink
386
- * @param props Image Link props
387
- */
388
- constructor(props) {
389
- super(props);
390
- /**
391
- * Route path
392
- */
393
- this.to = '';
394
- /**
395
- * Image source.
396
- */
397
- this.src = '';
398
- /**
399
- * Defines the component height. Possible values for this property can be
400
- * <samp>'auto', '100%', '400px' or 400</samp>
401
- */
402
- this.height = 'auto';
403
- /**
404
- * Defines the component min height. Possible values for this property can be
405
- * <samp>'auto', '100%', '400px' or 400</samp>
406
- */
407
- this.minHeight = 'auto';
408
- /**
409
- * Defines the component max height. Possible values for this property can be
410
- * <samp>'auto', '100%', '400px' or 400</samp>
411
- */
412
- this.maxHeight = 'none';
413
- /**
414
- * Set component height to fill all space available
415
- */
416
- this.fillHeight = false;
417
- /**
418
- * Defines the component width. Possible values for this property can be
419
- * <samp>'auto', '100%', '400px' or 400</samp>
420
- */
421
- this.width = 'auto';
422
- /**
423
- * Defines the component min width. Possible values for this property can be
424
- * <samp>'auto', '100%', '400px' or 400</samp>
425
- */
426
- this.minWidth = 'auto';
427
- /**
428
- * Defines the component max height. Possible values for this property can be
429
- * <samp>'auto', '100%', '400px' or 400</samp>
430
- */
431
- this.maxWidth = 'none';
432
- this.to = this.getInitValue('to', props.to, this.to);
433
- this.src = this.getInitValue('src', props.src, this.src);
434
- this.height = this.getInitValue('height', props.height, this.height);
435
- this.minHeight = this.getInitValue('minHeight', props.minHeight, this.minHeight);
436
- this.maxHeight = this.getInitValue('maxHeight', props.maxHeight, this.maxHeight);
437
- this.fillHeight = this.getInitValue('fillHeight', props.fillHeight, this.fillHeight);
438
- this.width = this.getInitValue('width', props.width, this.width);
439
- this.minWidth = this.getInitValue('minWidth', props.minWidth, this.minWidth);
440
- this.maxWidth = this.getInitValue('maxWidth', props.maxWidth, this.maxWidth);
441
- this.createAccessors();
442
- }
443
- load(event, element) {
444
- this.callEvent('load', { event, element, component: this });
445
- }
446
- }
447
-
448
- /**
449
- * Teknisa product card component
450
- */
451
- class ProductCard extends common.ComponentRender {
452
- /**
453
- * Creates a new instance of ProductCard
454
- * @param props Product Card props
455
- */
456
- constructor(props) {
457
- super(props);
458
- /**
459
- * Route path.
460
- */
461
- this.to = '';
462
- /**
463
- * Product Id.
464
- */
465
- this.id = '';
466
- /**
467
- * Image source Product.
468
- */
469
- this.src = '';
470
- /**
471
- * Product name.
472
- */
473
- this.productName = '';
474
- /**
475
- * Path to image to be shown when error
476
- */
477
- this.errorImagePath = '';
478
- /**
479
- * Text to be shown when error
480
- */
481
- this.errorImageText = 'UNAVAILABLE_IMAGE';
482
- /**
483
- * Card width
484
- */
485
- this.width = '';
486
- /**
487
- * Sets the height for the component.
488
- */
489
- this.height = 'auto';
490
- /**
491
- * Sets the maximum height for the component.
492
- */
493
- this.maxHeight = 'none';
494
- /**
495
- * Sets the minimum height for the component.
496
- */
497
- this.minHeight = 'none';
498
- this.currencyFormatterFn = core.FormatterParserProvider.getFormatter('ZdCurrency');
499
- this.id = this.getInitValue('id', props.id, this.id);
500
- this.productName = this.getInitValue('productName', props.productName, this.productName);
501
- this.productSupplier = this.getInitValue('productSupplier', props.productSupplier, this.productSupplier);
502
- this.productBrand = this.getInitValue('productBrand', props.productBrand, this.productBrand);
503
- this.productPrice = this.getInitValue('productPrice', props.productPrice, this.productPrice);
504
- this.to = this.getInitValue('to', props.to, this.to);
505
- this.src = this.getInitValue('src', props.src, this.src);
506
- this.errorImagePath = this.getInitValue('errorImagePath', props.errorImagePath, this.errorImagePath);
507
- this.errorImageText = this.getInitValue('errorImageText', props.errorImageText, this.errorImageText);
508
- this.width = this.getInitValue('width', props.width, this.width);
509
- this.height = this.getInitValue('height', props.height, this.height);
510
- this.maxHeight = this.getInitValue('maxHeight', props.maxHeight, this.maxHeight);
511
- this.minHeight = this.getInitValue('minHeight', props.minHeight, this.minHeight);
512
- this.createAccessors();
513
- }
514
- get productPriceFormat() {
515
- const price = +(this.productPrice || 0);
516
- return this.currencyFormatterFn(price);
517
- }
518
- }
519
-
520
- /**
521
- * Base class for IterableComponentRender component.
522
- * This component uses every row returned by Iterable.datasource to render
523
- * components defined by componentMetadata property.
524
- * If the data inside the datasource is changed you should perform
525
- * a datasource.get() to force updating the rendered components.
526
- */
527
- class IterableComponentRender extends common.Iterable {
528
- }
529
-
530
- /**
531
- * Base class for IterableCarousel component.
532
- * This component uses every row returned by IterableComponentRender.datasource to render
533
- * slides defined by componentMetadata property, inside a carousel component.
534
- */
535
- class IterableCarousel extends common.Carousel {
536
- constructor(props) {
537
- super(props);
538
- this.iterable = new common.IterableComponentRender(Object.assign(Object.assign({}, props.iterable), { name: `${props.name}_iterable`, component: 'TekIterableComponentRender' }));
539
- }
540
- get children() {
541
- var _a, _b;
542
- return ((_b = (_a = this.iterable) === null || _a === void 0 ? void 0 : _a.datasource) === null || _b === void 0 ? void 0 : _b.data.map(this.iterable.getComponentMetadata.bind(this.iterable))) || [];
543
- }
544
- set children(value) {
545
- if (value && value.length) {
546
- throw new Error('You should not change children when using IterableCarousel');
547
- }
548
- }
549
- }
550
-
551
- // eslint-disable-next-line
552
- const loading = 'data:image/gif;base64,R0lGODlhlgCWAPf/AC1oxPa+ADarUdmsFEB/m0yTcjiMhEafWjFova2SNDZotX10VsOfJDlosFZnge25BnJtXTukVWVmaFh1eIuOZ1x0ZEFopHpyWGFpcS5ow+q2CVNnhmVnZvW9AW5qYUyKXUJnofW+AKWNOV9mcS9owZuGQTporlCGXbWXLmNrazxnqeKyDoGDZVFniFZ6ZNSpGJ+IPoR4Ud+wEURnnmtpYklnlll5YbGUMcagIk5njmhnZWpoZGF0aWBmbkdnmbyaKUtnlEaBfWdmZTNou0WUW5WDRFtmeGZmZ82kHqecTXqIdzRouGJmbPC6BIB2VDxnrGNmakyHYPO8AkxnkUh0qmRpZl9wZVxndmRmaVhnffS9AqmPN09ni96vEUmQWzBowC1ow2FtZVR3gl5ndFGCYEVnnF1mdGR9i1dnf7qZK4l7TnRvXOK1FD6eV8ijIG6Cgl58lF1rfEBnpFVsi1pmeo5+Sk56dz9np5OCRjaqUi5pxNarFndwWmNqZm9sYFx7a098itGnG4d6T7ikPKKLO1Rmg+e1Cr2bKVhme0GbVkpmk5mWW5GBSM+nHLiYLPG7BIp8TUKZWUFsqWJnbltmd0hnmNqtFExtm1tsgaiOOIx9TNuuE6CKPWJmbcqjH1OJb8CdJjFovlpwb+u5CzioU1aFbjdos0qYXJOPXWFwczepUnBsX8qrKuW0DD5nqdmsFUl+kTtnrDdntNKuI+OzDVRnhYuEV52HPzNqvjltuVBqkJeERNirFnVvXKSMOjVsvDmLhEJxsTloss+sJTeqUdyzGkaeWreYLmBqdjmMhDyhVvC8B49/STinVVV+YVp/bEuScq6fRj5tr8CnNUV/lUNnoGZnZkCFgTaqUVeCYTuLgz2Ig02RcUySck+QcTxpr5qQUFCPXjZsullviFh4ZNaxH0KAmEGYXFJ4oFCNcEdsoUicWpmFQkRoo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/zjji9OzhGSu1Rp6RSW/RzDOaicw5esZJrqpbx4iFiynZd0mYgtiuEQuaSndMmJAzhY4E8vDjy59Pv779+/jz69/Pv7///wAGKOCABBZo4IEIJqjgggw26OCDEEYo4YQUVmjhhRhmqOGGHHbo4YcghijiiCSWaOKJKKao4oostujiizDGKOOMNNZo44045qjjjjz26OOPQAYp5JBEFmnkkUgmqSRVAQEAIfkEBQQA/wAsAAAAAJYAlgAACPEA/wkcSLCgwYMIEypcyLChw4cQI0qcSLGixYsYM2rcyLGjx48gQ4ocSbKkyZMoU6pcybKly5cwY8qcSbOmzZs4c+rcybOnz59AgwodSrSo0aNIkypdyrSp06dQo0qdSrWq1atYs2rdyrWr169gw4odS7as2bNo06pdy7at27dw48qdS7eu3bt48+rdy7ev37+AAwseTLiw4cOIEytezLix48eQI0ueTLmy5cuYM2vezLmz58+gQ4seTbq06dOoU6tezbq169ewY8ueTbu27du4c+vezbu379/AgwsfTry48ePIkytfzry58+fQo0ufbjggACH5BAUEAP8ALAAAAAABAAEAAAgEAP8FBAA7';
553
- /**
554
- * Teknisa component
555
- */
556
- class Loading extends common.Loading {
557
- /**
558
- * Creates a new instance of TekLoading
559
- * @param props Image Link props
560
- */
561
- constructor(props) {
562
- super(props);
563
- /**
564
- * text to show in Loader Overlay
565
- */
566
- this.text = '';
567
- /**
568
- * zIndex value.
569
- */
570
- this.zIndex = '999';
571
- /**
572
- * loading path.
573
- */
574
- this.image = loading;
575
- this.text = this.getInitValue('text', props.text, this.text);
576
- this.zIndex = this.getInitValue('zIndex', props.zIndex, this.zIndex);
577
- this.image = this.getInitValue('image', props.image, this.image);
578
- }
579
- }
580
-
581
- /**
582
- * Notifications component is used to show notifications
583
- */
584
- class Notifications extends common.Iterable {
585
- constructor(props) {
586
- super(props);
587
- this.allNotificationsPath = '';
588
- this.cardTitle = {
589
- name: 'notification-card-title',
590
- component: 'TekCardTitle',
591
- title: 'NOTIFICATIONS',
592
- rightSlot: [
593
- {
594
- name: 'mark-read-tag',
595
- component: 'ZdTag',
596
- tag: 'a',
597
- events: {
598
- click: this.markAsRead.bind(this),
599
- },
600
- children: [
601
- {
602
- name: 'mark-read-text',
603
- cssClass: 'mark-read-text',
604
- component: 'ZdText',
605
- text: 'MARK_ALL_AS_READ',
606
- },
607
- ],
608
- },
609
- ],
610
- };
611
- this.allNotificationsPath = this.getInitValue('allNotificationsPath', props.allNotificationsPath, this.allNotificationsPath);
612
- this.createAccessors();
613
- }
614
- markAsRead({ event, element }) {
615
- this.callEvent('markAllAsReadClick', { event, element, component: this });
616
- }
617
- showAll(event, element) {
618
- this.callEvent('showAllClick', { event, element, component: this });
619
- }
620
- notificationClick(event, notification, element) {
621
- this.callEvent('notificationClick', {
622
- event, notification, element, component: this,
623
- });
624
- }
625
- }
626
-
627
- const tuple = (...args) => args;
628
- const columnAggregationValues = tuple('SUM', 'MIN', 'MAX', 'AVG', 'COUNT', undefined);
629
-
630
- /*! *****************************************************************************
631
- Copyright (c) Microsoft Corporation.
632
-
633
- Permission to use, copy, modify, and/or distribute this software for any
634
- purpose with or without fee is hereby granted.
635
-
636
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
637
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
638
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
639
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
640
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
641
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
642
- PERFORMANCE OF THIS SOFTWARE.
643
- ***************************************************************************** */
644
-
645
- function __decorate(decorators, target, key, desc) {
646
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
647
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
648
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
649
- return c > 3 && r && Object.defineProperty(target, key, r), r;
650
- }
651
-
652
- function __awaiter(thisArg, _arguments, P, generator) {
653
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
654
- return new (P || (P = Promise))(function (resolve, reject) {
655
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
656
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
657
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
658
- step((generator = generator.apply(thisArg, _arguments || [])).next());
659
- });
660
- }
661
-
662
- /**
663
- * Class to translate a TekRestDatasource dynamicFilter to the ZhReports format
664
- */
665
- class ReportFilter {
666
- constructor(filter) {
667
- this.filter = {};
668
- this.messages = {
669
- CONTAINS: 'TEKGRID_CONTAINS',
670
- NOT_CONTAINS: 'TEKGRID_NOT_CONTAINS',
671
- EQUALS: 'TEKGRID_EQUALS',
672
- NOT_EQUAL: 'TEKGRID_NOT_EQUALS',
673
- GREATER_THAN: 'TEKGRID_GREATER_THAN',
674
- LESS_THAN: 'TEKGRID_LESS_THAN',
675
- GREATER_THAN_EQUALS: 'TEKGRID_GREATER_THAN_EQUALS',
676
- LESS_THAN_EQUALS: 'TEKGRID_LESS_THAN_EQUALS',
677
- IN: 'TEKGRID_IN',
678
- NOT_IN: 'TEKGRID_NOT_IN',
679
- BETWEEN: 'TEKGRID_BETWEEN',
680
- AND: 'TEKGRID_AND',
681
- OR: 'TEKGRID_OR',
682
- };
683
- this.filter = filter;
684
- }
685
- build() {
686
- return Object.keys(this.filter).map((key) => {
687
- const items = this.filter[key];
688
- const words = [];
689
- items.forEach((item, index) => {
690
- const operation = this.messages[item.operation];
691
- words.push(core.I18n.translate(operation));
692
- words.push(item.value);
693
- const isLast = index === items.length - 1;
694
- if (!isLast) {
695
- const next = items[index + 1];
696
- const relation = this.messages[next.relation];
697
- words.push(core.I18n.translate(relation));
698
- }
699
- });
700
- const value = words.join(' ').trim();
701
- return {
702
- value,
703
- label: key,
704
- };
705
- });
706
- }
707
- }
708
-
709
- /**
710
- * Delete rows error
711
- */
712
- class TekGridDeleteRowsError extends Error {
713
- constructor() {
714
- super('TekGrid can\'t automatically delete rows when selectAllPages property is true.'
715
- + ' You should delete them manually using the beforeDelete event and preventing'
716
- + ' the default execution');
717
- this.name = 'TekGridDeleteRowsError';
718
- }
719
- }
720
-
721
- class ButtonOption {
722
- constructor(config) {
723
- this.config = config;
724
- }
725
- buildComponent(grid) {
726
- const { type, label, portrait = true, iconName, } = this.config;
727
- const orientation = portrait ? 'portrait' : 'landscape';
728
- return {
729
- label,
730
- iconName,
731
- name: `${grid.name}_export_${type}_${orientation}`,
732
- component: 'ZdButton',
733
- flat: true,
734
- events: {
735
- click: () => grid.getReport(type, portrait),
736
- },
737
- };
738
- }
739
- }
740
-
741
- class MultiOption {
742
- constructor(config) {
743
- this.config = config;
744
- }
745
- formatName(id, type, grid) {
746
- return `${grid.name}_export_${type}_${id}`;
747
- }
748
- buildTooltip(option, type, grid) {
749
- const { label } = option;
750
- return {
751
- name: this.formatName(`tooltip_${label}`, type, grid),
752
- component: 'ZdTooltip',
753
- bottom: true,
754
- label,
755
- children: [],
756
- };
757
- }
758
- buildButton(option, type, grid) {
759
- const { cssClass, label, iconName, reportParams, } = option;
760
- const { portrait: optionPortrait, rowObj } = reportParams || {};
761
- return {
762
- name: this.formatName(`button_${label}`, type, grid),
763
- component: 'ZdButton',
764
- cssClass,
765
- icon: true,
766
- iconName,
767
- events: {
768
- click: () => grid.getReport(type, optionPortrait, rowObj),
769
- },
770
- };
771
- }
772
- buildDivider(option, type, grid) {
773
- const { label } = option;
774
- return {
775
- name: this.formatName(`divider_${label}`, type, grid),
776
- component: 'ZdDivider',
777
- cssClass: 'zd-my-1',
778
- vertical: true,
779
- };
780
- }
781
- buildComponent(grid) {
782
- const { type, label, multiOption, } = this.config;
783
- const optionComponents = multiOption.map((option) => ([
784
- Object.assign(Object.assign({}, this.buildTooltip(option, type, grid)), { children: [
785
- this.buildButton(option, type, grid),
786
- ] }),
787
- this.buildDivider(option, type, grid),
788
- ]))
789
- .flat();
790
- optionComponents.pop();
791
- const text = {
792
- name: this.formatName('text', type, grid),
793
- component: 'ZdText',
794
- cssClass: 'zd-display-flex zd-align-center zd-flex-grow-1 tek-grid-export-multioption-text',
795
- events: {
796
- click: ({ event }) => event === null || event === void 0 ? void 0 : event.stopPropagation(),
797
- },
798
- text: label || '',
799
- };
800
- const result = {
801
- name: this.formatName('row', type, grid),
802
- component: 'ZdRow',
803
- cssClass: 'zd-display-flex zd-ma-0 zd-py-0 zd-gap-x-1 tek-grid-export-multioption-row',
804
- children: [text, ...optionComponents],
805
- };
806
- return result;
807
- }
808
- }
809
-
810
- class GridBase {
811
- constructor(grid) {
812
- this.exportConfigButtons = [];
813
- this.defaultToolbar = {};
814
- this.atoms = {
815
- TITLE: '_gridTitle',
816
- HIDE_BUTTON: '_hideButton',
817
- ADD_BUTTON: '_addButton',
818
- DELETE_BUTTON: '_deleteButton',
819
- REFRESH_BUTTON: '_refreshButton',
820
- COLUMNS_BUTTON: '_columnsButton',
821
- LAYOUT_BUTTON: '_layout_options',
822
- EXPORT_BUTTON: '_exportButton',
823
- ACTIONS_BUTTON: '_actionsButton',
824
- SAVE_BUTTON: '_saveButton',
825
- CANCEL_BUTTON: '_cancelButton',
826
- SEARCH: '_gridSearch',
827
- FILTER_BUTTON: '_filterButton',
828
- FILTER_MODAL: '-filter-modal',
829
- FILTER_FORM: '-filter-form',
830
- EXPORT_DROPDOWN: '_export_dropdown',
831
- ACTIONS_DROPDOWN: '_actions_dropdown',
832
- };
833
- this.grid = grid;
834
- this.exportConfigButtons = this.getExportConfigButtons();
835
- this.initializeDefaultToolbarItems();
836
- }
837
- getOption(config) {
838
- if (config.multiOption)
839
- return new MultiOption(config);
840
- return new ButtonOption(config);
841
- }
842
- getExportConfigButtons() {
843
- return this.grid.exportConfig.map((config) => {
844
- const option = this.getOption(config);
845
- return option.buildComponent(this.grid);
846
- });
847
- }
848
- initializeDefaultToolbarItems() {
849
- this.defaultToolbar = {
850
- title: () => ({
851
- name: `${this.grid.name}_title`,
852
- component: 'ZdText',
853
- cssClass: 'toolbar-title',
854
- tag: 'h2',
855
- text: this.grid.title,
856
- title: this.grid.title,
857
- }),
858
- hideButton: () => ({
859
- name: `${this.grid.name}_hideTooltip`,
860
- component: 'ZdTooltip',
861
- label: 'TEKGRID_HIDE',
862
- bottom: true,
863
- children: [
864
- {
865
- name: `${this.grid.name}_hideButton`,
866
- component: 'ZdIcon',
867
- iconName: 'mdi-chevron-right',
868
- isVisible: `{{GridController_${this.grid.componentId}.showHideButton}}`,
869
- cssClass: '',
870
- events: {
871
- click: this.hideButtonClick.bind(this),
872
- },
873
- },
874
- ],
875
- }),
876
- addButton: () => ({
877
- name: `${this.grid.name}_add_tooltip`,
878
- component: 'ZdTooltip',
879
- label: 'TEKGRID_ADD',
880
- bottom: true,
881
- children: [
882
- {
883
- name: `${this.grid.name}_addButton`,
884
- component: 'ZdButton',
885
- icon: true,
886
- iconName: 'add',
887
- isVisible: `{{GridController_${this.grid.componentId}.showAddButton}}`,
888
- events: {
889
- click: this.addButtonClick.bind(this),
890
- },
891
- },
892
- ],
893
- }),
894
- deleteButton: () => ({
895
- name: `${this.grid.name}_delete_tooltip`,
896
- component: 'ZdTooltip',
897
- label: 'TEKGRID_DELETE',
898
- bottom: true,
899
- children: [
900
- {
901
- name: `${this.grid.name}_deleteButton`,
902
- component: 'ZdButton',
903
- icon: true,
904
- iconName: 'delete',
905
- isVisible: `{{GridController_${this.grid.componentId}.showDeleteButton}}`,
906
- disabled: `{{GridController_${this.grid.componentId}.disableDeleteButton}}`,
907
- events: {
908
- click: this.deleteButtonClick.bind(this),
909
- },
910
- },
911
- ],
912
- }),
913
- divider: (index) => ({
914
- name: `${this.grid.name}_divider${index}`,
915
- component: 'ZdDivider',
916
- cssClass: 'toolbar-divider',
917
- vertical: true,
918
- isVisible: `{{GridController_${this.grid.componentId}.showDivider}}`,
919
- }),
920
- refreshButton: () => ({
921
- name: `${this.grid.name}_refresh_tooltip`,
922
- component: 'ZdTooltip',
923
- label: 'TEKGRID_REFRESH',
924
- bottom: true,
925
- children: [
926
- {
927
- name: `${this.grid.name}_refreshButton`,
928
- component: 'ZdButton',
929
- icon: true,
930
- iconName: 'refresh',
931
- isVisible: `{{GridController_${this.grid.componentId}.showReloadButton}}`,
932
- events: {
933
- click: this.reloadGrid.bind(this),
934
- },
935
- },
936
- ],
937
- }),
938
- optionsDivider: (index) => ({
939
- name: `${this.grid.name}_options_divider${index}`,
940
- component: 'ZdDivider',
941
- cssClass: 'toolbar-divider',
942
- vertical: true,
943
- isVisible: `{{GridController_${this.grid.componentId}.showOptionsDivider}}`,
944
- }),
945
- columnsButton: () => ({
946
- name: `${this.grid.name}_columns_button_tooltip`,
947
- component: 'ZdTooltip',
948
- label: 'TEKGRID_COLUMNS',
949
- bottom: true,
950
- children: [
951
- {
952
- name: `${this.grid.name}_columnsButton`,
953
- component: 'TekGridColumnsButton',
954
- isVisible: `{{GridController_${this.grid.componentId}.showColumnsButton}}`,
955
- iterableComponentName: this.grid.name,
956
- hideGroups: !(this.grid instanceof TekGrid),
957
- ignoreColumns: `{{GridController_${this.grid.componentId}.columnsButtonIgnore}}`,
958
- },
959
- ],
960
- }),
961
- layoutOptions: () => ({
962
- name: `${this.grid.name}_layout_options`,
963
- component: 'TekGridLayoutOptions',
964
- isVisible: `{{GridController_${this.grid.componentId}.showLayoutOptionsButton}}`,
965
- }),
966
- exportDropdown: () => ({
967
- name: `${this.grid.name}_export_dropdown`,
968
- component: 'ZdDropdown',
969
- cssClass: 'tekgrid-actions-dropdown',
970
- offsetY: true,
971
- activator: {
972
- name: `${this.grid.name}_exportButton`,
973
- component: 'ZdButton',
974
- icon: true,
975
- iconName: 'fileDownload',
976
- isVisible: `{{GridController_${this.grid.componentId}.showExportButton}}`,
977
- },
978
- children: this.grid.exportActions || this.exportConfigButtons,
979
- }),
980
- actionsDivider: (index) => ({
981
- name: `${this.grid.name}_actions_divider${index}`,
982
- component: 'ZdDivider',
983
- cssClass: 'toolbar-divider',
984
- vertical: true,
985
- isVisible: `{{GridController_${this.grid.componentId}.showActionsButton}}`,
986
- }),
987
- actionsDropdown: () => ({
988
- name: `${this.grid.name}_actions_tooltip`,
989
- component: 'ZdTooltip',
990
- label: 'TEKGRID_ACTIONS',
991
- bottom: true,
992
- children: [
993
- {
994
- name: `${this.grid.name}_actions_dropdown`,
995
- component: 'ZdDropdown',
996
- cssClass: 'tekgrid-actions-dropdown',
997
- offsetY: true,
998
- activator: {
999
- name: `${this.grid.name}_actionsButton`,
1000
- component: 'ZdButton',
1001
- icon: true,
1002
- iconName: 'more',
1003
- isVisible: `{{GridController_${this.grid.componentId}.showActionsButton}}`,
1004
- },
1005
- children: this.grid.actions,
1006
- },
1007
- ],
1008
- }),
1009
- saveButton: () => ({
1010
- name: `${this.grid.name}_saveButton`,
1011
- component: 'ZdButton',
1012
- label: 'TEKGRID_SAVE',
1013
- isVisible: `{{GridController_${this.grid.componentId}.showEditButtons}}`,
1014
- small: true,
1015
- events: {
1016
- click: this.saveChanges.bind(this),
1017
- },
1018
- }),
1019
- cancelButton: () => ({
1020
- name: `${this.grid.name}_cancelButton`,
1021
- component: 'ZdButton',
1022
- label: 'TEKGRID_CANCEL',
1023
- outline: true,
1024
- cssClass: 'zd-mx-2',
1025
- isVisible: `{{GridController_${this.grid.componentId}.showEditButtons}}`,
1026
- small: true,
1027
- events: {
1028
- click: this.cancelChanges.bind(this),
1029
- },
1030
- }),
1031
- gridSearch: () => ({
1032
- name: `${this.grid.name}_gridSearch`,
1033
- component: 'ZdSearch',
1034
- cssClass: 'zd-grid-search',
1035
- iterableComponentName: `${this.grid.name}`,
1036
- isVisible: `{{GridController_${this.grid.componentId}.showSearchInput}}`,
1037
- }),
1038
- filterButton: () => ({
1039
- name: `${this.grid.name}_filter_tooltip`,
1040
- component: 'ZdTooltip',
1041
- label: 'TEKGRID_FILTER',
1042
- bottom: true,
1043
- children: [
1044
- {
1045
- name: `${this.grid.name}_filterButton`,
1046
- component: 'TekGridFilterButton',
1047
- grid: this.grid,
1048
- gridName: this.grid.name,
1049
- showCheckboxAll: this.grid.showCheckboxAllFilter,
1050
- isVisible: `{{GridController_${this.grid.componentId}.showFilterButton}}`,
1051
- events: {
1052
- onCreated: this.loadFilterButton.bind(this),
1053
- },
1054
- },
1055
- ],
1056
- }),
1057
- };
1058
- }
1059
- processUserToolbarItems(toolbarDivChildren) {
1060
- this.grid.toolbarConfig.forEach((item, index) => {
1061
- if (typeof item === 'object' && item.component) {
1062
- toolbarDivChildren.push(item);
1063
- }
1064
- else if (typeof item === 'string') {
1065
- const toolbarToPropertyMap = {
1066
- addButton: 'addButton',
1067
- deleteButton: 'deleteButton',
1068
- refreshButton: 'refreshButton',
1069
- columnsButton: 'columnsButton',
1070
- layoutOptions: 'layoutButton',
1071
- exportDropdown: 'exportButton',
1072
- actionsDropdown: 'actionsButton',
1073
- gridSearch: 'searchInput',
1074
- filterButton: 'filterButton',
1075
- };
1076
- const gridProperty = toolbarToPropertyMap[item];
1077
- if (gridProperty && !this.grid[gridProperty]) {
1078
- this.grid[gridProperty] = true;
1079
- }
1080
- const itemFactory = this.defaultToolbar[item];
1081
- if (itemFactory) {
1082
- const predefinedItem = itemFactory(index);
1083
- if (predefinedItem) {
1084
- toolbarDivChildren.push(predefinedItem);
1085
- }
1086
- }
1087
- else {
1088
- console.warn(`Predefined toolbar item "${item}" not found.`);
1089
- }
1090
- }
1091
- else {
1092
- console.warn('Invalid item in toolbarConfig:', item);
1093
- }
1094
- });
1095
- }
1096
- /**
1097
- * Adiciona os itens padrão da toolbar quando nenhuma configuração é fornecida.
1098
- * @param toolbarDivChildren Array para adicionar os componentes da toolbar.
1099
- */
1100
- addDefaultToolbarItems(toolbarDivChildren) {
1101
- const defaultItems = [
1102
- 'addButton', 'deleteButton', 'divider', 'refreshButton', 'optionsDivider',
1103
- 'columnsButton', 'layoutOptions', 'exportDropdown', 'actionsDivider', 'actionsDropdown',
1104
- 'saveButton', 'cancelButton', 'divider', 'gridSearch', 'filterButton',
1105
- ];
1106
- defaultItems.forEach((itemName, index) => {
1107
- const itemFactory = this.defaultToolbar[itemName];
1108
- if (itemFactory) {
1109
- const predefinedItem = itemFactory(index);
1110
- if (predefinedItem) {
1111
- toolbarDivChildren.push(predefinedItem);
1112
- }
1113
- }
1114
- });
1115
- }
1116
- /**
1117
- * Cria os componentes que serão renderizados na toolbar do grid.
1118
- */
1119
- createToolbarProps() {
1120
- var _a, _b, _c, _d;
1121
- const toolbarItems = [];
1122
- const toolbarDivChildren = [];
1123
- const title = (_b = (_a = this.defaultToolbar).title) === null || _b === void 0 ? void 0 : _b.call(_a);
1124
- const hideButton = (_d = (_c = this.defaultToolbar).hideButton) === null || _d === void 0 ? void 0 : _d.call(_c);
1125
- if (title)
1126
- toolbarItems.push(title);
1127
- if (hideButton)
1128
- toolbarItems.push(hideButton);
1129
- if (this.grid.toolbarConfig && this.grid.toolbarConfig.length > 0) {
1130
- this.processUserToolbarItems(toolbarDivChildren);
1131
- }
1132
- else {
1133
- this.addDefaultToolbarItems(toolbarDivChildren);
1134
- }
1135
- toolbarItems.push({
1136
- name: `${this.grid.name}_toolbarDiv`,
1137
- component: 'ZdTag',
1138
- tag: 'div',
1139
- cssStyle: 'display: flex; align-items: center',
1140
- cssClass: `{{GridController_${this.grid.componentId}.toolbarVisible}}`,
1141
- isVisible: true,
1142
- children: toolbarDivChildren,
1143
- });
1144
- return toolbarItems;
1145
- }
1146
- loadFilterButton({ component }) {
1147
- this.filterButton = component;
1148
- }
1149
- hideButtonClick({ event }) {
1150
- if (!event.defaultPrevented) {
1151
- const instance = core.Metadata.getInstance(`${this.grid.name}_toolbarDiv`);
1152
- const icon = core.Metadata.getInstance(`${this.grid.name}_hideButton`);
1153
- const tooltip = core.Metadata.getInstance(`${this.grid.name}_hideTooltip`);
1154
- if (instance) {
1155
- instance.cssClass = instance.cssClass === 'toolbar-visible'
1156
- ? ''
1157
- : 'toolbar-visible';
1158
- icon.cssClass = icon.cssClass === 'is-rotated'
1159
- ? ''
1160
- : 'is-rotated';
1161
- tooltip.label = tooltip.label === 'TEKGRID_HIDE'
1162
- ? 'TEKGRID_SHOW'
1163
- : 'TEKGRID_HIDE';
1164
- }
1165
- }
1166
- }
1167
- addButtonClick({ event }) {
1168
- if (this.grid.editNewRowsOnly) {
1169
- this.grid.editingNewRows = true;
1170
- }
1171
- this.grid.callEvent('addClick', { component: this.grid, event });
1172
- }
1173
- deleteButtonClick({ event }) {
1174
- this.grid.callEvent('beforeDelete', { component: this.grid, event });
1175
- if (!event.defaultPrevented) {
1176
- if (this.grid.selectAllPages) {
1177
- throw new TekGridDeleteRowsError();
1178
- }
1179
- this.grid.deleteRows();
1180
- this.grid.callEvent('afterDelete', { component: this.grid });
1181
- }
1182
- }
1183
- reloadGrid({ event }) {
1184
- this.grid.callEvent('beforeReload', { component: this.grid, event });
1185
- if (event && event.defaultPrevented)
1186
- return;
1187
- this.grid.reload();
1188
- }
1189
- saveChanges({ event }) {
1190
- this.grid.callEvent('beforeSave', { component: this.grid, event });
1191
- if (!event.defaultPrevented) {
1192
- const save = (() => __awaiter(this, void 0, void 0, function* () {
1193
- yield this.grid.saveEditedRows();
1194
- this.grid.editingNewRows = false;
1195
- }));
1196
- save();
1197
- this.grid.callEvent('afterSave', { component: this.grid });
1198
- }
1199
- }
1200
- cancelChanges({ event }) {
1201
- this.grid.callEvent('beforeCancel', { component: this.grid, event });
1202
- if (!event.defaultPrevented) {
1203
- const cancel = (() => __awaiter(this, void 0, void 0, function* () {
1204
- yield this.grid.cancelEditedRows();
1205
- this.grid.editingNewRows = false;
1206
- }));
1207
- cancel();
1208
- this.grid.callEvent('afterCancel', { component: this.grid });
1209
- }
1210
- }
1211
- hideFilterModal() {
1212
- this.filterButton.hideFilterModal();
1213
- }
1214
- getFilterRelationsDatasource() {
1215
- return core.DatasourceFactory.factory({
1216
- data: this.getFilterOptionsData('relations'),
1217
- loadAll: true,
1218
- translate: ['text'],
1219
- });
1220
- }
1221
- getFilterOperationsDatasource() {
1222
- return core.DatasourceFactory.factory({
1223
- data: this.getFilterOptionsData('operations'),
1224
- loadAll: true,
1225
- translate: ['text'],
1226
- });
1227
- }
1228
- getFilterOptionsData(prop) {
1229
- const { datasource } = this.grid;
1230
- if (datasource instanceof TekRestDatasource || datasource instanceof TekMemoryDatasource) {
1231
- let options;
1232
- if (prop === 'relations') {
1233
- options = Object.keys(datasource.dynamicFilterRelations);
1234
- }
1235
- else {
1236
- options = Object.keys(datasource.dynamicFilterOperations);
1237
- }
1238
- return options.map((item) => ({
1239
- text: `TEKGRID_${item}`,
1240
- value: item,
1241
- }));
1242
- }
1243
- return [];
1244
- }
1245
- setSearch(search) {
1246
- return __awaiter(this, void 0, void 0, function* () {
1247
- const { datasource } = this.grid;
1248
- if (datasource instanceof TekRestDatasource || datasource instanceof TekMemoryDatasource) {
1249
- const lookupColumns = this.grid.columns.filter((column) => !!column.componentProps.datasource && !column.skipLookupSearch);
1250
- const searchJoin = {};
1251
- if (search) {
1252
- const promises = lookupColumns.map((column) => __awaiter(this, void 0, void 0, function* () {
1253
- const searchData = yield column.memorySearch(search);
1254
- const lookupId = column.componentProps.datasource.uniqueKey;
1255
- searchJoin[column.name] = searchData.map((row) => row[lookupId]);
1256
- }));
1257
- yield Promise.all(promises);
1258
- }
1259
- datasource.searchJoin = searchJoin;
1260
- }
1261
- datasource.page = 1;
1262
- return datasource.setSearch(search);
1263
- });
1264
- }
1265
- getAtomInstance(key) {
1266
- return core.Metadata.getInstance(`${this.grid.name}${this.atoms[key]}`);
1267
- }
1268
- getFilterInputs(columnName) {
1269
- return this.filterButton.getFilterInputs(columnName);
1270
- }
1271
- }
1272
- core.Messages.add({
1273
- 'pt-BR': {
1274
- translation: {
1275
- TEKGRID_CONTAINS: 'contém',
1276
- TEKGRID_NOT_CONTAINS: 'não contém',
1277
- TEKGRID_EQUALS: 'é igual a',
1278
- TEKGRID_NOT_EQUALS: 'é diferente de',
1279
- TEKGRID_GREATER_THAN: 'é maior que',
1280
- TEKGRID_LESS_THAN: 'é menor que',
1281
- TEKGRID_GREATER_THAN_EQUALS: 'é maior ou igual a',
1282
- TEKGRID_LESS_THAN_EQUALS: 'é menor ou igual a',
1283
- TEKGRID_IN: 'um dos valores',
1284
- TEKGRID_NOT_IN: 'nenhum dos valores',
1285
- TEKGRID_BETWEEN: 'está entre',
1286
- TEKGRID_AND: 'e',
1287
- TEKGRID_OR: 'ou',
1288
- TEKGRID_HIDE: 'Esconder Ações',
1289
- TEKGRID_SHOW: 'Mostrar Ações',
1290
- TEKGRID_ADD: 'Adicionar',
1291
- TEKGRID_DELETE: 'Excluir',
1292
- TEKGRID_REFRESH: 'Atualizar',
1293
- TEKGRID_COLUMNS: 'Colunas',
1294
- TEKGRID_ACTIONS: 'Ações',
1295
- TEKGRID_SAVE: 'Salvar',
1296
- TEKGRID_CANCEL: 'Cancelar',
1297
- TEKGRID_APPLY: 'Aplicar',
1298
- TEKGRID_FILTER: 'Filtro',
1299
- TEKGRID_MULTIPLE_VALUE_HINT: 'Separe valores usando ";"',
1300
- TEKGRID_EXPORT: 'Exportar',
1301
- TEKGRID_EXPORT_AS: 'Exportar como {{ type }}',
1302
- TEKGRID_PORTRAIT: 'Retrato',
1303
- TEKGRID_LANDSCAPE: 'Paisagem',
1304
- TEKGRID_COLUMN_VISIBLE: 'Visível',
1305
- TEKGRID_COLUMN_GROUPED: 'Grupo',
1306
- TEKGRID_COLUMN_AGGREGATION: 'Totalização',
1307
- TEKGRID_COLUMN_LABEL: 'Rótulo',
1308
- TEKGRID_COLUMN_ALIGNMENT: 'Alinhamento',
1309
- TEKGRID_COLUMN_GROUP_OPENED: 'Aberto (grupo)',
1310
- TEKGRID_COLUMN_ORDER: 'Ordem',
1311
- TEKGRID_COLUMN_ORDER_DIRECTION: 'Direção (ordem)',
1312
- TEKGRID_AGGREGATION_SUM: 'Soma',
1313
- TEKGRID_AGGREGATION_AVG: 'Média',
1314
- TEKGRID_AGGREGATION_MAX: 'Máximo',
1315
- TEKGRID_AGGREGATION_MIN: 'Mínimo',
1316
- TEKGRID_AGGREGATION_COUNT: 'Contador',
1317
- TEKGRID_MORE_OPTIONS: 'Mais opções',
1318
- TEKGRID_COLUMNS_OPTIONS: 'Configuração de colunas',
1319
- TEKGRID_CLOSE: 'Fechar',
1320
- TEKGRID_FIXED_COLUMNS: 'Colunas fixadas',
1321
- TEKGRID_VISIBLE_COLUMNS: 'Colunas visíveis',
1322
- TEKGRID_GROUPED_COLUMNS: 'Colunas agrupadas',
1323
- TEKGRID_ORDER: 'Ordem',
1324
- TEKGRID_OTHER_COLUMNS: 'Outras colunas',
1325
- TEKGRID_DROP_COLUMNS: 'Arraste colunas aqui',
1326
- TEKGRID_DETAILS_FOR: 'Detalhes para:',
1327
- TEKGRID_LEFT: 'Esquerda',
1328
- TEKGRID_CENTER: 'Centro',
1329
- TEKGRID_RIGHT: 'Direita',
1330
- TEKGRID_ASC: 'Crescente',
1331
- TEKGRID_DESC: 'Decrescente',
1332
- TEKGRID_SELECT_COLUMN: '(selecione uma ou mais colunas)',
1333
- TEKGRID_SELECT_ALL: 'Selecionar todas',
1334
- TEKGRID_HELPERVALUE_TODAY: 'Hoje',
1335
- TEKGRID_HELPERVALUE_TOMORROW: 'Amanhã',
1336
- TEKGRID_HELPERVALUE_YESTERDAY: 'Ontem',
1337
- TEKGRID_HELPERVALUE_LAST_7_DAYS: 'Últimos 7 Dias',
1338
- TEKGRID_HELPERVALUE_NEXT_7_DAYS: 'Próximos 7 Dias',
1339
- TEKGRID_HELPERVALUE_CURRENT_WEEK: 'Semana Atual',
1340
- TEKGRID_HELPERVALUE_CURRENT_MONTH: 'Mês Atual',
1341
- TEKGRID_HELPERVALUE_CURRENT_YEAR: 'Ano Atual',
1342
- TEKGRID_WITH_GROUPS: '(Com grupos)',
1343
- TEKGRID_GRID_MIRROR: '(Espelho do grid)',
1344
- TEKGRID_NO_DATA: 'Não há dados para exportar',
1345
- },
1346
- },
1347
- 'en-US': {
1348
- translation: {
1349
- TEKGRID_CONTAINS: 'contains',
1350
- TEKGRID_NOT_CONTAINS: 'does not contain',
1351
- TEKGRID_EQUALS: 'is equal to',
1352
- TEKGRID_NOT_EQUALS: 'is different from',
1353
- TEKGRID_GREATER_THAN: 'is greater than',
1354
- TEKGRID_LESS_THAN: 'is less than',
1355
- TEKGRID_GREATER_THAN_EQUALS: 'is greater or equals to',
1356
- TEKGRID_LESS_THAN_EQUALS: 'is less or equals to',
1357
- TEKGRID_IN: 'is in',
1358
- TEKGRID_NOT_IN: 'is not in',
1359
- TEKGRID_BETWEEN: 'is between',
1360
- TEKGRID_AND: 'and',
1361
- TEKGRID_OR: 'or',
1362
- TEKGRID_HIDE: 'Hide Actions',
1363
- TEKGRID_SHOW: 'Show Actions',
1364
- TEKGRID_ADD: 'Add',
1365
- TEKGRID_DELETE: 'Delete',
1366
- TEKGRID_REFRESH: 'Refresh',
1367
- TEKGRID_COLUMNS: 'Columns',
1368
- TEKGRID_ACTIONS: 'Actions',
1369
- TEKGRID_SAVE: 'Save',
1370
- TEKGRID_CANCEL: 'Cancel',
1371
- TEKGRID_APPLY: 'Apply',
1372
- TEKGRID_FILTER: 'Filter',
1373
- TEKGRID_MULTIPLE_VALUE_HINT: 'Separate values using ";"',
1374
- TEKGRID_EXPORT: 'Export',
1375
- TEKGRID_EXPORT_AS: 'Export as {{ type }}',
1376
- TEKGRID_PORTRAIT: 'Portrait',
1377
- TEKGRID_LANDSCAPE: 'Landscape',
1378
- TEKGRID_COLUMN_VISIBLE: 'Visible',
1379
- TEKGRID_COLUMN_GROUPED: 'Grouped',
1380
- TEKGRID_COLUMN_AGGREGATION: 'Aggregation',
1381
- TEKGRID_COLUMN_LABEL: 'Label',
1382
- TEKGRID_COLUMN_ALIGNMENT: 'Alignment',
1383
- TEKGRID_COLUMN_GROUP_OPENED: 'Opened (group)',
1384
- TEKGRID_COLUMN_ORDER: 'Order',
1385
- TEKGRID_COLUMN_ORDER_DIRECTION: 'Direction (order)',
1386
- TEKGRID_AGGREGATION_SUM: 'Sum',
1387
- TEKGRID_AGGREGATION_AVG: 'Average',
1388
- TEKGRID_AGGREGATION_MAX: 'Maximum',
1389
- TEKGRID_AGGREGATION_MIN: 'Minimum',
1390
- TEKGRID_AGGREGATION_COUNT: 'Count',
1391
- TEKGRID_MORE_OPTIONS: 'More options',
1392
- TEKGRID_COLUMNS_OPTIONS: 'Columns configuration',
1393
- TEKGRID_CLOSE: 'Close',
1394
- TEKGRID_FIXED_COLUMNS: 'Fixed columns',
1395
- TEKGRID_VISIBLE_COLUMNS: 'Visible columns',
1396
- TEKGRID_GROUPED_COLUMNS: 'Grouped columns',
1397
- TEKGRID_ORDER: 'Order',
1398
- TEKGRID_OTHER_COLUMNS: 'Other columns',
1399
- TEKGRID_DROP_COLUMNS: 'Drop columns here',
1400
- TEKGRID_DETAILS_FOR: 'Details for:',
1401
- TEKGRID_LEFT: 'Left',
1402
- TEKGRID_CENTER: 'Center',
1403
- TEKGRID_RIGHT: 'Right',
1404
- TEKGRID_ASC: 'Ascending',
1405
- TEKGRID_DESC: 'Descending',
1406
- TEKGRID_SELECT_COLUMN: '(select one or more columns)',
1407
- TEKGRID_SELECT_ALL: 'Select all',
1408
- TEKGRID_HELPERVALUE_TODAY: 'Today',
1409
- TEKGRID_HELPERVALUE_TOMORROW: 'Tomorrow',
1410
- TEKGRID_HELPERVALUE_YESTERDAY: 'Yesterday',
1411
- TEKGRID_HELPERVALUE_LAST_7_DAYS: 'Last 7 Days',
1412
- TEKGRID_HELPERVALUE_NEXT_7_DAYS: 'Next 7 Days',
1413
- TEKGRID_HELPERVALUE_CURRENT_WEEK: 'Current Week',
1414
- TEKGRID_HELPERVALUE_CURRENT_MONTH: 'Current Month',
1415
- TEKGRID_HELPERVALUE_CURRENT_YEAR: 'Current Year',
1416
- TEKGRID_WITH_GROUPS: '(With groups)',
1417
- TEKGRID_GRID_MIRROR: '(Grid mirror)',
1418
- TEKGRID_NO_DATA: 'There is no data to export',
1419
- },
1420
- },
1421
- 'es-CL': {
1422
- translation: {
1423
- TEKGRID_CONTAINS: 'contiene',
1424
- TEKGRID_NOT_CONTAINS: 'no contiene',
1425
- TEKGRID_EQUALS: 'igual',
1426
- TEKGRID_NOT_EQUALS: 'es diferente de',
1427
- TEKGRID_GREATER_THAN: 'es mayor que',
1428
- TEKGRID_LESS_THAN: 'es menor que',
1429
- TEKGRID_GREATER_THAN_EQUALS: 'es mayor o igual que',
1430
- TEKGRID_LESS_THAN_EQUALS: 'es menor o igual que',
1431
- TEKGRID_IN: 'uno de los valores',
1432
- TEKGRID_NOT_IN: 'ninguno de los valores',
1433
- TEKGRID_BETWEEN: 'está entre',
1434
- TEKGRID_AND: 'e',
1435
- TEKGRID_OR: 'o',
1436
- TEKGRID_HIDE: 'Ocultar Acciones',
1437
- TEKGRID_SHOW: 'Mostrar Acciones',
1438
- TEKGRID_ADD: 'Añadir',
1439
- TEKGRID_DELETE: 'Eliminar',
1440
- TEKGRID_REFRESH: 'Actualizar',
1441
- TEKGRID_COLUMNS: 'Colunas',
1442
- TEKGRID_ACTIONS: 'Acciónes',
1443
- TEKGRID_SAVE: 'Guardar',
1444
- TEKGRID_CANCEL: 'Cancelar',
1445
- TEKGRID_APPLY: 'Aplicar',
1446
- TEKGRID_FILTER: 'Filtro',
1447
- TEKGRID_MULTIPLE_VALUE_HINT: 'Separe los valores usando ";"',
1448
- TEKGRID_EXPORT: 'Exportar',
1449
- TEKGRID_EXPORT_AS: 'Exportar como {{ type }}',
1450
- TEKGRID_PORTRAIT: 'Vertical',
1451
- TEKGRID_LANDSCAPE: 'Horizontal',
1452
- TEKGRID_COLUMN_VISIBLE: 'Visible',
1453
- TEKGRID_COLUMN_GROUPED: 'Grupo',
1454
- TEKGRID_COLUMN_AGGREGATION: 'Totalización',
1455
- TEKGRID_COLUMN_LABEL: 'Etiqueta',
1456
- TEKGRID_COLUMN_ALIGNMENT: 'alineación',
1457
- TEKGRID_COLUMN_GROUP_OPENED: 'Abierto (grupo)',
1458
- TEKGRID_COLUMN_ORDER: 'Orden',
1459
- TEKGRID_COLUMN_ORDER_DIRECTION: 'Dirección (orden)',
1460
- TEKGRID_AGGREGATION_SUM: 'Suma',
1461
- TEKGRID_AGGREGATION_AVG: 'Media',
1462
- TEKGRID_AGGREGATION_MAX: 'Máximo',
1463
- TEKGRID_AGGREGATION_MIN: 'Mínimo',
1464
- TEKGRID_AGGREGATION_COUNT: 'Contar',
1465
- TEKGRID_MORE_OPTIONS: 'Mas opciones',
1466
- TEKGRID_COLUMNS_OPTIONS: 'Configuración de columna',
1467
- TEKGRID_CLOSE: 'Cerrar',
1468
- TEKGRID_FIXED_COLUMNS: 'Columnas fijas',
1469
- TEKGRID_VISIBLE_COLUMNS: 'Columnas visibles',
1470
- TEKGRID_GROUPED_COLUMNS: 'Columnas agrupadas',
1471
- TEKGRID_ORDER: 'Orden',
1472
- TEKGRID_OTHER_COLUMNS: 'Otras columnas',
1473
- TEKGRID_DROP_COLUMNS: 'Arrastra columnas aquí',
1474
- TEKGRID_DETAILS_FOR: 'Detalles para',
1475
- TEKGRID_LEFT: 'Izquierda',
1476
- TEKGRID_CENTER: 'Centro',
1477
- TEKGRID_RIGHT: 'Derecha',
1478
- TEKGRID_ASC: 'Creciente',
1479
- TEKGRID_DESC: 'Decreciente',
1480
- TEKGRID_SELECT_COLUMN: '(seleccione una o más columnas)',
1481
- TEKGRID_SELECT_ALL: 'Seleccionar todas',
1482
- TEKGRID_HELPERVALUE_TODAY: 'Hoy',
1483
- TEKGRID_HELPERVALUE_TOMORROW: 'Mañana',
1484
- TEKGRID_HELPERVALUE_YESTERDAY: 'Ayer',
1485
- TEKGRID_HELPERVALUE_LAST_7_DAYS: 'Últimos 7 días',
1486
- TEKGRID_HELPERVALUE_NEXT_7_DAYS: 'Próximos 7 días',
1487
- TEKGRID_HELPERVALUE_CURRENT_WEEK: 'Semana actual',
1488
- TEKGRID_HELPERVALUE_CURRENT_MONTH: 'Mes actual',
1489
- TEKGRID_HELPERVALUE_CURRENT_YEAR: 'Año actual',
1490
- TEKGRID_WITH_GROUPS: '(Con grupos)',
1491
- TEKGRID_GRID_MIRROR: '(Espejo de grid)',
1492
- TEKGRID_NO_DATA: 'No hay datos para exportar',
1493
- },
1494
- },
1495
- });
1496
-
1497
- class GridController {
1498
- constructor(grid) {
1499
- this.openToolbar = true;
1500
- this.grid = grid;
1501
- this.openToolbar = this.grid.toolbarOpened;
1502
- }
1503
- get gridTitle() {
1504
- return this.grid.title;
1505
- }
1506
- get showAddButton() {
1507
- return this.grid.addButton && !this.isEditing;
1508
- }
1509
- get showDeleteButton() {
1510
- return this.grid.deleteButton !== 'none' && !this.isEditing;
1511
- }
1512
- get showFilterButton() {
1513
- return this.grid.filterButton;
1514
- }
1515
- get showModalFilterProps() {
1516
- return this.grid.modalFilterProps;
1517
- }
1518
- get showSearchInput() {
1519
- return this.grid.showSearch;
1520
- }
1521
- get showReloadButton() {
1522
- return this.grid.showReload && !this.isEditing;
1523
- }
1524
- get showColumnsButton() {
1525
- return this.grid.columnsButton && !this.isEditing;
1526
- }
1527
- get columnsButtonIgnore() {
1528
- return this.grid.columnsButtonIgnore;
1529
- }
1530
- get showLayoutOptionsButton() {
1531
- return this.grid.showLayoutOptions && !this.isEditing;
1532
- }
1533
- get showDivider() {
1534
- return !this.isEditing;
1535
- }
1536
- get showOptionsDivider() {
1537
- return (this.grid.columnsButton || this.grid.showLayoutOptions || this.grid.showExport)
1538
- && !this.isEditing;
1539
- }
1540
- get showHideButton() {
1541
- return this.grid.showHideButton;
1542
- }
1543
- get showActionsButton() {
1544
- return this.grid.actions.length > 0 && !this.isEditing;
1545
- }
1546
- get showExportButton() {
1547
- return this.grid.showExport && !this.isEditing;
1548
- }
1549
- get showActionAndExportButton() {
1550
- return ((this.showLayoutOptionsButton || this.showColumnsButton)
1551
- && (this.showActionsButton || this.showExportButton || this.showSearchInput)) && !this.isEditing;
1552
- }
1553
- get isEditing() {
1554
- return this.grid.editing;
1555
- }
1556
- get showEditButtons() {
1557
- return this.isEditing && this.grid.showEditButtons;
1558
- }
1559
- get isNotEditing() {
1560
- return !this.isEditing;
1561
- }
1562
- get disableDeleteButton() {
1563
- if (this.grid.deleteButton === 'selection') {
1564
- if (this.grid.selectAllPages) {
1565
- const { allSelected, except } = this.grid.selectionState;
1566
- return (allSelected && except.length === this.grid.datasource.total)
1567
- || (!allSelected && except.length === 0);
1568
- }
1569
- return this.grid.selectedRows.length === 0;
1570
- }
1571
- if (this.grid.deleteButton === 'currentRow') {
1572
- return !this.grid.datasource.currentRow[this.grid.datasource.uniqueKey];
1573
- }
1574
- return false;
1575
- }
1576
- }
1577
-
1578
- /**
1579
- * Extracts properties from an object based on a list of properties
1580
- * @param obj object whose properties will be extracted
1581
- * @param props array of strings with the properties to be extracted
1582
- * @returns object containing the extracted properties
1583
- */
1584
- const extractProperties = (obj, props) => {
1585
- const result = {};
1586
- props.forEach((prop) => {
1587
- if (obj[prop] !== undefined) {
1588
- result[prop] = obj[prop];
1589
- }
1590
- });
1591
- return result;
1592
- };
1593
-
1594
- const DynamicFilterOperations = {
1595
- CONTAINS: true,
1596
- NOT_CONTAINS: true,
1597
- EQUALS: true,
1598
- NOT_EQUALS: true,
1599
- GREATER_THAN: true,
1600
- LESS_THAN: true,
1601
- GREATER_THAN_EQUALS: true,
1602
- LESS_THAN_EQUALS: true,
1603
- IN: true,
1604
- NOT_IN: true,
1605
- BETWEEN: true,
1606
- };
1607
- const DynamicFilterRelations = {
1608
- AND: true,
1609
- OR: true,
1610
- };
1611
-
1612
- class TekMemoryDatasource extends core.MemoryDatasource {
1613
- /**
1614
- * Create new datasource
1615
- * @param props Datasource properties
1616
- */
1617
- constructor(props) {
1618
- super(props);
1619
- /**
1620
- * Dynamic Filter Operations
1621
- */
1622
- this.dynamicFilterOperations = DynamicFilterOperations;
1623
- /**
1624
- * Dynamic Filter Relations
1625
- */
1626
- this.dynamicFilterRelations = DynamicFilterRelations;
1627
- /**
1628
- * Dynamic Filter applied flag
1629
- */
1630
- this.dynamicFilterApplied = '';
1631
- if (!this.watchUrl) {
1632
- this.dynamicFilter = this.getInitValue('dynamicFilter', props.dynamicFilter, {});
1633
- this.searchJoin = this.getInitValue('searchJoin', props.searchJoin, {});
1634
- }
1635
- this.createAccessors();
1636
- this.createObjAccessors(this.dynamicFilter, 'dynamicFilter');
1637
- this.createObjAccessors(this.searchJoin, 'searchJoin');
1638
- this.get();
1639
- }
1640
- updateReservedKeys() {
1641
- this.reservedKeys.dynamic_filter = true;
1642
- this.reservedKeys.search_join = true;
1643
- }
1644
- updateInternalProperties(datasource = {}) {
1645
- if (!this.watchUrl)
1646
- return;
1647
- this.updateReservedKeys();
1648
- super.updateInternalProperties(datasource);
1649
- const queryString = core.URL.getParsedQueryStringFromUrl();
1650
- this.dynamicFilter = this.getEncodedParam(queryString.dynamic_filter, datasource.dynamicFilter);
1651
- this.searchJoin = this.getEncodedParam(queryString.search_join, datasource.searchJoin);
1652
- }
1653
- getEncodedParam(urlParam, datasourceParam = {}) {
1654
- return urlParam ? JSON.parse(atob(urlParam)) : datasourceParam;
1655
- }
1656
- getQueryStringValues() {
1657
- const values = super.getQueryStringValues();
1658
- if (this.dynamicFilter && Object.keys(this.dynamicFilter).length) {
1659
- values.dynamic_filter = btoa(JSON.stringify(this.dynamicFilter));
1660
- }
1661
- if (this.searchJoin && Object.keys(this.searchJoin).length) {
1662
- values.search_join = btoa(JSON.stringify(this.searchJoin));
1663
- }
1664
- return values;
1665
- }
1666
- getUrlQueryString() {
1667
- const superQueryString = super.getUrlQueryString();
1668
- const query = core.URL.getParsedQueryStringFromUrl();
1669
- let dynamicFilterQuerystring = '';
1670
- if (query.dynamic_filter) {
1671
- dynamicFilterQuerystring = `&${core.URL.getFormattedQueryString({
1672
- dynamic_filter: query.dynamic_filter,
1673
- })}`;
1674
- }
1675
- let searchJoinQuerystring = '';
1676
- if (query.search_join) {
1677
- searchJoinQuerystring = `&${core.URL.getFormattedQueryString({
1678
- search_join: query.search_join,
1679
- })}`;
1680
- }
1681
- return superQueryString + dynamicFilterQuerystring + searchJoinQuerystring;
1682
- }
1683
- /**
1684
- * Allows the comunication between the base filter and the dynamic filter
1685
- * @param filtroDinamico
1686
- * @returns
1687
- */
1688
- setBaseFilter(filtroDinamico) {
1689
- return this.setDynamicFilter(filtroDinamico);
1690
- }
1691
- /**
1692
- * Adds a new dynamic filter position or replace if exists
1693
- * @param column Dynamic Filter column name
1694
- * @param value Dynamic Filter value
1695
- * @returns Promise with data collection
1696
- */
1697
- addDynamicFilter(column, value) {
1698
- if (this.isValidDynamicFilterValue(column, value)) {
1699
- this.dynamicFilter[column] = value;
1700
- return this.updateDynamicFilter();
1701
- }
1702
- return this.removeDynamicFilter(column);
1703
- }
1704
- /**
1705
- * Removes a dynamic filter position
1706
- * @param column Dynamic Filter column name
1707
- * @returns Promise with data collection
1708
- */
1709
- removeDynamicFilter(column) {
1710
- delete this.dynamicFilter[column];
1711
- return this.updateDynamicFilter();
1712
- }
1713
- /**
1714
- * Sets new dynamic filter value
1715
- * @param filter Dynamic Filter value
1716
- * @returns Promise with data collection
1717
- */
1718
- setDynamicFilter(filter) {
1719
- this.dynamicFilter = {};
1720
- Object.keys(filter).forEach((column) => {
1721
- if (this.isValidDynamicFilterValue(column, filter[column])) {
1722
- this.dynamicFilter[column] = filter[column];
1723
- }
1724
- else {
1725
- delete this.dynamicFilter[column];
1726
- }
1727
- });
1728
- return this.updateDynamicFilter();
1729
- }
1730
- /**
1731
- * Clears Dynamic filter value
1732
- * @returns Promise with data collection
1733
- */
1734
- clearDynamicFilter() {
1735
- this.dynamicFilter = {};
1736
- return this.updateDynamicFilter();
1737
- }
1738
- /**
1739
- * Resets page and selected rows and tries to update the url
1740
- * @returns Promise with data collection
1741
- */
1742
- updateDynamicFilter() {
1743
- return __awaiter(this, void 0, void 0, function* () {
1744
- this.page = this.firstPage;
1745
- this.selectedRows = [];
1746
- this.visibleSelectedRows = [];
1747
- if (this.watchUrl) {
1748
- if (this.dynamicFilter && Object.keys(this.dynamicFilter).length) {
1749
- core.URL.updateQueryString({
1750
- dynamic_filter: btoa(JSON.stringify(this.dynamicFilter)),
1751
- });
1752
- }
1753
- else {
1754
- core.URL.updateQueryString({
1755
- dynamic_filter: undefined,
1756
- });
1757
- }
1758
- }
1759
- return this.get();
1760
- });
1761
- }
1762
- /**
1763
- * Checks if a filter value is valid
1764
- * @param value Filter value
1765
- * @returns Is valid filter value
1766
- */
1767
- isValidDynamicFilterValue(column, value) {
1768
- if (!Array.isArray(value))
1769
- return false;
1770
- return !this.reservedKeys[column]
1771
- && value.length > 0
1772
- && value.every((filterValue) => filterValue
1773
- && this.dynamicFilterOperations[filterValue.operation]
1774
- && this.dynamicFilterRelations[filterValue.relation]
1775
- && filterValue.value !== ''
1776
- && filterValue.value !== null);
1777
- }
1778
- clone() {
1779
- return Object.assign(Object.assign({}, super.clone()), { dynamicFilter: this.dynamicFilter, searchJoin: this.searchJoin, type: 'tek-memory' });
1780
- }
1781
- /**
1782
- * Updates filtered data
1783
- */
1784
- updateFilteredData() {
1785
- // first apply filters (simple and dynamic)
1786
- this.filteredData = Object.keys(this.filter).length
1787
- ? this.allData.filter((row) => this.getRowByFilter(row))
1788
- : Array.from(this.allData);
1789
- if (this.dynamicFilter && Object.keys(this.dynamicFilter).length) {
1790
- this.filteredData = this.filteredData.filter((row) => this.getRowByDynamicFilter(row));
1791
- }
1792
- const searchWithoutSearchJoin = (row) => {
1793
- const searchRow = Object.assign({}, row);
1794
- if (this.searchJoin) {
1795
- // do not search on columns with searchJoin
1796
- Object.keys(this.searchJoin).forEach((key) => delete searchRow[key]);
1797
- }
1798
- return this.getRowBySearch(searchRow);
1799
- };
1800
- // only after do the search
1801
- const searchData = this.search
1802
- ? this.filteredData.filter(searchWithoutSearchJoin)
1803
- : this.filteredData;
1804
- let searchIds = searchData.map((row) => row[this.uniqueKey]);
1805
- if (this.searchJoin && Object.keys(this.searchJoin).length) {
1806
- const searchJoinData = this.filteredData.filter((row) => this.getRowBySearchJoin(row));
1807
- // get the ids from search and searchJoin
1808
- searchIds = searchIds
1809
- .concat(searchJoinData.map((row) => row[this.uniqueKey]))
1810
- .sort();
1811
- }
1812
- // filter filteredData using searchIds
1813
- this.filteredData = this.allData.filter((row) => searchIds.indexOf(row[this.uniqueKey]) !== -1);
1814
- }
1815
- getRowByDynamicFilter(row) {
1816
- let filtered;
1817
- try {
1818
- Object.keys(this.dynamicFilter).forEach((key) => {
1819
- const filterItems = this.dynamicFilter[key];
1820
- filterItems.forEach((item) => {
1821
- if (filtered === false && item.relation === 'AND')
1822
- return;
1823
- if (filtered === true && item.relation === 'OR')
1824
- return;
1825
- const columnValue = core.Utils.normalize(row[key].toString());
1826
- let value = '';
1827
- if (Array.isArray(item.value)) {
1828
- value = item.value.map((val) => core.Utils.normalize(val.toString()));
1829
- switch (item.operation) {
1830
- case 'IN':
1831
- filtered = value.includes(columnValue);
1832
- break;
1833
- case 'NOT_IN':
1834
- filtered = !value.includes(columnValue);
1835
- break;
1836
- case 'BETWEEN':
1837
- filtered = (Number(columnValue) || columnValue) >= (Number(value[0]) || value[0])
1838
- && (Number(columnValue) || columnValue) <= (Number(value[1]) || value[1]);
1839
- break;
1840
- default:
1841
- break;
1842
- }
1843
- }
1844
- else {
1845
- value = core.Utils.normalize(item.value.toString());
1846
- switch (item.operation) {
1847
- case 'CONTAINS':
1848
- filtered = columnValue.indexOf(value) !== -1;
1849
- break;
1850
- case 'NOT_CONTAINS':
1851
- filtered = columnValue.indexOf(value) === -1;
1852
- break;
1853
- case 'EQUALS':
1854
- filtered = columnValue === value;
1855
- break;
1856
- case 'NOT_EQUALS':
1857
- filtered = columnValue !== value;
1858
- break;
1859
- case 'GREATER_THAN':
1860
- filtered = (Number(columnValue) || columnValue) > (Number(value) || value);
1861
- break;
1862
- case 'LESS_THAN':
1863
- filtered = (Number(columnValue) || columnValue) < (Number(value) || value);
1864
- break;
1865
- case 'GREATER_THAN_EQUALS':
1866
- filtered = (Number(columnValue) || columnValue) >= (Number(value) || value);
1867
- break;
1868
- case 'LESS_THAN_EQUALS':
1869
- filtered = (Number(columnValue) || columnValue) <= (Number(value) || value);
1870
- break;
1871
- default:
1872
- break;
1873
- }
1874
- }
1875
- });
1876
- });
1877
- }
1878
- catch (_a) {
1879
- // do nothing
1880
- }
1881
- return filtered;
1882
- }
1883
- getRowBySearchJoin(row) {
1884
- return Object.keys(this.searchJoin).some((key) => this.searchJoin[key].includes(row[key]));
1885
- }
1886
- }
1887
- core.DatasourceFactory.register('tek-memory', TekMemoryDatasource);
1888
-
1889
- class TekRestDatasource extends core.RestDatasource {
1890
- /**
1891
- * Create new datasource
1892
- * @param props Datasource properties
1893
- */
1894
- constructor(props) {
1895
- super(Object.assign(Object.assign({}, props), { lazyLoad: true }));
1896
- /**
1897
- * Dynamic Filter Operations
1898
- */
1899
- this.dynamicFilterOperations = DynamicFilterOperations;
1900
- /**
1901
- * Dynamic Filter Relations
1902
- */
1903
- this.dynamicFilterRelations = DynamicFilterRelations;
1904
- /**
1905
- * Dynamic Filter applied flag
1906
- */
1907
- this.dynamicFilterApplied = '';
1908
- if (!this.watchUrl) {
1909
- this.dynamicFilter = this.getInitValue('dynamicFilter', props.dynamicFilter, {});
1910
- this.searchJoin = this.getInitValue('searchJoin', props.searchJoin, {});
1911
- }
1912
- this.lazyLoad = this.getInitValue('lazyLoad', props.lazyLoad, this.lazyLoad);
1913
- this.createAccessors();
1914
- this.createObjAccessors(this.dynamicFilter, 'dynamicFilter');
1915
- this.createObjAccessors(this.searchJoin, 'searchJoin');
1916
- if (!this.lazyLoad) {
1917
- this.get();
1918
- }
1919
- }
1920
- updateReservedKeys() {
1921
- this.reservedKeys.dynamic_filter = true;
1922
- this.reservedKeys.search_join = true;
1923
- }
1924
- updateInternalProperties(datasource = {}) {
1925
- if (!this.watchUrl)
1926
- return;
1927
- this.updateReservedKeys();
1928
- super.updateInternalProperties(datasource);
1929
- const queryString = core.URL.getParsedQueryStringFromUrl();
1930
- this.dynamicFilter = this.getEncodedParam(queryString.dynamic_filter, datasource.dynamicFilter);
1931
- this.searchJoin = this.getEncodedParam(queryString.search_join, datasource.searchJoin);
1932
- }
1933
- getEncodedParam(urlParam, datasourceParam = {}) {
1934
- return urlParam ? JSON.parse(atob(urlParam)) : datasourceParam;
1935
- }
1936
- getQueryStringValues() {
1937
- const values = super.getQueryStringValues();
1938
- if (this.dynamicFilter && Object.keys(this.dynamicFilter).length) {
1939
- values.dynamic_filter = btoa(JSON.stringify(this.dynamicFilter));
1940
- }
1941
- if (this.searchJoin && Object.keys(this.searchJoin).length) {
1942
- values.search_join = btoa(JSON.stringify(this.searchJoin));
1943
- }
1944
- return values;
1945
- }
1946
- getUrlQueryString() {
1947
- const superQueryString = super.getUrlQueryString();
1948
- const query = core.URL.getParsedQueryStringFromUrl();
1949
- let dynamicFilterQuerystring = '';
1950
- if (query.dynamic_filter) {
1951
- dynamicFilterQuerystring = `&${core.URL.getFormattedQueryString({
1952
- dynamic_filter: query.dynamic_filter,
1953
- })}`;
1954
- }
1955
- let searchJoinQuerystring = '';
1956
- if (query.search_join) {
1957
- searchJoinQuerystring = `&${core.URL.getFormattedQueryString({
1958
- search_join: query.search_join,
1959
- })}`;
1960
- }
1961
- return superQueryString + dynamicFilterQuerystring + searchJoinQuerystring;
1962
- }
1963
- /**
1964
- * Allows the comunication between the base filter and the dynamic filter
1965
- * @param filtroDinamico
1966
- * @returns
1967
- */
1968
- setBaseFilter(filtroDinamico) {
1969
- return this.setDynamicFilter(filtroDinamico);
1970
- }
1971
- /**
1972
- * Adds a new dynamic filter position or replace if exists
1973
- * @param column Dynamic Filter column name
1974
- * @param value Dynamic Filter value
1975
- * @returns Promise with data collection
1976
- */
1977
- addDynamicFilter(column, value) {
1978
- if (this.isValidDynamicFilterValue(column, value)) {
1979
- this.dynamicFilter[column] = value;
1980
- return this.updateDynamicFilter();
1981
- }
1982
- return this.removeDynamicFilter(column);
1983
- }
1984
- /**
1985
- * Removes a dynamic filter position
1986
- * @param column Dynamic Filter column name
1987
- * @returns Promise with data collection
1988
- */
1989
- removeDynamicFilter(column) {
1990
- delete this.dynamicFilter[column];
1991
- return this.updateDynamicFilter();
1992
- }
1993
- /**
1994
- * Sets new dynamic filter value
1995
- * @param filter Dynamic Filter value
1996
- * @returns Promise with data collection
1997
- */
1998
- setDynamicFilter(filter) {
1999
- this.dynamicFilter = {};
2000
- Object.keys(filter).forEach((column) => {
2001
- if (this.isValidDynamicFilterValue(column, filter[column])) {
2002
- this.dynamicFilter[column] = filter[column];
2003
- }
2004
- else {
2005
- delete this.dynamicFilter[column];
2006
- }
2007
- });
2008
- return this.updateDynamicFilter();
2009
- }
2010
- /**
2011
- * Clears Dynamic filter value
2012
- * @returns Promise with data collection
2013
- */
2014
- clearDynamicFilter() {
2015
- this.dynamicFilter = {};
2016
- return this.updateDynamicFilter();
2017
- }
2018
- /**
2019
- * Resets page and selected rows and tries to update the url
2020
- * @returns Promise with data collection
2021
- */
2022
- updateDynamicFilter() {
2023
- return __awaiter(this, void 0, void 0, function* () {
2024
- this.page = this.firstPage;
2025
- this.selectedRows = [];
2026
- this.visibleSelectedRows = [];
2027
- if (this.watchUrl) {
2028
- if (this.dynamicFilter && Object.keys(this.dynamicFilter).length) {
2029
- core.URL.updateQueryString({
2030
- dynamic_filter: btoa(JSON.stringify(this.dynamicFilter)),
2031
- });
2032
- }
2033
- else {
2034
- core.URL.updateQueryString({
2035
- dynamic_filter: undefined,
2036
- });
2037
- }
2038
- }
2039
- return this.get();
2040
- });
2041
- }
2042
- /**
2043
- * Checks if a filter value is valid
2044
- * @param value Filter value
2045
- * @returns Is valid filter value
2046
- */
2047
- isValidDynamicFilterValue(column, value) {
2048
- if (!Array.isArray(value))
2049
- return false;
2050
- return !this.reservedKeys[column]
2051
- && value.length > 0
2052
- && value.every((filterValue) => filterValue
2053
- && this.dynamicFilterOperations[filterValue.operation]
2054
- && this.dynamicFilterRelations[filterValue.relation]
2055
- && filterValue.value !== ''
2056
- && filterValue.value !== null);
2057
- }
2058
- /**
2059
- * Retrieves request params
2060
- */
2061
- getRequestParams() {
2062
- const requestParams = super.getRequestParams();
2063
- const isNotEmptyObj = (obj) => !!(obj && Object.keys(obj).length);
2064
- const isValid = this.dynamicFilter && Object.keys(this.dynamicFilter).every((column) => {
2065
- const value = this.dynamicFilter[column];
2066
- return value && value.length > 0 && this.isValidDynamicFilterValue(column, value);
2067
- });
2068
- if (isNotEmptyObj(this.dynamicFilter) && isValid) {
2069
- requestParams.dynamic_filter = btoa(JSON.stringify(this.dynamicFilter));
2070
- }
2071
- if (isNotEmptyObj(this.searchJoin)) {
2072
- requestParams.search_join = btoa(JSON.stringify(this.searchJoin));
2073
- }
2074
- return requestParams;
2075
- }
2076
- clone() {
2077
- return Object.assign(Object.assign({}, super.clone()), { dynamicFilter: this.dynamicFilter, searchJoin: this.searchJoin, type: 'tek-rest' });
2078
- }
2079
- }
2080
- core.DatasourceFactory.register('tek-rest', TekRestDatasource);
2081
-
2082
- /**
2083
- * Base class for TekGrid column
2084
- */
2085
- class TekGridColumn extends common.GridColumnEditable {
2086
- /* istanbul ignore next */
2087
- /**
2088
- * Creates a new TekGrid Column.
2089
- * @param props TekGrid column properties
2090
- */
2091
- constructor(props, grid) {
2092
- super(props);
2093
- /* filter component props */
2094
- this.filterProps = [];
2095
- /* column can be use to filter */
2096
- this.filterable = true;
2097
- /* should not consider lookup column on search */
2098
- this.skipLookupSearch = false;
2099
- /* column is grouped */
2100
- this.groupedValue = false;
2101
- /* Value to show when grouped value is empty */
2102
- this.groupLabelForEmptyValue = '';
2103
- /* column is visible */
2104
- this.isVisibleValue = true;
2105
- /**
2106
- * Defines if the column should store the componentProps datasource.data in memory
2107
- */
2108
- this.storeData = true;
2109
- this.lookup = debounce__default["default"](this.lookupFn, 100);
2110
- this.grid = grid;
2111
- this.isVisible = this.getInitValue('isVisible', props.isVisible, this.isVisible);
2112
- this.filterProps = this.getInitValue('filterProps', props.filterProps, this.filterProps);
2113
- this.filterable = this.getInitValue('filterable', props.filterable, this.filterable);
2114
- this.filterIndex = this.getInitValue('filterIndex', props.filterIndex, this.filterIndex);
2115
- this.skipLookupSearch = this.getInitValue('skipLookupSearch', props.skipLookupSearch, this.skipLookupSearch);
2116
- this.grouped = this.getInitValue('grouped', props.grouped, this.grouped);
2117
- this.groupOpened = this.getInitValue('groupOpened', props.groupOpened, this.groupOpened);
2118
- this.aggregation = this.getInitValue('aggregation', props.aggregation, this.aggregation);
2119
- this.groupLabelForEmptyValue = this.getInitValue('groupLabelForEmptyValue', props.groupLabelForEmptyValue, this.groupLabelForEmptyValue);
2120
- this.storeData = this.getInitValue('storeData', props.storeData, this.storeData);
2121
- this.createAccessors();
2122
- }
2123
- getLookupData(lookupColumn, value) {
2124
- const emptyRow = {};
2125
- if (this.lookupData[value]) {
2126
- return this.lookupData[value];
2127
- }
2128
- this.lookupData[value] = emptyRow;
2129
- const dataIndex = this.lookupDatasource.data.findIndex((row) => row[lookupColumn] === value);
2130
- if (dataIndex !== -1) {
2131
- this.lookupData[value] = this.lookupDatasource.data[dataIndex];
2132
- return this.lookupData[value];
2133
- }
2134
- this.dataToLookup = (this.dataToLookup || []);
2135
- this.dataToLookup.push(value);
2136
- this.lookup(lookupColumn);
2137
- return emptyRow;
2138
- }
2139
- lookupFn(lookupColumn, dataToLookup) {
2140
- return __awaiter(this, void 0, void 0, function* () {
2141
- let data = [];
2142
- this.loading = true;
2143
- if (this.storeData) {
2144
- data = yield this.lookupDatasource.get();
2145
- }
2146
- else {
2147
- const filteredData = Array.from(new Set(dataToLookup || this.dataToLookup)); // remove duplicates
2148
- if (!dataToLookup) {
2149
- this.dataToLookup = [];
2150
- }
2151
- data = yield this.lookupDatasource.addFilter(lookupColumn, filteredData);
2152
- }
2153
- const lookupData = {};
2154
- data.forEach((row) => {
2155
- lookupData[row[lookupColumn]] = row;
2156
- });
2157
- this.lookupData = Object.assign(Object.assign({}, this.lookupData), lookupData);
2158
- this.lookupDataCount += 1;
2159
- this.loading = false;
2160
- });
2161
- }
2162
- getBatchLookupData(lookupColumn, values) {
2163
- return __awaiter(this, void 0, void 0, function* () {
2164
- const batch = [];
2165
- const dataToLookup = [];
2166
- values.forEach((value) => {
2167
- if (this.lookupData[value]) {
2168
- batch.push(this.lookupData[value]);
2169
- return;
2170
- }
2171
- const dataIndex = this.lookupDatasource.data.findIndex((row) => row[lookupColumn] === value);
2172
- if (dataIndex !== -1) {
2173
- this.lookupData[value] = this.lookupDatasource.data[dataIndex];
2174
- batch.push(this.lookupData[value]);
2175
- return;
2176
- }
2177
- dataToLookup.push(value);
2178
- });
2179
- if (dataToLookup.length > 0) {
2180
- yield this.lookupFn(lookupColumn, dataToLookup);
2181
- dataToLookup.forEach((value) => {
2182
- const row = this.lookupData[value];
2183
- if (row)
2184
- batch.push(row);
2185
- });
2186
- }
2187
- return batch;
2188
- });
2189
- }
2190
- /**
2191
- * Memory search, without changing lookupDatasource
2192
- */
2193
- memorySearch(search) {
2194
- return __awaiter(this, void 0, void 0, function* () {
2195
- if (!this.lookupDatasource) {
2196
- throw new Error('Can\'t search in a column that doesn\'t have a datasource');
2197
- }
2198
- let { data } = this.lookupDatasource;
2199
- if (this.storeData) {
2200
- if (!data.length) {
2201
- data = yield this.lookupDatasource.get();
2202
- }
2203
- }
2204
- else {
2205
- // datasource without the lookup filters
2206
- const defaultDs = core.DatasourceFactory.factory(Object.assign(Object.assign({}, this.componentProps.datasource), { lazyLoad: true, loadAll: true }));
2207
- data = yield defaultDs.get();
2208
- }
2209
- const { dataText } = this.componentProps;
2210
- const searchIn = Array.isArray(dataText) ? dataText : [dataText];
2211
- // get datasource as memory
2212
- const datasource = core.DatasourceFactory.factory({
2213
- searchIn,
2214
- data,
2215
- type: 'memory',
2216
- loadAll: true,
2217
- });
2218
- return datasource.setSearch(search);
2219
- });
2220
- }
2221
- get grouped() {
2222
- return this.groupedValue;
2223
- }
2224
- set grouped(value) {
2225
- const changed = value !== this.groupedValue;
2226
- this.groupedValue = value;
2227
- if (changed) {
2228
- this.changeGrouping();
2229
- }
2230
- }
2231
- get aggregation() {
2232
- return this.aggregationValue;
2233
- }
2234
- set aggregation(value) {
2235
- const changed = value !== this.aggregationValue;
2236
- this.aggregationValue = value;
2237
- if (changed) {
2238
- this.changeGrouping();
2239
- }
2240
- }
2241
- get groupOpened() {
2242
- return this.groupOpenedValue;
2243
- }
2244
- set groupOpened(value) {
2245
- const changed = value !== this.groupOpenedValue;
2246
- this.groupOpenedValue = value;
2247
- if (changed) {
2248
- this.changeGrouping();
2249
- }
2250
- }
2251
- get isVisible() {
2252
- return this.isVisibleValue && !this.grouped;
2253
- }
2254
- set isVisible(value) {
2255
- this.isVisibleValue = value;
2256
- }
2257
- changeGrouping() {
2258
- // wait for grid.constructor to be fully executed
2259
- setTimeout(() => {
2260
- this.grid.updateGrouping();
2261
- });
2262
- }
2263
- }
2264
-
2265
- /**
2266
- * Thrown when a row has incomplete group information.
2267
- * Provides details about the missing groups and the problematic row.
2268
- */
2269
- class IncompleteGroupsError extends Error {
2270
- constructor(row, missingGroups) {
2271
- const rowPreview = JSON.stringify(row);
2272
- const message = `Row groups are incomplete. Missing groups: ${missingGroups.join(', ')}.\nRow data:\n${rowPreview}`;
2273
- super(message);
2274
- this.name = 'IncompleteGroupsError';
2275
- }
2276
- }
2277
-
2278
- /* TekGrid Class */
2279
- class TekGrid extends common.GridEditable {
2280
- /**
2281
- * TekGrid class constructor
2282
- * @param props TekGrid properties
2283
- */
2284
- constructor(props) {
2285
- super(props);
2286
- /* Grid Title */
2287
- this.title = '';
2288
- /* Show Add button */
2289
- this.addButton = false;
2290
- /* Show Delete button */
2291
- this.deleteButton = 'none';
2292
- /* Show Delete button */
2293
- this.actions = [];
2294
- /* Show edit button */
2295
- this.showEditButtons = true;
2296
- /* Show Filter button */
2297
- this.filterButton = false;
2298
- /* Show SearchInput */
2299
- this.showSearch = true;
2300
- /* Show Column Filter button */
2301
- this.columnFilterButton = false;
2302
- /* Show Columns button */
2303
- this.columnsButton = false;
2304
- /* Defines if the grid is the unique grid on screen */
2305
- this.mainGrid = true;
2306
- /* Columns to be ignored on columns button */
2307
- this.columnsButtonIgnore = [];
2308
- /* Show Hide button */
2309
- this.showHideButton = true;
2310
- /**
2311
- * Enables column dragging
2312
- * @public
2313
- */
2314
- this.dragColumns = true;
2315
- /**
2316
- * Components that will be rendered on toolbar slot
2317
- */
2318
- this.toolbarConfig = [];
2319
- /**
2320
- * Enables column resizing
2321
- * @public
2322
- */
2323
- this.resizeColumns = true;
2324
- /**
2325
- * Enables layout saving
2326
- * @public
2327
- */
2328
- this.showLayoutOptions = true;
2329
- this.modalFilterProps = {
2330
- name: this.name,
2331
- height: 'auto',
2332
- persistent: true,
2333
- cssClass: '',
2334
- cssStyle: '',
2335
- dark: false,
2336
- draggable: false,
2337
- fullscreen: false,
2338
- dragHandle: '',
2339
- title: 'FILTER',
2340
- };
2341
- /**
2342
- * Show export button
2343
- */
2344
- this.showExport = false;
2345
- /**
2346
- * Show refresh button
2347
- */
2348
- this.showReload = true;
2349
- /**
2350
- * Export config
2351
- */
2352
- this.exportConfig = [
2353
- {
2354
- type: 'pdf',
2355
- label: core.I18n.translate('TEKGRID_EXPORT_AS', { type: 'PDF' }),
2356
- multiOption: [
2357
- { label: core.I18n.translate('TEKGRID_PORTRAIT'), iconName: 'mdi-file-outline' },
2358
- {
2359
- label: core.I18n.translate('TEKGRID_LANDSCAPE'),
2360
- iconName: 'mdi-file-outline',
2361
- cssClass: 'tek-grid-export-landscape',
2362
- reportParams: { portrait: false },
2363
- },
2364
- ],
2365
- },
2366
- {
2367
- type: 'xls',
2368
- label: core.I18n.translate('TEKGRID_EXPORT_AS', {
2369
- type: 'XLS',
2370
- }),
2371
- },
2372
- {
2373
- type: 'xls2',
2374
- label: core.I18n.translate('TEKGRID_EXPORT_AS', {
2375
- type: `XLS ${core.I18n.translate('TEKGRID_WITH_GROUPS')}`,
2376
- }),
2377
- },
2378
- {
2379
- type: 'xls3',
2380
- label: core.I18n.translate('TEKGRID_EXPORT_AS', {
2381
- type: `XLS ${core.I18n.translate('TEKGRID_GRID_MIRROR')}`,
2382
- }),
2383
- },
2384
- {
2385
- type: 'csv',
2386
- label: core.I18n.translate('TEKGRID_EXPORT_AS', { type: 'CSV' }),
2387
- },
2388
- ];
2389
- /**
2390
- * Groups should be opened by default after building
2391
- */
2392
- this.groupsOpened = false;
2393
- /**
2394
- * Show Total summary
2395
- */
2396
- this.showSummaryTotal = true;
2397
- this.groupColumnNames = [];
2398
- this.summaryColumns = [];
2399
- this.groupColumns = [];
2400
- this.toolbarSlotProps = false;
2401
- this.groupedData = [];
2402
- this.editNewRowsOnly = false;
2403
- this.showCheckboxAllFilter = core.Config.gridShowCheckboxAllFilter || false;
2404
- this.defaultFilter = {};
2405
- this.toolbarOpened = true;
2406
- this.reportTitle = '';
2407
- this.defaultLazy = false;
2408
- this.groups = [];
2409
- this.summary = {};
2410
- /**
2411
- * Tasks that should be finished before loading the grid data
2412
- */
2413
- this.tasksBeforeLoad = [];
2414
- this.request = debounce__default["default"](() => { this.datasource.get(); }, 500);
2415
- this.updateGrouping = debounce__default["default"]((lazyLoad = false) => {
2416
- this.updateGroupedData(lazyLoad);
2417
- }, 100);
2418
- this.title = this.getInitValue('title', props.title, this.title);
2419
- this.addButton = this.getInitValue('addButton', props.addButton, this.addButton);
2420
- this.deleteButton = this.getInitValue('deleteButton', props.deleteButton, this.deleteButton);
2421
- this.filterButton = this.getInitValue('filterButton', props.filterButton, this.filterButton);
2422
- this.showSearch = this.getInitValue('showSearch', props.showSearch, this.showSearch);
2423
- this.columnFilterButton = this.getInitValue('columnFilterButton', props.columnFilterButton, this.columnFilterButton);
2424
- this.columnsButton = this.getInitValue('columnsButton', props.columnsButton, this.columnsButton);
2425
- this.columnsButtonIgnore = this.getInitValue('columnsButtonIgnore', props.columnsButtonIgnore, this.columnsButtonIgnore);
2426
- this.showHideButton = this.getInitValue('showHideButton', props.showHideButton, this.showHideButton);
2427
- this.showEditButtons = this.getInitValue('showEditButtons', props.showEditButtons, this.showEditButtons);
2428
- this.dragColumns = this.getInitValue('dragColumns', props.dragColumns, this.dragColumns);
2429
- this.resizeColumns = this.getInitValue('resizeColumns', props.resizeColumns, this.resizeColumns);
2430
- this.showLayoutOptions = this.getInitValue('showLayoutOptions', props.showLayoutOptions, this.showLayoutOptions);
2431
- this.xlsDefaultType = this.getInitValue('xlsDefaultType', props.xlsDefaultType, this.xlsDefaultType);
2432
- this.showExport = this.getInitValue('showExport', props.showExport, this.showExport);
2433
- this.showReload = this.getInitValue('showReload', props.showReload, this.showReload);
2434
- this.exportConfig = this.getInitValue('exportConfig', props.exportConfig, this.exportConfig);
2435
- this.modalFilterProps = this.getInitValue('modalFilterProps', props.modalFilterProps, this.modalFilterProps);
2436
- this.exportActions = props.exportActions || this.exportActions;
2437
- this.groupsOpened = this.getInitValue('groupsOpened', props.groupsOpened, this.groupsOpened);
2438
- this.showSummaryTotal = this.getInitValue('showSummaryTotal', props.showSummaryTotal, this.showSummaryTotal);
2439
- this.showCheckboxAllFilter = this.getInitValue('showCheckboxAllFilter', props.showCheckboxAllFilter, this.showCheckboxAllFilter);
2440
- this.defaultFilter = this.getInitValue('defaultFilter', props.defaultFilter, this.defaultFilter);
2441
- this.toolbarConfig = this.getInitValue('toolbarConfig', props.toolbarConfig, this.toolbarConfig);
2442
- this.toolbarOpened = this.getInitValue('toolbarOpened', props.toolbarOpened, this.toolbarOpened);
2443
- this.editNewRowsOnly = this.getInitValue('editNewRowsOnly', props.editNewRowsOnly, this.editNewRowsOnly);
2444
- this.mainGrid = this.getInitValue('mainGrid', props.mainGrid, this.mainGrid);
2445
- this.reportTitle = this.getInitValue('reportTitle', props.reportTitle, this.reportTitle);
2446
- this.reportLabelFormatter = this.getInitValue('reportLabelFormatter', props.reportLabelFormatter, this.reportLabelFormatter);
2447
- this.actions = props.actions || this.actions;
2448
- this.toolbarSlotProps = props.toolbarSlot !== undefined;
2449
- if (this.deleteButton === 'selection') {
2450
- this.selectable = true;
2451
- }
2452
- this.keyShortcutKeyMapping = {
2453
- 'mod+f': {
2454
- event: this.focusSearchInput.bind(this),
2455
- stop: true,
2456
- active: !this.mainGrid,
2457
- input: true,
2458
- },
2459
- 'mod+l': {
2460
- event: ({ event, element }) => {
2461
- if (this.filterButton) {
2462
- const instance = core.Metadata.getInstance(`${this.name}_filterButton`);
2463
- instance.click(event, element);
2464
- }
2465
- },
2466
- stop: true,
2467
- active: !this.mainGrid,
2468
- input: true,
2469
- },
2470
- 'mod+enter': {
2471
- event: () => {
2472
- const instance = core.Metadata.getInstance(`${this.name}_actions_dropdown`);
2473
- instance.setFocus();
2474
- instance.value = !instance.value;
2475
- },
2476
- stop: true,
2477
- active: !this.mainGrid,
2478
- input: true,
2479
- },
2480
- };
2481
- this.createAccessors();
2482
- this.defaultLazy = this.getDefaultLazy(props);
2483
- this.gridBase = new GridBase(this);
2484
- this.filterOperationsDatasource = this.gridBase.getFilterOperationsDatasource();
2485
- this.filterRelationsDatasource = this.gridBase.getFilterRelationsDatasource();
2486
- }
2487
- getDatasourceDefaults() {
2488
- return { lazyLoad: true };
2489
- }
2490
- getDefaultLazy(props) {
2491
- if (typeof props.datasource === 'object') {
2492
- return props.datasource.lazyLoad;
2493
- }
2494
- if (typeof props.datasource === 'string' && core.Accessor.isAccessorDefinition(props.datasource)) {
2495
- const [controller, accessor] = core.Accessor.getAccessor(props.datasource);
2496
- const instance = core.Loader.getInstance(controller);
2497
- return instance[accessor].lazyLoad || false;
2498
- }
2499
- return false;
2500
- }
2501
- onCreated() {
2502
- super.onCreated();
2503
- core.Loader.addController(`GridController_${this.componentId}`, new GridController(this));
2504
- if (!this.toolbarSlotProps)
2505
- this.toolbarSlot = this.gridBase.createToolbarProps();
2506
- this.navigationKeyMapping.left = {
2507
- event: this.directionalLeft.bind(this),
2508
- stop: true,
2509
- active: true,
2510
- };
2511
- this.navigationKeyMapping.right = {
2512
- event: this.directionalRight.bind(this),
2513
- stop: true,
2514
- active: true,
2515
- };
2516
- }
2517
- onMounted(element) {
2518
- super.onMounted(element);
2519
- core.KeyMap.bind(this.keyShortcutKeyMapping, this, element);
2520
- this.initGrouping(this.defaultLazy);
2521
- }
2522
- onBeforeDestroy() {
2523
- super.onBeforeDestroy();
2524
- core.KeyMap.unbind(this.keyShortcutKeyMapping, this);
2525
- }
2526
- focusSearchInput() {
2527
- const searchInput = core.Metadata.getInstance(`${this.name}_gridSearch`);
2528
- searchInput.setFocus();
2529
- }
2530
- get layoutOptions() {
2531
- if (!this.showLayoutOptions)
2532
- return undefined;
2533
- return core.Metadata.getInstance(`${this.name}_layout_options`);
2534
- }
2535
- instantiateCancelColumn() {
2536
- return new TekGridColumn(this.getCancelColumnProps(), this);
2537
- }
2538
- /**
2539
- * Get Grid columns objects
2540
- * @param columns Grid columns parameter
2541
- */
2542
- getColumns(columns) {
2543
- return columns.map((column) => new TekGridColumn(column, this));
2544
- }
2545
- columnHasFilterData(column) {
2546
- if (this.datasource instanceof TekRestDatasource
2547
- || this.datasource instanceof TekMemoryDatasource) {
2548
- const dynamicFilter = this.datasource.dynamicFilter[column.name];
2549
- return dynamicFilter && dynamicFilter.length > 0;
2550
- }
2551
- return this.datasource.filter[column.name] && this.datasource.filter[column.name].length > 0;
2552
- }
2553
- buildReportGroups() {
2554
- return this.columns
2555
- .filter((column) => column.grouped)
2556
- .map((column) => ({
2557
- field: column.name,
2558
- header: {
2559
- displayfield: column.name,
2560
- label: core.I18n.translate(column.label),
2561
- },
2562
- name: column.name,
2563
- }));
2564
- }
2565
- buildReportAggregations() {
2566
- const aggregations = {};
2567
- this.columns
2568
- .filter((column) => column.aggregation)
2569
- .forEach((column) => {
2570
- aggregations[column.name] = { expression: column.aggregation };
2571
- });
2572
- return aggregations;
2573
- }
2574
- getReport(type, portrait, rowObj = {}) {
2575
- return __awaiter(this, void 0, void 0, function* () {
2576
- const report = new common.Report(this, this.title || this.reportTitle);
2577
- const reportGroups = this.buildReportGroups();
2578
- const reportAggregations = this.buildReportAggregations();
2579
- let typeValue = type;
2580
- if (reportGroups.length === 0 && type.substring(0, 3) === 'xls') {
2581
- typeValue = 'xls';
2582
- }
2583
- let filter;
2584
- if (this.datasource instanceof TekRestDatasource
2585
- || this.datasource instanceof TekMemoryDatasource) {
2586
- const dynamicFilter = Object.assign({}, this.datasource.dynamicFilter);
2587
- const formatFilter = (name) => __awaiter(this, void 0, void 0, function* () {
2588
- let column;
2589
- try {
2590
- column = this.getColumn(name);
2591
- }
2592
- catch (e) {
2593
- if (e instanceof common.ColumnNotFoundError) {
2594
- return;
2595
- }
2596
- throw e;
2597
- }
2598
- const { label } = column;
2599
- // change filter keys to column labels
2600
- dynamicFilter[label] = [...dynamicFilter[name]];
2601
- delete dynamicFilter[name];
2602
- if (!column.componentProps.datasource)
2603
- return;
2604
- const values = dynamicFilter[label].map((filterItem) => filterItem.value);
2605
- yield column.getBatchLookupData(name, values);
2606
- dynamicFilter[label] = dynamicFilter[label].map((filterItem) => {
2607
- const item = Object.assign({}, filterItem);
2608
- const { value } = item;
2609
- const formatted = column.formatterByRow({ [name]: value }, { formatterDataText: undefined });
2610
- item.value = formatted;
2611
- return item;
2612
- });
2613
- });
2614
- const promises = Object.keys(dynamicFilter).map(formatFilter);
2615
- yield Promise.all(promises);
2616
- const reportFilter = new ReportFilter(dynamicFilter);
2617
- filter = reportFilter.build();
2618
- }
2619
- let beforeOpen;
2620
- if (typeof this.events.beforeOpenReport === 'function') {
2621
- beforeOpen = this.events.beforeOpenReport;
2622
- }
2623
- try {
2624
- const reportUrl = yield report
2625
- .getReport(typeValue, portrait, {
2626
- metaData: merge__default["default"](rowObj, {
2627
- filter,
2628
- groups: reportGroups,
2629
- columns: reportAggregations,
2630
- xlsDefaultType: this.xlsDefaultType,
2631
- }),
2632
- }, beforeOpen, this.reportLabelFormatter);
2633
- window.open(reportUrl);
2634
- }
2635
- catch (e) {
2636
- if (e instanceof common.EmptyDataError) {
2637
- common.AlertService.show({ name: 'no-data-warning', text: core.I18n.translate('TEKGRID_NO_DATA'), color: 'warning' });
2638
- return;
2639
- }
2640
- throw e;
2641
- }
2642
- });
2643
- }
2644
- registerTask(task) {
2645
- this.tasksBeforeLoad.push(task);
2646
- }
2647
- /**
2648
- * Loads grid data after resolving all tasks
2649
- */
2650
- loadAfterTasks() {
2651
- return __awaiter(this, void 0, void 0, function* () {
2652
- Promise.all(this.tasksBeforeLoad.map((promise) => promise.catch(() => undefined)));
2653
- this.tasksBeforeLoad = [];
2654
- return this.request();
2655
- });
2656
- }
2657
- initGrouping(lazyLoad) {
2658
- this.initGroups();
2659
- this.initSummaryColumns();
2660
- const originalGetFunction = this.datasource.get;
2661
- this.originalDatasourceLoadAll = this.datasource.loadAll;
2662
- this.originalDatasourceLimit = this.datasource.limit;
2663
- this.datasource.get = this.buildGetFunction(originalGetFunction);
2664
- this.updateGrouping(lazyLoad);
2665
- }
2666
- buildGetFunction(originalGet) {
2667
- return () => __awaiter(this, void 0, void 0, function* () {
2668
- return originalGet.call(this.datasource).then((data) => {
2669
- if (this.groupColumns.length
2670
- || (this.showSummaryTotal && this.summaryColumns.length)) {
2671
- this.buildGroupedData();
2672
- }
2673
- return data;
2674
- });
2675
- });
2676
- }
2677
- updateGroupedData(lazyLoad) {
2678
- return __awaiter(this, void 0, void 0, function* () {
2679
- this.initSummaryColumns();
2680
- this.groupedData = [];
2681
- this.groupColumns = this.columns.filter((column) => column.grouped);
2682
- this.groupColumnNames = this.groupColumns.map((column) => column.name);
2683
- if (this.groupColumns.length
2684
- || (this.showSummaryTotal && this.summaryColumns.length)) {
2685
- if (this.groupColumns.length) {
2686
- const groupOrderColumns = this.groupColumnNames.map((column) => `${column}.asc`);
2687
- const otherOrderColumns = this.datasource.order.filter((column) => this.groupColumnNames.indexOf(column.split('.')[0]) === -1);
2688
- this.datasource.order = groupOrderColumns.concat(otherOrderColumns);
2689
- }
2690
- this.datasource.loadAll = true;
2691
- }
2692
- else {
2693
- this.datasource.loadAll = this.originalDatasourceLoadAll;
2694
- this.datasource.limit = this.originalDatasourceLimit;
2695
- }
2696
- if (!lazyLoad && this.datasource) {
2697
- yield this.loadAfterTasks();
2698
- }
2699
- if (this.virtualScroll && this.viewUpdateScrollData) {
2700
- this.viewUpdateScrollData();
2701
- }
2702
- if (this.viewUpdateFixedColumns) {
2703
- this.viewUpdateFixedColumns();
2704
- }
2705
- });
2706
- }
2707
- /**
2708
- * It takes a flat array of data and groups it by the group columns specified in
2709
- * the grid.
2710
- */
2711
- buildGroupedData() {
2712
- this.initGroups();
2713
- this.initSummaryColumns();
2714
- this.groupedData = [];
2715
- this.datasource.data.forEach((row) => {
2716
- let groupBreak = false;
2717
- this.groups.forEach((group, index) => {
2718
- const groupValue = row[group.name];
2719
- if (group.lastValue !== groupValue || groupBreak) {
2720
- if (!groupBreak) {
2721
- this.addGroupFooters(index);
2722
- }
2723
- group.lastValue = groupValue;
2724
- this.resetFooterVariables(group);
2725
- this.addGroupHeader(row, group, index);
2726
- groupBreak = true;
2727
- }
2728
- });
2729
- this.groups.forEach((group) => {
2730
- group.lastGroupHeaderRow.children.push(row);
2731
- });
2732
- const groupHeaders = this.groups
2733
- .map((group) => group.lastGroupHeaderRow)
2734
- .filter(Boolean);
2735
- this.groupedData.push(Object.assign(Object.assign({}, row), { groupHeaders }));
2736
- this.calcSummary(row);
2737
- });
2738
- if (this.groupedData.length > 0) {
2739
- this.addGroupFooters(0);
2740
- if (this.showSummaryTotal && this.summaryColumns.length > 0) {
2741
- const summaryRow = this.getSummary();
2742
- this.groupedData.push(summaryRow);
2743
- }
2744
- }
2745
- }
2746
- initGroups() {
2747
- this.groups = [];
2748
- this.groupColumns.forEach((column) => {
2749
- const newGroup = {
2750
- column,
2751
- name: column.name,
2752
- label: column.label,
2753
- lastValue: undefined,
2754
- initialized: false,
2755
- footer: {},
2756
- };
2757
- this.resetFooterVariables(newGroup);
2758
- this.groups.push(newGroup);
2759
- });
2760
- }
2761
- initSummaryColumns() {
2762
- this.summaryColumns = this.columns.filter((column) => !!column.aggregation && !column.grouped);
2763
- this.summary = {};
2764
- }
2765
- addGroupHeader(row, group, index) {
2766
- const groupValue = this.getGroupValue(group, row) || group.column.groupLabelForEmptyValue;
2767
- const groupHeaderRow = {
2768
- group: true,
2769
- groupRow: row,
2770
- groupColumnName: group.column.name,
2771
- groupHeader: true,
2772
- groupIndex: index,
2773
- groupLabel: core.I18n.translate(group.label),
2774
- groupValue,
2775
- groupOpened: group.column.groupOpened || this.groupsOpened,
2776
- groupHeaders: [],
2777
- children: [],
2778
- };
2779
- // add header for outer groups to the added row
2780
- for (let i = 0; i < index; i += 1) {
2781
- groupHeaderRow.groupHeaders.push(this.groups[i].lastGroupHeaderRow);
2782
- }
2783
- group.lastGroupHeaderRow = groupHeaderRow;
2784
- group.initialized = true;
2785
- this.groupedData.push(groupHeaderRow);
2786
- }
2787
- addGroupFooters(groupIndex) {
2788
- if (this.summaryColumns.length === 0) {
2789
- return;
2790
- }
2791
- for (let i = this.groups.length - 1; i >= groupIndex; i -= 1) {
2792
- if (!this.groups[i].initialized)
2793
- return;
2794
- const groupFooterRow = this.getGroupFooter(this.groups[i], i);
2795
- groupFooterRow.groupHeaders = this.getGroupHeaders(groupIndex);
2796
- this.groupedData.push(groupFooterRow);
2797
- }
2798
- }
2799
- /**
2800
- * Creates a group footer, calculating its summary data
2801
- * @param group Group to which this footer is related
2802
- * @param groupIndex Index of the group
2803
- * @returns new group footer
2804
- */
2805
- getGroupFooter(group, groupIndex) {
2806
- const groupFooterRow = Object.assign({ groupIndex, groupFooter: true, groupHeaders: [], groupLabel: group.lastGroupHeaderRow.groupLabel, groupValue: group.lastGroupHeaderRow.groupValue }, this.getSummaryData(group.footer));
2807
- return groupFooterRow;
2808
- }
2809
- /**
2810
- * Gets all of the group headers that belong to the group at the specified index
2811
- * This method should be called only during the groups creation process because it depends on the
2812
- * group creation order (because it accesses lastGroupHeaderRow that changes during the creation process)
2813
- * @param groupIndex
2814
- * @returns
2815
- */
2816
- getGroupHeaders(groupIndex) {
2817
- const groupHeaders = [];
2818
- for (let i = 0; i <= groupIndex; i += 1) {
2819
- groupHeaders.push(this.groups[i].lastGroupHeaderRow);
2820
- }
2821
- return groupHeaders;
2822
- }
2823
- /**
2824
- * Updates all footers summary data and the summary total
2825
- */
2826
- updateSummary() {
2827
- this.summary = {};
2828
- this.groups.forEach((group) => {
2829
- this.resetFooterVariables(group);
2830
- });
2831
- this.groupedData.forEach((row) => {
2832
- if (this.isGroupHeader(row))
2833
- return;
2834
- if (this.isGroupFooter(row)) {
2835
- this.updateGroupFooterSummary(row);
2836
- this.resetFooterVariables(this.groups[row.groupIndex]);
2837
- return;
2838
- }
2839
- if (this.isGroupSummary(row)) {
2840
- this.updateSummaryTotal(row);
2841
- return;
2842
- }
2843
- this.calcSummary(row);
2844
- });
2845
- }
2846
- /**
2847
- * Takes a group footer and updates its summary data
2848
- */
2849
- updateGroupFooterSummary(groupFooter) {
2850
- const group = this.groups[groupFooter.groupIndex];
2851
- const summary = this.getSummaryData(group.footer);
2852
- Object.keys(summary).forEach((key) => {
2853
- // change properties one by one to avoid changing the object reference
2854
- groupFooter[key] = summary[key];
2855
- });
2856
- }
2857
- /**
2858
- * Updates the total summary data
2859
- */
2860
- updateSummaryTotal(summaryTotal) {
2861
- const summary = this.getSummaryData(this.summary);
2862
- Object.keys(summary).forEach((key) => {
2863
- // change properties one by one to avoid changing the object reference
2864
- summaryTotal[key] = summary[key];
2865
- });
2866
- }
2867
- resetFooterVariables(group) {
2868
- this.summaryColumns.forEach((column) => {
2869
- group.footer[column.name] = {
2870
- count: 0,
2871
- sum: undefined,
2872
- avg: undefined,
2873
- min: undefined,
2874
- max: undefined,
2875
- };
2876
- });
2877
- }
2878
- isUndefined(value) {
2879
- return value === undefined || value === null;
2880
- }
2881
- calcSummaryValues(columnName, summary, rowValue) {
2882
- if (!this.isUndefined(rowValue)) {
2883
- summary.count += 1;
2884
- if (this.events.calcSummary) {
2885
- this.callEvent('calcSummary', {
2886
- component: this, columnName, summary, rowValue,
2887
- });
2888
- }
2889
- else {
2890
- if (summary.min === undefined)
2891
- summary.min = rowValue;
2892
- if (summary.max === undefined)
2893
- summary.max = rowValue;
2894
- summary.min = rowValue < summary.min ? rowValue : summary.min;
2895
- summary.max = rowValue > summary.max ? rowValue : summary.max;
2896
- if (typeof rowValue === 'number') {
2897
- summary.sum = (summary.sum || 0) + rowValue;
2898
- }
2899
- }
2900
- }
2901
- }
2902
- calcSummary(row) {
2903
- if (this.summaryColumns.length === 0)
2904
- return;
2905
- this.summaryColumns.forEach((column) => {
2906
- const columnName = column.name;
2907
- const rowValue = this.getVisibleValue(row, column);
2908
- if (this.isUndefined(this.summary[columnName])) {
2909
- this.summary[columnName] = {
2910
- count: 0,
2911
- sum: undefined,
2912
- avg: undefined,
2913
- min: undefined,
2914
- max: undefined,
2915
- };
2916
- }
2917
- this.calcSummaryValues(columnName, this.summary[columnName], rowValue);
2918
- this.groups.forEach((group) => {
2919
- this.calcSummaryValues(columnName, group.footer[columnName], rowValue);
2920
- });
2921
- });
2922
- }
2923
- getSummary() {
2924
- const summaryRow = Object.assign({ groupFooter: true, groupSummary: true }, this.getSummaryData(this.summary));
2925
- return summaryRow;
2926
- }
2927
- getSummaryData(group) {
2928
- const summaryData = {};
2929
- this.summaryColumns.forEach((column) => {
2930
- const { aggregation } = column;
2931
- const currentGroup = group[column.name];
2932
- if (aggregation === 'COUNT') {
2933
- summaryData[column.name] = currentGroup.count;
2934
- }
2935
- else if (aggregation === 'SUM') {
2936
- summaryData[column.name] = currentGroup.sum;
2937
- }
2938
- else if (aggregation === 'AVG') {
2939
- if (currentGroup.avg) {
2940
- summaryData[column.name] = currentGroup.avg;
2941
- }
2942
- else if (typeof currentGroup.sum === 'number') {
2943
- summaryData[column.name] = currentGroup.sum / currentGroup.count;
2944
- }
2945
- }
2946
- else if (aggregation === 'MIN') {
2947
- summaryData[column.name] = currentGroup.min;
2948
- }
2949
- else {
2950
- // if (aggregation === 'MAX') {
2951
- summaryData[column.name] = currentGroup.max;
2952
- }
2953
- });
2954
- return summaryData;
2955
- }
2956
- openGroup(group) {
2957
- group.groupOpened = !group.groupOpened;
2958
- if (this.virtualScroll && this.viewUpdateScrollData)
2959
- this.viewUpdateScrollData();
2960
- }
2961
- isItemVisible(row) {
2962
- return (!row.groupHeaders
2963
- || !row.groupHeaders.length
2964
- || row.groupHeaders.every((group) => group.groupOpened));
2965
- }
2966
- getGroupValue(group, row) {
2967
- const groupColumn = this.getColumn(group.column.name);
2968
- const rowKey = row[this.datasource.uniqueKey];
2969
- if (!this.cellsApplied[rowKey]) {
2970
- this.reapplyConditions(row);
2971
- }
2972
- const cellProps = this.cellsApplied[rowKey][groupColumn.name];
2973
- const groupValue = groupColumn.formatterByRow(row, cellProps);
2974
- return groupValue;
2975
- }
2976
- getEditedRows(revalidate = false, silent = false) {
2977
- return super.getEditedRows(revalidate, silent).map((row) => {
2978
- const cleanRow = Object.assign({}, row);
2979
- delete cleanRow.groupHeaders;
2980
- return cleanRow;
2981
- });
2982
- }
2983
- setSearch(search) {
2984
- return __awaiter(this, void 0, void 0, function* () {
2985
- return this.gridBase.setSearch(search);
2986
- });
2987
- }
2988
- isGrouped() {
2989
- return (this.groupColumnNames.length
2990
- || (this.showSummaryTotal && this.summaryColumns.length));
2991
- }
2992
- navigateDown(params) {
2993
- if (!this.isGrouped()) {
2994
- super.navigateDown();
2995
- return;
2996
- }
2997
- if (this.cellSelection && this.viewNavigate) {
2998
- this.viewNavigate('down');
2999
- return;
3000
- }
3001
- const { index } = params;
3002
- if (!this.groupedData.length || index === this.groupedData.length)
3003
- return;
3004
- const { uniqueKey, currentRow } = this.datasource;
3005
- const rowIndex = index !== undefined
3006
- ? index
3007
- : this.groupedData.findIndex((row) => {
3008
- if (currentRow.group) {
3009
- return row.group && row.groupValue === currentRow.groupValue;
3010
- }
3011
- return row[uniqueKey] && row[uniqueKey] === currentRow[uniqueKey];
3012
- });
3013
- const newRow = this.groupedData[rowIndex + 1];
3014
- if (!newRow || !this.isItemVisible(newRow) || newRow.groupFooter) {
3015
- this.navigateDown({ index: rowIndex + 1 });
3016
- return;
3017
- }
3018
- this.datasource.currentRow = newRow;
3019
- }
3020
- navigateUp(params) {
3021
- if (!this.isGrouped()) {
3022
- super.navigateUp();
3023
- return;
3024
- }
3025
- if (this.cellSelection && this.viewNavigate) {
3026
- this.viewNavigate('up');
3027
- return;
3028
- }
3029
- const { index } = params;
3030
- if (!this.groupedData.length || index === -1)
3031
- return;
3032
- const { uniqueKey, currentRow } = this.datasource;
3033
- let rowIndex;
3034
- rowIndex = index !== undefined
3035
- ? index
3036
- : this.groupedData.findIndex((row) => {
3037
- if (currentRow.group) {
3038
- return row.group && row.groupValue === currentRow.groupValue;
3039
- }
3040
- return row[uniqueKey] && row[uniqueKey] === currentRow[uniqueKey];
3041
- });
3042
- if (rowIndex === -1)
3043
- rowIndex = this.groupedData.length;
3044
- const newRow = this.groupedData[rowIndex - 1];
3045
- if (!newRow || !this.isItemVisible(newRow) || newRow.groupFooter) {
3046
- this.navigateUp({ index: rowIndex - 1 });
3047
- return;
3048
- }
3049
- this.datasource.currentRow = newRow;
3050
- }
3051
- directionalLeft(params) {
3052
- var _a;
3053
- const { currentRow } = this.datasource;
3054
- if (currentRow.group && currentRow.groupOpened) {
3055
- currentRow.groupOpened = false;
3056
- return;
3057
- }
3058
- if (!this.cellSelection && ((_a = currentRow.groupHeaders) === null || _a === void 0 ? void 0 : _a.length)) {
3059
- this.datasource.currentRow = currentRow.groupHeaders[currentRow.groupHeaders.length - 1];
3060
- return;
3061
- }
3062
- this.navigateLeft(params);
3063
- }
3064
- directionalRight(params) {
3065
- const { currentRow } = this.datasource;
3066
- if (currentRow.group && !currentRow.groupOpened) {
3067
- currentRow.groupOpened = true;
3068
- return;
3069
- }
3070
- this.navigateRight(params);
3071
- }
3072
- /**
3073
- * Dispatches row click event
3074
- * @param row Grid row
3075
- * @param event DOM event
3076
- * @param element DOM Element
3077
- */
3078
- rowClick(row, event, element) {
3079
- if (!this.preventRowClick) {
3080
- this.datasource.currentRow = row;
3081
- this.callEvent('rowClick', {
3082
- event,
3083
- element,
3084
- row,
3085
- component: this,
3086
- column: undefined,
3087
- });
3088
- }
3089
- this.preventRowClick = false;
3090
- }
3091
- rowDoubleClick(row, event, element) {
3092
- if (!this.preventRowDoubleClick) {
3093
- this.datasource.currentRow = row;
3094
- this.callEvent('rowDoubleClick', {
3095
- event,
3096
- element,
3097
- row,
3098
- component: this,
3099
- column: undefined,
3100
- });
3101
- }
3102
- this.preventRowDoubleClick = false;
3103
- }
3104
- /**
3105
- * Dispatches group row click event
3106
- * @param row Grid row
3107
- * @param event DOM event
3108
- * @param element DOM Element
3109
- */
3110
- groupRowClick(row, event, element) {
3111
- if (!this.preventRowClick) {
3112
- this.datasource.currentRow = row;
3113
- this.callEvent('groupRowClick', {
3114
- event,
3115
- element,
3116
- row,
3117
- component: this,
3118
- column: undefined,
3119
- });
3120
- }
3121
- this.preventRowClick = false;
3122
- }
3123
- groupRowDoubleClick(row, event, element) {
3124
- if (!this.preventRowDoubleClick) {
3125
- this.datasource.currentRow = row;
3126
- this.callEvent('groupRowDoubleClick', {
3127
- event,
3128
- element,
3129
- row,
3130
- component: this,
3131
- column: undefined,
3132
- });
3133
- }
3134
- this.preventRowDoubleClick = false;
3135
- }
3136
- /**
3137
- * Dispatches group select/unselect event
3138
- * @param row Group row
3139
- * @param isSelected Row is selected
3140
- * @param event DOM event
3141
- * @param element DOM Element
3142
- */
3143
- selectGroupClick(row, isSelected, event, element) {
3144
- if (isSelected) {
3145
- this.callEvent('groupSelected', {
3146
- event,
3147
- element,
3148
- row,
3149
- component: this,
3150
- column: undefined,
3151
- });
3152
- }
3153
- else {
3154
- this.callEvent('groupUnselected', {
3155
- event,
3156
- element,
3157
- row,
3158
- component: this,
3159
- column: undefined,
3160
- });
3161
- }
3162
- }
3163
- getAtomInstance(key) {
3164
- return this.gridBase.getAtomInstance(key);
3165
- }
3166
- getFilterInputs(columnName) {
3167
- return this.gridBase.getFilterInputs(columnName);
3168
- }
3169
- isColumnSearchable(column) {
3170
- return column.searchable && (!this.searchVisibleOnly || column.isVisible || column.grouped);
3171
- }
3172
- getColumn(name) {
3173
- return super.getColumn(name);
3174
- }
3175
- /**
3176
- * Adds new row to the datasource data and pushes it to the editedRows
3177
- * @param row Row
3178
- * @param position whether the new Row will be inserted at the beginning or end of the data array
3179
- */
3180
- addNewRow(row, position = 'end') {
3181
- const _super = Object.create(null, {
3182
- addNewRow: { get: () => super.addNewRow }
3183
- });
3184
- return __awaiter(this, void 0, void 0, function* () {
3185
- if (!this.groupColumns.length) {
3186
- yield _super.addNewRow.call(this, row, position);
3187
- return;
3188
- }
3189
- this.insertRowInDatasource(row, position);
3190
- this.saveRowReference(row);
3191
- this.addGroupedRow(row, position);
3192
- this.editing = true;
3193
- });
3194
- }
3195
- /**
3196
- * Takes a row and adds it to the selected group (datasource.currentRow)
3197
- * @param row the new row to be added
3198
- * @param position the position, at the beginning of the group or at the end
3199
- */
3200
- addToSelection(row, position = 'end') {
3201
- const { currentRow } = this.datasource;
3202
- // if the currentRow is a group, use the groupRow as reference
3203
- const referenceRow = this.isGroupHeader(currentRow) ? currentRow.groupRow : currentRow;
3204
- // extract the group properties from the referenceRow to add to the new row
3205
- const groupProperties = extractProperties(referenceRow, this.groupColumnNames);
3206
- const rowWithGroups = Object.assign(Object.assign({}, row), groupProperties);
3207
- return this.addNewRow(rowWithGroups, position);
3208
- }
3209
- /**
3210
- * Adds a new row to the groupedData array
3211
- * @param row the new row to be added
3212
- * @param position the position, at the beginning of the group or at the end
3213
- */
3214
- addGroupedRow(row, position) {
3215
- const missingGroups = this.findMissingGroups(row);
3216
- if (missingGroups.length > 0) {
3217
- throw new IncompleteGroupsError(row, missingGroups);
3218
- }
3219
- const { index, group } = this.findLastGroupingIndex(row);
3220
- const groupHeaders = [...group.groupHeaders, group];
3221
- const newGroupedRow = Object.assign(Object.assign({}, row), { groupHeaders });
3222
- if (position === 'end') {
3223
- const childrenLength = group.children.length;
3224
- this.groupedData.splice(index + childrenLength + 1, 0, newGroupedRow);
3225
- }
3226
- else {
3227
- this.groupedData.splice(index + 1, 0, newGroupedRow);
3228
- }
3229
- groupHeaders.forEach((groupHeader) => {
3230
- // open all groups, making the new row visible to the user
3231
- groupHeader.groupOpened = true;
3232
- this.addRowToGroupChildren(row, groupHeader, position);
3233
- });
3234
- }
3235
- findMissingGroups(row) {
3236
- return this.groupColumnNames.filter((group) => row[group] === undefined);
3237
- }
3238
- /**
3239
- * Finds the last group (most internal group) where a row should be inserted
3240
- * @param row to be inserted
3241
- * @returns the index and the group where the row should be inserted
3242
- */
3243
- findLastGroupingIndex(row) {
3244
- const index = this.groupedData.findIndex((groupRow) => {
3245
- // ignore rows that are not headers or not the last grouping (most internal groping)
3246
- if (!this.isGroupHeader(groupRow) || !this.isLastGrouping(groupRow))
3247
- return false;
3248
- // if the new added row is not part of the group, ignore it
3249
- if (groupRow.groupValue !== row[groupRow.groupColumnName])
3250
- return false;
3251
- if (this.groupColumns.length === 1)
3252
- return true;
3253
- const matchHeaders = groupRow.groupHeaders.every((groupHeader) => (groupHeader.groupValue === row[groupHeader.groupColumnName]));
3254
- return matchHeaders;
3255
- });
3256
- if (index === -1) {
3257
- // No existing group found, so we create the full group hierarchy
3258
- return this.createGroupHierarchyForRow(row);
3259
- }
3260
- const group = this.groupedData[index];
3261
- return { index, group };
3262
- }
3263
- /**
3264
- * Creates a group hierarchy for a new row, creating intermediate groups if needed
3265
- * @param row to be inserted
3266
- * @returns the index and the group where the row should be inserted
3267
- */
3268
- createGroupHierarchyForRow(row) {
3269
- let groupHeaders = [];
3270
- let insertionIndex = this.groupedData.length; // default to end
3271
- this.groups.forEach((column) => {
3272
- const groupValue = row[column.name];
3273
- const existingGroupIndex = this.groupedData.findIndex((groupRow) => this.isGroupHeader(groupRow)
3274
- && groupRow.groupColumnName === column.name
3275
- && groupRow.groupValue === groupValue
3276
- && groupRow.groupHeaders.every((h, j) => h.groupValue === groupHeaders[j].groupValue));
3277
- if (existingGroupIndex !== -1) {
3278
- const existingGroup = this.groupedData[existingGroupIndex];
3279
- groupHeaders = [...existingGroup.groupHeaders, existingGroup];
3280
- insertionIndex = existingGroupIndex;
3281
- return;
3282
- }
3283
- // Create new group header
3284
- const newGroup = {
3285
- group: true,
3286
- groupHeader: true,
3287
- groupValue,
3288
- groupColumnName: column.name,
3289
- groupHeaders: [...groupHeaders],
3290
- children: [],
3291
- groupRow: row,
3292
- groupIndex: groupHeaders.length,
3293
- groupLabel: core.I18n.translate(column.label),
3294
- groupOpened: true,
3295
- };
3296
- // Insert right after last insertionIndex
3297
- insertionIndex += 1;
3298
- this.groupedData.splice(insertionIndex, 0, newGroup);
3299
- groupHeaders.push(newGroup);
3300
- });
3301
- const group = groupHeaders[groupHeaders.length - 1]; // the most inner group
3302
- return { index: insertionIndex, group };
3303
- }
3304
- /**
3305
- * Adds a row to the children of a group
3306
- */
3307
- addRowToGroupChildren(row, group, position) {
3308
- if (position === 'end') {
3309
- group.children.push(row);
3310
- return;
3311
- }
3312
- group.children.unshift(row);
3313
- }
3314
- /**
3315
- * Checks if a row is a group header, adding typescript type-checking
3316
- */
3317
- isGroupHeader(row) {
3318
- return row.groupHeader;
3319
- }
3320
- /**
3321
- * Checks if a row is a group footer, adding typescript type-checking
3322
- */
3323
- isGroupFooter(row) {
3324
- return row.groupFooter && !row.groupSummary;
3325
- }
3326
- /**
3327
- * Checks if a row is a summary, adding typescript type-checking
3328
- */
3329
- isGroupSummary(row) {
3330
- return row.groupSummary;
3331
- }
3332
- /**
3333
- * Checks if a row is the last grouping of the grid (the most internal grouping)
3334
- */
3335
- isLastGrouping(group) {
3336
- return group.groupColumnName === this.groupColumns[this.groupColumns.length - 1].name;
3337
- }
3338
- /**
3339
- * change event of editable components
3340
- * - override to call updateSummary on change
3341
- */
3342
- changeEditableComponent(column, row, value, component) {
3343
- super.changeEditableComponent(column, row, value, component);
3344
- this.updateSummary();
3345
- }
3346
- }
3347
-
3348
- class TekGridColumnsButtonController extends common.IterableColumnsButtonController {
3349
- changeGroupedColumn(column, { component, event, element }) {
3350
- column.grouped = component.value;
3351
- if (!column.grouped) {
3352
- const index = this.iterableComponent.datasource.order.indexOf(`${column.name}.asc`);
3353
- this.iterableComponent.datasource.order.splice(index, 1);
3354
- }
3355
- this.iterableComponent.changeLayout(event, element);
3356
- }
3357
- changeAggregationColumn(column, { component, event, element }) {
3358
- const newValue = component.value || undefined;
3359
- if (column.aggregation !== newValue) {
3360
- this.iterableComponent.changeLayout(event, element);
3361
- }
3362
- column.aggregation = newValue;
3363
- }
3364
- showHideTekColumn(column, { component, event, element }) {
3365
- if (!component.value && column.grouped)
3366
- column.grouped = false;
3367
- column.isVisible = component.value;
3368
- this.iterableComponent.changeLayout(event, element);
3369
- }
3370
- }
3371
-
3372
- /**
3373
- * Base class for TekGrid Columns Button component
3374
- */
3375
- class TekGridColumnsButton extends common.IterableColumnsButton {
3376
- constructor(props) {
3377
- super(props);
3378
- this.hideGroups = false;
3379
- this.aggregationDataSet = [];
3380
- this.hideGroups = this.getInitValue('hideGroups', props.hideGroups, this.hideGroups);
3381
- this.createAccessors();
3382
- }
3383
- onCreated() {
3384
- super.onCreated();
3385
- this.controller = new TekGridColumnsButtonController(this.iterableComponent);
3386
- core.Loader.addController(`IterableColumnsButtonController_${this.componentId}`, this.controller);
3387
- }
3388
- getAggregationSelectData() {
3389
- if (!this.aggregationDataSet.length) {
3390
- this.aggregationDataSet = columnAggregationValues.filter(Boolean).map((value) => ({
3391
- text: core.I18n.translate(`TEKGRID_AGGREGATION_${value}`),
3392
- value,
3393
- }));
3394
- }
3395
- return this.aggregationDataSet;
3396
- }
3397
- }
3398
-
3399
- class TekFilterHelper {
3400
- static getLabel(name) {
3401
- return core.DateHelper.getLabel(name);
3402
- }
3403
- static getValue(name, column) {
3404
- return core.DateHelper.getValue(name, column.componentProps.dateFormat);
3405
- }
3406
- static register(name, label, fn) {
3407
- core.DateHelper.register(name, label, fn);
3408
- }
3409
- static unregister(name) {
3410
- core.DateHelper.unregister(name);
3411
- }
3412
- }
3413
-
3414
- /**
3415
- * Base class for TekGrid Filter Button component
3416
- */
3417
- class TekGridFilterButton extends common.Button {
3418
- constructor(props) {
3419
- super(props);
3420
- this.showCheckboxAll = false;
3421
- this.filterFormInputs = {};
3422
- this.gridName = this.getInitValue('gridName', props.gridName, this.gridName);
3423
- this.grid = this.getInitValue('grid', props.grid, undefined);
3424
- this.showCheckboxAll = this.getInitValue('showCheckboxAll', props.showCheckboxAll, this.showCheckboxAll);
3425
- this.createAccessors();
3426
- if (!this.grid)
3427
- this.loadGrid();
3428
- }
3429
- loadGrid(gridName) {
3430
- if (gridName)
3431
- this.gridName = gridName;
3432
- if (!this.gridName)
3433
- return;
3434
- this.grid = core.Metadata.getInstances(this.gridName)[0];
3435
- }
3436
- click(event) {
3437
- this.callEvent('click', { component: this, event });
3438
- this.grid.callEvent('filterClick', { component: this.grid, event });
3439
- if (!(event === null || event === void 0 ? void 0 : event.defaultPrevented)) {
3440
- this.createFilterFromColumns.call(this);
3441
- }
3442
- }
3443
- loadFilterValues({ component }) {
3444
- const changedCompNames = [];
3445
- const { datasource } = this.grid;
3446
- if (datasource instanceof TekRestDatasource || datasource instanceof TekMemoryDatasource) {
3447
- const { dynamicFilter } = datasource;
3448
- const newDynamicFilter = Object.assign(Object.assign({}, this.grid.defaultFilter), dynamicFilter);
3449
- Object.keys(newDynamicFilter).forEach((column) => {
3450
- if (newDynamicFilter[column] && newDynamicFilter[column].length > 0) {
3451
- newDynamicFilter[column].forEach((filterItem, index) => {
3452
- const relation = filterItem.relation || 'AND';
3453
- const operation = filterItem.operation || 'CONTAINS';
3454
- const compName = `${this.grid.name}-filter-${relation}-${operation}-${column}-${index}`;
3455
- changedCompNames.push(compName);
3456
- component.value[compName] = filterItem.value;
3457
- let helperValue = '';
3458
- const columnObj = this.grid.getColumn(column);
3459
- if (columnObj instanceof TekGridColumn) {
3460
- const { filterProps } = columnObj;
3461
- if (!Array.isArray(filterProps)) {
3462
- helperValue = filterProps.helperValue || '';
3463
- }
3464
- else {
3465
- filterProps.forEach((prop) => {
3466
- if ((prop.relation || 'AND') === relation && (prop.operation || 'CONTAINS') === operation) {
3467
- helperValue = prop.helperValue || '';
3468
- }
3469
- });
3470
- }
3471
- const inputObj = core.Metadata.getInstances(compName);
3472
- if (helperValue && inputObj.length && inputObj[0]) {
3473
- inputObj[0].hint = TekFilterHelper.getLabel(helperValue);
3474
- }
3475
- }
3476
- });
3477
- }
3478
- });
3479
- }
3480
- else {
3481
- const { filter } = datasource;
3482
- const newFilter = Object.assign(Object.assign({}, this.grid.defaultFilter), filter);
3483
- Object.keys(newFilter).forEach((item) => {
3484
- if (newFilter[item]) {
3485
- const compName = `${this.grid.name}-filter-AND-CONTAINS-${item}-0`;
3486
- changedCompNames.push(compName);
3487
- component.value[compName] = newFilter[item];
3488
- }
3489
- });
3490
- }
3491
- Object.keys(component.value).forEach((compName) => {
3492
- if (changedCompNames.indexOf(compName) === -1) {
3493
- component.value[compName] = null;
3494
- }
3495
- });
3496
- }
3497
- hideFilterModal() {
3498
- this.filterModal.hide();
3499
- }
3500
- destroyFilterModal() {
3501
- if (this.filterModal)
3502
- this.filterModal.destroy();
3503
- }
3504
- createFilterFromColumns() {
3505
- if (!this.filterModal) {
3506
- const originalProps = {
3507
- height: 'auto',
3508
- maxHeight: '18.75rem',
3509
- persistent: true,
3510
- title: 'FILTER',
3511
- };
3512
- const mergeModalFilterProps = Object.assign(originalProps, this.grid.modalFilterProps);
3513
- const filterModalDef = {
3514
- name: `${this.grid.name}-filter-modal`,
3515
- persistent: mergeModalFilterProps.persistent,
3516
- grid: mergeModalFilterProps.grid,
3517
- cssClass: mergeModalFilterProps.cssClass,
3518
- cssStyle: mergeModalFilterProps.cssStyle,
3519
- draggable: mergeModalFilterProps.draggable,
3520
- dragHandle: mergeModalFilterProps.dragHandle,
3521
- fullscreen: mergeModalFilterProps.fullscreen,
3522
- light: mergeModalFilterProps.light,
3523
- dark: mergeModalFilterProps.dark,
3524
- escKeydownStop: false,
3525
- children: [
3526
- {
3527
- name: `${this.grid.name}-filter-header-container`,
3528
- component: 'ZdContainer',
3529
- cssClass: 'zd-pa-0 zd-display-flex',
3530
- children: [
3531
- {
3532
- name: `${this.grid.name}-filter-title`,
3533
- component: 'ZdText',
3534
- cssStyle: `color: ${'var(--v-primary-base);'}`,
3535
- text: mergeModalFilterProps.title,
3536
- tag: 'h3',
3537
- },
3538
- {
3539
- name: `${this.grid.name}-filter-spacer`,
3540
- component: 'VSpacer',
3541
- },
3542
- {
3543
- name: `${this.grid.name}-filter-close-button`,
3544
- component: 'ZdModalCloseButton',
3545
- small: true,
3546
- modalName: `${this.grid.name}-filter-modal`,
3547
- },
3548
- ],
3549
- },
3550
- {
3551
- name: `${this.grid.name}-filter-content-container`,
3552
- component: 'ZdContainer',
3553
- scrollView: true,
3554
- cssClass: 'zd-my-2 zd-pa-0 tek-grid-filter-content-container',
3555
- maxHeight: mergeModalFilterProps.maxHeight,
3556
- height: mergeModalFilterProps.height,
3557
- children: [
3558
- {
3559
- name: `${this.grid.name}-filter-form`,
3560
- component: 'ZdForm',
3561
- cssClass: 'zd-my-2 zd-pa-0',
3562
- children: this.getFilterModalComponents(),
3563
- events: {
3564
- onMounted: this.loadFilterValues.bind(this),
3565
- },
3566
- },
3567
- ],
3568
- },
3569
- {
3570
- name: `${this.grid.name}-filter-footer-container`,
3571
- component: 'ZdContainer',
3572
- cssClass: 'zd-pa-0',
3573
- children: [
3574
- {
3575
- name: `${this.grid.name}-filter-footer`,
3576
- component: 'ZdFooter',
3577
- color: 'transparent',
3578
- padless: true,
3579
- leftSlot: [
3580
- {
3581
- name: `${this.grid.name}-filter-clearButton`,
3582
- component: 'ZdButton',
3583
- label: 'CLEAR',
3584
- outline: true,
3585
- events: {
3586
- click: this.clearFilter.bind(this),
3587
- },
3588
- },
3589
- ],
3590
- rightSlot: [
3591
- {
3592
- name: `${this.grid.name}-filter-cancelButton`,
3593
- component: 'ZdButton',
3594
- label: 'CANCEL',
3595
- keyMap: {
3596
- esc: {
3597
- event: this.hideFilterModal.bind(this),
3598
- focus: true,
3599
- visible: true,
3600
- input: true,
3601
- stop: true,
3602
- },
3603
- },
3604
- outline: true,
3605
- events: {
3606
- click: this.hideFilterModal.bind(this),
3607
- },
3608
- },
3609
- {
3610
- name: `${this.grid.name}-filter-okButton`,
3611
- component: 'ZdButton',
3612
- label: 'OK',
3613
- events: {
3614
- click: this.applyFilter.bind(this),
3615
- },
3616
- keyMap: {
3617
- 'mod+enter': {
3618
- event: this.applyFilter.bind(this),
3619
- focus: true,
3620
- input: true,
3621
- stop: true,
3622
- visible: true,
3623
- },
3624
- },
3625
- },
3626
- ],
3627
- },
3628
- ],
3629
- },
3630
- ],
3631
- };
3632
- this.filterModal = common.ModalService.create(filterModalDef);
3633
- }
3634
- else {
3635
- this.loadFilterValues({ component: core.Metadata.getInstance(`${this.grid.name}-filter-form`) });
3636
- }
3637
- this.filterModal.show();
3638
- }
3639
- onBeforeDestroy() {
3640
- super.onBeforeDestroy();
3641
- this.destroyFilterModal();
3642
- }
3643
- formatFormValue(filterForm) {
3644
- return Object.keys(filterForm.value).reduce((result, item) => {
3645
- try {
3646
- const itemInstance = filterForm.getChildInstance(item);
3647
- if (!(itemInstance instanceof common.SelectMultiple) || !itemInstance.checkboxAll)
3648
- return result;
3649
- // when selectmultiple with checkboxAll, should either remove it from the filter or
3650
- // change the value to T, depending on selectAllCompatibilityMode
3651
- if (core.Config.selectAllCompatibilityMode) {
3652
- result[item] = 'T';
3653
- return result;
3654
- }
3655
- delete result[item];
3656
- return result;
3657
- }
3658
- catch (e) {
3659
- return result;
3660
- }
3661
- }, Object.assign({}, filterForm.value));
3662
- }
3663
- applyFilter({ event }) {
3664
- const filterForm = core.Metadata.getInstance(`${this.grid.name}-filter-form`);
3665
- if (filterForm.validate()) {
3666
- const { datasource } = this.grid;
3667
- const filter = {};
3668
- const formValue = this.formatFormValue(filterForm);
3669
- if (datasource instanceof TekRestDatasource || datasource instanceof TekMemoryDatasource) {
3670
- Object.keys(formValue).forEach((item) => {
3671
- const itemValue = formValue[item];
3672
- if (itemValue && !(Array.isArray(itemValue) && !itemValue.length)) {
3673
- const relationAndOperationAndName = item.split(`${this.grid.name}-filter-`)[1];
3674
- const [relation, operation] = relationAndOperationAndName.split('-');
3675
- let columnName = relationAndOperationAndName.split(`${relation}-${operation}-`)[1];
3676
- columnName = columnName.split('-').slice(0, -1).join('-'); // remove index
3677
- if (!filter[columnName]) {
3678
- filter[columnName] = [];
3679
- }
3680
- const value = itemValue;
3681
- filter[columnName].push({
3682
- relation,
3683
- operation,
3684
- value,
3685
- });
3686
- }
3687
- });
3688
- datasource.dynamicFilter = filter;
3689
- this.setFilter(filter, event, datasource.setBaseFilter.bind(datasource));
3690
- }
3691
- else {
3692
- Object.keys(formValue).forEach((item) => {
3693
- let columnName = item.split(`${this.grid.name}-filter-AND-CONTAINS-`)[1];
3694
- columnName = columnName.split('-').slice(0, -1).join('-'); // remove index
3695
- if (formValue[item]) {
3696
- filter[columnName] = formValue[item];
3697
- }
3698
- });
3699
- datasource.filter = filter;
3700
- this.setFilter(filter, event, datasource.setBaseFilter.bind(datasource));
3701
- }
3702
- this.grid.changeLayout(event);
3703
- }
3704
- }
3705
- setFilter(filter, event, filterFn) {
3706
- this.grid.callEvent('beforeApplyFilter', { component: this.grid, event });
3707
- if (event.defaultPrevented)
3708
- return;
3709
- filterFn(filter);
3710
- this.hideFilterModal();
3711
- }
3712
- clearFilter() {
3713
- const filterForm = core.Metadata.getInstance(`${this.grid.name}-filter-form`);
3714
- Object.keys(filterForm.value).forEach((item) => {
3715
- filterForm.value[item] = null;
3716
- });
3717
- }
3718
- sortFilterIndex(col1, col2) {
3719
- const index1 = col1.filterIndex !== undefined ? col1.filterIndex : Number.MAX_SAFE_INTEGER;
3720
- const index2 = col2.filterIndex !== undefined ? col2.filterIndex : Number.MAX_SAFE_INTEGER;
3721
- return index1 - index2;
3722
- }
3723
- getFilterInputs(columnName) {
3724
- const mapper = (name) => core.Metadata.getInstance(name);
3725
- if (columnName) {
3726
- return this.filterFormInputs[columnName].map(mapper);
3727
- }
3728
- const values = Object.values(this.filterFormInputs);
3729
- return values.reduce((result, current) => ([...result, ...current.map(mapper)]), []);
3730
- }
3731
- getFilterModalComponents() {
3732
- const filterColumns = [];
3733
- let columnComponentName;
3734
- [...this.grid.columns].sort(this.sortFilterIndex).forEach((column) => {
3735
- const filterProps = Array.isArray(column.filterProps) ? column.filterProps : [column.filterProps];
3736
- if (column.filterable && filterProps && filterProps.length > 0) {
3737
- this.filterFormInputs[column.name] = [];
3738
- filterProps.forEach((filterItem, index) => {
3739
- var _a;
3740
- const { datasource } = this.grid;
3741
- if (datasource instanceof TekRestDatasource || datasource instanceof TekMemoryDatasource) {
3742
- const relation = filterItem.relation || 'AND';
3743
- const operation = filterItem.operation || 'CONTAINS';
3744
- columnComponentName = `${this.grid.name}-filter-${relation}-${operation}-${column.name}-${index}`;
3745
- }
3746
- else {
3747
- columnComponentName = `${this.grid.name}-filter-AND-CONTAINS-${column.name}-${index}`;
3748
- }
3749
- this.filterFormInputs[column.name].push(columnComponentName);
3750
- const newColumnComponent = Object.assign(Object.assign(Object.assign({ label: column.label }, column.componentProps), filterItem), { name: columnComponentName });
3751
- if (filterItem.helperOptions) {
3752
- if (!newColumnComponent.events)
3753
- newColumnComponent.events = {};
3754
- newColumnComponent.events.change = this.changeHelperEvent.bind(this, column);
3755
- }
3756
- if (newColumnComponent.component === 'ZdSelectMultiple') {
3757
- newColumnComponent.showCheckboxAll = (_a = newColumnComponent.showCheckboxAll) !== null && _a !== void 0 ? _a : this.showCheckboxAll;
3758
- }
3759
- filterColumns.push(newColumnComponent);
3760
- });
3761
- }
3762
- });
3763
- return filterColumns;
3764
- }
3765
- changeHelperEvent(column, { component }) {
3766
- const { helperValue } = component;
3767
- const componentName = component.name;
3768
- if (!Array.isArray(column.filterProps)) {
3769
- column.filterProps.helperValue = helperValue;
3770
- }
3771
- else {
3772
- column.filterProps.forEach((prop) => {
3773
- const relationAndOperationAndName = componentName.split(`${this.grid.name}-filter-`)[1];
3774
- const [relation, operation] = relationAndOperationAndName.split('-');
3775
- if ((prop.relation || 'AND') === relation && (prop.operation || 'CONTAINS') === operation) {
3776
- prop.helperValue = helperValue;
3777
- }
3778
- });
3779
- }
3780
- }
3781
- }
3782
-
3783
- class TekGridLayoutOptions extends common.ComponentRender {
3784
- constructor() {
3785
- super(...arguments);
3786
- this.currentLayoutName = '';
3787
- this.layoutEdited = false;
3788
- this.layouts = {};
3789
- this.layoutNames = [];
3790
- this.originalColumnProps = [];
3791
- this.originalDatasourceOrder = [];
3792
- this.originalDatasourceDynamicFilter = {};
3793
- this.originalDatasourceFilter = {};
3794
- }
3795
- getParentGrid() {
3796
- let { parent } = this;
3797
- while (parent
3798
- && !(parent.constructor === common.Grid
3799
- || parent.constructor.prototype instanceof common.Grid)) {
3800
- parent = parent.parent;
3801
- }
3802
- return parent;
3803
- }
3804
- onMounted(element) {
3805
- const _super = Object.create(null, {
3806
- onMounted: { get: () => super.onMounted }
3807
- });
3808
- return __awaiter(this, void 0, void 0, function* () {
3809
- _super.onMounted.call(this, element);
3810
- this.grid = this.getParentGrid();
3811
- this.originalDatasourceOrder = [...this.grid.datasource.order];
3812
- this.originalDatasourceDynamicFilter = Object.assign({}, this.grid.datasource.dynamicFilter);
3813
- this.originalDatasourceFilter = Object.assign({}, this.grid.datasource.filter);
3814
- this.originalColumnProps = this.grid.columns.map((column) => ({
3815
- name: column.name,
3816
- label: column.label,
3817
- align: column.align,
3818
- isVisible: column.isVisible,
3819
- minWidth: column.minWidth,
3820
- maxWidth: column.maxWidth,
3821
- width: column.width,
3822
- fixed: column.fixed,
3823
- grouped: column.grouped,
3824
- groupOpened: column.groupOpened,
3825
- aggregation: column.aggregation,
3826
- filterHelperValue: this.getHelperValue(column),
3827
- }));
3828
- let layoutsInfo = {};
3829
- const promise = this.loadLayoutsInfo();
3830
- if (this.grid instanceof TekGrid) {
3831
- this.grid.registerTask(promise);
3832
- }
3833
- layoutsInfo = yield promise;
3834
- if (layoutsInfo.layouts) {
3835
- this.layouts = layoutsInfo.layouts;
3836
- this.layoutNames = Object.keys(this.layouts);
3837
- if (layoutsInfo.currentLayoutName) {
3838
- this.currentLayoutName = layoutsInfo.currentLayoutName;
3839
- this.applyLayout(this.currentLayoutName, false);
3840
- }
3841
- }
3842
- });
3843
- }
3844
- loadLayoutsInfo() {
3845
- return __awaiter(this, void 0, void 0, function* () {
3846
- const eventFunction = this.events.loadLayouts || this.grid.events.loadLayouts;
3847
- if (eventFunction && typeof eventFunction === 'function') {
3848
- return eventFunction({ component: this.grid });
3849
- }
3850
- if (core.Config.loadGridLayoutsEndPoint) {
3851
- const route = core.Config.loadGridLayoutsEndPoint;
3852
- const response = yield core.Http.get(`${route}?id=${this.grid.name}`);
3853
- const responseData = response.data.data;
3854
- return responseData.length && responseData[0]
3855
- ? responseData[0].layouts
3856
- : responseData.layouts || {};
3857
- }
3858
- return JSON.parse(localStorage.getItem(this.grid.name) || '{}');
3859
- });
3860
- }
3861
- getHelperValue(column) {
3862
- if (column instanceof TekGridColumn) {
3863
- if (!Array.isArray(column.filterProps))
3864
- return column.filterProps.helperValue;
3865
- return column.filterProps.map((prop) => prop.helperValue);
3866
- }
3867
- return '';
3868
- }
3869
- newLayout(layout) {
3870
- this.fixColumns(layout);
3871
- this.currentLayoutName = layout.name;
3872
- this.addLayout(layout);
3873
- this.layoutEdited = false;
3874
- }
3875
- addLayout(layout) {
3876
- this.fixColumns(layout);
3877
- this.layouts[layout.name] = layout;
3878
- this.saveLayouts();
3879
- }
3880
- discardChanges() {
3881
- const layoutSelected = this.layouts[this.currentLayoutName];
3882
- if (this.viewApplyLayout) {
3883
- this.viewApplyLayout(layoutSelected);
3884
- }
3885
- this.layoutEdited = false;
3886
- }
3887
- applyLayout(name, save = true) {
3888
- this.currentLayoutName = name;
3889
- const layoutSelected = this.layouts[name];
3890
- if (this.viewApplyLayout) {
3891
- this.viewApplyLayout(layoutSelected);
3892
- }
3893
- if (save) {
3894
- this.saveLayouts();
3895
- }
3896
- this.layoutEdited = false;
3897
- }
3898
- saveLayouts() {
3899
- this.layoutNames = Object.keys(this.layouts);
3900
- const layoutInfo = {
3901
- currentLayoutName: this.currentLayoutName,
3902
- layouts: this.layouts,
3903
- };
3904
- const eventFunction = this.events.saveLayouts || this.grid.events.saveLayouts;
3905
- if (eventFunction && typeof eventFunction === 'function') {
3906
- eventFunction({ component: this.grid, layouts: layoutInfo });
3907
- }
3908
- else if (core.Config.saveGridLayoutsEndPoint) {
3909
- const route = core.Config.saveGridLayoutsEndPoint;
3910
- core.Http.post(route, { id: this.grid.name, layouts: layoutInfo });
3911
- }
3912
- else {
3913
- localStorage.setItem(this.grid.name, JSON.stringify(layoutInfo));
3914
- }
3915
- }
3916
- deleteLayout(name) {
3917
- if (this.currentLayoutName === name) {
3918
- this.currentLayoutName = '';
3919
- this.applyLayout(this.currentLayoutName, false);
3920
- }
3921
- delete this.layouts[name];
3922
- this.saveLayouts();
3923
- }
3924
- updateLayout(name, layout) {
3925
- this.fixColumns(layout);
3926
- this.currentLayoutName = name;
3927
- layout.name = name;
3928
- this.layouts[layout.name] = layout;
3929
- this.saveLayouts();
3930
- this.layoutEdited = false;
3931
- }
3932
- updateDefaultLayout(layout) {
3933
- this.fixColumns(layout);
3934
- this.originalDatasourceOrder = layout.order || this.originalDatasourceOrder;
3935
- this.originalDatasourceDynamicFilter = layout.dynamicFilter || this.originalDatasourceDynamicFilter;
3936
- this.originalDatasourceFilter = layout.filter || this.originalDatasourceFilter;
3937
- if (layout.columns) {
3938
- this.originalColumnProps = layout.columns.map((column) => {
3939
- const originalColumnIdx = this.originalColumnProps.findIndex((item) => item.name === column.name);
3940
- const originalColumn = originalColumnIdx !== -1
3941
- ? this.originalColumnProps[originalColumnIdx]
3942
- : {};
3943
- return Object.assign(Object.assign({}, originalColumn), column);
3944
- });
3945
- }
3946
- if (this.currentLayoutName === '') {
3947
- this.applyLayout(this.currentLayoutName, false);
3948
- }
3949
- }
3950
- fixColumns(layout) {
3951
- const hasLayoutColumns = !!layout.columns;
3952
- layout.columns = layout.columns || [];
3953
- const layoutColumnNames = layout.columns.map((layoutColumn) => layoutColumn.name);
3954
- this.grid.columns.forEach((gridColumn) => {
3955
- if (!hasLayoutColumns
3956
- || layoutColumnNames.indexOf(gridColumn.name) === -1) {
3957
- layout.columns.push({
3958
- name: gridColumn.name,
3959
- label: gridColumn.label,
3960
- align: gridColumn.align,
3961
- isVisible: !hasLayoutColumns && gridColumn.isVisible,
3962
- width: gridColumn.width,
3963
- minWidth: gridColumn.minWidth,
3964
- maxWidth: gridColumn.maxWidth,
3965
- fixed: gridColumn.fixed,
3966
- grouped: gridColumn.grouped,
3967
- groupOpened: gridColumn.groupOpened,
3968
- aggregation: gridColumn.aggregation,
3969
- filterHelperValue: this.getHelperValue(gridColumn),
3970
- });
3971
- }
3972
- });
3973
- }
3974
- }
3975
-
3976
- /* TekTreeGrid Class */
3977
- class TekTreeGrid extends common.TreeGridEditable {
3978
- /**
3979
- * TekTreeGrid class constructor
3980
- * @param props TekTreeGrid properties
3981
- */
3982
- constructor(props) {
3983
- super(props);
3984
- /* Grid Title */
3985
- this.title = '';
3986
- /* Show Add button */
3987
- this.addButton = false;
3988
- /**
3989
- * Components that will be rendered on toolbar slot
3990
- */
3991
- this.toolbarConfig = [];
3992
- /* Show edit buttons */
3993
- this.showEditButtons = true;
3994
- /* Show Delete button */
3995
- this.deleteButton = 'none';
3996
- /* Show Delete button */
3997
- this.actions = [];
3998
- /* Show Filter button */
3999
- this.filterButton = false;
4000
- /* Define modal filter props */
4001
- this.modalFilterProps = {
4002
- name: this.name,
4003
- height: 'auto',
4004
- persistent: true,
4005
- cssClass: '',
4006
- cssStyle: '',
4007
- dark: false,
4008
- draggable: false,
4009
- fullscreen: false,
4010
- dragHandle: '',
4011
- title: 'FILTER',
4012
- };
4013
- /* Show search Input */
4014
- this.showSearch = true;
4015
- /* Show Hide button */
4016
- this.showHideButton = true;
4017
- /* Show Column Filter button */
4018
- this.columnFilterButton = false;
4019
- /* Show Columns button */
4020
- this.columnsButton = false;
4021
- /* Columns to be ignored on columns button */
4022
- this.columnsButtonIgnore = [];
4023
- /**
4024
- * Enables column dragging
4025
- * @public
4026
- */
4027
- this.dragColumns = true;
4028
- /**
4029
- * Defines if the grid is the unique grid on screen
4030
- */
4031
- this.mainGrid = true;
4032
- /**
4033
- * Enables column resizing
4034
- * @public
4035
- */
4036
- this.resizeColumns = true;
4037
- /**
4038
- * Enables layout saving
4039
- * @public
4040
- */
4041
- this.showLayoutOptions = true;
4042
- /**
4043
- * Show export button
4044
- */
4045
- this.showExport = false;
4046
- /**
4047
- * Show refresh button
4048
- */
4049
- this.showReload = true;
4050
- this.toolbarOpened = true;
4051
- /**
4052
- * Export config
4053
- */
4054
- this.exportConfig = [
4055
- {
4056
- type: 'pdf',
4057
- label: core.I18n.translate('TEKGRID_EXPORT_AS', { type: 'PDF' }),
4058
- multiOption: [
4059
- { label: core.I18n.translate('TEKGRID_PORTRAIT'), iconName: 'mdi-file-outline' },
4060
- {
4061
- label: core.I18n.translate('TEKGRID_LANDSCAPE'),
4062
- iconName: 'mdi-file-outline',
4063
- cssClass: 'tek-grid-export-landscape',
4064
- reportParams: { portrait: false },
4065
- },
4066
- ],
4067
- },
4068
- {
4069
- type: 'xls',
4070
- label: core.I18n.translate('TEKGRID_EXPORT_AS', {
4071
- type: 'XLS',
4072
- }),
4073
- },
4074
- {
4075
- type: 'xls2',
4076
- label: core.I18n.translate('TEKGRID_EXPORT_AS', {
4077
- type: `XLS ${core.I18n.translate('TEKGRID_WITH_GROUPS')}`,
4078
- }),
4079
- },
4080
- {
4081
- type: 'xls3',
4082
- label: core.I18n.translate('TEKGRID_EXPORT_AS', {
4083
- type: `XLS ${core.I18n.translate('TEKGRID_GRID_MIRROR')}`,
4084
- }),
4085
- },
4086
- {
4087
- type: 'csv',
4088
- label: core.I18n.translate('TEKGRID_EXPORT_AS', { type: 'CSV' }),
4089
- },
4090
- ];
4091
- this.toolbarSlotProps = false;
4092
- this.showCheckboxAllFilter = false;
4093
- this.defaultFilter = {};
4094
- this.reportTitle = '';
4095
- this.title = this.getInitValue('title', props.title, this.title);
4096
- this.addButton = this.getInitValue('addButton', props.addButton, this.addButton);
4097
- this.deleteButton = this.getInitValue('deleteButton', props.deleteButton, this.deleteButton);
4098
- this.showEditButtons = this.getInitValue('showEditButtons', props.showEditButtons, this.showEditButtons);
4099
- this.filterButton = this.getInitValue('filterButton', props.filterButton, this.filterButton);
4100
- this.showSearch = this.getInitValue('showSearch', props.showSearch, this.showSearch);
4101
- this.showHideButton = this.getInitValue('showHideButton', props.showHideButton, this.showHideButton);
4102
- this.columnFilterButton = this.getInitValue('columnFilterButton', props.columnFilterButton, this.columnFilterButton);
4103
- this.columnsButton = this.getInitValue('columnsButton', props.columnsButton, this.columnsButton);
4104
- this.columnsButtonIgnore = this.getInitValue('columnsButtonIgnore', props.columnsButtonIgnore, this.columnsButtonIgnore);
4105
- this.dragColumns = this.getInitValue('dragColumns', props.dragColumns, this.dragColumns);
4106
- this.resizeColumns = this.getInitValue('resizeColumns', props.resizeColumns, this.resizeColumns);
4107
- this.showLayoutOptions = this.getInitValue('showLayoutOptions', props.showLayoutOptions, this.showLayoutOptions);
4108
- this.showExport = this.getInitValue('showExport', props.showExport, this.showExport);
4109
- this.showReload = this.getInitValue('showReload', props.showReload, this.showReload);
4110
- this.exportConfig = this.getInitValue('exportConfig', props.exportConfig, this.exportConfig);
4111
- this.modalFilterProps = this.getInitValue('modalFilterProps', props.modalFilterProps, this.modalFilterProps);
4112
- this.showCheckboxAllFilter = this.getInitValue('showCheckboxAllFilter', props.showCheckboxAllFilter, this.showCheckboxAllFilter);
4113
- this.defaultFilter = this.getInitValue('defaultFilter', props.defaultFilter, this.defaultFilter);
4114
- this.toolbarConfig = this.getInitValue('toolbarConfig', props.toolbarConfig, this.toolbarConfig);
4115
- this.toolbarOpened = this.getInitValue('toolbarOpened', props.toolbarOpened, this.toolbarOpened);
4116
- this.exportActions = props.exportActions || this.exportActions;
4117
- this.reportTitle = this.getInitValue('reportTitle', props.reportTitle, this.reportTitle);
4118
- this.actions = props.actions || this.actions;
4119
- this.toolbarSlotProps = props.toolbarSlot !== undefined;
4120
- if (this.deleteButton === 'selection') {
4121
- this.selectable = true;
4122
- }
4123
- this.keyShortcutKeyMapping = {
4124
- 'mod+f': {
4125
- event: this.focusSearchInput.bind(this),
4126
- stop: true,
4127
- active: !this.mainGrid,
4128
- input: true,
4129
- },
4130
- 'mod+l': {
4131
- event: ({ event, element }) => {
4132
- if (this.filterButton) {
4133
- const instance = core.Metadata.getInstance(`${this.name}_filterButton`);
4134
- instance.click(event, element);
4135
- }
4136
- },
4137
- stop: true,
4138
- active: !this.mainGrid,
4139
- input: true,
4140
- },
4141
- 'mod+enter': {
4142
- event: () => {
4143
- const instance = core.Metadata.getInstance(`${this.name}_actions_dropdown`);
4144
- instance.setFocus();
4145
- instance.value = !instance.value;
4146
- },
4147
- stop: true,
4148
- active: !this.mainGrid,
4149
- input: true,
4150
- },
4151
- };
4152
- this.gridBase = new GridBase(this);
4153
- this.filterOperationsDatasource = this.gridBase.getFilterOperationsDatasource();
4154
- this.filterRelationsDatasource = this.gridBase.getFilterRelationsDatasource();
4155
- this.createAccessors();
4156
- }
4157
- onMounted(element) {
4158
- super.onMounted(element);
4159
- core.KeyMap.bind(this.keyShortcutKeyMapping, this, element);
4160
- }
4161
- onBeforeDestroy() {
4162
- super.onBeforeDestroy();
4163
- core.KeyMap.unbind(this.keyShortcutKeyMapping, this);
4164
- }
4165
- onCreated() {
4166
- super.onCreated();
4167
- core.Loader.addController(`GridController_${this.componentId}`, new GridController(this));
4168
- if (!this.toolbarSlotProps)
4169
- this.toolbarSlot = this.gridBase.createToolbarProps();
4170
- }
4171
- focusSearchInput() {
4172
- const searchInput = core.Metadata.getInstance(`${this.name}_gridSearch`);
4173
- searchInput.setFocus();
4174
- }
4175
- get layoutOptions() {
4176
- if (!this.showLayoutOptions)
4177
- return undefined;
4178
- return core.Metadata.getInstance(`${this.name}_layout_options`);
4179
- }
4180
- /**
4181
- * Get Grid columns objects
4182
- * @param columns Grid columns parameter
4183
- */
4184
- getColumns(columns) {
4185
- return columns.map((column) => new TekGridColumn(column, this));
4186
- }
4187
- columnHasFilterData(column) {
4188
- if (this.datasource instanceof TekRestDatasource
4189
- || this.datasource instanceof TekMemoryDatasource) {
4190
- const dynamicFilter = this.datasource.dynamicFilter[column.name];
4191
- return dynamicFilter && dynamicFilter.length > 0;
4192
- }
4193
- return this.datasource.filter[column.name];
4194
- }
4195
- getReport(type, portrait, rowObj = {}) {
4196
- return __awaiter(this, void 0, void 0, function* () {
4197
- const report = new common.Report(this, this.title || this.reportTitle);
4198
- const reportGroups = {};
4199
- const reportAggregations = {};
4200
- let filter;
4201
- if (this.datasource instanceof TekRestDatasource
4202
- || this.datasource instanceof TekMemoryDatasource) {
4203
- const reportFilter = new ReportFilter(this.datasource.dynamicFilter);
4204
- filter = reportFilter.build();
4205
- }
4206
- let beforeOpen;
4207
- if (typeof this.events.beforeOpenReport === 'function') {
4208
- beforeOpen = this.events.beforeOpenReport;
4209
- }
4210
- return report
4211
- .getReport(type, portrait, {
4212
- metaData: merge__default["default"](rowObj, {
4213
- filter,
4214
- groups: reportGroups,
4215
- columns: reportAggregations,
4216
- }),
4217
- }, beforeOpen)
4218
- .then((reportUrl) => window.open(reportUrl));
4219
- });
4220
- }
4221
- setSearch(search) {
4222
- return __awaiter(this, void 0, void 0, function* () {
4223
- return this.gridBase.setSearch(search);
4224
- });
4225
- }
4226
- /**
4227
- * Dispatches row click event
4228
- * @param row Grid row
4229
- * @param event DOM event
4230
- * @param element DOM Element
4231
- */
4232
- rowClick(row, event, element) {
4233
- if (!this.preventRowClick) {
4234
- this.datasource.currentRow = row;
4235
- this.callEvent('rowClick', {
4236
- event,
4237
- element,
4238
- row,
4239
- component: this,
4240
- column: undefined,
4241
- });
4242
- }
4243
- this.preventRowClick = false;
4244
- }
4245
- getAtomInstance(key) {
4246
- return this.gridBase.getAtomInstance(key);
4247
- }
4248
- getFilterInputs(columnName) {
4249
- return this.gridBase.getFilterInputs(columnName);
4250
- }
4251
- getColumn(name) {
4252
- return super.getColumn(name);
4253
- }
4254
- }
4255
-
4256
- let TekUserInfoController = class TekUserInfoController {
4257
- constructor(component) {
4258
- this.component = component;
4259
- }
4260
- get versionInfo() {
4261
- return this.component.versionInfo;
4262
- }
4263
- get name() {
4264
- var _a;
4265
- return ((_a = this.versionInfo) === null || _a === void 0 ? void 0 : _a.name) || '';
4266
- }
4267
- set name(value) {
4268
- if (!this.versionInfo)
4269
- return;
4270
- this.versionInfo.name = value;
4271
- }
4272
- get version() {
4273
- var _a;
4274
- return ((_a = this.versionInfo) === null || _a === void 0 ? void 0 : _a.version) || '';
4275
- }
4276
- set version(value) {
4277
- if (!this.versionInfo)
4278
- return;
4279
- this.versionInfo.version = value;
4280
- }
4281
- get hasDefaultEmail() {
4282
- return !!this.component.defaultEmail;
4283
- }
4284
- get hasAboutImage() {
4285
- return !!this.component.aboutImage;
4286
- }
4287
- mergeText(name, version) {
4288
- return `<li>${name} - <b>${version}</b></li>`;
4289
- }
4290
- get mainVersion() {
4291
- var _a;
4292
- if (!((_a = this.versionInfo) === null || _a === void 0 ? void 0 : _a.name) || !this.versionInfo.version)
4293
- return '';
4294
- return `${this.versionInfo.name} - <b>${this.versionInfo.version}</b>`;
4295
- }
4296
- getItems(tab) {
4297
- if (!this.versionInfo)
4298
- return [];
4299
- const tabInfo = this.versionInfo[tab];
4300
- return `<ul>${tabInfo.map((item) => this.mergeText(item.name, item.version)).join('')}</ul>`;
4301
- }
4302
- get frontendItems() {
4303
- return this.getItems('frontend');
4304
- }
4305
- get backendItems() {
4306
- return this.getItems('backend');
4307
- }
4308
- get modulesItems() {
4309
- return this.getItems('modules');
4310
- }
4311
- get showReportError() {
4312
- const { reportError } = this.component.visibleItems;
4313
- return reportError || reportError === undefined;
4314
- }
4315
- get showVersionInfo() {
4316
- const { versionInfo } = this.component.visibleItems;
4317
- return versionInfo || versionInfo === undefined;
4318
- }
4319
- get showAbout() {
4320
- const { about } = this.component.visibleItems;
4321
- return about || about === undefined;
4322
- }
4323
- };
4324
- TekUserInfoController = __decorate([
4325
- core.Singleton
4326
- ], TekUserInfoController);
4327
-
4328
- class TekUserInfo extends zdUserInfoCommon.UserInfo {
4329
- constructor(props) {
4330
- super(props);
4331
- /**
4332
- * Data about the application version
4333
- */
4334
- this.versionInfo = null;
4335
- /**
4336
- * Default email address to be defined in the Report Bug form
4337
- */
4338
- this.defaultEmail = '';
4339
- /**
4340
- * Url from which the version info will be retrieved
4341
- */
4342
- this.versionUrl = '';
4343
- /**
4344
- * Path to the image to be shown on about modal
4345
- */
4346
- this.aboutImage = '';
4347
- this.aboutModalHeaderHeight = '';
4348
- this.versionInfo = this.getInitValue('versionInfo', props.versionInfo, this.versionInfo);
4349
- this.defaultEmail = this.getInitValue('defaultEmail', props.defaultEmail, this.defaultEmail);
4350
- this.versionUrl = this.getInitValue('versionUrl', props.versionUrl, this.versionUrl);
4351
- this.aboutImage = this.getInitValue('aboutImage', props.aboutImage, this.aboutImage);
4352
- this.aboutModalHeaderHeight = this.getInitValue('aboutModalHeaderHeight', props.aboutModalHeaderHeight, this.aboutModalHeaderHeight);
4353
- this.createAccessors();
4354
- this.propBottomSlot = props.bottomSlot;
4355
- }
4356
- getBottomSlot() {
4357
- return [
4358
- {
4359
- name: `${this.name}_bottom_list`,
4360
- component: 'TekUserInfoList',
4361
- parentName: this.name,
4362
- },
4363
- ];
4364
- }
4365
- onAboutClick() {
4366
- if (!this.aboutModal) {
4367
- this.aboutModal = common.ModalService.create({
4368
- name: `${this.name}_about_modal`,
4369
- cssClass: 'about-modal',
4370
- grid: { cols: 8, sm: 4, lg: 5 },
4371
- height: '60%',
4372
- children: [
4373
- {
4374
- name: `${this.name}_about_header`,
4375
- component: 'ZdHeader',
4376
- color: 'transparent',
4377
- padless: true,
4378
- elevation: 0,
4379
- height: this.aboutModalHeaderHeight,
4380
- rightSlot: [
4381
- {
4382
- name: `${this.name}_about_close_button`,
4383
- component: 'ZdModalCloseButton',
4384
- small: true,
4385
- modalName: `${this.name}_about_modal`,
4386
- },
4387
- ],
4388
- leftSlot: [
4389
- {
4390
- name: `${this.name}_about_row`,
4391
- component: 'ZdTag',
4392
- tag: 'div',
4393
- cssStyle: 'width: 100%',
4394
- cssClass: 'zd-justify-center zd-px-6',
4395
- isVisible: `{{TekUserInfoController_${this.componentId}.hasAboutImage}}`,
4396
- children: [
4397
- {
4398
- name: `${this.name}_about_image`,
4399
- cssClass: 'zd-tekUserInfo-about-image',
4400
- component: 'ZdImage',
4401
- width: '100%',
4402
- src: this.aboutImage,
4403
- },
4404
- ],
4405
- },
4406
- ],
4407
- },
4408
- {
4409
- name: `${this.name}_version_tabs`,
4410
- cssClass: 'zd-pt-3 zd-tekUserInfo-tab',
4411
- component: 'ZdTabs',
4412
- tabs: [
4413
- {
4414
- name: `${this.name}_version_frontend_tab`,
4415
- tabTitle: 'Frontend',
4416
- children: this.getVersionTree('frontend'),
4417
- },
4418
- {
4419
- name: `${this.name}_version_backend_tab`,
4420
- tabTitle: 'Backend',
4421
- children: this.getVersionTree('backend'),
4422
- },
4423
- {
4424
- name: `${this.name}_version_modules_tab`,
4425
- tabTitle: 'Modules',
4426
- children: this.getVersionTree('modules'),
4427
- },
4428
- ],
4429
- },
4430
- ],
4431
- });
4432
- }
4433
- this.aboutModal.show();
4434
- }
4435
- getVersionTree(tab) {
4436
- if (!this.versionInfo)
4437
- return [];
4438
- const main = {
4439
- name: `${this.name}_version_${tab}_main`,
4440
- component: 'ZdText',
4441
- text: `{{TekUserInfoController_${this.componentId}.mainVersion}}`,
4442
- };
4443
- const itemsComponent = {
4444
- name: `${this.name}_version_${tab}`,
4445
- component: 'ZdText',
4446
- cssClass: 'zd-pl-4',
4447
- text: `{{TekUserInfoController_${this.componentId}.${tab}Items}}`,
4448
- };
4449
- return [main, itemsComponent];
4450
- }
4451
- onReportClick() {
4452
- if (!this.reportModal) {
4453
- this.reportModal = common.ModalService.create({
4454
- name: `${this.name}_report_modal`,
4455
- children: [
4456
- {
4457
- name: `${this.name}_report_header`,
4458
- component: 'ZdHeader',
4459
- color: 'transparent',
4460
- padless: true,
4461
- elevation: 0,
4462
- leftSlot: [
4463
- {
4464
- name: `${this.name}_report_title`,
4465
- component: 'ZdText',
4466
- text: 'TEKUSERINFO_REPORT_ERROR',
4467
- cssClass: 'zd-theme-font-title',
4468
- },
4469
- ],
4470
- rightSlot: [
4471
- {
4472
- name: `${this.name}_report_close_button`,
4473
- component: 'ZdModalCloseButton',
4474
- small: true,
4475
- modalName: `${this.name}_report_modal`,
4476
- },
4477
- ],
4478
- },
4479
- {
4480
- name: `${this.name}_report_form`,
4481
- component: 'ZdForm',
4482
- cssClass: 'zd-pt-4',
4483
- children: [
4484
- {
4485
- name: 'report_email',
4486
- component: 'ZdTextInput',
4487
- label: 'E-mail',
4488
- grid: {
4489
- cols: '12',
4490
- },
4491
- value: this.defaultEmail,
4492
- readonly: `{{TekUserInfoController_${this.componentId}.hasDefaultEmail}}`,
4493
- validations: {
4494
- required: {},
4495
- email: {},
4496
- },
4497
- },
4498
- {
4499
- name: 'report_cc',
4500
- component: 'ZdTextInput',
4501
- label: 'CC',
4502
- placeholder: 'TEKUSERINFO_EMAIL_PLACEHOLDER',
4503
- grid: {
4504
- cols: '12',
4505
- },
4506
- },
4507
- {
4508
- name: 'report_type',
4509
- component: 'ZdSelect',
4510
- label: 'TEKUSERINFO_TYPE',
4511
- dataValue: 'value',
4512
- dataText: 'text',
4513
- datasource: {
4514
- uniqueKey: 'value',
4515
- translate: true,
4516
- data: [
4517
- { value: '0', text: 'TEKUSERINFO_ERROR' },
4518
- { value: '1', text: 'TEKUSERINFO_IMPROVEMENT' },
4519
- ],
4520
- },
4521
- grid: {
4522
- cols: '12',
4523
- },
4524
- validations: {
4525
- required: {},
4526
- },
4527
- },
4528
- {
4529
- name: 'report_description',
4530
- component: 'ZdTextarea',
4531
- label: 'TEKUSERINFO_DESCRIPTION',
4532
- grid: {
4533
- cols: '12',
4534
- },
4535
- validations: {
4536
- required: {},
4537
- },
4538
- },
4539
- ],
4540
- },
4541
- {
4542
- name: `${this.name}_report_footer`,
4543
- component: 'ZdFooter',
4544
- color: 'transparent',
4545
- padless: true,
4546
- rightSlot: [
4547
- {
4548
- name: `${this.name}_report_cancel`,
4549
- component: 'ZdButton',
4550
- label: 'TEKUSERINFO_CANCEL',
4551
- outline: true,
4552
- events: {
4553
- click: () => { var _a; (_a = this.reportModal) === null || _a === void 0 ? void 0 : _a.hide(); },
4554
- },
4555
- },
4556
- {
4557
- name: `${this.name}_report_send`,
4558
- component: 'ZdButton',
4559
- label: 'TEKUSERINFO_SEND',
4560
- events: {
4561
- click: (args) => this.onSendReport(args),
4562
- },
4563
- },
4564
- ],
4565
- },
4566
- ],
4567
- });
4568
- }
4569
- this.reportModal.show();
4570
- }
4571
- onSendReport({ event, element }) {
4572
- if (!this.reportModal)
4573
- return;
4574
- const form = core.Metadata.getInstance(`${this.name}_report_form`);
4575
- if (!form.validate())
4576
- return;
4577
- this.callEvent('onSendReport', {
4578
- event, element, component: this, form,
4579
- });
4580
- this.reportModal.hide();
4581
- }
4582
- onCreated() {
4583
- super.onCreated();
4584
- core.Loader.addController(`TekUserInfoController_${this.componentId}`, new TekUserInfoController(this));
4585
- this.bottomSlot = this.propBottomSlot ? this.propBottomSlot : this.getBottomSlot();
4586
- }
4587
- onMounted(element) {
4588
- const _super = Object.create(null, {
4589
- onMounted: { get: () => super.onMounted }
4590
- });
4591
- return __awaiter(this, void 0, void 0, function* () {
4592
- _super.onMounted.call(this, element);
4593
- if (this.versionUrl) {
4594
- const res = yield core.Http.get(this.versionUrl);
4595
- this.versionInfo = res.data.versionInfo;
4596
- }
4597
- });
4598
- }
4599
- }
4600
- core.Messages.add({
4601
- 'pt-BR': {
4602
- translation: {
4603
- TEKUSERINFO_ABOUT: 'Sobre',
4604
- TEKUSERINFO_REPORT_ERROR: 'Reportar Erro',
4605
- TEKUSERINFO_EMAIL_PLACEHOLDER: 'Separe e-mails usando ";"',
4606
- TEKUSERINFO_TYPE: 'Tipo',
4607
- TEKUSERINFO_ERROR: 'Erro',
4608
- TEKUSERINFO_IMPROVEMENT: 'Melhoria',
4609
- TEKUSERINFO_DESCRIPTION: 'Descrição',
4610
- TEKUSERINFO_CANCEL: 'Cancelar',
4611
- TEKUSERINFO_SEND: 'Enviar',
4612
- },
4613
- },
4614
- 'en-US': {
4615
- translation: {
4616
- TEKUSERINFO_ABOUT: 'About',
4617
- TEKUSERINFO_REPORT_ERROR: 'Report Bug',
4618
- TEKUSERINFO_EMAIL_PLACEHOLDER: 'Separate e-mails using ";"',
4619
- TEKUSERINFO_TYPE: 'Type',
4620
- TEKUSERINFO_ERROR: 'Bug',
4621
- TEKUSERINFO_IMPROVEMENT: 'Improvement',
4622
- TEKUSERINFO_DESCRIPTION: 'Description',
4623
- TEKUSERINFO_CANCEL: 'Cancel',
4624
- TEKUSERINFO_SEND: 'Send',
4625
- },
4626
- },
4627
- 'es-CL': {
4628
- translation: {
4629
- TEKUSERINFO_ABOUT: 'Sobre',
4630
- TEKUSERINFO_REPORT_ERROR: 'Reportar Error',
4631
- TEKUSERINFO_EMAIL_PLACEHOLDER: 'Separar e-mails usando ";"',
4632
- TEKUSERINFO_TYPE: 'Tipo',
4633
- TEKUSERINFO_ERROR: 'Error',
4634
- TEKUSERINFO_IMPROVEMENT: 'Mejora',
4635
- TEKUSERINFO_DESCRIPTION: 'Descripción',
4636
- TEKUSERINFO_CANCEL: 'Cancelar',
4637
- TEKUSERINFO_SEND: 'Enviar',
4638
- },
4639
- },
4640
- });
4641
-
4642
- class TekUserInfoList extends common.List {
4643
- constructor(props) {
4644
- super(props);
4645
- /**
4646
- * Name of the user info component
4647
- */
4648
- this.parentName = '';
4649
- this.dense = true;
4650
- this.parentName = props.parentName || '';
4651
- this.items = this.getItems();
4652
- }
4653
- getItems() {
4654
- const parent = this.parentName ? core.Metadata.getInstance(this.parentName) : this.parent;
4655
- if (!(parent instanceof TekUserInfo)) {
4656
- throw Error(`Could not find the TekUserInfo component associated with ${this.name} TekUserInfoList`);
4657
- }
4658
- return [
4659
- {
4660
- name: `${parent.name}_version`,
4661
- component: 'ZdListItem',
4662
- title: `{{TekUserInfoController_${parent.componentId}.name}}`,
4663
- subtitle: `{{TekUserInfoController_${parent.componentId}.version}}`,
4664
- isVisible: `{{TekUserInfoController_${parent.componentId}.showVersionInfo}}`,
4665
- cssClass: 'zd-px-2',
4666
- },
4667
- {
4668
- name: `${parent.name}_about`,
4669
- component: 'ZdListItem',
4670
- title: 'TEKUSERINFO_ABOUT',
4671
- prependIcon: 'infoOutline',
4672
- cssClass: 'zd-px-2',
4673
- isVisible: `{{TekUserInfoController_${parent.componentId}.showAbout}}`,
4674
- events: {
4675
- click: () => parent.onAboutClick(),
4676
- },
4677
- },
4678
- {
4679
- name: `${parent.name}_report`,
4680
- component: 'ZdListItem',
4681
- title: 'TEKUSERINFO_REPORT_ERROR',
4682
- prependIcon: 'mdi-ladybug',
4683
- cssClass: 'zd-px-2',
4684
- isVisible: `{{TekUserInfoController_${parent.componentId}.showReportError}}`,
4685
- events: {
4686
- click: () => parent.onReportClick(),
4687
- },
4688
- },
4689
- ];
4690
- }
4691
- }
4692
-
4693
- class TekDragGrid extends TekGrid {
4694
- constructor(props) {
4695
- super(Object.assign(Object.assign({}, props), { datasource: Object.assign(Object.assign({}, props.datasource), { order: [`${props.orderColumnName}.${props.orderMode || 'asc'}`] }) }));
4696
- this.internalOrderColumnName = '';
4697
- this.internalOrderMode = 'asc';
4698
- this.internalOrderColumnName = this.getInitValue('orderColumnName', props.orderColumnName, this.orderColumnName);
4699
- this.internalOrderMode = this.getInitValue('orderMode', props.orderMode, this.orderMode);
4700
- this.createAccessors();
4701
- this.draggable = new zdDragGridCommon.Draggable(this.orderColumnName, this.orderMode);
4702
- }
4703
- set orderColumnName(value) {
4704
- this.internalOrderColumnName = value;
4705
- this.draggable.orderColumnName = value;
4706
- }
4707
- get orderColumnName() {
4708
- return this.internalOrderColumnName;
4709
- }
4710
- set orderMode(value) {
4711
- this.internalOrderMode = value;
4712
- this.draggable.orderColumnName = value;
4713
- }
4714
- get orderMode() {
4715
- return this.internalOrderMode;
4716
- }
4717
- /**
4718
- * Event triggered when dragged element is moving
4719
- * @param event DOM event
4720
- * @param row row being dragged
4721
- * @param element HTML element
4722
- * @returns return false to cancel dragging
4723
- */
4724
- onDragMove(event, row, element) {
4725
- this.callEvent('onDragMove', {
4726
- component: this,
4727
- event,
4728
- row,
4729
- element,
4730
- });
4731
- return true;
4732
- }
4733
- /**
4734
- * Event triggered when drag starts
4735
- * @param event DOM event
4736
- * @param row row being dragged
4737
- * @param element HTML element
4738
- */
4739
- onDragStart(event, row, element) {
4740
- return this.callEvent('onDragStart', {
4741
- component: this,
4742
- event,
4743
- row,
4744
- element,
4745
- });
4746
- }
4747
- /**
4748
- * Event triggered when drag ends
4749
- * @param event DOM event
4750
- * @param row row being dragged
4751
- * @param element HTML element
4752
- */
4753
- onDragEnd(event, row, element) {
4754
- const { oldIndex, newIndex } = event;
4755
- const changes = this.draggable.getDragChanges(oldIndex, newIndex, this.datasource, this.getEditedRows());
4756
- this.editing = true;
4757
- const orderColumn = new common.GridColumnEditable({ name: this.orderColumnName });
4758
- changes.forEach((change) => {
4759
- this.changeEditableComponent(orderColumn, change.row, change.value);
4760
- });
4761
- this.callEvent('inlineEdit', {
4762
- event,
4763
- element,
4764
- row,
4765
- column: { name: this.orderColumnName },
4766
- component: this,
4767
- });
4768
- this.callEvent('onDragEnd', {
4769
- component: this,
4770
- event,
4771
- row,
4772
- element,
4773
- });
4774
- }
4775
- }
4776
-
4777
- core.Messages.add({
4778
- 'pt-BR': {
4779
- translation: {
4780
- NO_NOTIFICATIONS: 'Nenhuma Notificação',
4781
- MARK_ALL_AS_READ: 'Marcar todas como lidas',
4782
- NOTIFICATIONS: 'Notificações',
4783
- SEE_ALL_NOTIFICATIONS: 'Ver todas notificações',
4784
- UNAVAILABLE_IMAGE: 'Imagem indisponível',
4785
- REFRESH: 'Atualizar',
4786
- ACTIONS: 'Ações',
4787
- FILTER: 'Filtro',
4788
- LAYOUT: 'Layout: ',
4789
- NEW_LAYOUT: 'Novo layout',
4790
- DEFAULT_LAYOUT: 'Padrão',
4791
- LAYOUT_MODIFIED: 'O layout atual foi modificado. Crie um novo layout, sobrescreva um existente ou descarte as alterações',
4792
- LAYOUT_NOT_MODIFIED: 'Crie um novo layout ou aplique um dos layouts já existentes',
4793
- LAYOUT_DISCART_CHANGES: 'Descartar alterações',
4794
- },
4795
- },
4796
- 'en-US': {
4797
- translation: {
4798
- NO_NOTIFICATIONS: 'No Notifications',
4799
- MARK_ALL_AS_READ: 'Mark all as read',
4800
- NOTIFICATIONS: 'Notifications',
4801
- SEE_ALL_NOTIFICATIONS: 'See all notifications',
4802
- UNAVAILABLE_IMAGE: 'Unavailable image',
4803
- REFRESH: 'Refresh',
4804
- ACTIONS: 'Actions',
4805
- FILTER: 'Filter',
4806
- LAYOUT: 'Layout: ',
4807
- NEW_LAYOUT: 'New layout',
4808
- DEFAULT_LAYOUT: 'Default',
4809
- LAYOUT_MODIFIED: 'The current layout has been modified. Create a new layout, overwrite an existing one or discard changes',
4810
- LAYOUT_NOT_MODIFIED: 'Create a new layout or apply one of the existing layouts',
4811
- LAYOUT_DISCART_CHANGES: 'Discard changes',
4812
- },
4813
- },
4814
- 'es-CL': {
4815
- translation: {
4816
- NO_NOTIFICATIONS: 'Sin Notificación',
4817
- MARK_ALL_AS_READ: 'Marcar todo como leído',
4818
- NOTIFICATIONS: 'Notificaciones',
4819
- SEE_ALL_NOTIFICATIONS: 'Ver todas las notificaciones',
4820
- UNAVAILABLE_IMAGE: 'Imagen no disponible',
4821
- REFRESH: 'Actualizar',
4822
- ACTIONS: 'Acciones',
4823
- FILTER: 'Filtro',
4824
- LAYOUT: 'Disposición: ',
4825
- NEW_LAYOUT: 'Nueva disposición',
4826
- DEFAULT_LAYOUT: 'Default',
4827
- LAYOUT_MODIFIED: 'La disposición actual ha sido modificada. Cree una nueva disposición, sobrescriba una existente o descarte los cambios',
4828
- LAYOUT_NOT_MODIFIED: 'Cree una nueva disposición o aplique una de las disposiciones existentes',
4829
- LAYOUT_DISCART_CHANGES: 'Descartar los cambios',
4830
- },
4831
- },
4832
- });
4833
-
4834
- const packageContent = require('../package.json');
4835
- core.VersionService.addPackageVersion(packageContent.name, packageContent.version);
4836
-
4837
- exports.BreadcrumbHeader = BreadcrumbHeader;
4838
- exports.CardTitle = CardTitle;
4839
- exports.CrudAddButton = CrudAddButton;
4840
- exports.CrudButton = CrudButton;
4841
- exports.CrudCancelButton = CrudCancelButton;
4842
- exports.CrudDeleteButton = CrudDeleteButton;
4843
- exports.CrudForm = CrudForm;
4844
- exports.CrudSaveButton = CrudSaveButton;
4845
- exports.DynamicFilterOperations = DynamicFilterOperations;
4846
- exports.DynamicFilterRelations = DynamicFilterRelations;
4847
- exports.Image = Image;
4848
- exports.IterableCarousel = IterableCarousel;
4849
- exports.IterableComponentRender = IterableComponentRender;
4850
- exports.Loading = Loading;
4851
- exports.Notifications = Notifications;
4852
- exports.ProductCard = ProductCard;
4853
- exports.TekDragGrid = TekDragGrid;
4854
- exports.TekFilterHelper = TekFilterHelper;
4855
- exports.TekGrid = TekGrid;
4856
- exports.TekGridColumn = TekGridColumn;
4857
- exports.TekGridColumnsButton = TekGridColumnsButton;
4858
- exports.TekGridColumnsButtonController = TekGridColumnsButtonController;
4859
- exports.TekGridFilterButton = TekGridFilterButton;
4860
- exports.TekGridLayoutOptions = TekGridLayoutOptions;
4861
- exports.TekMemoryDatasource = TekMemoryDatasource;
4862
- exports.TekRestDatasource = TekRestDatasource;
4863
- exports.TekTreeGrid = TekTreeGrid;
4864
- exports.TekUserInfo = TekUserInfo;
4865
- exports.TekUserInfoList = TekUserInfoList;
4866
- exports.columnAggregationValues = columnAggregationValues;
4867
-
4868
- Object.defineProperty(exports, '__esModule', { value: true });
4869
-
4870
- }));