impaktapps-ui-builder 1.0.111 → 1.0.113

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,30 +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
- const keys = Object.keys(handlerResponse.data)
185
- keys.map((e) => {
186
- formDataHolder[e] = { ...formDataHolder, [e]: handlerResponse.data[e] }
187
- })
188
-
186
+ store.setFormdata((pre: any) => { return { ...pre, ...handlerResponse?.data } })
189
187
  }
190
188
  }
191
189
  else if (eventConfig.type === "Table" && eventConfig.lazyLoading) {
192
190
  if (handlerResponse && handlerResponse?.data) {
193
191
  formDataHolder[componentName] = handlerResponse.data?.data
194
192
  formDataHolder[`${componentName}_RowCount`] = handlerResponse.data?.meta?.totalRowCount
193
+ store.setFormdata((pre) => { return { ...pre, ...formDataHolder } });
195
194
  }
196
195
  }
197
196
  else {
198
197
  if (handlerResponse) {
199
198
  formDataHolder[componentName] = handlerResponse.data
199
+ store.setFormdata((pre) => { return { ...pre, ...formDataHolder } });
200
200
  }
201
201
  }
202
- };
202
+ }
203
203
 
204
204
  const buildBodyFormat = (body: any[], formData: any, userValue: any, store: any) => {
205
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,11 +62,11 @@ 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 {
@@ -90,7 +90,7 @@ export default (funcParams: funcParamsProps) => {
90
90
  config: {}, componentName: "",
91
91
  store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
92
92
  functionsProvider: funcParams.functionsProvider,
93
- serviceHolder: this, eventGroups, formDataHolder,
93
+ serviceHolder: this, eventGroups, formDataHolder
94
94
  }
95
95
 
96
96
  funcParams.store.setSchema(
@@ -104,33 +104,31 @@ export default (funcParams: funcParamsProps) => {
104
104
  await executeRefreshHandler({
105
105
  config: {}, componentName: "",
106
106
  store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
107
- serviceHolder: this, eventGroups, formDataHolder: formDataHolder
107
+ serviceHolder: this, eventGroups, formDataHolder: {}
108
108
  })
109
- funcParams.store.setFormdata((pre) => ({ ...pre, ...formDataHolder }))
109
+
110
110
  uiSchema.elements.push(notifyUiSchema);
111
111
  funcParams.store.setUiSchema(uiSchema);
112
112
  },
113
113
  onCellRenderer: (cellParams) => {
114
- const cloneEventGroup = _.cloneDeep(eventGroups)
115
- if (cloneEventGroup.onCellRenderer) {
114
+ if (eventGroups.onCellRenderer) {
116
115
  let finalResponse = {};
117
116
  const path = funcParams.dynamicData?.tableButtonPath || funcParams?.dynamicData?.path?.split(".")[0];
118
- if (cloneEventGroup?.onCellRenderer?.[path]) {
119
- for (const eventConfig of cloneEventGroup?.onCellRenderer?.[path]) {
120
- executeEventsParameters.store.functionParameters = cellParams
121
- finalResponse = executeEvents({
122
- ...executeEventsParameters,
123
- config: eventConfig,
124
- componentName: path
125
- })
126
- }
127
- return finalResponse
117
+
118
+ for (const eventConfig of eventGroups?.onCellRenderer?.[path]) {
119
+ executeEventsParameters.store.functionParameters = cellParams
120
+ finalResponse = executeEvents({
121
+ ...executeEventsParameters,
122
+ config: eventConfig,
123
+ componentName: path
124
+ })
128
125
  }
126
+ return finalResponse
129
127
  }
130
128
  return {}
131
129
  },
132
- onClick: async function () {
133
- await this.callHandler("onClick")
130
+ onClick: function () {
131
+ this.callHandler("onClick")
134
132
  },
135
133
  onKeyDown: function () {
136
134
  this.callHandler("onKeyDown")
@@ -167,7 +165,7 @@ export default (funcParams: funcParamsProps) => {
167
165
  { key: "sorting", value: paginationValues.sorting || [] },
168
166
  { key: "filters", value: paginationValues.tableColumnConfig || [] },
169
167
  { key: "globalFilter", value: paginationValues.globalFilter ?? '' },
170
- { key: "expandedRowIds", value: paginationValues.expandedRowIds ?? [] }
168
+ { key: "expandedRowIds", value: paginationValues.expandedRowIds ?? []}
171
169
  ]
172
170
  const response = await this.callExecuteEvents(paginationValues, apiBody, "onLoad");
173
171
  return response?.data;
@@ -232,14 +230,14 @@ export default (funcParams: funcParamsProps) => {
232
230
  },
233
231
  onNext: async function (functionParameters) {
234
232
  const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[0];
235
- await this.callHandler("onNext", functionParameters)
233
+ await this.callHandler("onNext", functionParameters)
236
234
  if (eventGroups?.["onNext"]?.[path] === undefined) {
237
235
  functionParameters?.handleNext()
238
236
  }
239
237
  },
240
238
  onReset: async function (functionParameters) {
241
239
  const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[0];
242
- this.callHandler("onReset", functionParameters)
240
+ await this.callHandler("onReset", functionParameters)
243
241
  if (eventGroups?.["onReset"]?.[path] === undefined) {
244
242
  functionParameters?.handleReset()
245
243
  }
@@ -247,29 +245,18 @@ export default (funcParams: funcParamsProps) => {
247
245
  callHandler: async function (eventType: string, functionParameters?: any) {
248
246
  const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[funcParams.dynamicData.path.split(".").length - 1];
249
247
  if (eventGroups?.[eventType]?.[path] !== undefined) {
250
- (eventGroups?.[eventType]?.[path].map(async (eventConfig) => {
248
+ Promise.all(eventGroups?.[eventType]?.[path].map((eventConfig) => {
251
249
  executeEventsParameters.store.functionParameters = functionParameters
252
- if (eventConfig.Handler === "refresh") {
253
- await executeRefreshHandler({
254
- ...executeEventsParameters,
255
- config: eventConfig,
256
- componentName: path,
257
- formDataHolder: formDataHolder
258
- })
259
- funcParams.store.setFormdata((pre) => ({ ...pre, ...formDataHolder }));
260
-
261
- } else {
262
- executeEvents({
263
- ...executeEventsParameters,
264
- config: eventConfig,
265
- componentName: path
266
- })
267
- }
250
+ executeEvents({
251
+ ...executeEventsParameters,
252
+ config: eventConfig,
253
+ componentName: path
254
+ })
268
255
  }))
269
256
  }
270
257
  },
271
258
  downloadFile: downloadFile,
272
- downloadFileFromUrl: downloadFileFromUrl,
259
+ download: doDownload,
273
260
  ...funcParams.functionsProvider
274
261
  };
275
262
  };