@sankhyalabs/sankhyablocks 5.16.0 → 5.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/dist/cjs/ParamType-90b440a0.js +13 -0
  2. package/dist/cjs/{SnkMessageBuilder-cf80308c.js → SnkMessageBuilder-3b5b5614.js} +30 -1
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  5. package/dist/cjs/snk-actions-button.cjs.entry.js +704 -0
  6. package/dist/cjs/snk-actions-form.cjs.entry.js +200 -0
  7. package/dist/cjs/snk-application.cjs.entry.js +1 -1
  8. package/dist/cjs/snk-attach.cjs.entry.js +1 -1
  9. package/dist/cjs/snk-client-confirm.cjs.entry.js +52 -0
  10. package/dist/cjs/snk-configurator.cjs.entry.js +1 -1
  11. package/dist/cjs/snk-crud.cjs.entry.js +1 -1
  12. package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
  13. package/dist/cjs/{snk-data-unit-bd271acd.js → snk-data-unit-e9c20097.js} +1 -1
  14. package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
  15. package/dist/cjs/snk-detail-view.cjs.entry.js +4 -4
  16. package/dist/cjs/snk-grid.cjs.entry.js +4 -4
  17. package/dist/cjs/{snk-guides-viewer-0ab3746e.js → snk-guides-viewer-c8843478.js} +2 -2
  18. package/dist/cjs/snk-guides-viewer.cjs.entry.js +3 -3
  19. package/dist/cjs/snk-simple-bar_2.cjs.entry.js +2 -2
  20. package/dist/cjs/snk-taskbar.cjs.entry.js +1 -1
  21. package/dist/cjs/{taskbar-elements-bc2598f9.js → taskbar-elements-3be287d6.js} +3 -0
  22. package/dist/cjs/{taskbar-processor-e1e3bbf7.js → taskbar-processor-02f0fc84.js} +1 -1
  23. package/dist/collection/collection-manifest.json +3 -0
  24. package/dist/collection/components/snk-actions-button/actions/enum/ActionsType.js +8 -0
  25. package/dist/collection/components/snk-actions-button/actions/enum/ParamType.js +11 -0
  26. package/dist/collection/components/snk-actions-button/actions/enum/RefreshType.js +7 -0
  27. package/dist/collection/components/snk-actions-button/actions/executor/java.executor.js +22 -0
  28. package/dist/collection/components/snk-actions-button/actions/executor/javascript.executor.js +20 -0
  29. package/dist/collection/components/snk-actions-button/actions/executor/launch-screen.executor.js +42 -0
  30. package/dist/collection/components/snk-actions-button/actions/executor/procedure.executor.js +26 -0
  31. package/dist/collection/components/snk-actions-button/actions/factory/executor.factory.js +26 -0
  32. package/dist/collection/components/snk-actions-button/actions/index.js +343 -0
  33. package/dist/collection/components/snk-actions-button/actions/interfaces/IAction.js +7 -0
  34. package/dist/collection/components/snk-actions-button/actions/interfaces/IExecSource.js +1 -0
  35. package/dist/collection/components/snk-actions-button/actions/interfaces/IExecuteActions.js +1 -0
  36. package/dist/collection/components/snk-actions-button/actions/interfaces/IExecuteActionsProps.js +1 -0
  37. package/dist/collection/components/snk-actions-button/actions/interfaces/IResultParam.js +1 -0
  38. package/dist/collection/components/snk-actions-button/clientEvent/index.js +87 -0
  39. package/dist/collection/components/snk-actions-button/clientEvent/interfaces/IClientEventConfirm.js +1 -0
  40. package/dist/collection/components/snk-actions-button/snk-actions-button.css +38 -0
  41. package/dist/collection/components/snk-actions-button/snk-actions-button.js +139 -0
  42. package/dist/collection/components/snk-actions-button/subcomponents/snk-actions-form.js +263 -0
  43. package/dist/collection/components/snk-actions-button/subcomponents/snk-client-confirm.js +134 -0
  44. package/dist/collection/components/snk-configurator/snk-configurator.css +1 -1
  45. package/dist/collection/components/snk-grid/snk-grid.js +2 -2
  46. package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +3 -0
  47. package/dist/collection/lib/message/SnkMessageBuilder.js +3 -1
  48. package/dist/collection/lib/message/resources/snk-actions-button.msg.js +27 -0
  49. package/dist/components/ParamType.js +13 -0
  50. package/dist/components/SnkMessageBuilder.js +30 -1
  51. package/dist/components/index.d.ts +3 -0
  52. package/dist/components/index.js +3 -0
  53. package/dist/components/snk-actions-button.d.ts +11 -0
  54. package/dist/components/snk-actions-button.js +6 -0
  55. package/dist/components/snk-actions-button2.js +718 -0
  56. package/dist/components/snk-actions-form.d.ts +11 -0
  57. package/dist/components/snk-actions-form.js +218 -0
  58. package/dist/components/snk-attach2.js +7 -1
  59. package/dist/components/snk-client-confirm.d.ts +11 -0
  60. package/dist/components/snk-client-confirm.js +71 -0
  61. package/dist/components/snk-configurator2.js +1 -1
  62. package/dist/components/snk-crud.js +7 -1
  63. package/dist/components/snk-detail-view2.js +13 -2
  64. package/dist/components/snk-grid2.js +9 -3
  65. package/dist/components/snk-simple-crud2.js +7 -1
  66. package/dist/components/snk-taskbar2.js +10 -1
  67. package/dist/esm/ParamType-d5152b06.js +13 -0
  68. package/dist/esm/{SnkMessageBuilder-1a169545.js → SnkMessageBuilder-188a38bb.js} +30 -1
  69. package/dist/esm/loader.js +1 -1
  70. package/dist/esm/sankhyablocks.js +1 -1
  71. package/dist/esm/snk-actions-button.entry.js +700 -0
  72. package/dist/esm/snk-actions-form.entry.js +196 -0
  73. package/dist/esm/snk-application.entry.js +1 -1
  74. package/dist/esm/snk-attach.entry.js +1 -1
  75. package/dist/esm/snk-client-confirm.entry.js +48 -0
  76. package/dist/esm/snk-configurator.entry.js +1 -1
  77. package/dist/esm/snk-crud.entry.js +1 -1
  78. package/dist/esm/snk-data-exporter.entry.js +2 -2
  79. package/dist/esm/{snk-data-unit-476024e9.js → snk-data-unit-79b1583a.js} +1 -1
  80. package/dist/esm/snk-data-unit.entry.js +2 -2
  81. package/dist/esm/snk-detail-view.entry.js +4 -4
  82. package/dist/esm/snk-grid.entry.js +4 -4
  83. package/dist/esm/{snk-guides-viewer-767f5a74.js → snk-guides-viewer-59d3a78c.js} +2 -2
  84. package/dist/esm/snk-guides-viewer.entry.js +3 -3
  85. package/dist/esm/snk-simple-bar_2.entry.js +2 -2
  86. package/dist/esm/snk-taskbar.entry.js +1 -1
  87. package/dist/esm/{taskbar-elements-e6af3e93.js → taskbar-elements-8ff33c26.js} +3 -0
  88. package/dist/esm/{taskbar-processor-a40798b8.js → taskbar-processor-20de6616.js} +1 -1
  89. package/dist/sankhyablocks/{p-3e17b147.js → p-0b40c655.js} +1 -1
  90. package/dist/sankhyablocks/{p-de9caf1e.entry.js → p-0b6ddb67.entry.js} +1 -1
  91. package/dist/sankhyablocks/p-19692f92.js +1 -0
  92. package/dist/sankhyablocks/{p-6df8c88b.entry.js → p-257c71a7.entry.js} +1 -1
  93. package/dist/sankhyablocks/{p-551165d8.js → p-28c12f65.js} +1 -1
  94. package/dist/sankhyablocks/{p-78de64fb.entry.js → p-2d0fc912.entry.js} +1 -1
  95. package/dist/sankhyablocks/p-384c4a6b.js +1 -0
  96. package/dist/sankhyablocks/{p-f43629f3.entry.js → p-44c2ed16.entry.js} +1 -1
  97. package/dist/sankhyablocks/{p-4f05a335.entry.js → p-44cf545f.entry.js} +1 -1
  98. package/dist/sankhyablocks/{p-ec1c64be.entry.js → p-8ce9ea9f.entry.js} +1 -1
  99. package/dist/sankhyablocks/{p-e0c04667.entry.js → p-9c7f7214.entry.js} +1 -1
  100. package/dist/sankhyablocks/p-9f66bc54.entry.js +1 -0
  101. package/dist/sankhyablocks/{p-c74fca58.js → p-b34d23fa.js} +1 -1
  102. package/dist/sankhyablocks/p-b680fa7a.entry.js +1 -0
  103. package/dist/sankhyablocks/p-b75ce8b8.entry.js +1 -0
  104. package/dist/sankhyablocks/{p-9e92ed74.entry.js → p-cbe93a18.entry.js} +2 -2
  105. package/dist/sankhyablocks/p-eaad0aa8.js +1 -0
  106. package/dist/sankhyablocks/{p-7956b9dd.entry.js → p-eb07d0eb.entry.js} +1 -1
  107. package/dist/sankhyablocks/p-f27dc5e9.entry.js +1 -0
  108. package/dist/sankhyablocks/p-fa2d0376.entry.js +1 -0
  109. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  110. package/dist/types/components/snk-actions-button/actions/enum/ActionsType.d.ts +7 -0
  111. package/dist/types/components/snk-actions-button/actions/enum/ParamType.d.ts +10 -0
  112. package/dist/types/components/snk-actions-button/actions/enum/RefreshType.d.ts +6 -0
  113. package/dist/types/components/snk-actions-button/actions/executor/java.executor.d.ts +6 -0
  114. package/dist/types/components/snk-actions-button/actions/executor/javascript.executor.d.ts +6 -0
  115. package/dist/types/components/snk-actions-button/actions/executor/launch-screen.executor.d.ts +10 -0
  116. package/dist/types/components/snk-actions-button/actions/executor/procedure.executor.d.ts +6 -0
  117. package/dist/types/components/snk-actions-button/actions/factory/executor.factory.d.ts +7 -0
  118. package/dist/types/components/snk-actions-button/actions/index.d.ts +27 -0
  119. package/dist/types/components/snk-actions-button/actions/interfaces/IAction.d.ts +55 -0
  120. package/dist/types/components/snk-actions-button/actions/interfaces/IExecSource.d.ts +17 -0
  121. package/dist/types/components/snk-actions-button/actions/interfaces/IExecuteActions.d.ts +4 -0
  122. package/dist/types/components/snk-actions-button/actions/interfaces/IExecuteActionsProps.d.ts +4 -0
  123. package/dist/types/components/snk-actions-button/actions/interfaces/IResultParam.d.ts +14 -0
  124. package/dist/types/components/snk-actions-button/clientEvent/index.d.ts +4 -0
  125. package/dist/types/components/snk-actions-button/clientEvent/interfaces/IClientEventConfirm.d.ts +35 -0
  126. package/dist/types/components/snk-actions-button/snk-actions-button.d.ts +27 -0
  127. package/dist/types/components/snk-actions-button/subcomponents/snk-actions-form.d.ts +41 -0
  128. package/dist/types/components/snk-actions-button/subcomponents/snk-client-confirm.d.ts +31 -0
  129. package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +2 -1
  130. package/dist/types/components.d.ts +96 -0
  131. package/dist/types/lib/message/resources/snk-actions-button.msg.d.ts +1 -0
  132. package/package.json +1 -1
  133. package/react/components.d.ts +3 -0
  134. package/react/components.js +3 -0
  135. package/react/components.js.map +1 -1
  136. package/dist/sankhyablocks/p-1c5d5e5c.entry.js +0 -1
  137. package/dist/sankhyablocks/p-39082fc3.js +0 -1
  138. package/dist/sankhyablocks/p-8d40909d.entry.js +0 -1
  139. package/dist/sankhyablocks/p-d410f45a.js +0 -1
@@ -0,0 +1,26 @@
1
+ import JavaExecutor from "../executor/java.executor";
2
+ import JavascriptExecutor from "../executor/javascript.executor";
3
+ import LaunchScreenExecutor from "../executor/launch-screen.executor";
4
+ import ProcedureExecutor from "../executor/procedure.executor";
5
+ import { ActionsType } from "../enum/ActionsType";
6
+ import { ApplicationContext, ErrorException } from "@sankhyalabs/core";
7
+ export default class ExecutorFactory {
8
+ constructor(actionType) {
9
+ this.actionType = actionType;
10
+ this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
11
+ }
12
+ get executor() {
13
+ switch (this.actionType) {
14
+ case ActionsType.LAUNCH_SCREEN:
15
+ return new LaunchScreenExecutor();
16
+ case ActionsType.JAVASCRIPT:
17
+ return new JavascriptExecutor();
18
+ case ActionsType.JAVA:
19
+ return new JavaExecutor();
20
+ case ActionsType.PROCEDURE:
21
+ return new ProcedureExecutor();
22
+ default:
23
+ throw new ErrorException(this._application.messagesBuilder.getMessage("snkActionsButton.title.error", undefined), this._application.messagesBuilder.getMessage("snkActionsButton.action.nonExistentType", { actionType: this.actionType }));
24
+ }
25
+ }
26
+ }
@@ -0,0 +1,343 @@
1
+ import { ApplicationContext, DateUtils, ErrorException, ObjectUtils, StringUtils, WarningException } from "@sankhyalabs/core";
2
+ import { RefreshType } from "./enum/RefreshType";
3
+ import { ParamType } from "./enum/ParamType";
4
+ import { DataFetcher } from "../../../lib";
5
+ import { ActionsType } from "./enum/ActionsType";
6
+ const MASTER_ROW_PROPERTY = "__MASTER_ROW__";
7
+ const ENTITY_NAME_PROPERTY = '__ENTITY_NAME__';
8
+ const NUFIN_COLUMN = 'NUFIN';
9
+ const SERVICE_GET_CONFIGURATIONS = 'SystemUtilsSP.getConf';
10
+ export default class Actions {
11
+ constructor(actionsExecuteInterface, dataUnit) {
12
+ var _a;
13
+ this._lastValuesCache = {};
14
+ this._actionsExecuteInterface = actionsExecuteInterface;
15
+ this._dataUnit = dataUnit;
16
+ this._selectedRows = ((_a = dataUnit === null || dataUnit === void 0 ? void 0 : dataUnit.getSelectionInfo()) === null || _a === void 0 ? void 0 : _a.isAllRecords()) ? [] : dataUnit === null || dataUnit === void 0 ? void 0 : dataUnit.getSelectionInfo().records;
17
+ this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
18
+ }
19
+ apply(action, hasParamsToSave) {
20
+ this._application.closePopUp();
21
+ this._actionsExecuteInterface.execute(action, this._dataUnit)
22
+ .then(({ execSource, callback }) => {
23
+ this.resolvePromptParams(action, execSource, hasParamsToSave)
24
+ .then(() => {
25
+ this.actionExecute(execSource, callback);
26
+ });
27
+ });
28
+ }
29
+ ;
30
+ async execute(action) {
31
+ var _a;
32
+ if (!action.actionConfig) {
33
+ throw new WarningException(this._application.messagesBuilder.getMessage("snkActionsButton.title.warning", undefined), this._application.messagesBuilder.getMessage("snkActionsButton.action.incorrectAction", { description: action.description }));
34
+ }
35
+ if (!!((_a = action.actionConfig.params) === null || _a === void 0 ? void 0 : _a.promptParam)) {
36
+ const paramsSource = action.actionConfig.params.promptParam;
37
+ let hasParamsToSave = false;
38
+ for (let i = 0; i < paramsSource.length; i++) {
39
+ let paramSource = paramsSource[i];
40
+ if (!hasParamsToSave && paramSource.saveLast === 'true') {
41
+ hasParamsToSave = true;
42
+ break;
43
+ }
44
+ }
45
+ if (hasParamsToSave) {
46
+ action.actionConfig.params.promptParam = await this.loadSavedValuesIntoParams(action);
47
+ }
48
+ const form = document.createElement("snk-actions-form");
49
+ window.document.body.appendChild(form);
50
+ form.action = ObjectUtils.copy(action);
51
+ form.applyParameters = (resultAction) => {
52
+ this.apply(resultAction, hasParamsToSave);
53
+ };
54
+ form.openPopup();
55
+ }
56
+ else if (action.type != ActionsType.LAUNCH_SCREEN) {
57
+ this._actionsExecuteInterface.execute(action, this._dataUnit)
58
+ .then(({ execSource, callback }) => {
59
+ this.actionExecute(execSource, callback);
60
+ });
61
+ }
62
+ else {
63
+ this._actionsExecuteInterface.execute(action, this._dataUnit);
64
+ }
65
+ }
66
+ loadSavedValuesIntoParams(action) {
67
+ return this.loadLastValues(action)
68
+ .then((lastParams) => {
69
+ let resultParams = action.actionConfig.params.promptParam;
70
+ if (lastParams) {
71
+ lastParams.param.forEach(lastParam => {
72
+ resultParams = resultParams.map((param) => {
73
+ if (param.name !== lastParam.paramName)
74
+ return param;
75
+ if (param.paramType === 'B') {
76
+ return Object.assign(Object.assign({}, param), { value: lastParam.$ === 'S' });
77
+ }
78
+ return Object.assign(Object.assign({}, param), { value: lastParam.$ });
79
+ });
80
+ });
81
+ }
82
+ return resultParams;
83
+ });
84
+ }
85
+ actionExecute(execSource, callback) {
86
+ execSource.virtualPage = this.buildVirtualPage();
87
+ this.prepareAndExecute(execSource, callback);
88
+ this.recordsReloader(execSource.refreshType);
89
+ }
90
+ resolvePromptParams(action, execSource, hasParamsToSave) {
91
+ return new Promise(resolve => {
92
+ const paramsSource = action.actionConfig.params.promptParam;
93
+ let params = [];
94
+ paramsSource.forEach(paramSource => {
95
+ params.push(this.buildPromptParam(paramSource));
96
+ });
97
+ this.putParamsOnExecSource(params, execSource);
98
+ if (hasParamsToSave) {
99
+ this.saveLastValues(action, params);
100
+ }
101
+ resolve();
102
+ });
103
+ }
104
+ buildPromptParam(param) {
105
+ let type = param.paramType;
106
+ let isCheckbox = false;
107
+ let fieldProps;
108
+ let entityPK;
109
+ let value = param.value;
110
+ switch (type) {
111
+ case ParamType.DATE:
112
+ type = 'D';
113
+ break;
114
+ case ParamType.DATETIME:
115
+ type = 'H';
116
+ break;
117
+ case ParamType.DECIMAL:
118
+ type = 'F';
119
+ fieldProps = {
120
+ 'sk-precision': Number(param.precision)
121
+ };
122
+ break;
123
+ case ParamType.BOOLEAN:
124
+ type = 'S';
125
+ isCheckbox = true;
126
+ value = param.value ? 'S' : 'N';
127
+ break;
128
+ case ParamType.ENTITY:
129
+ fieldProps = {
130
+ 'sk-entity-name': param.entityName,
131
+ 'sk-allow-show-hierarchical-mode': param.hierarchyEntity,
132
+ 'sk-data-type': 'S'
133
+ };
134
+ if (param.hierarchyEntity && param.entityPK) {
135
+ entityPK = param.entityPK;
136
+ }
137
+ value = param.value ? Number(param.value) : null;
138
+ break;
139
+ case ParamType.OPTIONS:
140
+ type = 'O';
141
+ let options = param.options.split(';').map(function (opc, index) {
142
+ let data;
143
+ let value;
144
+ if (opc.indexOf('=') > -1) {
145
+ let opcArr = opc.split('=');
146
+ data = opcArr[0];
147
+ value = opcArr[1];
148
+ }
149
+ else {
150
+ data = (index + 1);
151
+ value = opc;
152
+ }
153
+ return {
154
+ data: data,
155
+ value: value
156
+ };
157
+ });
158
+ fieldProps = {
159
+ 'sk-options': options
160
+ };
161
+ break;
162
+ }
163
+ return {
164
+ description: param.label,
165
+ required: param.required == 'true',
166
+ fieldName: param.name,
167
+ fieldNameOri: param.name,
168
+ entityPK: entityPK,
169
+ paramType: param.paramType,
170
+ type: type,
171
+ isCheckbox: isCheckbox,
172
+ saveLast: param.saveLast,
173
+ fieldProp: fieldProps,
174
+ value: value,
175
+ isGeneratedName: param.isGeneratedName
176
+ };
177
+ }
178
+ putParamsOnExecSource(params, execSource) {
179
+ execSource.params = {
180
+ param: []
181
+ };
182
+ params.forEach(param => {
183
+ if (param.isGeneratedName && param.value) {
184
+ throw new ErrorException(this._application.messagesBuilder.getMessage("snkActionsButton.title.error", undefined), this._application.messagesBuilder.getMessage("snkActionsButton.action.emptyParamName", undefined));
185
+ }
186
+ if (!StringUtils.isEmpty(param.value)) {
187
+ execSource.params.param.push({
188
+ type: this.getParamDataType(param.paramType),
189
+ paramName: param.fieldName,
190
+ $: this.getParamValue(param)
191
+ });
192
+ }
193
+ });
194
+ }
195
+ getParamDataType(type) {
196
+ let dataType;
197
+ switch (type) {
198
+ case "D":
199
+ dataType = "F";
200
+ break;
201
+ case "DT":
202
+ case "DH":
203
+ dataType = "D";
204
+ break;
205
+ case "B":
206
+ case "ENTITY":
207
+ case "SO":
208
+ dataType = "S";
209
+ break;
210
+ default:
211
+ dataType = type;
212
+ }
213
+ return dataType;
214
+ }
215
+ getParamValue(param) {
216
+ let value = param.value;
217
+ if (!value) {
218
+ return value;
219
+ }
220
+ if (param.paramType == 'DT') {
221
+ value = DateUtils.formatDate(value);
222
+ }
223
+ else if (param.paramType == 'DH') {
224
+ value = DateUtils.formatDateTime(value);
225
+ }
226
+ return value;
227
+ }
228
+ async loadLastValues(action) {
229
+ const resourceId = await this.buildResourceId(action.actionID);
230
+ return new Promise((resolve, reject) => {
231
+ if (this._lastValuesCache[resourceId]) {
232
+ resolve(this._lastValuesCache[resourceId]);
233
+ }
234
+ else {
235
+ const config = {
236
+ config: {
237
+ chave: resourceId,
238
+ tipo: 'T'
239
+ }
240
+ };
241
+ DataFetcher.get().callServiceBroker(SERVICE_GET_CONFIGURATIONS, config)
242
+ .then((result) => {
243
+ var _a, _b;
244
+ let lastParams;
245
+ if ((_b = (_a = result.config) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.params) {
246
+ lastParams = result.config.data.params;
247
+ if (!Array.isArray(lastParams.param)) {
248
+ lastParams.param = [lastParams.param];
249
+ }
250
+ }
251
+ this._lastValuesCache[resourceId] = lastParams;
252
+ resolve(lastParams);
253
+ }).catch((error) => {
254
+ reject(error);
255
+ });
256
+ }
257
+ });
258
+ }
259
+ async saveLastValues(action, params) {
260
+ if (this._application) {
261
+ let config = {
262
+ params: {
263
+ param: []
264
+ }
265
+ };
266
+ params.forEach(param => {
267
+ if (param.saveLast == 'true') {
268
+ config.params.param.push({
269
+ paramName: param.fieldName,
270
+ $: param.value
271
+ });
272
+ }
273
+ });
274
+ const resourceId = await this.buildResourceId(action.actionID);
275
+ this._lastValuesCache[resourceId] = config.params;
276
+ this._application.saveConfig(resourceId, config);
277
+ }
278
+ }
279
+ async buildResourceId(actionId) {
280
+ let appResId = '';
281
+ appResId = await this._application.getResourceID();
282
+ return appResId + '.actionconfig.' + actionId;
283
+ }
284
+ prepareAndExecute(execSource, executeAction) {
285
+ this.addRows(execSource);
286
+ executeAction(execSource);
287
+ }
288
+ addRows(execSource) {
289
+ const rows = {
290
+ row: []
291
+ };
292
+ const sourceRows = this._selectedRows;
293
+ for (const i in sourceRows) {
294
+ const sourceRow = sourceRows[i];
295
+ const row = {};
296
+ if (sourceRow.hasOwnProperty(MASTER_ROW_PROPERTY)) {
297
+ row.master = 'S';
298
+ row.entityName = sourceRow.__ENTITY_NAME__;
299
+ delete sourceRow[MASTER_ROW_PROPERTY];
300
+ delete sourceRow[ENTITY_NAME_PROPERTY];
301
+ }
302
+ for (const fieldName in sourceRow) {
303
+ if (fieldName !== NUFIN_COLUMN)
304
+ continue;
305
+ if (!row.field) {
306
+ row.field = [];
307
+ }
308
+ row.field.push({
309
+ fieldName: fieldName,
310
+ $: sourceRow[fieldName]
311
+ });
312
+ }
313
+ rows.row.push(row);
314
+ }
315
+ if (rows.row.length > 0) {
316
+ execSource.rows = rows;
317
+ }
318
+ }
319
+ recordsReloader(refreshType) {
320
+ switch (refreshType) {
321
+ case RefreshType.NONE:
322
+ break;
323
+ case RefreshType.PARENT:
324
+ case RefreshType.MASTER:
325
+ case RefreshType.ALL:
326
+ this._dataUnit.loadData();
327
+ break;
328
+ default:
329
+ this._dataUnit.reloadCurrentRecord();
330
+ }
331
+ }
332
+ ;
333
+ buildVirtualPage() {
334
+ var _a, _b, _c, _d;
335
+ if ((_b = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.getSelectionInfo()) === null || _b === void 0 ? void 0 : _b.isAllRecords()) {
336
+ const virtualPage = {
337
+ filters: { filters: (_c = this._dataUnit) === null || _c === void 0 ? void 0 : _c.getAppliedFilters() },
338
+ orders: { orders: (_d = this._dataUnit) === null || _d === void 0 ? void 0 : _d.getSort() },
339
+ };
340
+ return virtualPage;
341
+ }
342
+ }
343
+ }
@@ -0,0 +1,87 @@
1
+ import { ApplicationContext } from "@sankhyalabs/core";
2
+ import { ActionsType } from "../actions/enum/ActionsType";
3
+ const CONFIRMACAO = "__CONFIRMACAO__";
4
+ const ESCOLHA_SIM_NAO = "__ESCOLHA_SIMNAO__";
5
+ export default class ClientEventConfirm {
6
+ clientConfirm(clientEvent, recaller) {
7
+ const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
8
+ let actionType = "";
9
+ if (clientEvent.content.event.hasOwnProperty('stpCall')) {
10
+ recaller.requestBody = clientEvent.content.event.stpCall;
11
+ actionType = ActionsType.PROCEDURE;
12
+ }
13
+ else if (clientEvent.content.event.hasOwnProperty('runScript')) {
14
+ recaller.requestBody = clientEvent.content.event.runScript;
15
+ actionType = ActionsType.JAVASCRIPT;
16
+ }
17
+ else if (clientEvent.content.event.hasOwnProperty('javaCall')) {
18
+ recaller.requestBody = clientEvent.content.event.javaCall;
19
+ actionType = ActionsType.JAVA;
20
+ }
21
+ let param = {
22
+ type: 'S',
23
+ sequence: clientEvent.content.event.sequence
24
+ };
25
+ if (!recaller.requestBody.params) {
26
+ recaller.requestBody.params = {
27
+ param: []
28
+ };
29
+ }
30
+ else {
31
+ if (!Array.isArray(recaller.requestBody.params.param)) {
32
+ recaller.requestBody.params.param = [recaller.requestBody.params.param];
33
+ }
34
+ }
35
+ recaller.requestBody.params.param.push(param);
36
+ const title = clientEvent.content.event.title.$;
37
+ const message = clientEvent.content.event.message.$;
38
+ let requestBody;
39
+ switch (actionType) {
40
+ case ActionsType.JAVASCRIPT:
41
+ requestBody = { runScript: recaller.requestBody };
42
+ break;
43
+ case ActionsType.PROCEDURE:
44
+ requestBody = {
45
+ requestBody: {
46
+ stpCall: recaller.requestBody
47
+ }
48
+ };
49
+ break;
50
+ case ActionsType.JAVA:
51
+ requestBody = {
52
+ requestBody: {
53
+ javaCall: recaller.requestBody
54
+ }
55
+ };
56
+ break;
57
+ }
58
+ if (clientEvent.content.event.showNoOption == 'S') {
59
+ param.paramName = ESCOLHA_SIM_NAO;
60
+ const form = document.createElement("snk-client-confirm");
61
+ window.document.body.appendChild(form);
62
+ form.titleMessage = title;
63
+ form.message = message;
64
+ form.accept = () => {
65
+ param.$ = 'S';
66
+ recaller.reCall(requestBody);
67
+ };
68
+ form.cancel = () => {
69
+ param.$ = 'N';
70
+ recaller.reCall(requestBody);
71
+ };
72
+ form.openPopup();
73
+ }
74
+ else {
75
+ application.confirm(title, message, null, 'warn', {
76
+ labelCancel: "Cancelar",
77
+ labelConfirm: "Sim"
78
+ }).then((confirmResult) => {
79
+ if (confirmResult) {
80
+ param.paramName = CONFIRMACAO;
81
+ param.$ = 'S';
82
+ recaller.reCall(requestBody);
83
+ }
84
+ });
85
+ }
86
+ }
87
+ }
@@ -0,0 +1,38 @@
1
+ :host {
2
+ /*@doc Define o posicionamento de z-index do componente.*/
3
+ --snk-actions-button--z-index: var(--most-visible, 3);
4
+
5
+ /*private*/
6
+ display: flex;
7
+ width: fit-content;
8
+ height: fit-content;
9
+ }
10
+
11
+ .snk-actions-button {
12
+ /*private*/
13
+ display: flex;
14
+ width: fit-content;
15
+ height: fit-content;
16
+ }
17
+
18
+ .snk-actions-button__dropdown--show {
19
+ /*private*/
20
+ display: flex;
21
+ flex-direction: column;
22
+ position: fixed;
23
+ }
24
+
25
+ .snk-actions-button__dropdown > ez-dropdown {
26
+ /*private*/
27
+ position: relative;
28
+ }
29
+
30
+ .snk-actions-button--overlap {
31
+ /*public*/
32
+ z-index: var(--snk-actions-button--z-index);
33
+ }
34
+
35
+ .snk-actions-button__dropdown {
36
+ /*private*/
37
+ display: none;
38
+ }
@@ -0,0 +1,139 @@
1
+ import { h, Host } from '@stencil/core';
2
+ import { ApplicationContext, ArrayUtils, ElementIDUtils } from '@sankhyalabs/core';
3
+ import { DataFetcher } from '../../lib/http/data-fetcher/DataFetcher';
4
+ import ExecutorFactory from './actions/factory/executor.factory';
5
+ import Actions from './actions';
6
+ import ClientEventConfirm from './clientEvent';
7
+ export class SnkActionsButton {
8
+ constructor() {
9
+ this.CLIENT_EVENT_CONFIRM_NAME = "br.com.sankhya.actionbutton.clientconfirm";
10
+ this.handleClick = (evt) => {
11
+ const selectedAction = this._actions.find((action) => action.actionID == evt.detail.id);
12
+ const executor = new ExecutorFactory(selectedAction.type).executor;
13
+ const action = new Actions(executor, this._dataUnit);
14
+ action.execute(Object.assign({}, selectedAction));
15
+ this._showDropdown = false;
16
+ };
17
+ this._items = [];
18
+ this._showDropdown = false;
19
+ this._actions = [];
20
+ this._isOrderActions = false;
21
+ }
22
+ async getActions() {
23
+ let param = {
24
+ param: {
25
+ entityName: this._entityName,
26
+ resourceID: this._resourceID
27
+ }
28
+ };
29
+ return DataFetcher.get().callServiceBroker('ActionButtonsSP.getActions', param).then((result) => {
30
+ var _a;
31
+ if (!((_a = result.actions) === null || _a === void 0 ? void 0 : _a.action))
32
+ return;
33
+ if (this._isOrderActions) {
34
+ this._actions = ArrayUtils.sortAlphabetically(result.actions.action, 'description');
35
+ }
36
+ else {
37
+ this._actions = result.actions.action;
38
+ }
39
+ });
40
+ }
41
+ controlDropdown() {
42
+ this._showDropdown = !this._showDropdown;
43
+ }
44
+ canShowDropdown() {
45
+ var _a;
46
+ return this._showDropdown && ((_a = this._items) === null || _a === void 0 ? void 0 : _a.length) > 0;
47
+ }
48
+ positionDropdown() {
49
+ var _a;
50
+ const bounding = (_a = this._ezButton) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
51
+ if (!bounding || !this._dropdownParent)
52
+ return;
53
+ this._dropdownParent.style.top = (bounding.y + bounding.height + 5) + "px";
54
+ this._dropdownParent.style.left = bounding.x + "px";
55
+ }
56
+ closeDropdown(evt) {
57
+ const target = evt === null || evt === void 0 ? void 0 : evt.target;
58
+ if (!target)
59
+ return;
60
+ if (!target.closest(".snk-actions-button")) {
61
+ this._showDropdown = false;
62
+ }
63
+ }
64
+ setEvents() {
65
+ document.removeEventListener("click", this.closeDropdown.bind(this));
66
+ document.addEventListener("click", this.closeDropdown.bind(this));
67
+ document.removeEventListener("scroll", this.positionDropdown.bind(this));
68
+ document.addEventListener("scroll", this.positionDropdown.bind(this));
69
+ }
70
+ async componentWillLoad() {
71
+ var _a;
72
+ this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
73
+ this._resourceID = await this._application.getResourceID();
74
+ this._isOrderActions = await this._application.getBooleanParam('global.ordenar.acoes.personalizadas');
75
+ this._dataUnit = (_a = this._element.parentElement) === null || _a === void 0 ? void 0 : _a.dataUnit;
76
+ this._entityName = this._dataUnit.name.split('/')[2];
77
+ this.setEvents();
78
+ this.getActions().then(() => {
79
+ this.loadItems();
80
+ });
81
+ }
82
+ async componentDidLoad() {
83
+ if (!this._element)
84
+ return;
85
+ ElementIDUtils.addIDInfo(this._element);
86
+ this.positionDropdown();
87
+ if (!(await this._application.hasClientEvent(this.CLIENT_EVENT_CONFIRM_NAME))) {
88
+ const clientEventConfirm = new ClientEventConfirm();
89
+ this._application.addClientEvent(this.CLIENT_EVENT_CONFIRM_NAME, clientEventConfirm.clientConfirm);
90
+ }
91
+ }
92
+ componentDidUpdate() {
93
+ this.positionDropdown();
94
+ }
95
+ loadItems() {
96
+ if (!this._actions || this._actions.length == 0)
97
+ return;
98
+ this._actions.forEach(action => {
99
+ this._items.push({ id: action.actionID, label: action.description });
100
+ });
101
+ }
102
+ getElementID(sufix) {
103
+ return {
104
+ [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: ElementIDUtils.getInternalIDInfo(sufix)
105
+ };
106
+ }
107
+ render() {
108
+ return (h(Host, null, (this._actions && this._actions.length > 0) &&
109
+ (h("div", { class: `ez-padding-left--medium snk-actions-button
110
+ ${this.canShowDropdown() ? " snk-actions-button--overlap" : ""}
111
+ ` }, h("ez-button", Object.assign({ ref: (ref) => this._ezButton = ref, iconName: "acao", size: "small", mode: "icon", title: this._application.messagesBuilder.getMessage("snkActionsButton.title.actions", undefined), onClick: () => this.controlDropdown() }, this.getElementID("button"))), h("div", Object.assign({ ref: (ref) => this._dropdownParent = ref, class: `${this.canShowDropdown() ?
112
+ "snk-actions-button__dropdown--show" :
113
+ "snk-actions-button__dropdown"}
114
+ ` }, this.getElementID("dropdown")), (this.canShowDropdown()) &&
115
+ (h("ez-dropdown", Object.assign({ items: this._items, onEzClick: (evt) => this.handleClick(evt) }, this.getElementID("dropdown"))))))), (this.canShowDropdown()) &&
116
+ (h("div", Object.assign({ class: "ez-scrim ez-scrim--light" }, this.getElementID("ezScrim"))))));
117
+ }
118
+ static get is() { return "snk-actions-button"; }
119
+ static get encapsulation() { return "scoped"; }
120
+ static get originalStyleUrls() {
121
+ return {
122
+ "$": ["snk-actions-button.css"]
123
+ };
124
+ }
125
+ static get styleUrls() {
126
+ return {
127
+ "$": ["snk-actions-button.css"]
128
+ };
129
+ }
130
+ static get states() {
131
+ return {
132
+ "_items": {},
133
+ "_showDropdown": {},
134
+ "_actions": {},
135
+ "_isOrderActions": {}
136
+ };
137
+ }
138
+ static get elementRef() { return "_element"; }
139
+ }