impaktapps-ui-builder 0.0.412-mtreemap.20 → 0.0.412-mtreemap.22

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