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