@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.
- package/dist/cjs/ParamType-90b440a0.js +13 -0
- package/dist/cjs/{SnkMessageBuilder-cf80308c.js → SnkMessageBuilder-3b5b5614.js} +30 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button.cjs.entry.js +704 -0
- package/dist/cjs/snk-actions-form.cjs.entry.js +200 -0
- package/dist/cjs/snk-application.cjs.entry.js +1 -1
- package/dist/cjs/snk-attach.cjs.entry.js +1 -1
- package/dist/cjs/snk-client-confirm.cjs.entry.js +52 -0
- package/dist/cjs/snk-configurator.cjs.entry.js +1 -1
- package/dist/cjs/snk-crud.cjs.entry.js +1 -1
- package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
- package/dist/cjs/{snk-data-unit-bd271acd.js → snk-data-unit-e9c20097.js} +1 -1
- package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
- package/dist/cjs/snk-detail-view.cjs.entry.js +4 -4
- package/dist/cjs/snk-grid.cjs.entry.js +4 -4
- package/dist/cjs/{snk-guides-viewer-0ab3746e.js → snk-guides-viewer-c8843478.js} +2 -2
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +3 -3
- package/dist/cjs/snk-simple-bar_2.cjs.entry.js +2 -2
- package/dist/cjs/snk-taskbar.cjs.entry.js +1 -1
- package/dist/cjs/{taskbar-elements-bc2598f9.js → taskbar-elements-3be287d6.js} +3 -0
- package/dist/cjs/{taskbar-processor-e1e3bbf7.js → taskbar-processor-02f0fc84.js} +1 -1
- package/dist/collection/collection-manifest.json +3 -0
- package/dist/collection/components/snk-actions-button/actions/enum/ActionsType.js +8 -0
- package/dist/collection/components/snk-actions-button/actions/enum/ParamType.js +11 -0
- package/dist/collection/components/snk-actions-button/actions/enum/RefreshType.js +7 -0
- package/dist/collection/components/snk-actions-button/actions/executor/java.executor.js +22 -0
- package/dist/collection/components/snk-actions-button/actions/executor/javascript.executor.js +20 -0
- package/dist/collection/components/snk-actions-button/actions/executor/launch-screen.executor.js +42 -0
- package/dist/collection/components/snk-actions-button/actions/executor/procedure.executor.js +26 -0
- package/dist/collection/components/snk-actions-button/actions/factory/executor.factory.js +26 -0
- package/dist/collection/components/snk-actions-button/actions/index.js +343 -0
- package/dist/collection/components/snk-actions-button/actions/interfaces/IAction.js +7 -0
- package/dist/collection/components/snk-actions-button/actions/interfaces/IExecSource.js +1 -0
- package/dist/collection/components/snk-actions-button/actions/interfaces/IExecuteActions.js +1 -0
- package/dist/collection/components/snk-actions-button/actions/interfaces/IExecuteActionsProps.js +1 -0
- package/dist/collection/components/snk-actions-button/actions/interfaces/IResultParam.js +1 -0
- package/dist/collection/components/snk-actions-button/clientEvent/index.js +87 -0
- package/dist/collection/components/snk-actions-button/clientEvent/interfaces/IClientEventConfirm.js +1 -0
- package/dist/collection/components/snk-actions-button/snk-actions-button.css +38 -0
- package/dist/collection/components/snk-actions-button/snk-actions-button.js +139 -0
- package/dist/collection/components/snk-actions-button/subcomponents/snk-actions-form.js +263 -0
- package/dist/collection/components/snk-actions-button/subcomponents/snk-client-confirm.js +134 -0
- package/dist/collection/components/snk-configurator/snk-configurator.css +1 -1
- package/dist/collection/components/snk-grid/snk-grid.js +2 -2
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +3 -0
- package/dist/collection/lib/message/SnkMessageBuilder.js +3 -1
- package/dist/collection/lib/message/resources/snk-actions-button.msg.js +27 -0
- package/dist/components/ParamType.js +13 -0
- package/dist/components/SnkMessageBuilder.js +30 -1
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.js +3 -0
- package/dist/components/snk-actions-button.d.ts +11 -0
- package/dist/components/snk-actions-button.js +6 -0
- package/dist/components/snk-actions-button2.js +718 -0
- package/dist/components/snk-actions-form.d.ts +11 -0
- package/dist/components/snk-actions-form.js +218 -0
- package/dist/components/snk-attach2.js +7 -1
- package/dist/components/snk-client-confirm.d.ts +11 -0
- package/dist/components/snk-client-confirm.js +71 -0
- package/dist/components/snk-configurator2.js +1 -1
- package/dist/components/snk-crud.js +7 -1
- package/dist/components/snk-detail-view2.js +13 -2
- package/dist/components/snk-grid2.js +9 -3
- package/dist/components/snk-simple-crud2.js +7 -1
- package/dist/components/snk-taskbar2.js +10 -1
- package/dist/esm/ParamType-d5152b06.js +13 -0
- package/dist/esm/{SnkMessageBuilder-1a169545.js → SnkMessageBuilder-188a38bb.js} +30 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button.entry.js +700 -0
- package/dist/esm/snk-actions-form.entry.js +196 -0
- package/dist/esm/snk-application.entry.js +1 -1
- package/dist/esm/snk-attach.entry.js +1 -1
- package/dist/esm/snk-client-confirm.entry.js +48 -0
- package/dist/esm/snk-configurator.entry.js +1 -1
- package/dist/esm/snk-crud.entry.js +1 -1
- package/dist/esm/snk-data-exporter.entry.js +2 -2
- package/dist/esm/{snk-data-unit-476024e9.js → snk-data-unit-79b1583a.js} +1 -1
- package/dist/esm/snk-data-unit.entry.js +2 -2
- package/dist/esm/snk-detail-view.entry.js +4 -4
- package/dist/esm/snk-grid.entry.js +4 -4
- package/dist/esm/{snk-guides-viewer-767f5a74.js → snk-guides-viewer-59d3a78c.js} +2 -2
- package/dist/esm/snk-guides-viewer.entry.js +3 -3
- package/dist/esm/snk-simple-bar_2.entry.js +2 -2
- package/dist/esm/snk-taskbar.entry.js +1 -1
- package/dist/esm/{taskbar-elements-e6af3e93.js → taskbar-elements-8ff33c26.js} +3 -0
- package/dist/esm/{taskbar-processor-a40798b8.js → taskbar-processor-20de6616.js} +1 -1
- package/dist/sankhyablocks/{p-3e17b147.js → p-0b40c655.js} +1 -1
- package/dist/sankhyablocks/{p-de9caf1e.entry.js → p-0b6ddb67.entry.js} +1 -1
- package/dist/sankhyablocks/p-19692f92.js +1 -0
- package/dist/sankhyablocks/{p-6df8c88b.entry.js → p-257c71a7.entry.js} +1 -1
- package/dist/sankhyablocks/{p-551165d8.js → p-28c12f65.js} +1 -1
- package/dist/sankhyablocks/{p-78de64fb.entry.js → p-2d0fc912.entry.js} +1 -1
- package/dist/sankhyablocks/p-384c4a6b.js +1 -0
- package/dist/sankhyablocks/{p-f43629f3.entry.js → p-44c2ed16.entry.js} +1 -1
- package/dist/sankhyablocks/{p-4f05a335.entry.js → p-44cf545f.entry.js} +1 -1
- package/dist/sankhyablocks/{p-ec1c64be.entry.js → p-8ce9ea9f.entry.js} +1 -1
- package/dist/sankhyablocks/{p-e0c04667.entry.js → p-9c7f7214.entry.js} +1 -1
- package/dist/sankhyablocks/p-9f66bc54.entry.js +1 -0
- package/dist/sankhyablocks/{p-c74fca58.js → p-b34d23fa.js} +1 -1
- package/dist/sankhyablocks/p-b680fa7a.entry.js +1 -0
- package/dist/sankhyablocks/p-b75ce8b8.entry.js +1 -0
- package/dist/sankhyablocks/{p-9e92ed74.entry.js → p-cbe93a18.entry.js} +2 -2
- package/dist/sankhyablocks/p-eaad0aa8.js +1 -0
- package/dist/sankhyablocks/{p-7956b9dd.entry.js → p-eb07d0eb.entry.js} +1 -1
- package/dist/sankhyablocks/p-f27dc5e9.entry.js +1 -0
- package/dist/sankhyablocks/p-fa2d0376.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-actions-button/actions/enum/ActionsType.d.ts +7 -0
- package/dist/types/components/snk-actions-button/actions/enum/ParamType.d.ts +10 -0
- package/dist/types/components/snk-actions-button/actions/enum/RefreshType.d.ts +6 -0
- package/dist/types/components/snk-actions-button/actions/executor/java.executor.d.ts +6 -0
- package/dist/types/components/snk-actions-button/actions/executor/javascript.executor.d.ts +6 -0
- package/dist/types/components/snk-actions-button/actions/executor/launch-screen.executor.d.ts +10 -0
- package/dist/types/components/snk-actions-button/actions/executor/procedure.executor.d.ts +6 -0
- package/dist/types/components/snk-actions-button/actions/factory/executor.factory.d.ts +7 -0
- package/dist/types/components/snk-actions-button/actions/index.d.ts +27 -0
- package/dist/types/components/snk-actions-button/actions/interfaces/IAction.d.ts +55 -0
- package/dist/types/components/snk-actions-button/actions/interfaces/IExecSource.d.ts +17 -0
- package/dist/types/components/snk-actions-button/actions/interfaces/IExecuteActions.d.ts +4 -0
- package/dist/types/components/snk-actions-button/actions/interfaces/IExecuteActionsProps.d.ts +4 -0
- package/dist/types/components/snk-actions-button/actions/interfaces/IResultParam.d.ts +14 -0
- package/dist/types/components/snk-actions-button/clientEvent/index.d.ts +4 -0
- package/dist/types/components/snk-actions-button/clientEvent/interfaces/IClientEventConfirm.d.ts +35 -0
- package/dist/types/components/snk-actions-button/snk-actions-button.d.ts +27 -0
- package/dist/types/components/snk-actions-button/subcomponents/snk-actions-form.d.ts +41 -0
- package/dist/types/components/snk-actions-button/subcomponents/snk-client-confirm.d.ts +31 -0
- package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +2 -1
- package/dist/types/components.d.ts +96 -0
- package/dist/types/lib/message/resources/snk-actions-button.msg.d.ts +1 -0
- package/package.json +1 -1
- package/react/components.d.ts +3 -0
- package/react/components.js +3 -0
- package/react/components.js.map +1 -1
- package/dist/sankhyablocks/p-1c5d5e5c.entry.js +0 -1
- package/dist/sankhyablocks/p-39082fc3.js +0 -1
- package/dist/sankhyablocks/p-8d40909d.entry.js +0 -1
- package/dist/sankhyablocks/p-d410f45a.js +0 -1
@@ -0,0 +1,704 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
+
|
5
|
+
const index = require('./index-21bd01e1.js');
|
6
|
+
const core = require('@sankhyalabs/core');
|
7
|
+
const DataFetcher = require('./DataFetcher-a9d0228f.js');
|
8
|
+
const ParamType = require('./ParamType-90b440a0.js');
|
9
|
+
require('./pesquisa-fetcher-954b74c3.js');
|
10
|
+
require('./index-f400b1d6.js');
|
11
|
+
require('./_commonjsHelpers-537d719a.js');
|
12
|
+
|
13
|
+
const SERVICE_ACTION_EXECUTE_JAVA = 'ActionButtonsSP.executeJava';
|
14
|
+
class JavaExecutor {
|
15
|
+
execute(action) {
|
16
|
+
var _a;
|
17
|
+
const execSource = {
|
18
|
+
actionID: action.actionID,
|
19
|
+
refreshType: (_a = action.actionConfig.javaCall) === null || _a === void 0 ? void 0 : _a.refreshType
|
20
|
+
};
|
21
|
+
return new Promise((resolve) => {
|
22
|
+
resolve({ execSource, callback: this.callExecJava });
|
23
|
+
});
|
24
|
+
}
|
25
|
+
callExecJava(execSource) {
|
26
|
+
const request = {
|
27
|
+
requestBody: {
|
28
|
+
javaCall: execSource
|
29
|
+
}
|
30
|
+
};
|
31
|
+
DataFetcher.DataFetcher.get().callServiceBroker(SERVICE_ACTION_EXECUTE_JAVA, JSON.stringify(request));
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
const SERVICE_ACTION_EXECUTE_SCRIPT = 'ActionButtonsSP.executeScript';
|
36
|
+
class JavascriptExecutor {
|
37
|
+
execute(action) {
|
38
|
+
var _a;
|
39
|
+
const execSource = {
|
40
|
+
actionID: action.actionID,
|
41
|
+
refreshType: (_a = action.actionConfig.runScript) === null || _a === void 0 ? void 0 : _a.refreshType
|
42
|
+
};
|
43
|
+
return new Promise((resolve) => {
|
44
|
+
resolve({ execSource, callback: this.callExecScript });
|
45
|
+
});
|
46
|
+
}
|
47
|
+
callExecScript(execSource) {
|
48
|
+
const request = {
|
49
|
+
runScript: execSource
|
50
|
+
};
|
51
|
+
DataFetcher.DataFetcher.get().callServiceBroker(SERVICE_ACTION_EXECUTE_SCRIPT, request);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
class LaunchScreenExecutor {
|
56
|
+
constructor() {
|
57
|
+
this._application = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
58
|
+
}
|
59
|
+
async execute(action, dataUnit) {
|
60
|
+
const resourceID = action.resourceID;
|
61
|
+
if (!resourceID)
|
62
|
+
return;
|
63
|
+
let launchObject = await this.buildLaunchObject(action, dataUnit);
|
64
|
+
this._application.openApp(resourceID, launchObject);
|
65
|
+
return null;
|
66
|
+
}
|
67
|
+
buildLaunchObject(action, dataUnit) {
|
68
|
+
return new Promise((resolve) => {
|
69
|
+
let params = action.actionConfig.params.param;
|
70
|
+
if (params && params.length > 0) {
|
71
|
+
let launchObject = {};
|
72
|
+
let processedParams = [];
|
73
|
+
params.forEach(param => {
|
74
|
+
const localField = param.localField;
|
75
|
+
let value = dataUnit.getFieldValue(localField);
|
76
|
+
if (!value) {
|
77
|
+
let localFieldLabel = dataUnit.getField(localField).label;
|
78
|
+
localFieldLabel = core.StringUtils.isEmpty(dataUnit.getField(localField).label) ? localField : localFieldLabel;
|
79
|
+
throw new core.ErrorException(this._application.messagesBuilder.getMessage("snkActionsButton.title.error", undefined), this._application.messagesBuilder.getMessage("snkActionsButton.launchScreen.emptyField", { description: action.description, localFieldLabel: localFieldLabel }));
|
80
|
+
}
|
81
|
+
value = core.StringUtils.isEmpty(value.toString()) ? undefined : value.toString();
|
82
|
+
launchObject[param.targetField] = value;
|
83
|
+
processedParams.push({
|
84
|
+
fieldName: param.targetField,
|
85
|
+
value: value
|
86
|
+
});
|
87
|
+
});
|
88
|
+
launchObject.ACTION_PARAMETERS = processedParams;
|
89
|
+
launchObject.call_time = Date.now();
|
90
|
+
resolve(launchObject);
|
91
|
+
}
|
92
|
+
resolve(null);
|
93
|
+
});
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
const SERVICE_ACTION_EXECUTE_STP = 'ActionButtonsSP.executeSTP';
|
98
|
+
class ProcedureExecutor {
|
99
|
+
execute(action) {
|
100
|
+
var _a, _b, _c;
|
101
|
+
const procName = (_a = action.actionConfig.dbCall) === null || _a === void 0 ? void 0 : _a.name;
|
102
|
+
const rootEntity = (_b = action.actionConfig.dbCall) === null || _b === void 0 ? void 0 : _b.rootEntity;
|
103
|
+
const execSource = {
|
104
|
+
actionID: action.actionID,
|
105
|
+
refreshType: (_c = action.actionConfig.dbCall) === null || _c === void 0 ? void 0 : _c.refreshType,
|
106
|
+
procName: procName,
|
107
|
+
rootEntity: rootEntity
|
108
|
+
};
|
109
|
+
return new Promise((resolve) => {
|
110
|
+
resolve({ execSource, callback: this.callExecProcedure });
|
111
|
+
});
|
112
|
+
}
|
113
|
+
callExecProcedure(execSource) {
|
114
|
+
const request = {
|
115
|
+
requestBody: {
|
116
|
+
stpCall: execSource
|
117
|
+
}
|
118
|
+
};
|
119
|
+
DataFetcher.DataFetcher.get().callServiceBroker(SERVICE_ACTION_EXECUTE_STP, JSON.stringify(request));
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
var ActionsType;
|
124
|
+
(function (ActionsType) {
|
125
|
+
ActionsType["LAUNCH_SCREEN"] = "LC";
|
126
|
+
ActionsType["JAVASCRIPT"] = "SC";
|
127
|
+
ActionsType["JAVA"] = "RJ";
|
128
|
+
ActionsType["PROCEDURE"] = "SP";
|
129
|
+
ActionsType["EMBEDDED"] = "EB";
|
130
|
+
})(ActionsType || (ActionsType = {}));
|
131
|
+
|
132
|
+
class ExecutorFactory {
|
133
|
+
constructor(actionType) {
|
134
|
+
this.actionType = actionType;
|
135
|
+
this._application = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
136
|
+
}
|
137
|
+
get executor() {
|
138
|
+
switch (this.actionType) {
|
139
|
+
case ActionsType.LAUNCH_SCREEN:
|
140
|
+
return new LaunchScreenExecutor();
|
141
|
+
case ActionsType.JAVASCRIPT:
|
142
|
+
return new JavascriptExecutor();
|
143
|
+
case ActionsType.JAVA:
|
144
|
+
return new JavaExecutor();
|
145
|
+
case ActionsType.PROCEDURE:
|
146
|
+
return new ProcedureExecutor();
|
147
|
+
default:
|
148
|
+
throw new core.ErrorException(this._application.messagesBuilder.getMessage("snkActionsButton.title.error", undefined), this._application.messagesBuilder.getMessage("snkActionsButton.action.nonExistentType", { actionType: this.actionType }));
|
149
|
+
}
|
150
|
+
}
|
151
|
+
}
|
152
|
+
|
153
|
+
var RefreshType;
|
154
|
+
(function (RefreshType) {
|
155
|
+
RefreshType["NONE"] = "NONE";
|
156
|
+
RefreshType["PARENT"] = "PARENT";
|
157
|
+
RefreshType["MASTER"] = "MASTER";
|
158
|
+
RefreshType["ALL"] = "ALL";
|
159
|
+
})(RefreshType || (RefreshType = {}));
|
160
|
+
|
161
|
+
const MASTER_ROW_PROPERTY = "__MASTER_ROW__";
|
162
|
+
const ENTITY_NAME_PROPERTY = '__ENTITY_NAME__';
|
163
|
+
const NUFIN_COLUMN = 'NUFIN';
|
164
|
+
const SERVICE_GET_CONFIGURATIONS = 'SystemUtilsSP.getConf';
|
165
|
+
class Actions {
|
166
|
+
constructor(actionsExecuteInterface, dataUnit) {
|
167
|
+
var _a;
|
168
|
+
this._lastValuesCache = {};
|
169
|
+
this._actionsExecuteInterface = actionsExecuteInterface;
|
170
|
+
this._dataUnit = dataUnit;
|
171
|
+
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;
|
172
|
+
this._application = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
173
|
+
}
|
174
|
+
apply(action, hasParamsToSave) {
|
175
|
+
this._application.closePopUp();
|
176
|
+
this._actionsExecuteInterface.execute(action, this._dataUnit)
|
177
|
+
.then(({ execSource, callback }) => {
|
178
|
+
this.resolvePromptParams(action, execSource, hasParamsToSave)
|
179
|
+
.then(() => {
|
180
|
+
this.actionExecute(execSource, callback);
|
181
|
+
});
|
182
|
+
});
|
183
|
+
}
|
184
|
+
;
|
185
|
+
async execute(action) {
|
186
|
+
var _a;
|
187
|
+
if (!action.actionConfig) {
|
188
|
+
throw new core.WarningException(this._application.messagesBuilder.getMessage("snkActionsButton.title.warning", undefined), this._application.messagesBuilder.getMessage("snkActionsButton.action.incorrectAction", { description: action.description }));
|
189
|
+
}
|
190
|
+
if (!!((_a = action.actionConfig.params) === null || _a === void 0 ? void 0 : _a.promptParam)) {
|
191
|
+
const paramsSource = action.actionConfig.params.promptParam;
|
192
|
+
let hasParamsToSave = false;
|
193
|
+
for (let i = 0; i < paramsSource.length; i++) {
|
194
|
+
let paramSource = paramsSource[i];
|
195
|
+
if (!hasParamsToSave && paramSource.saveLast === 'true') {
|
196
|
+
hasParamsToSave = true;
|
197
|
+
break;
|
198
|
+
}
|
199
|
+
}
|
200
|
+
if (hasParamsToSave) {
|
201
|
+
action.actionConfig.params.promptParam = await this.loadSavedValuesIntoParams(action);
|
202
|
+
}
|
203
|
+
const form = document.createElement("snk-actions-form");
|
204
|
+
window.document.body.appendChild(form);
|
205
|
+
form.action = core.ObjectUtils.copy(action);
|
206
|
+
form.applyParameters = (resultAction) => {
|
207
|
+
this.apply(resultAction, hasParamsToSave);
|
208
|
+
};
|
209
|
+
form.openPopup();
|
210
|
+
}
|
211
|
+
else if (action.type != ActionsType.LAUNCH_SCREEN) {
|
212
|
+
this._actionsExecuteInterface.execute(action, this._dataUnit)
|
213
|
+
.then(({ execSource, callback }) => {
|
214
|
+
this.actionExecute(execSource, callback);
|
215
|
+
});
|
216
|
+
}
|
217
|
+
else {
|
218
|
+
this._actionsExecuteInterface.execute(action, this._dataUnit);
|
219
|
+
}
|
220
|
+
}
|
221
|
+
loadSavedValuesIntoParams(action) {
|
222
|
+
return this.loadLastValues(action)
|
223
|
+
.then((lastParams) => {
|
224
|
+
let resultParams = action.actionConfig.params.promptParam;
|
225
|
+
if (lastParams) {
|
226
|
+
lastParams.param.forEach(lastParam => {
|
227
|
+
resultParams = resultParams.map((param) => {
|
228
|
+
if (param.name !== lastParam.paramName)
|
229
|
+
return param;
|
230
|
+
if (param.paramType === 'B') {
|
231
|
+
return Object.assign(Object.assign({}, param), { value: lastParam.$ === 'S' });
|
232
|
+
}
|
233
|
+
return Object.assign(Object.assign({}, param), { value: lastParam.$ });
|
234
|
+
});
|
235
|
+
});
|
236
|
+
}
|
237
|
+
return resultParams;
|
238
|
+
});
|
239
|
+
}
|
240
|
+
actionExecute(execSource, callback) {
|
241
|
+
execSource.virtualPage = this.buildVirtualPage();
|
242
|
+
this.prepareAndExecute(execSource, callback);
|
243
|
+
this.recordsReloader(execSource.refreshType);
|
244
|
+
}
|
245
|
+
resolvePromptParams(action, execSource, hasParamsToSave) {
|
246
|
+
return new Promise(resolve => {
|
247
|
+
const paramsSource = action.actionConfig.params.promptParam;
|
248
|
+
let params = [];
|
249
|
+
paramsSource.forEach(paramSource => {
|
250
|
+
params.push(this.buildPromptParam(paramSource));
|
251
|
+
});
|
252
|
+
this.putParamsOnExecSource(params, execSource);
|
253
|
+
if (hasParamsToSave) {
|
254
|
+
this.saveLastValues(action, params);
|
255
|
+
}
|
256
|
+
resolve();
|
257
|
+
});
|
258
|
+
}
|
259
|
+
buildPromptParam(param) {
|
260
|
+
let type = param.paramType;
|
261
|
+
let isCheckbox = false;
|
262
|
+
let fieldProps;
|
263
|
+
let entityPK;
|
264
|
+
let value = param.value;
|
265
|
+
switch (type) {
|
266
|
+
case ParamType.ParamType.DATE:
|
267
|
+
type = 'D';
|
268
|
+
break;
|
269
|
+
case ParamType.ParamType.DATETIME:
|
270
|
+
type = 'H';
|
271
|
+
break;
|
272
|
+
case ParamType.ParamType.DECIMAL:
|
273
|
+
type = 'F';
|
274
|
+
fieldProps = {
|
275
|
+
'sk-precision': Number(param.precision)
|
276
|
+
};
|
277
|
+
break;
|
278
|
+
case ParamType.ParamType.BOOLEAN:
|
279
|
+
type = 'S';
|
280
|
+
isCheckbox = true;
|
281
|
+
value = param.value ? 'S' : 'N';
|
282
|
+
break;
|
283
|
+
case ParamType.ParamType.ENTITY:
|
284
|
+
fieldProps = {
|
285
|
+
'sk-entity-name': param.entityName,
|
286
|
+
'sk-allow-show-hierarchical-mode': param.hierarchyEntity,
|
287
|
+
'sk-data-type': 'S'
|
288
|
+
};
|
289
|
+
if (param.hierarchyEntity && param.entityPK) {
|
290
|
+
entityPK = param.entityPK;
|
291
|
+
}
|
292
|
+
value = param.value ? Number(param.value) : null;
|
293
|
+
break;
|
294
|
+
case ParamType.ParamType.OPTIONS:
|
295
|
+
type = 'O';
|
296
|
+
let options = param.options.split(';').map(function (opc, index) {
|
297
|
+
let data;
|
298
|
+
let value;
|
299
|
+
if (opc.indexOf('=') > -1) {
|
300
|
+
let opcArr = opc.split('=');
|
301
|
+
data = opcArr[0];
|
302
|
+
value = opcArr[1];
|
303
|
+
}
|
304
|
+
else {
|
305
|
+
data = (index + 1);
|
306
|
+
value = opc;
|
307
|
+
}
|
308
|
+
return {
|
309
|
+
data: data,
|
310
|
+
value: value
|
311
|
+
};
|
312
|
+
});
|
313
|
+
fieldProps = {
|
314
|
+
'sk-options': options
|
315
|
+
};
|
316
|
+
break;
|
317
|
+
}
|
318
|
+
return {
|
319
|
+
description: param.label,
|
320
|
+
required: param.required == 'true',
|
321
|
+
fieldName: param.name,
|
322
|
+
fieldNameOri: param.name,
|
323
|
+
entityPK: entityPK,
|
324
|
+
paramType: param.paramType,
|
325
|
+
type: type,
|
326
|
+
isCheckbox: isCheckbox,
|
327
|
+
saveLast: param.saveLast,
|
328
|
+
fieldProp: fieldProps,
|
329
|
+
value: value,
|
330
|
+
isGeneratedName: param.isGeneratedName
|
331
|
+
};
|
332
|
+
}
|
333
|
+
putParamsOnExecSource(params, execSource) {
|
334
|
+
execSource.params = {
|
335
|
+
param: []
|
336
|
+
};
|
337
|
+
params.forEach(param => {
|
338
|
+
if (param.isGeneratedName && param.value) {
|
339
|
+
throw new core.ErrorException(this._application.messagesBuilder.getMessage("snkActionsButton.title.error", undefined), this._application.messagesBuilder.getMessage("snkActionsButton.action.emptyParamName", undefined));
|
340
|
+
}
|
341
|
+
if (!core.StringUtils.isEmpty(param.value)) {
|
342
|
+
execSource.params.param.push({
|
343
|
+
type: this.getParamDataType(param.paramType),
|
344
|
+
paramName: param.fieldName,
|
345
|
+
$: this.getParamValue(param)
|
346
|
+
});
|
347
|
+
}
|
348
|
+
});
|
349
|
+
}
|
350
|
+
getParamDataType(type) {
|
351
|
+
let dataType;
|
352
|
+
switch (type) {
|
353
|
+
case "D":
|
354
|
+
dataType = "F";
|
355
|
+
break;
|
356
|
+
case "DT":
|
357
|
+
case "DH":
|
358
|
+
dataType = "D";
|
359
|
+
break;
|
360
|
+
case "B":
|
361
|
+
case "ENTITY":
|
362
|
+
case "SO":
|
363
|
+
dataType = "S";
|
364
|
+
break;
|
365
|
+
default:
|
366
|
+
dataType = type;
|
367
|
+
}
|
368
|
+
return dataType;
|
369
|
+
}
|
370
|
+
getParamValue(param) {
|
371
|
+
let value = param.value;
|
372
|
+
if (!value) {
|
373
|
+
return value;
|
374
|
+
}
|
375
|
+
if (param.paramType == 'DT') {
|
376
|
+
value = core.DateUtils.formatDate(value);
|
377
|
+
}
|
378
|
+
else if (param.paramType == 'DH') {
|
379
|
+
value = core.DateUtils.formatDateTime(value);
|
380
|
+
}
|
381
|
+
return value;
|
382
|
+
}
|
383
|
+
async loadLastValues(action) {
|
384
|
+
const resourceId = await this.buildResourceId(action.actionID);
|
385
|
+
return new Promise((resolve, reject) => {
|
386
|
+
if (this._lastValuesCache[resourceId]) {
|
387
|
+
resolve(this._lastValuesCache[resourceId]);
|
388
|
+
}
|
389
|
+
else {
|
390
|
+
const config = {
|
391
|
+
config: {
|
392
|
+
chave: resourceId,
|
393
|
+
tipo: 'T'
|
394
|
+
}
|
395
|
+
};
|
396
|
+
DataFetcher.DataFetcher.get().callServiceBroker(SERVICE_GET_CONFIGURATIONS, config)
|
397
|
+
.then((result) => {
|
398
|
+
var _a, _b;
|
399
|
+
let lastParams;
|
400
|
+
if ((_b = (_a = result.config) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.params) {
|
401
|
+
lastParams = result.config.data.params;
|
402
|
+
if (!Array.isArray(lastParams.param)) {
|
403
|
+
lastParams.param = [lastParams.param];
|
404
|
+
}
|
405
|
+
}
|
406
|
+
this._lastValuesCache[resourceId] = lastParams;
|
407
|
+
resolve(lastParams);
|
408
|
+
}).catch((error) => {
|
409
|
+
reject(error);
|
410
|
+
});
|
411
|
+
}
|
412
|
+
});
|
413
|
+
}
|
414
|
+
async saveLastValues(action, params) {
|
415
|
+
if (this._application) {
|
416
|
+
let config = {
|
417
|
+
params: {
|
418
|
+
param: []
|
419
|
+
}
|
420
|
+
};
|
421
|
+
params.forEach(param => {
|
422
|
+
if (param.saveLast == 'true') {
|
423
|
+
config.params.param.push({
|
424
|
+
paramName: param.fieldName,
|
425
|
+
$: param.value
|
426
|
+
});
|
427
|
+
}
|
428
|
+
});
|
429
|
+
const resourceId = await this.buildResourceId(action.actionID);
|
430
|
+
this._lastValuesCache[resourceId] = config.params;
|
431
|
+
this._application.saveConfig(resourceId, config);
|
432
|
+
}
|
433
|
+
}
|
434
|
+
async buildResourceId(actionId) {
|
435
|
+
let appResId = '';
|
436
|
+
appResId = await this._application.getResourceID();
|
437
|
+
return appResId + '.actionconfig.' + actionId;
|
438
|
+
}
|
439
|
+
prepareAndExecute(execSource, executeAction) {
|
440
|
+
this.addRows(execSource);
|
441
|
+
executeAction(execSource);
|
442
|
+
}
|
443
|
+
addRows(execSource) {
|
444
|
+
const rows = {
|
445
|
+
row: []
|
446
|
+
};
|
447
|
+
const sourceRows = this._selectedRows;
|
448
|
+
for (const i in sourceRows) {
|
449
|
+
const sourceRow = sourceRows[i];
|
450
|
+
const row = {};
|
451
|
+
if (sourceRow.hasOwnProperty(MASTER_ROW_PROPERTY)) {
|
452
|
+
row.master = 'S';
|
453
|
+
row.entityName = sourceRow.__ENTITY_NAME__;
|
454
|
+
delete sourceRow[MASTER_ROW_PROPERTY];
|
455
|
+
delete sourceRow[ENTITY_NAME_PROPERTY];
|
456
|
+
}
|
457
|
+
for (const fieldName in sourceRow) {
|
458
|
+
if (fieldName !== NUFIN_COLUMN)
|
459
|
+
continue;
|
460
|
+
if (!row.field) {
|
461
|
+
row.field = [];
|
462
|
+
}
|
463
|
+
row.field.push({
|
464
|
+
fieldName: fieldName,
|
465
|
+
$: sourceRow[fieldName]
|
466
|
+
});
|
467
|
+
}
|
468
|
+
rows.row.push(row);
|
469
|
+
}
|
470
|
+
if (rows.row.length > 0) {
|
471
|
+
execSource.rows = rows;
|
472
|
+
}
|
473
|
+
}
|
474
|
+
recordsReloader(refreshType) {
|
475
|
+
switch (refreshType) {
|
476
|
+
case RefreshType.NONE:
|
477
|
+
break;
|
478
|
+
case RefreshType.PARENT:
|
479
|
+
case RefreshType.MASTER:
|
480
|
+
case RefreshType.ALL:
|
481
|
+
this._dataUnit.loadData();
|
482
|
+
break;
|
483
|
+
default:
|
484
|
+
this._dataUnit.reloadCurrentRecord();
|
485
|
+
}
|
486
|
+
}
|
487
|
+
;
|
488
|
+
buildVirtualPage() {
|
489
|
+
var _a, _b, _c, _d;
|
490
|
+
if ((_b = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.getSelectionInfo()) === null || _b === void 0 ? void 0 : _b.isAllRecords()) {
|
491
|
+
const virtualPage = {
|
492
|
+
filters: { filters: (_c = this._dataUnit) === null || _c === void 0 ? void 0 : _c.getAppliedFilters() },
|
493
|
+
orders: { orders: (_d = this._dataUnit) === null || _d === void 0 ? void 0 : _d.getSort() },
|
494
|
+
};
|
495
|
+
return virtualPage;
|
496
|
+
}
|
497
|
+
}
|
498
|
+
}
|
499
|
+
|
500
|
+
const CONFIRMACAO = "__CONFIRMACAO__";
|
501
|
+
const ESCOLHA_SIM_NAO = "__ESCOLHA_SIMNAO__";
|
502
|
+
class ClientEventConfirm {
|
503
|
+
clientConfirm(clientEvent, recaller) {
|
504
|
+
const application = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
505
|
+
let actionType = "";
|
506
|
+
if (clientEvent.content.event.hasOwnProperty('stpCall')) {
|
507
|
+
recaller.requestBody = clientEvent.content.event.stpCall;
|
508
|
+
actionType = ActionsType.PROCEDURE;
|
509
|
+
}
|
510
|
+
else if (clientEvent.content.event.hasOwnProperty('runScript')) {
|
511
|
+
recaller.requestBody = clientEvent.content.event.runScript;
|
512
|
+
actionType = ActionsType.JAVASCRIPT;
|
513
|
+
}
|
514
|
+
else if (clientEvent.content.event.hasOwnProperty('javaCall')) {
|
515
|
+
recaller.requestBody = clientEvent.content.event.javaCall;
|
516
|
+
actionType = ActionsType.JAVA;
|
517
|
+
}
|
518
|
+
let param = {
|
519
|
+
type: 'S',
|
520
|
+
sequence: clientEvent.content.event.sequence
|
521
|
+
};
|
522
|
+
if (!recaller.requestBody.params) {
|
523
|
+
recaller.requestBody.params = {
|
524
|
+
param: []
|
525
|
+
};
|
526
|
+
}
|
527
|
+
else {
|
528
|
+
if (!Array.isArray(recaller.requestBody.params.param)) {
|
529
|
+
recaller.requestBody.params.param = [recaller.requestBody.params.param];
|
530
|
+
}
|
531
|
+
}
|
532
|
+
recaller.requestBody.params.param.push(param);
|
533
|
+
const title = clientEvent.content.event.title.$;
|
534
|
+
const message = clientEvent.content.event.message.$;
|
535
|
+
let requestBody;
|
536
|
+
switch (actionType) {
|
537
|
+
case ActionsType.JAVASCRIPT:
|
538
|
+
requestBody = { runScript: recaller.requestBody };
|
539
|
+
break;
|
540
|
+
case ActionsType.PROCEDURE:
|
541
|
+
requestBody = {
|
542
|
+
requestBody: {
|
543
|
+
stpCall: recaller.requestBody
|
544
|
+
}
|
545
|
+
};
|
546
|
+
break;
|
547
|
+
case ActionsType.JAVA:
|
548
|
+
requestBody = {
|
549
|
+
requestBody: {
|
550
|
+
javaCall: recaller.requestBody
|
551
|
+
}
|
552
|
+
};
|
553
|
+
break;
|
554
|
+
}
|
555
|
+
if (clientEvent.content.event.showNoOption == 'S') {
|
556
|
+
param.paramName = ESCOLHA_SIM_NAO;
|
557
|
+
const form = document.createElement("snk-client-confirm");
|
558
|
+
window.document.body.appendChild(form);
|
559
|
+
form.titleMessage = title;
|
560
|
+
form.message = message;
|
561
|
+
form.accept = () => {
|
562
|
+
param.$ = 'S';
|
563
|
+
recaller.reCall(requestBody);
|
564
|
+
};
|
565
|
+
form.cancel = () => {
|
566
|
+
param.$ = 'N';
|
567
|
+
recaller.reCall(requestBody);
|
568
|
+
};
|
569
|
+
form.openPopup();
|
570
|
+
}
|
571
|
+
else {
|
572
|
+
application.confirm(title, message, null, 'warn', {
|
573
|
+
labelCancel: "Cancelar",
|
574
|
+
labelConfirm: "Sim"
|
575
|
+
}).then((confirmResult) => {
|
576
|
+
if (confirmResult) {
|
577
|
+
param.paramName = CONFIRMACAO;
|
578
|
+
param.$ = 'S';
|
579
|
+
recaller.reCall(requestBody);
|
580
|
+
}
|
581
|
+
});
|
582
|
+
}
|
583
|
+
}
|
584
|
+
}
|
585
|
+
|
586
|
+
const snkActionsButtonCss = ".sc-snk-actions-button-h{--snk-actions-button--z-index:var(--most-visible, 3);display:flex;width:fit-content;height:fit-content}.snk-actions-button.sc-snk-actions-button{display:flex;width:fit-content;height:fit-content}.snk-actions-button__dropdown--show.sc-snk-actions-button{display:flex;flex-direction:column;position:fixed}.snk-actions-button__dropdown.sc-snk-actions-button>ez-dropdown.sc-snk-actions-button{position:relative}.snk-actions-button--overlap.sc-snk-actions-button{z-index:var(--snk-actions-button--z-index)}.snk-actions-button__dropdown.sc-snk-actions-button{display:none}";
|
587
|
+
|
588
|
+
const SnkActionsButton = class {
|
589
|
+
constructor(hostRef) {
|
590
|
+
index.registerInstance(this, hostRef);
|
591
|
+
this.CLIENT_EVENT_CONFIRM_NAME = "br.com.sankhya.actionbutton.clientconfirm";
|
592
|
+
this.handleClick = (evt) => {
|
593
|
+
const selectedAction = this._actions.find((action) => action.actionID == evt.detail.id);
|
594
|
+
const executor = new ExecutorFactory(selectedAction.type).executor;
|
595
|
+
const action = new Actions(executor, this._dataUnit);
|
596
|
+
action.execute(Object.assign({}, selectedAction));
|
597
|
+
this._showDropdown = false;
|
598
|
+
};
|
599
|
+
this._items = [];
|
600
|
+
this._showDropdown = false;
|
601
|
+
this._actions = [];
|
602
|
+
this._isOrderActions = false;
|
603
|
+
}
|
604
|
+
async getActions() {
|
605
|
+
let param = {
|
606
|
+
param: {
|
607
|
+
entityName: this._entityName,
|
608
|
+
resourceID: this._resourceID
|
609
|
+
}
|
610
|
+
};
|
611
|
+
return DataFetcher.DataFetcher.get().callServiceBroker('ActionButtonsSP.getActions', param).then((result) => {
|
612
|
+
var _a;
|
613
|
+
if (!((_a = result.actions) === null || _a === void 0 ? void 0 : _a.action))
|
614
|
+
return;
|
615
|
+
if (this._isOrderActions) {
|
616
|
+
this._actions = core.ArrayUtils.sortAlphabetically(result.actions.action, 'description');
|
617
|
+
}
|
618
|
+
else {
|
619
|
+
this._actions = result.actions.action;
|
620
|
+
}
|
621
|
+
});
|
622
|
+
}
|
623
|
+
controlDropdown() {
|
624
|
+
this._showDropdown = !this._showDropdown;
|
625
|
+
}
|
626
|
+
canShowDropdown() {
|
627
|
+
var _a;
|
628
|
+
return this._showDropdown && ((_a = this._items) === null || _a === void 0 ? void 0 : _a.length) > 0;
|
629
|
+
}
|
630
|
+
positionDropdown() {
|
631
|
+
var _a;
|
632
|
+
const bounding = (_a = this._ezButton) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
633
|
+
if (!bounding || !this._dropdownParent)
|
634
|
+
return;
|
635
|
+
this._dropdownParent.style.top = (bounding.y + bounding.height + 5) + "px";
|
636
|
+
this._dropdownParent.style.left = bounding.x + "px";
|
637
|
+
}
|
638
|
+
closeDropdown(evt) {
|
639
|
+
const target = evt === null || evt === void 0 ? void 0 : evt.target;
|
640
|
+
if (!target)
|
641
|
+
return;
|
642
|
+
if (!target.closest(".snk-actions-button")) {
|
643
|
+
this._showDropdown = false;
|
644
|
+
}
|
645
|
+
}
|
646
|
+
setEvents() {
|
647
|
+
document.removeEventListener("click", this.closeDropdown.bind(this));
|
648
|
+
document.addEventListener("click", this.closeDropdown.bind(this));
|
649
|
+
document.removeEventListener("scroll", this.positionDropdown.bind(this));
|
650
|
+
document.addEventListener("scroll", this.positionDropdown.bind(this));
|
651
|
+
}
|
652
|
+
async componentWillLoad() {
|
653
|
+
var _a;
|
654
|
+
this._application = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
655
|
+
this._resourceID = await this._application.getResourceID();
|
656
|
+
this._isOrderActions = await this._application.getBooleanParam('global.ordenar.acoes.personalizadas');
|
657
|
+
this._dataUnit = (_a = this._element.parentElement) === null || _a === void 0 ? void 0 : _a.dataUnit;
|
658
|
+
this._entityName = this._dataUnit.name.split('/')[2];
|
659
|
+
this.setEvents();
|
660
|
+
this.getActions().then(() => {
|
661
|
+
this.loadItems();
|
662
|
+
});
|
663
|
+
}
|
664
|
+
async componentDidLoad() {
|
665
|
+
if (!this._element)
|
666
|
+
return;
|
667
|
+
core.ElementIDUtils.addIDInfo(this._element);
|
668
|
+
this.positionDropdown();
|
669
|
+
if (!(await this._application.hasClientEvent(this.CLIENT_EVENT_CONFIRM_NAME))) {
|
670
|
+
const clientEventConfirm = new ClientEventConfirm();
|
671
|
+
this._application.addClientEvent(this.CLIENT_EVENT_CONFIRM_NAME, clientEventConfirm.clientConfirm);
|
672
|
+
}
|
673
|
+
}
|
674
|
+
componentDidUpdate() {
|
675
|
+
this.positionDropdown();
|
676
|
+
}
|
677
|
+
loadItems() {
|
678
|
+
if (!this._actions || this._actions.length == 0)
|
679
|
+
return;
|
680
|
+
this._actions.forEach(action => {
|
681
|
+
this._items.push({ id: action.actionID, label: action.description });
|
682
|
+
});
|
683
|
+
}
|
684
|
+
getElementID(sufix) {
|
685
|
+
return {
|
686
|
+
[core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: core.ElementIDUtils.getInternalIDInfo(sufix)
|
687
|
+
};
|
688
|
+
}
|
689
|
+
render() {
|
690
|
+
return (index.h(index.Host, null, (this._actions && this._actions.length > 0) &&
|
691
|
+
(index.h("div", { class: `ez-padding-left--medium snk-actions-button
|
692
|
+
${this.canShowDropdown() ? " snk-actions-button--overlap" : ""}
|
693
|
+
` }, index.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"))), index.h("div", Object.assign({ ref: (ref) => this._dropdownParent = ref, class: `${this.canShowDropdown() ?
|
694
|
+
"snk-actions-button__dropdown--show" :
|
695
|
+
"snk-actions-button__dropdown"}
|
696
|
+
` }, this.getElementID("dropdown")), (this.canShowDropdown()) &&
|
697
|
+
(index.h("ez-dropdown", Object.assign({ items: this._items, onEzClick: (evt) => this.handleClick(evt) }, this.getElementID("dropdown"))))))), (this.canShowDropdown()) &&
|
698
|
+
(index.h("div", Object.assign({ class: "ez-scrim ez-scrim--light" }, this.getElementID("ezScrim"))))));
|
699
|
+
}
|
700
|
+
get _element() { return index.getElement(this); }
|
701
|
+
};
|
702
|
+
SnkActionsButton.style = snkActionsButtonCss;
|
703
|
+
|
704
|
+
exports.snk_actions_button = SnkActionsButton;
|