impaktapps-ui-builder 1.0.119 → 1.0.120

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.
@@ -1,4 +1,4 @@
1
- import _, { isObject, mapKeys } from "lodash";
1
+ import _ from "lodash";
2
2
  import { handlersProps } from "./interface";
3
3
  export const executeEvents = (params: handlersProps) => {
4
4
  let nextEvent = [];
@@ -68,7 +68,8 @@ function executeEventsHandler(params: handlersProps) {
68
68
  params.componentName,
69
69
  params.config,
70
70
  params.store,
71
- params.formDataHolder,
71
+ params.service,
72
+ params.formDataHolder
72
73
  );
73
74
  } else if (params.config.Handler === "onBackHandler") {
74
75
  return params.store.functionParameters?.handleBack();
@@ -143,7 +144,8 @@ function executeCustomHandler(params: handlersProps) {
143
144
  }
144
145
 
145
146
  }
146
- function mergeFormdata(handlerResponse: any, componentName: string, eventConfig: any, store: any, formDataHolder: any) {
147
+
148
+ function mergeFormdata(handlerResponse: any, componentName: string, eventConfig: any, store: any, service: any, formDataHolder: any) {
147
149
  if (eventConfig.type === "Select" && handlerResponse?.data) {
148
150
  if (!_.isEmpty(handlerResponse?.data)) {
149
151
  store.setSchema((pre) => {
@@ -176,28 +178,28 @@ function mergeFormdata(handlerResponse: any, componentName: string, eventConfig:
176
178
  }
177
179
  }
178
180
  else if (eventConfig.type === "page") {
179
- if (!(_.isEmpty(handlerResponse?.data) && handlerResponse?.data && isObject(handlerResponse.data))) {
181
+ if (!(_.isEmpty(handlerResponse?.data) && handlerResponse?.data)) {
180
182
  store.newData = {
181
183
  ...store.newData,
182
184
  ...handlerResponse?.data
183
185
  }
184
- Object.keys(handlerResponse.data).forEach((e) => {
185
- formDataHolder[e] = handlerResponse.data[e]
186
- })
186
+ store.setFormdata((pre: any) => { return { ...pre, ...handlerResponse?.data } })
187
187
  }
188
188
  }
189
189
  else if (eventConfig.type === "Table" && eventConfig.lazyLoading) {
190
190
  if (handlerResponse && handlerResponse?.data) {
191
191
  formDataHolder[componentName] = handlerResponse.data?.data
192
192
  formDataHolder[`${componentName}_RowCount`] = handlerResponse.data?.meta?.totalRowCount
193
+ store.setFormdata((pre) => { return { ...pre, ...formDataHolder } });
193
194
  }
194
195
  }
195
196
  else {
196
- if (handlerResponse?.data) {
197
+ if (handlerResponse) {
197
198
  formDataHolder[componentName] = handlerResponse.data
199
+ store.setFormdata((pre) => { return { ...pre, ...formDataHolder } });
198
200
  }
199
201
  }
200
- };
202
+ }
201
203
 
202
204
  const buildBodyFormat = (body: any[], formData: any, userValue: any, store: any) => {
203
205
  let finalBody = { ...userValue?.payload };
@@ -1,5 +1,5 @@
1
1
  import _, { isEmpty } from "lodash";
2
- import { downloadFileFromUrl, downloadFile } from "./downloadFile";
2
+ import { doDownload, downloadFile } from "./downloadFile";
3
3
  import { executeEvents, executeRefreshHandler } from "./events";
4
4
  import { handlersProps } from "./interface";
5
5
  let compType: string;
@@ -62,17 +62,20 @@ export const extractEvents = (eventConfig: any) => {
62
62
  return eventGroups;
63
63
  };
64
64
  export default (funcParams: funcParamsProps) => {
65
- const formDataHolder = {};
65
+ const formDataHolder = {}
66
66
  let executeEventsParameters: handlersProps = {
67
67
  config: {}, componentName: "",
68
68
  store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
69
- serviceHolder: { downloadFile, download: downloadFileFromUrl, ...funcParams.functionsProvider }, eventGroups,
69
+ serviceHolder: { downloadFile, download: doDownload, ...funcParams.functionsProvider }, eventGroups,
70
70
  functionsProvider: funcParams.functionsProvider, formDataHolder
71
71
  };
72
72
  return {
73
73
  setPage: async function () {
74
74
  funcParams.store.setAdditionalErrors([]);
75
- funcParams.store.setFormdata(funcParams?.initFormData() || {});
75
+ funcParams.store.setFormdata((pre) => ({
76
+ ...pre,
77
+ ...(funcParams?.initFormData())
78
+ }));
76
79
  funcParams.store.setSchema({ type: "object", properties: {} });
77
80
  funcParams.store.newData = {};
78
81
  eventGroups = {};
@@ -90,7 +93,7 @@ export default (funcParams: funcParamsProps) => {
90
93
  config: {}, componentName: "",
91
94
  store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
92
95
  functionsProvider: funcParams.functionsProvider,
93
- serviceHolder: this, eventGroups, formDataHolder,
96
+ serviceHolder: this, eventGroups, formDataHolder
94
97
  }
95
98
 
96
99
  funcParams.store.setSchema(
@@ -101,32 +104,29 @@ export default (funcParams: funcParamsProps) => {
101
104
  }
102
105
  }
103
106
  )
104
- executeRefreshHandler({
107
+ await executeRefreshHandler({
105
108
  config: {}, componentName: "",
106
109
  store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
107
- serviceHolder: this, eventGroups, formDataHolder: formDataHolder
108
- }).then((e) => {
109
- funcParams.store.setFormdata((pre) => ({ ...pre, ...formDataHolder }))
110
- uiSchema.elements.push(notifyUiSchema);
111
- funcParams.store.setUiSchema(uiSchema);
112
- });
110
+ serviceHolder: this, eventGroups, formDataHolder: {}
111
+ })
112
+
113
+ uiSchema.elements.push(notifyUiSchema);
114
+ funcParams.store.setUiSchema(uiSchema);
113
115
  },
114
116
  onCellRenderer: (cellParams) => {
115
- const cloneEventGroup = _.cloneDeep(eventGroups)
116
- if (cloneEventGroup.onCellRenderer) {
117
+ if (eventGroups.onCellRenderer) {
117
118
  let finalResponse = {};
118
119
  const path = funcParams.dynamicData?.tableButtonPath || funcParams?.dynamicData?.path?.split(".")[0];
119
- if (cloneEventGroup?.onCellRenderer?.[path]) {
120
- for (const eventConfig of cloneEventGroup?.onCellRenderer?.[path]) {
121
- executeEventsParameters.store.functionParameters = cellParams
122
- finalResponse = executeEvents({
123
- ...executeEventsParameters,
124
- config: eventConfig,
125
- componentName: path
126
- })
127
- }
128
- return finalResponse
120
+
121
+ for (const eventConfig of eventGroups?.onCellRenderer?.[path]) {
122
+ executeEventsParameters.store.functionParameters = cellParams
123
+ finalResponse = executeEvents({
124
+ ...executeEventsParameters,
125
+ config: eventConfig,
126
+ componentName: path
127
+ })
129
128
  }
129
+ return finalResponse
130
130
  }
131
131
  return {}
132
132
  },
@@ -168,7 +168,7 @@ export default (funcParams: funcParamsProps) => {
168
168
  { key: "sorting", value: paginationValues.sorting || [] },
169
169
  { key: "filters", value: paginationValues.tableColumnConfig || [] },
170
170
  { key: "globalFilter", value: paginationValues.globalFilter ?? '' },
171
- { key: "expandedRowIds", value: paginationValues.expandedRowIds ?? [] }
171
+ { key: "expandedRowIds", value: paginationValues.expandedRowIds ?? []}
172
172
  ]
173
173
  const response = await this.callExecuteEvents(paginationValues, apiBody, "onLoad");
174
174
  return response?.data;
@@ -192,24 +192,11 @@ export default (funcParams: funcParamsProps) => {
192
192
  funcParams.store?.newData[componentName] !== undefined
193
193
  ) {
194
194
  for (const eventConfig of eventGroups.onChange[componentName]) {
195
-
196
- if (eventConfig.Handler === "refresh") {
197
- await executeEvents({
198
- ...executeEventsParameters,
199
- config: eventConfig,
200
- componentName,
201
- formDataHolder: formDataHolder
202
- })
203
- if (!isEmpty(formDataHolder)) {
204
- funcParams.store.setFormdata((pre) => ({ ...pre, ...formDataHolder }));
205
- }
206
- } else {
207
- await executeEvents({
208
- ...executeEventsParameters,
209
- config: eventConfig,
210
- componentName,
211
- })
212
- }
195
+ await executeEvents({
196
+ ...executeEventsParameters,
197
+ config: eventConfig,
198
+ componentName
199
+ })
213
200
  }
214
201
  }
215
202
  }))
@@ -239,44 +226,40 @@ export default (funcParams: funcParamsProps) => {
239
226
  },
240
227
  onBack: async function (functionParameters) {
241
228
  const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[0];
242
- this.callHandler("onBack", functionParameters)
229
+ await this.callHandler("onBack", functionParameters)
243
230
  if (eventGroups?.["onBack"]?.[path] === undefined) {
244
231
  functionParameters?.handleBack()
245
232
  }
246
233
  },
247
234
  onNext: async function (functionParameters) {
248
235
  const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[0];
249
- this.callHandler("onNext", functionParameters)
236
+ await this.callHandler("onNext", functionParameters)
250
237
  if (eventGroups?.["onNext"]?.[path] === undefined) {
251
238
  functionParameters?.handleNext()
252
239
  }
253
240
  },
254
241
  onReset: async function (functionParameters) {
255
242
  const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[0];
256
- this.callHandler("onReset", functionParameters)
243
+ await this.callHandler("onReset", functionParameters)
257
244
  if (eventGroups?.["onReset"]?.[path] === undefined) {
258
245
  functionParameters?.handleReset()
259
246
  }
260
247
  },
261
- callHandler: function (eventType: string, functionParameters?: any) {
248
+ callHandler: async function (eventType: string, functionParameters?: any) {
262
249
  const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[funcParams.dynamicData.path.split(".").length - 1];
263
250
  if (eventGroups?.[eventType]?.[path] !== undefined) {
264
- (eventGroups?.[eventType]?.[path].map(async (eventConfig) => {
251
+ Promise.all(eventGroups?.[eventType]?.[path].map((eventConfig) => {
265
252
  executeEventsParameters.store.functionParameters = functionParameters
266
- await executeEvents({
253
+ executeEvents({
267
254
  ...executeEventsParameters,
268
255
  config: eventConfig,
269
- componentName: path,
270
- formDataHolder: formDataHolder
256
+ componentName: path
271
257
  })
272
- if (!isEmpty(formDataHolder)) {
273
- funcParams.store.setFormdata((pre) => ({ ...pre, ...formDataHolder }));
274
- }
275
258
  }))
276
259
  }
277
260
  },
278
261
  downloadFile: downloadFile,
279
- downloadFileFromUrl: downloadFileFromUrl,
262
+ download: doDownload,
280
263
  ...funcParams.functionsProvider
281
264
  };
282
265
  };