@sankhyalabs/sankhyablocks 1.3.33 → 1.4.0-beta.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 (216) hide show
  1. package/dist/cjs/SnkMessageBuilder-7717f1e4.js +326 -0
  2. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  3. package/dist/cjs/css-shim-b8158822.js +6 -0
  4. package/dist/cjs/dom-36862b77.js +75 -0
  5. package/dist/cjs/filter-item-type.enum-e2e1bc5b.js +14 -0
  6. package/dist/cjs/index-02201bc9.js +2397 -0
  7. package/dist/cjs/index-b0b676c5.js +3298 -0
  8. package/dist/cjs/loader.cjs.js +19 -3
  9. package/dist/cjs/sankhyablocks.cjs.js +117 -5
  10. package/dist/cjs/shadow-css-346c0795.js +389 -0
  11. package/dist/cjs/snk-application.cjs.entry.js +721 -169
  12. package/dist/cjs/snk-crud.cjs.entry.js +70 -0
  13. package/dist/cjs/snk-data-unit.cjs.entry.js +280 -0
  14. package/dist/cjs/snk-filter-bar.cjs.entry.js +278 -0
  15. package/dist/cjs/snk-filter-binary-select.cjs.entry.js +47 -0
  16. package/dist/cjs/snk-filter-detail.cjs.entry.js +49 -0
  17. package/dist/cjs/snk-filter-item.cjs.entry.js +154 -0
  18. package/dist/cjs/snk-filter-list.cjs.entry.js +91 -0
  19. package/dist/cjs/snk-filter-multi-select.cjs.entry.js +23 -0
  20. package/dist/cjs/snk-filter-number.cjs.entry.js +24 -0
  21. package/dist/cjs/snk-filter-period.cjs.entry.js +37 -0
  22. package/dist/cjs/snk-filter-search.cjs.entry.js +44 -0
  23. package/dist/cjs/snk-filter-text.cjs.entry.js +22 -0
  24. package/dist/cjs/snk-form.cjs.entry.js +133 -0
  25. package/dist/cjs/snk-grid.cjs.entry.js +79 -0
  26. package/dist/cjs/snk-pesquisa.cjs.entry.js +5 -5
  27. package/dist/cjs/snk-taskbar.cjs.entry.js +160 -0
  28. package/dist/cjs/taskbar-elements-283c737e.js +93 -0
  29. package/dist/cjs/taskbar-processor-6bd0d35c.js +47 -0
  30. package/dist/cjs/teste-pesquisa.cjs.entry.js +5 -5
  31. package/dist/collection/collection-manifest.json +17 -2
  32. package/dist/collection/components/snk-application/errorhandler/snk-error-handler.js +9 -2
  33. package/dist/collection/components/snk-application/snk-application.js +1126 -621
  34. package/dist/collection/components/snk-crud/snk-crud.css +6 -0
  35. package/dist/collection/components/snk-crud/snk-crud.js +203 -0
  36. package/dist/collection/components/snk-data-unit/snk-data-unit.css +6 -0
  37. package/dist/collection/components/snk-data-unit/snk-data-unit.js +544 -0
  38. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.js +88 -0
  39. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.js +64 -0
  40. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-number.js +65 -0
  41. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-period.js +78 -0
  42. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-search.js +118 -0
  43. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-text.js +63 -0
  44. package/dist/collection/components/snk-filter-bar/filter-item/filter-item-type.enum.js +10 -0
  45. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +118 -0
  46. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +255 -0
  47. package/dist/collection/components/snk-filter-bar/filter-list/snk-filter-list.js +233 -0
  48. package/dist/collection/components/snk-filter-bar/snk-filter-bar.css +114 -0
  49. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +353 -0
  50. package/dist/collection/components/snk-form/snk-form.css +34 -0
  51. package/dist/collection/components/snk-form/snk-form.js +258 -0
  52. package/dist/collection/components/snk-grid/snk-grid.css +18 -0
  53. package/dist/collection/components/snk-grid/snk-grid.js +205 -0
  54. package/dist/collection/components/snk-pesquisa/snk-pesquisa.js +80 -79
  55. package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +86 -0
  56. package/dist/collection/components/snk-taskbar/processor/taskbar-processor.js +43 -0
  57. package/dist/collection/components/snk-taskbar/snk-taskbar.css +3 -0
  58. package/dist/collection/components/snk-taskbar/snk-taskbar.js +307 -0
  59. package/dist/collection/components/teste-pesquisa/teste-pesquisa.js +12 -9
  60. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +38 -13
  61. package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +52 -21
  62. package/dist/collection/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.js +54 -0
  63. package/dist/collection/lib/http/data-fetcher/fetchers/grid-config-fetcher.js +4 -3
  64. package/dist/collection/lib/http/data-fetcher/fetchers/totals-fetcher.js +47 -0
  65. package/dist/collection/lib/index.js +1 -0
  66. package/dist/collection/lib/message/SnkMessageBuilder.js +121 -0
  67. package/dist/collection/lib/message/resources/snk-data-unit.msg.js +23 -0
  68. package/dist/collection/lib/message/resources/snk-filter-bar.msg.js +18 -0
  69. package/dist/collection/lib/message/resources/snk-form.msg.js +10 -0
  70. package/dist/collection/lib/message/resources/snk-taskbar.msg.js +17 -0
  71. package/dist/components/SnkMessageBuilder.js +303 -0
  72. package/dist/components/filter-item-type.enum.js +12 -0
  73. package/dist/components/index.d.ts +18 -5
  74. package/dist/components/index.js +22 -0
  75. package/dist/components/index2.js +2384 -0
  76. package/dist/components/snk-application2.js +701 -140
  77. package/dist/components/snk-crud.d.ts +11 -0
  78. package/dist/components/snk-crud.js +133 -0
  79. package/dist/components/snk-data-unit.d.ts +11 -0
  80. package/dist/components/snk-data-unit.js +303 -0
  81. package/dist/components/snk-filter-bar.d.ts +11 -0
  82. package/dist/components/snk-filter-bar.js +6 -0
  83. package/dist/components/snk-filter-bar2.js +310 -0
  84. package/dist/components/snk-filter-binary-select.d.ts +11 -0
  85. package/dist/components/snk-filter-binary-select.js +63 -0
  86. package/dist/components/snk-filter-detail.d.ts +11 -0
  87. package/dist/components/snk-filter-detail.js +6 -0
  88. package/dist/components/snk-filter-detail2.js +63 -0
  89. package/dist/components/snk-filter-item.d.ts +11 -0
  90. package/dist/components/snk-filter-item.js +6 -0
  91. package/dist/components/snk-filter-item2.js +175 -0
  92. package/dist/components/snk-filter-list.d.ts +11 -0
  93. package/dist/components/snk-filter-list.js +6 -0
  94. package/dist/components/snk-filter-list2.js +111 -0
  95. package/dist/components/snk-filter-multi-select.d.ts +11 -0
  96. package/dist/components/snk-filter-multi-select.js +39 -0
  97. package/dist/components/snk-filter-number.d.ts +11 -0
  98. package/dist/components/snk-filter-number.js +40 -0
  99. package/dist/components/snk-filter-period.d.ts +11 -0
  100. package/dist/components/snk-filter-period.js +53 -0
  101. package/dist/components/snk-filter-search.d.ts +11 -0
  102. package/dist/components/snk-filter-search.js +62 -0
  103. package/dist/components/snk-filter-text.d.ts +11 -0
  104. package/dist/components/snk-filter-text.js +38 -0
  105. package/dist/components/snk-form.d.ts +11 -0
  106. package/dist/components/snk-form.js +6 -0
  107. package/dist/components/snk-form2.js +159 -0
  108. package/dist/components/snk-grid.d.ts +11 -0
  109. package/dist/components/snk-grid.js +6 -0
  110. package/dist/components/snk-grid2.js +127 -0
  111. package/dist/components/snk-pesquisa2.js +1 -1
  112. package/dist/components/snk-taskbar.d.ts +11 -0
  113. package/dist/components/snk-taskbar.js +6 -0
  114. package/dist/components/snk-taskbar2.js +264 -0
  115. package/dist/components/taskbar-processor.js +45 -0
  116. package/dist/components/teste-pesquisa.js +1 -1
  117. package/dist/esm/SnkMessageBuilder-a7da466b.js +303 -0
  118. package/dist/esm/app-globals-0f993ce5.js +3 -0
  119. package/dist/esm/css-shim-b3f2ee8d.js +4 -0
  120. package/dist/esm/dom-665d6011.js +73 -0
  121. package/dist/esm/filter-item-type.enum-61fbf80a.js +12 -0
  122. package/dist/esm/index-2b4d2d14.js +3262 -0
  123. package/dist/esm/index-f1d3e4da.js +2384 -0
  124. package/dist/esm/loader.js +19 -3
  125. package/dist/esm/polyfills/css-shim.js +1 -1
  126. package/dist/esm/sankhyablocks.js +117 -5
  127. package/dist/esm/shadow-css-b18e99d7.js +387 -0
  128. package/dist/esm/snk-application.entry.js +693 -141
  129. package/dist/esm/snk-crud.entry.js +66 -0
  130. package/dist/esm/snk-data-unit.entry.js +276 -0
  131. package/dist/esm/snk-filter-bar.entry.js +274 -0
  132. package/dist/esm/snk-filter-binary-select.entry.js +43 -0
  133. package/dist/esm/snk-filter-detail.entry.js +45 -0
  134. package/dist/esm/snk-filter-item.entry.js +150 -0
  135. package/dist/esm/snk-filter-list.entry.js +87 -0
  136. package/dist/esm/snk-filter-multi-select.entry.js +19 -0
  137. package/dist/esm/snk-filter-number.entry.js +20 -0
  138. package/dist/esm/snk-filter-period.entry.js +33 -0
  139. package/dist/esm/snk-filter-search.entry.js +40 -0
  140. package/dist/esm/snk-filter-text.entry.js +18 -0
  141. package/dist/esm/snk-form.entry.js +129 -0
  142. package/dist/esm/snk-grid.entry.js +75 -0
  143. package/dist/esm/snk-pesquisa.entry.js +2 -2
  144. package/dist/esm/snk-taskbar.entry.js +156 -0
  145. package/dist/esm/taskbar-elements-35d64ff9.js +90 -0
  146. package/dist/esm/taskbar-processor-aa6772c9.js +45 -0
  147. package/dist/esm/teste-pesquisa.entry.js +2 -2
  148. package/dist/sankhyablocks/SnkMessageBuilder-a7da466b.js +303 -0
  149. package/dist/sankhyablocks/app-globals-0f993ce5.js +3 -0
  150. package/dist/sankhyablocks/css-shim-b3f2ee8d.js +4 -0
  151. package/dist/sankhyablocks/dom-665d6011.js +73 -0
  152. package/dist/sankhyablocks/filter-item-type.enum-61fbf80a.js +12 -0
  153. package/dist/sankhyablocks/index-2b4d2d14.js +3262 -0
  154. package/dist/sankhyablocks/index-f1d3e4da.js +2384 -0
  155. package/dist/sankhyablocks/index.esm.js +1 -0
  156. package/dist/sankhyablocks/sankhyablocks.esm.js +129 -1
  157. package/dist/sankhyablocks/shadow-css-b18e99d7.js +387 -0
  158. package/dist/sankhyablocks/snk-application.entry.js +8148 -0
  159. package/dist/sankhyablocks/snk-crud.entry.js +66 -0
  160. package/dist/sankhyablocks/snk-data-unit.entry.js +276 -0
  161. package/dist/sankhyablocks/snk-filter-bar.entry.js +274 -0
  162. package/dist/sankhyablocks/snk-filter-binary-select.entry.js +43 -0
  163. package/dist/sankhyablocks/snk-filter-detail.entry.js +45 -0
  164. package/dist/sankhyablocks/snk-filter-item.entry.js +150 -0
  165. package/dist/sankhyablocks/snk-filter-list.entry.js +87 -0
  166. package/dist/sankhyablocks/snk-filter-multi-select.entry.js +19 -0
  167. package/dist/sankhyablocks/snk-filter-number.entry.js +20 -0
  168. package/dist/sankhyablocks/snk-filter-period.entry.js +33 -0
  169. package/dist/sankhyablocks/snk-filter-search.entry.js +40 -0
  170. package/dist/sankhyablocks/snk-filter-text.entry.js +18 -0
  171. package/dist/sankhyablocks/snk-form.entry.js +129 -0
  172. package/dist/sankhyablocks/snk-grid.entry.js +75 -0
  173. package/dist/sankhyablocks/snk-pesquisa.entry.js +311 -0
  174. package/dist/sankhyablocks/snk-taskbar.entry.js +156 -0
  175. package/dist/sankhyablocks/taskbar-elements-35d64ff9.js +90 -0
  176. package/dist/sankhyablocks/taskbar-processor-aa6772c9.js +45 -0
  177. package/dist/sankhyablocks/teste-pesquisa.entry.js +33 -0
  178. package/dist/types/components/snk-application/errorhandler/snk-error-handler.d.ts +1 -0
  179. package/dist/types/components/snk-application/snk-application.d.ts +145 -15
  180. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.d.ts +12 -0
  181. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.d.ts +7 -0
  182. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-number.d.ts +7 -0
  183. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-period.d.ts +14 -0
  184. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-search.d.ts +12 -0
  185. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-text.d.ts +7 -0
  186. package/dist/types/components/snk-filter-bar/filter-item/filter-item-type.enum.d.ts +9 -0
  187. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +14 -0
  188. package/dist/types/components/snk-filter-bar/filter-list/snk-filter-list.d.ts +40 -0
  189. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +51 -0
  190. package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +29 -0
  191. package/dist/types/components/snk-taskbar/processor/taskbar-processor.d.ts +12 -0
  192. package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +84 -0
  193. package/dist/types/components.d.ts +696 -8
  194. package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +7 -6
  195. package/dist/types/lib/http/data-fetcher/fetchers/dataunit-fetcher.d.ts +2 -0
  196. package/dist/types/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.d.ts +6 -0
  197. package/dist/types/lib/http/data-fetcher/fetchers/grid-config-fetcher.d.ts +1 -1
  198. package/dist/types/lib/http/data-fetcher/fetchers/totals-fetcher.d.ts +8 -0
  199. package/dist/types/lib/index.d.ts +1 -0
  200. package/dist/types/lib/message/SnkMessageBuilder.d.ts +42 -0
  201. package/dist/types/lib/message/resources/snk-data-unit.msg.d.ts +2 -0
  202. package/dist/types/lib/message/resources/snk-filter-bar.msg.d.ts +2 -0
  203. package/dist/types/lib/message/resources/snk-form.msg.d.ts +2 -0
  204. package/dist/types/lib/message/resources/snk-taskbar.msg.d.ts +2 -0
  205. package/dist/types/stencil-public-runtime.d.ts +15 -4
  206. package/loader/package.json +1 -0
  207. package/package.json +5 -5
  208. package/react/components.d.ts +0 -2
  209. package/react/components.js +0 -2
  210. package/react/components.js.map +1 -1
  211. package/dist/cjs/index-1133bc2a.js +0 -1235
  212. package/dist/esm/index-ffda6382.js +0 -1208
  213. package/dist/sankhyablocks/p-2a7b4cb3.entry.js +0 -1
  214. package/dist/sankhyablocks/p-9520d78a.entry.js +0 -1
  215. package/dist/sankhyablocks/p-bd1b31db.entry.js +0 -69
  216. package/dist/sankhyablocks/p-edcb9d8e.js +0 -2
@@ -0,0 +1,544 @@
1
+ import { Host, h } from '@stencil/core';
2
+ import { Action, ApplicationContext } from '@sankhyalabs/core';
3
+ import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
4
+ import { OperationMap } from '../../lib/message/SnkMessageBuilder';
5
+ export class SnkDataUnit {
6
+ constructor() {
7
+ this._onDataUnitResolve = [];
8
+ /**
9
+ * Determina quantas linhas são retornadas por página
10
+ */
11
+ this.pageSize = 150;
12
+ /**
13
+ * Quando ativada essa propriedade faz com que haja uma carga imediata no DataUnit
14
+ */
15
+ this.autoLoad = true;
16
+ this._dataUnitObserver = (action) => {
17
+ const duState = {
18
+ insertionMode: false,
19
+ hasNext: this.dataUnit.hasNext(),
20
+ hasPrevious: this.dataUnit.hasPrevious(),
21
+ copyMode: false,
22
+ isDirty: this.dataUnit.isDirty(),
23
+ hasDirtyRecords: this.dataUnit.hasDirtyRecords(),
24
+ selectedRecords: this.dataUnit.getSelectedRecords()
25
+ };
26
+ this.dataUnit.records.forEach(r => {
27
+ if (r.__record__id__.startsWith('NEW_')) {
28
+ duState.insertionMode = true;
29
+ duState.copyMode || (duState.copyMode = r['__record__source__id__'] != undefined);
30
+ }
31
+ });
32
+ this.dataState = duState;
33
+ if (action.type === Action.DATA_SAVED) {
34
+ const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0]);
35
+ if (msg != undefined) {
36
+ this.showSuccessMessage(msg);
37
+ }
38
+ }
39
+ if (action.type === Action.RECORDS_ADDED || action.type === Action.RECORDS_COPIED) {
40
+ this.insertionMode.emit();
41
+ }
42
+ if (action.type === Action.EDITION_CANCELED) {
43
+ this.cancelEdition.emit();
44
+ const cancelFinishMsg = this.getMessage("snkDataUnit.cancelInfo");
45
+ if (cancelFinishMsg != undefined) {
46
+ this.showSuccessMessage(cancelFinishMsg);
47
+ }
48
+ }
49
+ if (action.type === Action.RECORDS_REMOVED) {
50
+ const removeFinishMsg = this.getMessage("snkDataUnit.removeInfo", action.payload.cachedRecords[0]);
51
+ if (removeFinishMsg != undefined) {
52
+ this.showSuccessMessage(removeFinishMsg);
53
+ }
54
+ }
55
+ this._application.messagesBuilder.currentOperation = this.getMessageOperation();
56
+ };
57
+ }
58
+ observePageSize() {
59
+ if (this.dataUnit) {
60
+ this.dataUnit.pageSize = this.pageSize;
61
+ }
62
+ }
63
+ observeDataUnitName(newValue, oldValue) {
64
+ if (oldValue != newValue) {
65
+ this.dataUnit = undefined;
66
+ this.dataUnitName = newValue;
67
+ this.loadDataUnit();
68
+ }
69
+ }
70
+ observeEntityName(newValue, oldValue) {
71
+ if (oldValue != newValue) {
72
+ this.dataUnit = undefined;
73
+ this.entityName = newValue;
74
+ this.loadDataUnit();
75
+ }
76
+ }
77
+ observeDataState(newValue, oldValue) {
78
+ if (oldValue != newValue) {
79
+ this.dataStateChange.emit(newValue);
80
+ }
81
+ }
82
+ observeDataUnit() {
83
+ this.dataUnitReady.emit(this.dataUnit);
84
+ }
85
+ /**
86
+ * Pode-se obter o dataUnit através desse método. Outra forma, é ouvir o evento de
87
+ *
88
+ * @returns dataUnit
89
+ */
90
+ async getDataUnit() {
91
+ return new Promise((resolve) => {
92
+ if (this.dataUnit) {
93
+ resolve(this.dataUnit);
94
+ }
95
+ else {
96
+ this._onDataUnitResolve.push(resolve);
97
+ }
98
+ });
99
+ }
100
+ async interceptAction(action) {
101
+ return new Promise(resolve => {
102
+ switch (action.type) {
103
+ case Action.RECORDS_ADDED:
104
+ if (this.isAllowed("INSERT")) {
105
+ resolve(action);
106
+ }
107
+ else {
108
+ ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenInsert"));
109
+ }
110
+ break;
111
+ case Action.RECORDS_COPIED:
112
+ if (this.isAllowed("CLONE")) {
113
+ resolve(action);
114
+ }
115
+ else {
116
+ ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
117
+ }
118
+ break;
119
+ case Action.DATA_CHANGED:
120
+ case Action.CHANGING_DATA:
121
+ if (this.isAllowed("UPDATE")) {
122
+ resolve(action);
123
+ }
124
+ else {
125
+ this.dataUnit.cancelEdition();
126
+ ApplicationUtils.alert(this.getMessage("snkDataUnit.forbidden"), this.getMessage("snkDataUnit.forbiddenUpdate"));
127
+ }
128
+ break;
129
+ case Action.SAVING_DATA:
130
+ if (this.beforeSave) {
131
+ const continueAction = this.beforeSave(this.dataUnit);
132
+ if (continueAction instanceof Promise) {
133
+ continueAction.then(result => resolve(result ? action : undefined));
134
+ }
135
+ else {
136
+ resolve(continueAction ? action : undefined);
137
+ }
138
+ }
139
+ else {
140
+ resolve(action);
141
+ }
142
+ break;
143
+ case Action.DATA_SAVED:
144
+ if (this.afterSave) {
145
+ this.afterSave(this.dataUnit);
146
+ }
147
+ else {
148
+ resolve(action);
149
+ }
150
+ break;
151
+ case Action.EDITION_CANCELED:
152
+ if (this.dataState.hasDirtyRecords) {
153
+ const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
154
+ if (cancelConfirmation == undefined) {
155
+ resolve(action);
156
+ }
157
+ else {
158
+ const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
159
+ ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation)
160
+ .then((result) => resolve(result ? action : undefined));
161
+ }
162
+ }
163
+ else {
164
+ resolve(action);
165
+ }
166
+ break;
167
+ case Action.REMOVING_RECORDS:
168
+ if (this.isAllowed("REMOVE")) {
169
+ const removeConfirmation = this.getMessage("snkDataUnit.removeConfirmation");
170
+ if (removeConfirmation == undefined) {
171
+ resolve(action);
172
+ }
173
+ else {
174
+ const removeConfirmationTitle = this.getMessage("snkDataUnit.removeConfirmationTitle");
175
+ ApplicationUtils.confirm(removeConfirmationTitle, removeConfirmation, "delete", DialogType.CRITICAL, { btnConfirmDanger: true })
176
+ .then((result) => resolve(result ? action : undefined));
177
+ }
178
+ }
179
+ else {
180
+ ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenRemove"));
181
+ }
182
+ break;
183
+ default:
184
+ resolve(action);
185
+ }
186
+ });
187
+ }
188
+ showSuccessMessage(message) {
189
+ ApplicationUtils.info(message, { iconName: "check" });
190
+ }
191
+ isAllowed(flag) {
192
+ return this._permissions ? this._permissions.isSup || this._permissions[flag] : false;
193
+ }
194
+ /**
195
+ * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
196
+ * através de um pequeno modulo na estrutura da aplicação:
197
+ * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
198
+ * Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-data-unit.msg.ts"
199
+ */
200
+ getMessage(key, params = undefined) {
201
+ if (!params) {
202
+ params = this.getMessageParams();
203
+ }
204
+ return this._application.messagesBuilder.getMessage(key, params);
205
+ }
206
+ getMessageParams() {
207
+ //TODO: Atualmente ainda não usamos o recurso de multiseleção do dataunit, mas no futuro
208
+ //precisaremos criar um mecanismo para oferecer todos os registros selecionados para a
209
+ //mensagem
210
+ return this.dataState.selectedRecords ? this.dataState.selectedRecords[0] : undefined;
211
+ }
212
+ getMessageOperation() {
213
+ if (this.dataState.copyMode) {
214
+ return OperationMap.CLONE;
215
+ }
216
+ if (this.dataState.insertionMode) {
217
+ return OperationMap.INSERT;
218
+ }
219
+ if (this.dataState.isDirty) {
220
+ return OperationMap.UPDATE;
221
+ }
222
+ return OperationMap.CLEAN;
223
+ }
224
+ async loadDataUnit() {
225
+ if (!this.dataUnit) {
226
+ if (this._application && this.entityName) {
227
+ const cacheName = this.dataUnitName ? this.dataUnitName : this.entityName;
228
+ this.dataUnit = await this._application.getDataUnit(this.entityName, cacheName);
229
+ this.dataUnit.pageSize = this.pageSize;
230
+ this.dataUnit.unsubscribe(this._dataUnitObserver);
231
+ this.dataUnit.addInterceptor(this);
232
+ this.dataUnit.subscribe(this._dataUnitObserver);
233
+ let resolver;
234
+ while (resolver = this._onDataUnitResolve.pop()) {
235
+ resolver(this.dataUnit);
236
+ }
237
+ if (this.autoLoad) {
238
+ setTimeout(() => {
239
+ this.dataUnit.loadData();
240
+ }, 500); //TODO: Ajustar para aguardar filterProvider do dataunit estar pronto.
241
+ }
242
+ }
243
+ }
244
+ }
245
+ //---------------------------------------------
246
+ // Lifecycle web component
247
+ //---------------------------------------------
248
+ componentWillLoad() {
249
+ this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
250
+ this._application.getAllAccess().then(access => this._permissions = access);
251
+ }
252
+ componentDidLoad() {
253
+ this.loadDataUnit();
254
+ }
255
+ render() {
256
+ return (h(Host, null));
257
+ }
258
+ static get is() { return "snk-data-unit"; }
259
+ static get encapsulation() { return "scoped"; }
260
+ static get originalStyleUrls() {
261
+ return {
262
+ "$": ["snk-data-unit.css"]
263
+ };
264
+ }
265
+ static get styleUrls() {
266
+ return {
267
+ "$": ["snk-data-unit.css"]
268
+ };
269
+ }
270
+ static get properties() {
271
+ return {
272
+ "dataState": {
273
+ "type": "unknown",
274
+ "mutable": true,
275
+ "complexType": {
276
+ "original": "DataState",
277
+ "resolved": "DataState",
278
+ "references": {
279
+ "DataState": {
280
+ "location": "local"
281
+ }
282
+ }
283
+ },
284
+ "required": false,
285
+ "optional": false,
286
+ "docs": {
287
+ "tags": [],
288
+ "text": "O estato atual dos dados, isto \u00E9 se h\u00E1 altera\u00E7\u00E3o, insers\u00E3o, as linhas selecionadas, etc."
289
+ }
290
+ },
291
+ "dataUnitName": {
292
+ "type": "string",
293
+ "mutable": false,
294
+ "complexType": {
295
+ "original": "string",
296
+ "resolved": "string",
297
+ "references": {}
298
+ },
299
+ "required": false,
300
+ "optional": false,
301
+ "docs": {
302
+ "tags": [],
303
+ "text": "Este atributo \u00E9 usado para criar o dataUnit uma \u00FAnica vez. Se omitido ser\u00E1 usado o pr\u00F3prio nome\nda entidade."
304
+ },
305
+ "attribute": "data-unit-name",
306
+ "reflect": false
307
+ },
308
+ "entityName": {
309
+ "type": "string",
310
+ "mutable": false,
311
+ "complexType": {
312
+ "original": "string",
313
+ "resolved": "string",
314
+ "references": {}
315
+ },
316
+ "required": false,
317
+ "optional": false,
318
+ "docs": {
319
+ "tags": [],
320
+ "text": "Determina qual a entidade representa os dados em quest\u00E3o."
321
+ },
322
+ "attribute": "entity-name",
323
+ "reflect": false
324
+ },
325
+ "pageSize": {
326
+ "type": "number",
327
+ "mutable": false,
328
+ "complexType": {
329
+ "original": "number",
330
+ "resolved": "number",
331
+ "references": {}
332
+ },
333
+ "required": false,
334
+ "optional": false,
335
+ "docs": {
336
+ "tags": [],
337
+ "text": "Determina quantas linhas s\u00E3o retornadas por p\u00E1gina"
338
+ },
339
+ "attribute": "page-size",
340
+ "reflect": false,
341
+ "defaultValue": "150"
342
+ },
343
+ "dataUnit": {
344
+ "type": "unknown",
345
+ "mutable": true,
346
+ "complexType": {
347
+ "original": "DataUnit",
348
+ "resolved": "DataUnit",
349
+ "references": {
350
+ "DataUnit": {
351
+ "location": "import",
352
+ "path": "@sankhyalabs/core"
353
+ }
354
+ }
355
+ },
356
+ "required": false,
357
+ "optional": false,
358
+ "docs": {
359
+ "tags": [],
360
+ "text": "Uma vez instanciado, pode-se obter o dataUnit por esta propriedade"
361
+ }
362
+ },
363
+ "beforeSave": {
364
+ "type": "unknown",
365
+ "mutable": false,
366
+ "complexType": {
367
+ "original": "(dataUnit: DataUnit) => boolean | Promise<boolean>",
368
+ "resolved": "(dataUnit: DataUnit) => boolean | Promise<boolean>",
369
+ "references": {
370
+ "DataUnit": {
371
+ "location": "import",
372
+ "path": "@sankhyalabs/core"
373
+ },
374
+ "Promise": {
375
+ "location": "global"
376
+ }
377
+ }
378
+ },
379
+ "required": false,
380
+ "optional": false,
381
+ "docs": {
382
+ "tags": [],
383
+ "text": "Executado imediatamente antes da a\u00E7\u00E3o de salvar as altera\u00E7\u00F5es. \u00DAtil no caso de valida\u00E7\u00F5es por exemplo.\nCaso retorne \"false\" (ou a promessa se resolva como false), cancela a a\u00E7\u00E3o."
384
+ }
385
+ },
386
+ "afterSave": {
387
+ "type": "unknown",
388
+ "mutable": false,
389
+ "complexType": {
390
+ "original": "(dataUnit: DataUnit) => void",
391
+ "resolved": "(dataUnit: DataUnit) => void",
392
+ "references": {
393
+ "DataUnit": {
394
+ "location": "import",
395
+ "path": "@sankhyalabs/core"
396
+ }
397
+ }
398
+ },
399
+ "required": false,
400
+ "optional": false,
401
+ "docs": {
402
+ "tags": [],
403
+ "text": "Executado ap\u00F3s a a\u00E7\u00E3o de salvar"
404
+ }
405
+ },
406
+ "autoLoad": {
407
+ "type": "boolean",
408
+ "mutable": false,
409
+ "complexType": {
410
+ "original": "boolean",
411
+ "resolved": "boolean",
412
+ "references": {}
413
+ },
414
+ "required": false,
415
+ "optional": false,
416
+ "docs": {
417
+ "tags": [],
418
+ "text": "Quando ativada essa propriedade faz com que haja uma carga imediata no DataUnit"
419
+ },
420
+ "attribute": "auto-load",
421
+ "reflect": false,
422
+ "defaultValue": "true"
423
+ }
424
+ };
425
+ }
426
+ static get events() {
427
+ return [{
428
+ "method": "dataStateChange",
429
+ "name": "dataStateChange",
430
+ "bubbles": true,
431
+ "cancelable": true,
432
+ "composed": true,
433
+ "docs": {
434
+ "tags": [],
435
+ "text": "Disparado quando o h\u00E1 qualquer mudan\u00E7a de estado no DataUnit"
436
+ },
437
+ "complexType": {
438
+ "original": "DataState",
439
+ "resolved": "DataState",
440
+ "references": {
441
+ "DataState": {
442
+ "location": "local"
443
+ }
444
+ }
445
+ }
446
+ }, {
447
+ "method": "dataUnitReady",
448
+ "name": "dataUnitReady",
449
+ "bubbles": true,
450
+ "cancelable": true,
451
+ "composed": true,
452
+ "docs": {
453
+ "tags": [],
454
+ "text": "Disparado quando o DataUnit est\u00E1 pronto"
455
+ },
456
+ "complexType": {
457
+ "original": "DataUnit",
458
+ "resolved": "DataUnit",
459
+ "references": {
460
+ "DataUnit": {
461
+ "location": "import",
462
+ "path": "@sankhyalabs/core"
463
+ }
464
+ }
465
+ }
466
+ }, {
467
+ "method": "insertionMode",
468
+ "name": "insertionMode",
469
+ "bubbles": true,
470
+ "cancelable": true,
471
+ "composed": true,
472
+ "docs": {
473
+ "tags": [],
474
+ "text": "Disparado quando um registro \u00E9 adicionado ou copiado"
475
+ },
476
+ "complexType": {
477
+ "original": "void",
478
+ "resolved": "void",
479
+ "references": {}
480
+ }
481
+ }, {
482
+ "method": "cancelEdition",
483
+ "name": "cancelEdition",
484
+ "bubbles": true,
485
+ "cancelable": true,
486
+ "composed": true,
487
+ "docs": {
488
+ "tags": [],
489
+ "text": "Disparado quando se cancela uma insers\u00E3o/c\u00F3pia"
490
+ },
491
+ "complexType": {
492
+ "original": "void",
493
+ "resolved": "void",
494
+ "references": {}
495
+ }
496
+ }];
497
+ }
498
+ static get methods() {
499
+ return {
500
+ "getDataUnit": {
501
+ "complexType": {
502
+ "signature": "() => Promise<DataUnit>",
503
+ "parameters": [],
504
+ "references": {
505
+ "Promise": {
506
+ "location": "global"
507
+ },
508
+ "DataUnit": {
509
+ "location": "import",
510
+ "path": "@sankhyalabs/core"
511
+ }
512
+ },
513
+ "return": "Promise<DataUnit>"
514
+ },
515
+ "docs": {
516
+ "text": "Pode-se obter o dataUnit atrav\u00E9s desse m\u00E9todo. Outra forma, \u00E9 ouvir o evento de",
517
+ "tags": [{
518
+ "name": "returns",
519
+ "text": "dataUnit"
520
+ }]
521
+ }
522
+ }
523
+ };
524
+ }
525
+ static get elementRef() { return "element"; }
526
+ static get watchers() {
527
+ return [{
528
+ "propName": "pageSize",
529
+ "methodName": "observePageSize"
530
+ }, {
531
+ "propName": "dataUnitName",
532
+ "methodName": "observeDataUnitName"
533
+ }, {
534
+ "propName": "entityName",
535
+ "methodName": "observeEntityName"
536
+ }, {
537
+ "propName": "dataState",
538
+ "methodName": "observeDataState"
539
+ }, {
540
+ "propName": "dataUnit",
541
+ "methodName": "observeDataUnit"
542
+ }];
543
+ }
544
+ }
@@ -0,0 +1,88 @@
1
+ import { h, Host } from '@stencil/core';
2
+ import FilterItemType from '../filter-item-type.enum';
3
+ export class SnkFilterBinarySelect {
4
+ isSelected(option) {
5
+ return this.value == undefined || this.value === option;
6
+ }
7
+ ezChangeListener(evt) {
8
+ if (!evt.detail) {
9
+ this.assertCheckedOption(evt.target);
10
+ }
11
+ this.updateValue();
12
+ }
13
+ assertCheckedOption(updatingCheck) {
14
+ if (updatingCheck === this._checkOne) {
15
+ this._checkTwo.value = true;
16
+ }
17
+ else {
18
+ this._checkOne.value = true;
19
+ }
20
+ }
21
+ updateValue() {
22
+ if (!this._checkOne.value || !this._checkTwo.value) {
23
+ const [optOne, optTwo] = this.config.props.options;
24
+ this.value = this._checkOne.value ? optOne.name : optTwo.name;
25
+ }
26
+ else {
27
+ this.value = undefined;
28
+ }
29
+ }
30
+ render() {
31
+ if (!this.config || this.config.type !== FilterItemType.BINARY_SELECT) {
32
+ return undefined;
33
+ }
34
+ const [optOne, optTwo] = this.config.props.options;
35
+ return (h(Host, null, h("ez-check", { label: optOne.label, class: "sc-snk-filter-bar editor__ez-check", ref: (ref) => this._checkOne = ref, value: this.isSelected(optOne.name) }), h("ez-check", { label: optTwo.label, class: "sc-snk-filter-bar editor__ez-check", ref: (ref) => this._checkTwo = ref, value: this.isSelected(optTwo.name) })));
36
+ }
37
+ static get is() { return "snk-filter-binary-select"; }
38
+ static get properties() {
39
+ return {
40
+ "value": {
41
+ "type": "any",
42
+ "mutable": true,
43
+ "complexType": {
44
+ "original": "any",
45
+ "resolved": "any",
46
+ "references": {}
47
+ },
48
+ "required": false,
49
+ "optional": false,
50
+ "docs": {
51
+ "tags": [],
52
+ "text": ""
53
+ },
54
+ "attribute": "value",
55
+ "reflect": true
56
+ },
57
+ "config": {
58
+ "type": "unknown",
59
+ "mutable": false,
60
+ "complexType": {
61
+ "original": "SnkFilterItemConfig",
62
+ "resolved": "SnkFilterItemConfig",
63
+ "references": {
64
+ "SnkFilterItemConfig": {
65
+ "location": "import",
66
+ "path": "../snk-filter-item"
67
+ }
68
+ }
69
+ },
70
+ "required": false,
71
+ "optional": false,
72
+ "docs": {
73
+ "tags": [],
74
+ "text": ""
75
+ }
76
+ }
77
+ };
78
+ }
79
+ static get listeners() {
80
+ return [{
81
+ "name": "ezChange",
82
+ "method": "ezChangeListener",
83
+ "target": undefined,
84
+ "capture": false,
85
+ "passive": false
86
+ }];
87
+ }
88
+ }
@@ -0,0 +1,64 @@
1
+ import { h } from '@stencil/core';
2
+ import FilterItemType from '../filter-item-type.enum';
3
+ export class SnkFilterMultiSelect {
4
+ ezChangeListener(evt) {
5
+ this.value = evt.detail.value;
6
+ }
7
+ render() {
8
+ if (!this.config || this.config.type !== FilterItemType.MULTI_SELECT) {
9
+ return undefined;
10
+ }
11
+ return (h("ez-combo-box", { label: this.config.label, value: this.config.value, options: this.config.props.options }));
12
+ }
13
+ static get is() { return "snk-filter-multi-select"; }
14
+ static get properties() {
15
+ return {
16
+ "value": {
17
+ "type": "any",
18
+ "mutable": true,
19
+ "complexType": {
20
+ "original": "any",
21
+ "resolved": "any",
22
+ "references": {}
23
+ },
24
+ "required": false,
25
+ "optional": false,
26
+ "docs": {
27
+ "tags": [],
28
+ "text": ""
29
+ },
30
+ "attribute": "value",
31
+ "reflect": true
32
+ },
33
+ "config": {
34
+ "type": "unknown",
35
+ "mutable": false,
36
+ "complexType": {
37
+ "original": "SnkFilterItemConfig",
38
+ "resolved": "SnkFilterItemConfig",
39
+ "references": {
40
+ "SnkFilterItemConfig": {
41
+ "location": "import",
42
+ "path": "../snk-filter-item"
43
+ }
44
+ }
45
+ },
46
+ "required": false,
47
+ "optional": false,
48
+ "docs": {
49
+ "tags": [],
50
+ "text": ""
51
+ }
52
+ }
53
+ };
54
+ }
55
+ static get listeners() {
56
+ return [{
57
+ "name": "ezChange",
58
+ "method": "ezChangeListener",
59
+ "target": undefined,
60
+ "capture": false,
61
+ "passive": false
62
+ }];
63
+ }
64
+ }