impaktapps-ui-builder 0.0.412-mtreemap.20 → 0.0.412-mtreemap.21
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/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import { handlersProps } from "./interface";
|
|
|
3
3
|
export const executeEvents = (params: handlersProps) => {
|
|
4
4
|
let nextEvent = [];
|
|
5
5
|
let finalResponse = null;
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
if (params.config.isSync !== "Yes") {
|
|
8
8
|
return shouldEventExecute(params)
|
|
9
9
|
.then((shouldExecute) => {
|
|
@@ -52,7 +52,7 @@ export const executeEvents = (params: handlersProps) => {
|
|
|
52
52
|
}
|
|
53
53
|
return finalResponse;
|
|
54
54
|
}
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
function executeEventsHandler(params: handlersProps) {
|
|
57
57
|
if (params.config.Handler === "api") {
|
|
58
58
|
return executeApiRequest(params);
|
|
@@ -79,14 +79,14 @@ function executeEventsHandler(params: handlersProps) {
|
|
|
79
79
|
return params.store.functionParameters?.handleReset();
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
|
|
82
|
+
|
|
83
83
|
export function getRefreshElements(eventConfig: any, eventGropus: any) {
|
|
84
84
|
let result: string[] = [];
|
|
85
85
|
if (eventConfig?.refreshElements?.length > 0) {
|
|
86
86
|
result = eventConfig.refreshElements.map((e) => {
|
|
87
87
|
return e.value
|
|
88
88
|
})
|
|
89
|
-
|
|
89
|
+
|
|
90
90
|
} else {
|
|
91
91
|
if (eventGropus?.onLoad) {
|
|
92
92
|
result = Object.keys(eventGropus?.onLoad)
|
|
@@ -98,37 +98,23 @@ export function getRefreshElements(eventConfig: any, eventGropus: any) {
|
|
|
98
98
|
}
|
|
99
99
|
export async function executeRefreshHandler(params: handlersProps) {
|
|
100
100
|
const compToRefresh: string[] = getRefreshElements(params.config, params.eventGroups);
|
|
101
|
-
|
|
102
|
-
// Create an array of promises for the components to refresh
|
|
103
101
|
return Promise.allSettled(compToRefresh.map(componentName => {
|
|
104
102
|
const eventConfigs = params.eventGroups.onLoad[componentName];
|
|
105
|
-
|
|
106
|
-
// If eventConfigs is undefined, return a resolved promise
|
|
107
103
|
if (!eventConfigs) {
|
|
108
|
-
return Promise.resolve();
|
|
104
|
+
return Promise.resolve();
|
|
109
105
|
}
|
|
110
|
-
|
|
111
|
-
// Create an array of promises for the defined eventConfigs
|
|
112
106
|
return Promise.allSettled(eventConfigs.map(compEventConfig => {
|
|
113
107
|
return executeEvents({ ...params, config: compEventConfig, componentName });
|
|
114
108
|
}));
|
|
115
109
|
}));
|
|
116
110
|
}
|
|
117
|
-
// export function executeRefreshHandler(params: handlersProps) {
|
|
118
|
-
// const compToRefresh: string[] = getRefreshElements(params.config, params.eventGroups);
|
|
119
|
-
// return Promise.all(compToRefresh.map(componentName => {
|
|
120
|
-
// return Promise.all(params.eventGroups.onLoad[componentName].map(compEventConfig => {
|
|
121
|
-
// return executeEvents({ ...params, config: compEventConfig, componentName });
|
|
122
|
-
// }));
|
|
123
|
-
// }))
|
|
124
|
-
// };
|
|
125
111
|
export function executeApiRequest(params: any) {
|
|
126
112
|
const initialBody = { ...params.userValue?.payload };
|
|
127
113
|
const initialHeaders = {
|
|
128
114
|
"X-Requested-With": "XMLHttpRequest",
|
|
129
115
|
"Access-Control-Allow-Origin": "*"
|
|
130
116
|
};
|
|
131
|
-
|
|
117
|
+
|
|
132
118
|
const payloadApi = buildApiPayload(params.config, initialBody, initialHeaders, params.store, params.dynamicData, params.userValue, params.service)
|
|
133
119
|
return params.service[params.config.method](
|
|
134
120
|
params.config.path,
|
|
@@ -138,7 +124,7 @@ export function executeApiRequest(params: any) {
|
|
|
138
124
|
return response;
|
|
139
125
|
});
|
|
140
126
|
};
|
|
141
|
-
|
|
127
|
+
|
|
142
128
|
function executeInBuiltFunctionHandler(params: handlersProps) {
|
|
143
129
|
let parameter = {};
|
|
144
130
|
if (params.config.funcParametersCode) {
|
|
@@ -149,7 +135,7 @@ function executeInBuiltFunctionHandler(params: handlersProps) {
|
|
|
149
135
|
params.serviceHolder[params.config.inBuiltFunctionType](params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service)
|
|
150
136
|
}
|
|
151
137
|
}
|
|
152
|
-
|
|
138
|
+
|
|
153
139
|
function executeCustomHandler(params: handlersProps) {
|
|
154
140
|
const makeFunc = eval(params.config.eventCode)
|
|
155
141
|
if (params.config.isSync !== "Yes") {
|
|
@@ -158,9 +144,9 @@ function executeCustomHandler(params: handlersProps) {
|
|
|
158
144
|
const response = makeFunc(params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service, params.componentName)
|
|
159
145
|
return response;
|
|
160
146
|
}
|
|
161
|
-
|
|
147
|
+
|
|
162
148
|
}
|
|
163
|
-
|
|
149
|
+
|
|
164
150
|
function mergeFormdata(handlerResponse: any, componentName: string, eventConfig: any, store: any, service: any, formDataHolder: any) {
|
|
165
151
|
if (eventConfig.type === "Select" && !(_.isEmpty(handlerResponse?.data) && handlerResponse?.data)) {
|
|
166
152
|
store.setSchema((pre) => {
|
|
@@ -205,8 +191,8 @@ function mergeFormdata(handlerResponse: any, componentName: string, eventConfig:
|
|
|
205
191
|
}
|
|
206
192
|
}
|
|
207
193
|
}
|
|
208
|
-
|
|
209
|
-
const buildBodyFormat = (body: any[], formData: any, userValue: any) => {
|
|
194
|
+
|
|
195
|
+
const buildBodyFormat = (body: any[], formData: any, userValue: any, store: any) => {
|
|
210
196
|
let finalBody = { ...userValue?.payload };
|
|
211
197
|
body.map((elem) => {
|
|
212
198
|
if (typeof elem?.value !== "string") {
|
|
@@ -215,6 +201,15 @@ const buildBodyFormat = (body: any[], formData: any, userValue: any) => {
|
|
|
215
201
|
if (elem?.value?.startsWith("$userValue")) {
|
|
216
202
|
const finalpath = elem.value.substring(11);
|
|
217
203
|
finalBody[elem.key] = _.get(userValue, finalpath);;
|
|
204
|
+
} else if (elem?.value?.startsWith("$urlParams")) {
|
|
205
|
+
const finalpath = elem.value.substring(11);
|
|
206
|
+
const value = store?.searchParams?.get(finalpath);
|
|
207
|
+
finalBody[elem.key] = value;
|
|
208
|
+
}
|
|
209
|
+
else if (elem?.value?.startsWith("$local")) {
|
|
210
|
+
const finalpath = elem.value.substring(7);
|
|
211
|
+
const value = JSON.parse(localStorage.getItem(finalpath) || '""')
|
|
212
|
+
finalBody[elem.key] = value;
|
|
218
213
|
}
|
|
219
214
|
else if (elem?.value?.startsWith("$")) {
|
|
220
215
|
const finalpath = elem.value.substring(1);
|
|
@@ -231,7 +226,7 @@ const buildBodyFormat = (body: any[], formData: any, userValue: any) => {
|
|
|
231
226
|
})
|
|
232
227
|
return finalBody;
|
|
233
228
|
}
|
|
234
|
-
|
|
229
|
+
|
|
235
230
|
const buildHeadersFormat = (headers: any[]) => {
|
|
236
231
|
const headerObj = {
|
|
237
232
|
// "Content-Type": "application/json",
|
|
@@ -242,10 +237,10 @@ const buildHeadersFormat = (headers: any[]) => {
|
|
|
242
237
|
})
|
|
243
238
|
return headerObj;
|
|
244
239
|
}
|
|
245
|
-
|
|
240
|
+
|
|
246
241
|
export function shouldEventExecute(params: handlersProps) {
|
|
247
242
|
const startEvent = params.config?.events?.filter(e => e.eventType === "onStart");
|
|
248
|
-
|
|
243
|
+
|
|
249
244
|
if (startEvent?.length > 0) {
|
|
250
245
|
if (startEvent[0]?.isSync !== "Yes") {
|
|
251
246
|
return executeEventsHandler({ ...params, config: startEvent[0] }).then((response) => {
|
|
@@ -262,14 +257,14 @@ export function shouldEventExecute(params: handlersProps) {
|
|
|
262
257
|
}
|
|
263
258
|
}
|
|
264
259
|
}
|
|
265
|
-
|
|
266
|
-
|
|
260
|
+
|
|
261
|
+
|
|
267
262
|
export function buildApiPayload(compConfig: any, body: any, headers: any, store: any, dynamicData: any, userValue: any, service) {
|
|
268
263
|
if (compConfig?.headers) {
|
|
269
264
|
headers = buildHeadersFormat(compConfig.headers);
|
|
270
265
|
}
|
|
271
266
|
if (compConfig.body) {
|
|
272
|
-
body = { ...buildBodyFormat(compConfig.body, store.newData || store?.ctx?.core?.data || store.formData,
|
|
267
|
+
body = { ...buildBodyFormat(compConfig.body, store.newData || store?.ctx?.core?.data || store.formData,userValue, store) };
|
|
273
268
|
}
|
|
274
269
|
const promiseChain = { body, headers };
|
|
275
270
|
if (compConfig.apiBody) {
|
|
@@ -288,4 +283,4 @@ export function asyncOperation() {
|
|
|
288
283
|
}
|
|
289
284
|
}, 50);
|
|
290
285
|
});
|
|
291
|
-
}
|
|
286
|
+
}
|