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