impaktapps-ui-builder 0.0.382-alpha.322 → 0.0.382-alpha.324

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.382-alpha.322",
3
+ "version": "0.0.382-alpha.324",
4
4
  "scripts": {
5
5
  "dev": "vite",
6
6
  "build": "tsc && vite build",
@@ -1,4 +1,3 @@
1
- import React, { useState, useEffect } from "react";
2
1
  import _, { isEmpty } from "lodash";
3
2
  import { doDownload, downloadFile } from "./downloadFile";
4
3
  import { executeEvents, executeRefreshHandler } from "./events";
@@ -28,41 +27,20 @@ export const extractEvents = (eventConfig: any) => {
28
27
  eventGroups[event.eventType][eventConfigObj.name] = [];
29
28
  }
30
29
  const SuccessEvent = event?.events?.find((elem) => {
31
- return elem.eventType === "Success";
32
- });
33
- if (
34
- !SuccessEvent &&
35
- event.eventType === "onLoad"
36
- ) {
37
- event.events.push({
38
- Handler: "mergeFormdata",
39
- eventType: "Success",
40
- type: compType,
41
- lazyLoading: eventConfig.lazyLoading === "YES" ? true : false,
42
- });
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 })
43
34
  }
44
- if (
45
- !SuccessEvent &&
46
- (event.eventType === "onBack" ||
47
- event.eventType === "onNext" ||
48
- event.eventType === "onReset")
49
- ) {
50
- event.events.push({
51
- Handler: `${event.eventType}Handler`,
52
- eventType: "Success",
53
- type: compType,
54
- lazyLoading: eventConfig.lazyLoading === "YES" ? true : false,
55
- });
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 })
56
37
  }
57
- eventGroups[event.eventType][eventConfigObj.name].push({
58
- ...event,
59
- type: compType,
60
- });
38
+ eventGroups[event.eventType][eventConfigObj.name].push({ ...event, type: compType })
61
39
  });
62
40
  }
63
41
  }
64
42
 
65
- extractsConfigEvents(eventConfig);
43
+ extractsConfigEvents(eventConfig)
66
44
  if (eventConfig?.elements) {
67
45
  eventConfig.elements.forEach(extractEvents);
68
46
  }
@@ -70,15 +48,14 @@ export const extractEvents = (eventConfig: any) => {
70
48
  };
71
49
 
72
50
  interface funcParamsProps {
73
- store: any;
74
- dynamicData: any;
75
- config: any;
76
- uiSchema: any;
77
- schema: any;
78
- service: any;
79
- userValue: any;
51
+ store: any,
52
+ dynamicData: any,
53
+ config: any,
54
+ uiSchema: any,
55
+ schema: any,
56
+ service: any,
57
+ userValue: any,
80
58
  }
81
-
82
59
  export default (funcParams: funcParamsProps) => {
83
60
  eventGroups = {}
84
61
  eventGroups = extractEvents(funcParams.config)
@@ -87,44 +64,51 @@ export default (funcParams: funcParamsProps) => {
87
64
  store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
88
65
  serviceHolder: { downloadFile,download:doDownload }, eventGroups
89
66
  };
90
- const [isReady, setIsReady] = useState(false);
91
-
92
- useEffect(() => {
93
- if (isReady) {
94
- executeRefreshHandler({
95
- config: {},
96
- componentName: "",
97
- store: funcParams.store,
98
- dynamicData: funcParams.dynamicData,
99
- userValue: funcParams.userValue,
100
- service: funcParams.service,
101
- serviceHolder: this,
102
- eventGroups,
103
- });
104
- }
105
- }, [funcParams.store.formData]);
106
-
107
- const setPage = async function () {
108
- funcParams.store.setFormdata({});
109
-
110
-
111
- funcParams.store.setSchema(funcParams.schema);
112
-
113
- funcParams.uiSchema.elements.push(notifyUiSchema);
114
- funcParams.store.setUiSchema(funcParams.uiSchema);
115
- setIsReady(true);
116
- };
117
-
118
67
  return {
119
- setPage,
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
+ funcParams.store.setFormdata({});
86
+ setTimeout(() => {
87
+ executeRefreshHandler({
88
+ config: {},
89
+ componentName: "",
90
+ store: funcParams.store,
91
+ dynamicData: funcParams.dynamicData,
92
+ userValue: funcParams.userValue,
93
+ service: funcParams.service,
94
+ serviceHolder: this,
95
+ eventGroups,
96
+ });
97
+ }, 5000);
98
+ // await executeRefreshHandler({
99
+ // config: {}, componentName: "",
100
+ // store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
101
+ // serviceHolder: this, eventGroups
102
+ // })
103
+ },
120
104
  onClick: async function () {
121
- await this.callHandler("onClick");
105
+ await this.callHandler("onClick")
122
106
  },
123
107
  onFileDownload: async function () {
124
- await this.callHandler("onDownload");
108
+ await this.callHandler("onDownload")
125
109
  },
126
110
  onFileUpload: async function () {
127
- await this.callHandler("onUpload");
111
+ await this.callHandler("onUpload")
128
112
  },
129
113
  onPaginationChange: async function (paginationValues) {
130
114
  const apiBody = [
@@ -132,8 +116,8 @@ export default (funcParams: funcParamsProps) => {
132
116
  { key: "pageIndex", value: paginationValues.pagination.pageIndex },
133
117
  { key: "sorting", value: paginationValues.sorting || [] },
134
118
  { key: "filters", value: paginationValues.columnFilters || [] },
135
- { key: "globalFilter", value: paginationValues.globalFilter ?? "" },
136
- ];
119
+ { key: "globalFilter", value: paginationValues.globalFilter ?? '' }
120
+ ]
137
121
  const response = await this.updateConfigApiBody(paginationValues, apiBody);
138
122
  return response?.data;
139
123
  },
@@ -141,96 +125,97 @@ export default (funcParams: funcParamsProps) => {
141
125
  if (param.serachValue !== "" && param.serachValue !== undefined) {
142
126
  const apiBody = [
143
127
  { key: "searchValue", value: param.serachValue },
144
- { key: "currentValue", value: param.currentValue },
145
- ];
146
- return await this.updateConfigApiBody(param, apiBody);
128
+ { key: "currentValue", value: param.currentValue }
129
+ ]
130
+ return await this.updateConfigApiBody(param, apiBody)
147
131
  }
148
132
  },
149
133
  onChange: async function () {
150
134
  if (eventGroups.onChange) {
151
135
  const ChangeEventsKeysArray = Object.keys(eventGroups.onChange);
152
- Promise.all(
153
- ChangeEventsKeysArray.map(async (componentName: string) => {
154
- if (
155
- funcParams.store?.formData[componentName] !==
156
- funcParams.store.newData[componentName] &&
157
- funcParams.store?.newData[componentName] !== undefined
158
- ) {
159
- for (const eventConfig of eventGroups.onChange[componentName]) {
160
- await executeEvents({
161
- ...executeEventsParameters,
162
- config: eventConfig,
163
- componentName,
164
- });
165
- }
136
+ Promise.all(ChangeEventsKeysArray.map(async (componentName: string) => {
137
+ if (
138
+ funcParams.store?.formData[componentName] !== funcParams.store.newData[componentName] &&
139
+ funcParams.store?.newData[componentName] !== undefined
140
+ ) {
141
+ for (const eventConfig of eventGroups.onChange[componentName]) {
142
+ await executeEvents({
143
+ ...executeEventsParameters,
144
+ config: eventConfig,
145
+ componentName
146
+ })
166
147
  }
167
- })
168
- );
148
+ }
149
+ }))
169
150
  }
170
151
  },
171
152
  updateConfigApiBody: async function (paramValue, apiBody) {
172
153
  let LastCallResponse = undefined;
173
154
  for (const eventConfig of eventGroups?.onLoad[paramValue.path]) {
174
155
  if (eventConfig.body) {
175
- eventConfig.body = [...eventConfig.body, ...apiBody];
176
- } else {
177
- eventConfig.body = apiBody;
178
- }
156
+ eventConfig.body = [
157
+ ...eventConfig.body,
158
+ ...apiBody
159
+ ]
160
+ } else { eventConfig.body = apiBody; };
179
161
  const responseEvent = eventConfig?.events?.filter((elem) => {
180
- return elem.Handler !== "mergeFormdata";
181
- });
182
- eventConfig.events = responseEvent ?? [];
162
+ return elem.Handler !== "mergeFormdata"
163
+ })
164
+ eventConfig.events = responseEvent ?? []
183
165
  LastCallResponse = await executeEvents({
184
166
  ...executeEventsParameters,
185
167
  config: eventConfig,
186
- componentName: paramValue.path,
187
- });
168
+ componentName: paramValue.path
169
+ })
188
170
  }
189
- return LastCallResponse;
171
+ return LastCallResponse
190
172
  },
191
173
  onBack: async function (functionParameters) {
192
- const path =
193
- funcParams.dynamicData?.tableButtonPath ||
194
- funcParams.dynamicData.path.split(".")[0];
195
- await this.callHandler("onBack", functionParameters);
174
+ const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[0];
175
+ await this.callHandler("onBack", functionParameters)
196
176
  if (eventGroups?.["onBack"]?.[path] === undefined) {
197
- functionParameters?.handleBack();
177
+ functionParameters?.handleBack()
198
178
  }
199
179
  },
200
180
  onNext: async function (functionParameters) {
201
- const path =
202
- funcParams.dynamicData?.tableButtonPath ||
203
- funcParams.dynamicData.path.split(".")[0];
204
- await this.callHandler("onNext", functionParameters);
181
+ const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[0];
182
+ await this.callHandler("onNext", functionParameters)
205
183
  if (eventGroups?.["onNext"]?.[path] === undefined) {
206
- functionParameters?.handleNext();
184
+ functionParameters?.handleNext()
207
185
  }
208
186
  },
209
187
  onReset: async function (functionParameters) {
210
- const path =
211
- funcParams.dynamicData?.tableButtonPath ||
212
- funcParams.dynamicData.path.split(".")[0];
213
- await this.callHandler("onReset", functionParameters);
188
+ const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[0];
189
+ await this.callHandler("onReset", functionParameters)
214
190
  if (eventGroups?.["onReset"]?.[path] === undefined) {
215
- functionParameters?.handleReset();
191
+ functionParameters?.handleReset()
216
192
  }
217
193
  },
218
194
  callHandler: async function (eventType: string, functionParameters?: any) {
219
- const path =
220
- funcParams.dynamicData?.tableButtonPath ||
221
- funcParams.dynamicData.path.split(".")[0];
195
+ const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[0];
222
196
  if (eventGroups?.[eventType]?.[path] !== undefined) {
223
197
  for (const eventConfig of eventGroups?.[eventType]?.[path]) {
224
- executeEventsParameters.store.functionParameters = functionParameters;
198
+ executeEventsParameters.store.functionParameters = functionParameters
225
199
  await executeEvents({
226
200
  ...executeEventsParameters,
227
201
  config: eventConfig,
228
- componentName: path,
229
- });
202
+ componentName: path
203
+ })
230
204
  }
231
205
  }
232
206
  },
233
207
  downloadFile: downloadFile,
234
- download: doDownload,
208
+ download:doDownload,
235
209
  };
236
210
  };
211
+
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+
221
+