impaktapps-ui-builder 0.0.382-alpha.60 → 0.0.382-alpha.62

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,6 +1,215 @@
1
+ // import _, { isEmpty } from "lodash";
2
+ // import { doDownload, downloadFile } from "./downloadFile";
3
+ // import { executeEvents, executeRefreshHandler } from "./events";
4
+ // import { handlersProps } from "./interface";
5
+ // let compType: string;
6
+ // let eventGroups: any = {};
7
+ // const notifyUiSchema = {
8
+ // type: "Control",
9
+ // scope: "#/properties/notify",
10
+ // options: {
11
+ // widget: "Notify",
12
+ // },
13
+ // layout: 6,
14
+ // };
15
+
16
+ // export const extractEvents = (eventConfig: any) => {
17
+ // function extractsConfigEvents(eventConfigObj: any) {
18
+ // if (eventConfigObj.events) {
19
+ // eventConfigObj.events.forEach((event: any) => {
20
+ // if (eventConfigObj.type) {
21
+ // compType = eventConfigObj.type;
22
+ // }
23
+ // if (!eventGroups[event.eventType]) {
24
+ // eventGroups[event.eventType] = {};
25
+ // }
26
+ // if (!eventGroups[event.eventType][eventConfigObj.name]) {
27
+ // eventGroups[event.eventType][eventConfigObj.name] = [];
28
+ // }
29
+ // const SuccessEvent = event?.events?.find((elem) => {
30
+ // return elem.eventType === "Success"
31
+ // })
32
+ // if (!(!!SuccessEvent) && event.eventType === "onLoad") {
33
+ // event.events.push({ Handler: "mergeFormdata", eventType: "Success", type: compType, lazyLoading: eventConfig.lazyLoading === "YES" ? true : false })
34
+ // }
35
+ // if (!(!!SuccessEvent) && (event.eventType === "onBack" || event.eventType === "onNext"|| event.eventType === "onReset")) {
36
+ // event.events.push({ Handler: `${event.eventType}Handler`, eventType: "Success", type: compType, lazyLoading: eventConfig.lazyLoading === "YES" ? true : false })
37
+ // }
38
+ // eventGroups[event.eventType][eventConfigObj.name].push({ ...event, type: compType })
39
+ // });
40
+ // }
41
+ // }
42
+
43
+ // extractsConfigEvents(eventConfig)
44
+ // if (eventConfig?.elements) {
45
+ // eventConfig.elements.forEach(extractEvents);
46
+ // }
47
+ // return eventGroups;
48
+ // };
49
+
50
+ // interface funcParamsProps {
51
+ // store: any,
52
+ // dynamicData: any,
53
+ // config: any,
54
+ // uiSchema: any,
55
+ // schema: any,
56
+ // service: any,
57
+ // userValue: any,
58
+ // }
59
+ // export default (funcParams: funcParamsProps) => {
60
+ // eventGroups = {}
61
+ // eventGroups = extractEvents(funcParams.config)
62
+ // let executeEventsParameters: handlersProps = {
63
+ // config: {}, componentName: "",
64
+ // store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
65
+ // serviceHolder: { downloadFile,download:doDownload }, eventGroups
66
+ // };
67
+ // return {
68
+ // setPage: async function () {
69
+ // funcParams.store.setFormdata({});
70
+ // executeEventsParameters = {
71
+ // config: {}, componentName: "",
72
+ // store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
73
+ // serviceHolder: this, eventGroups
74
+ // }
75
+ // funcParams.store.setSchema(
76
+ // (pre: any) => {
77
+ // return {
78
+ // ...funcParams.schema, properties:
79
+ // { ...funcParams.schema.properties, ...pre.properties, }
80
+ // }
81
+ // }
82
+ // )
83
+ // funcParams.uiSchema.elements.push(notifyUiSchema);
84
+ // funcParams.store.setUiSchema(funcParams.uiSchema);
85
+ // await executeRefreshHandler({
86
+ // config: {}, componentName: "",
87
+ // store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
88
+ // serviceHolder: this, eventGroups
89
+ // })
90
+ // },
91
+ // onClick: async function () {
92
+ // await this.callHandler("onClick")
93
+ // },
94
+ // onFileDownload: async function () {
95
+ // await this.callHandler("onDownload")
96
+ // },
97
+ // onFileUpload: async function () {
98
+ // await this.callHandler("onUpload")
99
+ // },
100
+ // onPaginationChange: async function (paginationValues) {
101
+ // const apiBody = [
102
+ // { key: "size", value: paginationValues.pagination.pageSize },
103
+ // { key: "pageIndex", value: paginationValues.pagination.pageIndex },
104
+ // { key: "sorting", value: paginationValues.sorting || [] },
105
+ // { key: "filters", value: paginationValues.columnFilters || [] },
106
+ // { key: "globalFilter", value: paginationValues.globalFilter ?? '' }
107
+ // ]
108
+ // const response = await this.updateConfigApiBody(paginationValues, apiBody);
109
+ // return response?.data;
110
+ // },
111
+ // getSelectOptions: async function (param) {
112
+ // if (param.serachValue !== "" && param.serachValue !== undefined) {
113
+ // const apiBody = [
114
+ // { key: "searchValue", value: param.serachValue },
115
+ // { key: "currentValue", value: param.currentValue }
116
+ // ]
117
+ // return await this.updateConfigApiBody(param, apiBody)
118
+ // }
119
+ // },
120
+ // onChange: async function () {
121
+ // if (eventGroups.onChange) {
122
+ // funcParams.dynamicData?.setLoading(true);
123
+ // const ChangeEventsKeysArray = Object.keys(eventGroups.onChange);
124
+ // Promise.all(ChangeEventsKeysArray.map(async (componentName: string) => {
125
+ // if (
126
+ // funcParams.store?.formData[componentName] !== funcParams.store.newData[componentName] &&
127
+ // funcParams.store?.newData[componentName] !== undefined
128
+ // ) {
129
+ // for (const eventConfig of eventGroups.onChange[componentName]) {
130
+ // await executeEvents({
131
+ // ...executeEventsParameters,
132
+ // config: eventConfig,
133
+ // componentName
134
+ // })
135
+ // }
136
+ // }
137
+ // }))
138
+ // funcParams.dynamicData?.setLoading(false);
139
+ // }
140
+ // },
141
+ // updateConfigApiBody: async function (paramValue, apiBody) {
142
+ // let LastCallResponse = undefined;
143
+ // for (const eventConfig of eventGroups?.onLoad[paramValue.path]) {
144
+ // if (eventConfig.body) {
145
+ // eventConfig.body = [
146
+ // ...eventConfig.body,
147
+ // ...apiBody
148
+ // ]
149
+ // } else { eventConfig.body = apiBody; };
150
+ // const responseEvent = eventConfig?.events?.filter((elem) => {
151
+ // return elem.Handler !== "mergeFormdata"
152
+ // })
153
+ // eventConfig.events = responseEvent ?? []
154
+ // LastCallResponse = await executeEvents({
155
+ // ...executeEventsParameters,
156
+ // config: eventConfig,
157
+ // componentName: paramValue.path
158
+ // })
159
+ // }
160
+ // return LastCallResponse
161
+ // },
162
+ // onBack: async function (functionParameters) {
163
+ // const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[0];
164
+ // await this.callHandler("onBack", functionParameters)
165
+ // if (eventGroups?.["onBack"]?.[path] === undefined) {
166
+ // functionParameters?.handleBack()
167
+ // }
168
+ // },
169
+ // onNext: async function (functionParameters) {
170
+ // const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[0];
171
+ // await this.callHandler("onNext", functionParameters)
172
+ // if (eventGroups?.["onNext"]?.[path] === undefined) {
173
+ // functionParameters?.handleNext()
174
+ // }
175
+ // },
176
+ // backHandler:()=>{
177
+ // funcParams.store.navigate(-1)
178
+ // },
179
+ // onReset: async function (functionParameters) {
180
+ // const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[0];
181
+ // await this.callHandler("onReset", functionParameters)
182
+ // if (eventGroups?.["onReset"]?.[path] === undefined) {
183
+ // functionParameters?.handleReset()
184
+ // }
185
+ // },
186
+ // callHandler: async function (eventType: string, functionParameters?: any) {
187
+ // const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[0];
188
+ // if (eventGroups?.[eventType]?.[path] !== undefined) {
189
+ // for (const eventConfig of eventGroups?.[eventType]?.[path]) {
190
+ // executeEventsParameters.store.functionParameters = functionParameters
191
+ // await executeEvents({
192
+ // ...executeEventsParameters,
193
+ // config: eventConfig,
194
+ // componentName: path
195
+ // })
196
+ // }
197
+ // }
198
+ // },
199
+ // downloadFile: downloadFile,
200
+ // download:doDownload,
201
+ // };
202
+ // };
203
+
204
+
205
+
206
+
207
+
208
+
209
+
1
210
  import _, { isEmpty } from "lodash";
2
211
  import { doDownload, downloadFile } from "./downloadFile";
3
- import { executeEvents, executeRefreshHandler } from "./events";
212
+ import { asyncOperation, executeEvents, executeRefreshHandler } from "./events";
4
213
  import { handlersProps } from "./interface";
5
214
  let compType: string;
6
215
  let eventGroups: any = {};
@@ -32,7 +241,7 @@ export const extractEvents = (eventConfig: any) => {
32
241
  if (!(!!SuccessEvent) && event.eventType === "onLoad") {
33
242
  event.events.push({ Handler: "mergeFormdata", eventType: "Success", type: compType, lazyLoading: eventConfig.lazyLoading === "YES" ? true : false })
34
243
  }
35
- if (!(!!SuccessEvent) && (event.eventType === "onBack" || event.eventType === "onNext"|| event.eventType === "onReset")) {
244
+ if (!(!!SuccessEvent) && (event.eventType === "onBack" || event.eventType === "onNext" || event.eventType === "onReset")) {
36
245
  event.events.push({ Handler: `${event.eventType}Handler`, eventType: "Success", type: compType, lazyLoading: eventConfig.lazyLoading === "YES" ? true : false })
37
246
  }
38
247
  eventGroups[event.eventType][eventConfigObj.name].push({ ...event, type: compType })
@@ -55,6 +264,7 @@ interface funcParamsProps {
55
264
  schema: any,
56
265
  service: any,
57
266
  userValue: any,
267
+ functionsProvider?: Record<string, any>
58
268
  }
59
269
  export default (funcParams: funcParamsProps) => {
60
270
  eventGroups = {}
@@ -62,16 +272,25 @@ export default (funcParams: funcParamsProps) => {
62
272
  let executeEventsParameters: handlersProps = {
63
273
  config: {}, componentName: "",
64
274
  store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
65
- serviceHolder: { downloadFile,download:doDownload }, eventGroups
275
+ serviceHolder: { downloadFile, download: doDownload ,...funcParams.functionsProvider}, eventGroups,
276
+ functionsProvider: funcParams.functionsProvider,
66
277
  };
67
278
  return {
68
279
  setPage: async function () {
69
280
  funcParams.store.setFormdata({});
281
+ const demoData = await asyncOperation();
70
282
  executeEventsParameters = {
71
283
  config: {}, componentName: "",
72
284
  store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
285
+ functionsProvider: funcParams.functionsProvider,
73
286
  serviceHolder: this, eventGroups
74
287
  }
288
+ await executeRefreshHandler({
289
+ config: {}, componentName: "",
290
+ store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
291
+ serviceHolder: this, eventGroups
292
+ })
293
+ const demoData2 = await asyncOperation();
75
294
  funcParams.store.setSchema(
76
295
  (pre: any) => {
77
296
  return {
@@ -82,21 +301,23 @@ export default (funcParams: funcParamsProps) => {
82
301
  )
83
302
  funcParams.uiSchema.elements.push(notifyUiSchema);
84
303
  funcParams.store.setUiSchema(funcParams.uiSchema);
85
- await executeRefreshHandler({
86
- config: {}, componentName: "",
87
- store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
88
- serviceHolder: this, eventGroups
89
- })
304
+
90
305
  },
91
306
  onClick: async function () {
92
307
  await this.callHandler("onClick")
93
308
  },
309
+ onMount: async function () {
310
+ await this.callHandler("onMount")
311
+ },
94
312
  onFileDownload: async function () {
95
313
  await this.callHandler("onDownload")
96
314
  },
97
315
  onFileUpload: async function () {
98
316
  await this.callHandler("onUpload")
99
317
  },
318
+ backHandler:function(){
319
+ funcParams.store.navigate(-1)
320
+ },
100
321
  onPaginationChange: async function (paginationValues) {
101
322
  const apiBody = [
102
323
  { key: "size", value: paginationValues.pagination.pageSize },
@@ -114,12 +335,12 @@ export default (funcParams: funcParamsProps) => {
114
335
  { key: "searchValue", value: param.serachValue },
115
336
  { key: "currentValue", value: param.currentValue }
116
337
  ]
117
- return await this.updateConfigApiBody(param, apiBody)
338
+ const response = await this.updateConfigApiBody(param, apiBody);
339
+ return response?.data;
118
340
  }
119
341
  },
120
342
  onChange: async function () {
121
343
  if (eventGroups.onChange) {
122
- funcParams.dynamicData?.setLoading(true);
123
344
  const ChangeEventsKeysArray = Object.keys(eventGroups.onChange);
124
345
  Promise.all(ChangeEventsKeysArray.map(async (componentName: string) => {
125
346
  if (
@@ -135,7 +356,6 @@ export default (funcParams: funcParamsProps) => {
135
356
  }
136
357
  }
137
358
  }))
138
- funcParams.dynamicData?.setLoading(false);
139
359
  }
140
360
  },
141
361
  updateConfigApiBody: async function (paramValue, apiBody) {
@@ -173,9 +393,6 @@ export default (funcParams: funcParamsProps) => {
173
393
  functionParameters?.handleNext()
174
394
  }
175
395
  },
176
- backHandler:()=>{
177
- funcParams.store.navigate(-1)
178
- },
179
396
  onReset: async function (functionParameters) {
180
397
  const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[0];
181
398
  await this.callHandler("onReset", functionParameters)
@@ -197,17 +414,10 @@ export default (funcParams: funcParamsProps) => {
197
414
  }
198
415
  },
199
416
  downloadFile: downloadFile,
200
- download:doDownload,
417
+ download: doDownload,
418
+ ...funcParams.functionsProvider
201
419
  };
202
420
  };
203
421
 
204
422
 
205
423
 
206
-
207
-
208
-
209
-
210
-
211
-
212
-
213
-