impaktapps-ui-builder 0.0.410 → 0.0.412-a
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/dist/impaktapps-ui-builder.es.js +711 -884
- package/dist/impaktapps-ui-builder.es.js.map +1 -1
- package/dist/impaktapps-ui-builder.umd.js +14 -14
- package/dist/impaktapps-ui-builder.umd.js.map +1 -1
- package/dist/src/impaktapps-ui-builder/builder/build/buildBasicUiSchema.d.ts +4 -1
- package/dist/src/impaktapps-ui-builder/builder/build/buildDate.d.ts +1 -0
- package/dist/src/impaktapps-ui-builder/builder/build/buildInputSlider.d.ts +1 -0
- package/dist/src/impaktapps-ui-builder/builder/build/buildTreeMap.d.ts +1 -0
- package/dist/src/impaktapps-ui-builder/builder/build/uischema/buildPropertiesSection.d.ts +19 -0
- package/dist/src/impaktapps-ui-builder/builder/build/uischema/dateInputField.d.ts +19 -0
- package/dist/src/impaktapps-ui-builder/builder/build/uischema/lazyLoadingTable.d.ts +1 -0
- package/dist/src/impaktapps-ui-builder/builder/build/uischema/table.d.ts +1 -0
- package/dist/src/impaktapps-ui-builder/builder/build/uischema/wrapperSection.d.ts +1 -1
- package/dist/src/impaktapps-ui-builder/builder/elements/UiSchema/PageMaster/schema.d.ts +6 -0
- package/dist/src/impaktapps-ui-builder/builder/services/component.d.ts +2 -4
- package/dist/src/impaktapps-ui-builder/builder/services/event.d.ts +5 -3
- package/dist/src/impaktapps-ui-builder/builder/services/pageMaster.d.ts +9 -5
- package/dist/src/impaktapps-ui-builder/runtime/services/events.d.ts +7 -4
- package/dist/src/impaktapps-ui-builder/runtime/services/interface.d.ts +1 -0
- package/dist/src/impaktapps-ui-builder/runtime/services/service.d.ts +9 -7
- package/package.json +1 -1
- package/src/impaktapps-ui-builder/builder/build/buildBasicUiSchema.ts +9 -5
- package/src/impaktapps-ui-builder/builder/build/buildConfig.ts +11 -15
- package/src/impaktapps-ui-builder/builder/build/buildDate.ts +11 -1
- package/src/impaktapps-ui-builder/builder/build/buildInputSlider.ts +46 -0
- package/src/impaktapps-ui-builder/builder/build/buildLeaderboard.ts +8 -6
- package/src/impaktapps-ui-builder/builder/build/buildLineGraph.ts +6 -0
- package/src/impaktapps-ui-builder/builder/build/buildPieGraph.ts +22 -23
- package/src/impaktapps-ui-builder/builder/build/buildTabSection.ts +9 -2
- package/src/impaktapps-ui-builder/builder/build/buildTable.ts +1 -1
- package/src/impaktapps-ui-builder/builder/build/buildTreeMap.ts +58 -0
- package/src/impaktapps-ui-builder/builder/build/buildUiSchema.ts +54 -49
- package/src/impaktapps-ui-builder/builder/build/buildWrapperSection.ts +16 -11
- package/src/impaktapps-ui-builder/builder/build/uischema/buildPropertiesSection.ts +34 -8
- package/src/impaktapps-ui-builder/builder/build/uischema/card.ts +1 -1
- package/src/impaktapps-ui-builder/builder/build/uischema/coreSection.ts +19 -0
- package/src/impaktapps-ui-builder/builder/build/uischema/dateInputField.ts +20 -0
- package/src/impaktapps-ui-builder/builder/build/uischema/eventSection.ts +1 -1
- package/src/impaktapps-ui-builder/builder/build/uischema/graph.ts +1 -2
- package/src/impaktapps-ui-builder/builder/build/uischema/lazyLoadingTable.ts +1 -0
- package/src/impaktapps-ui-builder/builder/build/uischema/table.ts +1 -0
- package/src/impaktapps-ui-builder/builder/build/uischema/tableSection.ts +2 -4
- package/src/impaktapps-ui-builder/builder/build/uischema/wrapperSection.ts +1 -1
- package/src/impaktapps-ui-builder/builder/elements/UiSchema/Component/schema.ts +32 -17
- package/src/impaktapps-ui-builder/builder/elements/UiSchema/Component/uiSchema.ts +19 -213
- package/src/impaktapps-ui-builder/builder/elements/UiSchema/PageMaster/schema.ts +8 -1
- package/src/impaktapps-ui-builder/builder/elements/UiSchema/PageMaster/uiSchema.ts +67 -274
- package/src/impaktapps-ui-builder/builder/elements/UiSchema/event/schema.ts +2 -1
- package/src/impaktapps-ui-builder/builder/elements/UiSchema/event/uiSchema.ts +1 -104
- package/src/impaktapps-ui-builder/builder/services/component.ts +59 -74
- package/src/impaktapps-ui-builder/builder/services/event.ts +15 -13
- package/src/impaktapps-ui-builder/builder/services/pageMaster.ts +17 -26
- package/src/impaktapps-ui-builder/builder/services/utils.ts +1 -1
- package/src/impaktapps-ui-builder/runtime/services/downloadFile.ts +1 -1
- package/src/impaktapps-ui-builder/runtime/services/events.ts +147 -95
- package/src/impaktapps-ui-builder/runtime/services/interface.ts +2 -1
- package/src/impaktapps-ui-builder/runtime/services/service.ts +93 -50
|
@@ -1,102 +1,151 @@
|
|
|
1
1
|
import _, { cloneDeep } from "lodash";
|
|
2
2
|
import { handlersProps } from "./interface";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export const executeEvents = async (
|
|
6
|
-
params: handlersProps
|
|
7
|
-
) => {
|
|
3
|
+
export const executeEvents = (params: handlersProps) => {
|
|
8
4
|
let nextEvent = [];
|
|
9
5
|
let finalResponse = null;
|
|
6
|
+
|
|
7
|
+
if (params.config.isSync !== "Yes") {
|
|
8
|
+
return shouldEventExecute(params)
|
|
9
|
+
.then((shouldExecute) => {
|
|
10
|
+
if (!shouldExecute) {
|
|
11
|
+
throw new Error('onStart Event not allow to run Parent Events');
|
|
12
|
+
}
|
|
13
|
+
return executeEventsHandler(params);
|
|
14
|
+
})
|
|
15
|
+
.then((response) => {
|
|
16
|
+
finalResponse = response;
|
|
17
|
+
const SuccessEvent = params.config?.events.filter(e => e.eventType === "Success");
|
|
18
|
+
nextEvent = SuccessEvent;
|
|
19
|
+
})
|
|
20
|
+
.catch((err) => {
|
|
21
|
+
const FailEvent = params.config?.events?.filter(e => e.eventType === "Fail");
|
|
22
|
+
const setEvent = FailEvent?.length > 0 ? FailEvent : [];
|
|
23
|
+
nextEvent = setEvent;
|
|
24
|
+
})
|
|
25
|
+
.then(() => {
|
|
26
|
+
if (nextEvent?.length > 0) {
|
|
27
|
+
return nextEvent.reduce((chain, actionConfig) => {
|
|
28
|
+
return chain.then(() => executeEvents({ ...params, config: actionConfig, parentEventOutput: finalResponse }));
|
|
29
|
+
}, Promise.resolve());
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
.then(() => finalResponse)
|
|
33
|
+
}
|
|
34
|
+
const shouldExecute = shouldEventExecute(params);
|
|
35
|
+
if (!shouldExecute) {
|
|
36
|
+
return { response: undefined, events: undefined };
|
|
37
|
+
}
|
|
10
38
|
try {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
return { response: undefined, events: undefined };
|
|
14
|
-
}
|
|
15
|
-
const response = await executeEventsHandler(params)
|
|
16
|
-
finalResponse = response;
|
|
39
|
+
const eventsResponse = executeEventsHandler(params);
|
|
40
|
+
finalResponse = eventsResponse;
|
|
17
41
|
const SuccessEvent = params.config?.events.filter(e => e.eventType === "Success");
|
|
18
42
|
nextEvent = SuccessEvent;
|
|
19
|
-
} catch
|
|
20
|
-
const FailEvent = params.config?.events?.filter(e => e.eventType === "Fail")
|
|
21
|
-
const setEvent = FailEvent?.length > 0 ? FailEvent : []
|
|
43
|
+
} catch {
|
|
44
|
+
const FailEvent = params.config?.events?.filter(e => e.eventType === "Fail");
|
|
45
|
+
const setEvent = FailEvent?.length > 0 ? FailEvent : [];
|
|
22
46
|
nextEvent = setEvent;
|
|
23
47
|
}
|
|
24
48
|
if (nextEvent?.length > 0) {
|
|
25
49
|
for (const actionConfig of nextEvent) {
|
|
26
|
-
|
|
50
|
+
executeEvents({ ...params, config: actionConfig, parentEventOutput: finalResponse })
|
|
27
51
|
}
|
|
28
52
|
}
|
|
29
53
|
return finalResponse;
|
|
30
54
|
}
|
|
31
55
|
|
|
32
|
-
|
|
56
|
+
function executeEventsHandler(params: handlersProps) {
|
|
33
57
|
if (params.config.Handler === "api") {
|
|
34
|
-
return
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
else if (params.config.Handler === "
|
|
40
|
-
return
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
params.
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
else if (params.config.Handler === "
|
|
54
|
-
return params.store.functionParameters?.
|
|
55
|
-
}
|
|
56
|
-
else if (params.config.Handler === "onResetHandler") {
|
|
57
|
-
return params.store.functionParameters?.handleReset()
|
|
58
|
+
return executeApiRequest(params);
|
|
59
|
+
} else if (params.config.Handler === "inBuiltFunction") {
|
|
60
|
+
return executeInBuiltFunctionHandler(params);
|
|
61
|
+
} else if (params.config.Handler === "custom") {
|
|
62
|
+
return executeCustomHandler(params);
|
|
63
|
+
} else if (params.config.Handler === "refresh") {
|
|
64
|
+
return executeRefreshHandler(params);
|
|
65
|
+
} else if (params.config.Handler === "mergeFormdata") {
|
|
66
|
+
return mergeFormdata(
|
|
67
|
+
params.parentEventOutput,
|
|
68
|
+
params.componentName,
|
|
69
|
+
params.config,
|
|
70
|
+
params.store,
|
|
71
|
+
params.service
|
|
72
|
+
);
|
|
73
|
+
} else if (params.config.Handler === "onBackHandler") {
|
|
74
|
+
return params.store.functionParameters?.handleBack();
|
|
75
|
+
} else if (params.config.Handler === "onNextHandler") {
|
|
76
|
+
return params.store.functionParameters?.handleNext();
|
|
77
|
+
} else if (params.config.Handler === "onResetHandler") {
|
|
78
|
+
return params.store.functionParameters?.handleReset();
|
|
58
79
|
}
|
|
59
80
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
81
|
+
|
|
82
|
+
export function getRefreshElements(eventConfig: any, eventGropus: any) {
|
|
83
|
+
let result: string[] = [];
|
|
84
|
+
if (eventConfig?.refreshElements?.length > 0) {
|
|
85
|
+
result = eventConfig.refreshElements.map((e) => {
|
|
86
|
+
return e.value
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
} else {
|
|
90
|
+
if (eventGropus?.onLoad) {
|
|
91
|
+
result = Object.keys(eventGropus?.onLoad)
|
|
92
|
+
result.push(result[0]);
|
|
65
93
|
}
|
|
66
94
|
}
|
|
95
|
+
console.log(result);
|
|
96
|
+
return result;
|
|
67
97
|
}
|
|
68
|
-
|
|
98
|
+
export function executeRefreshHandler(params: handlersProps) {
|
|
99
|
+
const compToRefresh: string[] = getRefreshElements(params.config, params.eventGroups);
|
|
100
|
+
|
|
101
|
+
return Promise.all(compToRefresh.map(componentName => {
|
|
102
|
+
return Promise.all(params.eventGroups.onLoad[componentName].map(compEventConfig => {
|
|
103
|
+
return executeEvents({ ...params, config: compEventConfig, componentName });
|
|
104
|
+
}));
|
|
105
|
+
})).then(() => {
|
|
106
|
+
params.store.setFormdata(params.store.ctx.core.data)
|
|
107
|
+
})
|
|
108
|
+
};
|
|
109
|
+
export function executeApiRequest(params: any) {
|
|
69
110
|
const initialBody = { ...params.userValue?.payload };
|
|
70
111
|
const initialHeaders = {
|
|
71
112
|
"X-Requested-With": "XMLHttpRequest",
|
|
72
113
|
"Access-Control-Allow-Origin": "*"
|
|
73
114
|
};
|
|
74
|
-
const { body, headers } = await buildApiPayload(params.config, initialBody, initialHeaders, params.store, params.dynamicData, params.userValue, params.service)
|
|
75
115
|
|
|
76
|
-
const
|
|
116
|
+
const payloadApi = buildApiPayload(params.config, initialBody, initialHeaders, params.store, params.dynamicData, params.userValue, params.service)
|
|
117
|
+
return params.service[params.config.method](
|
|
77
118
|
params.config.path,
|
|
78
|
-
body,
|
|
79
|
-
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
}
|
|
119
|
+
payloadApi.body,
|
|
120
|
+
{ headers: payloadApi.headers }
|
|
121
|
+
).then((response) => {
|
|
122
|
+
return response;
|
|
123
|
+
});
|
|
124
|
+
};
|
|
83
125
|
|
|
84
|
-
|
|
126
|
+
function executeInBuiltFunctionHandler(params: handlersProps) {
|
|
85
127
|
let parameter = {};
|
|
86
128
|
if (params.config.funcParametersCode) {
|
|
87
129
|
const makeFunc = eval(params.config.funcParametersCode)
|
|
88
130
|
parameter = makeFunc(params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service);
|
|
131
|
+
params.serviceHolder[params.config.inBuiltFunctionType](parameter, params.service)
|
|
132
|
+
} else {
|
|
133
|
+
params.serviceHolder[params.config.inBuiltFunctionType](params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service)
|
|
89
134
|
}
|
|
90
|
-
params.serviceHolder[params.config.inBuiltFunctionType](parameter)
|
|
91
135
|
}
|
|
92
136
|
|
|
93
|
-
|
|
137
|
+
function executeCustomHandler(params: handlersProps) {
|
|
94
138
|
const makeFunc = eval(params.config.eventCode)
|
|
95
|
-
|
|
96
|
-
|
|
139
|
+
if (params.config.isSync !== "Yes") {
|
|
140
|
+
return makeFunc(params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service, params.componentName).then((res) => res)
|
|
141
|
+
} else {
|
|
142
|
+
const response = makeFunc(params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service, params.componentName)
|
|
143
|
+
return response;
|
|
144
|
+
}
|
|
145
|
+
|
|
97
146
|
}
|
|
98
147
|
|
|
99
|
-
|
|
148
|
+
function mergeFormdata(handlerResponse: any, componentName: string, eventConfig: any, store: any, service: any) {
|
|
100
149
|
if (eventConfig.type === "Select" && !(_.isEmpty(handlerResponse?.data) && handlerResponse?.data)) {
|
|
101
150
|
store.setSchema((pre) => {
|
|
102
151
|
return {
|
|
@@ -126,19 +175,22 @@ async function mergeFormdata(handlerResponse: any, componentName: string, eventC
|
|
|
126
175
|
}
|
|
127
176
|
else if (eventConfig.type === "page") {
|
|
128
177
|
if (!(_.isEmpty(handlerResponse?.data) && handlerResponse?.data)) {
|
|
129
|
-
store.
|
|
178
|
+
store.ctx.core.data = { ...store.ctx.core.data, ...handlerResponse.data }
|
|
179
|
+
// store.setFormdata((pre: any) => { return { ...pre, ...handlerResponse?.data } })
|
|
130
180
|
}
|
|
131
181
|
}
|
|
132
182
|
else {
|
|
133
183
|
if (handlerResponse) {
|
|
134
|
-
store.
|
|
135
|
-
|
|
184
|
+
store.ctx.core.data[componentName] =
|
|
185
|
+
eventConfig.lazyLoading ?
|
|
186
|
+
handlerResponse?.data?.data : handlerResponse.data
|
|
187
|
+
// store.setFormdata((pre) => { return { ...pre, [componentName]: eventConfig.lazyLoading ? handlerResponse?.data?.data : handlerResponse.data } });
|
|
136
188
|
}
|
|
137
189
|
}
|
|
138
190
|
}
|
|
139
191
|
|
|
140
192
|
const buildBodyFormat = (body: any[], formData: any, userValue: any) => {
|
|
141
|
-
|
|
193
|
+
let finalBody = { ...userValue?.payload };
|
|
142
194
|
body.map((elem) => {
|
|
143
195
|
if (typeof elem?.value !== "string") {
|
|
144
196
|
finalBody[elem.key] = elem.value;
|
|
@@ -150,7 +202,12 @@ const buildBodyFormat = (body: any[], formData: any, userValue: any) => {
|
|
|
150
202
|
else if (elem?.value?.startsWith("$")) {
|
|
151
203
|
const finalpath = elem.value.substring(1);
|
|
152
204
|
finalBody[elem.key] = _.get(formData, finalpath);;
|
|
153
|
-
} else {
|
|
205
|
+
} else if (elem?.value === "*" && elem?.key === "*") {
|
|
206
|
+
finalBody = { ...finalBody, ...formData };
|
|
207
|
+
} else if (elem?.value === "*") {
|
|
208
|
+
finalBody[elem.key] = formData;
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
154
211
|
finalBody[elem.key] = elem.value;
|
|
155
212
|
}
|
|
156
213
|
}
|
|
@@ -169,51 +226,46 @@ const buildHeadersFormat = (headers: any[]) => {
|
|
|
169
226
|
return headerObj;
|
|
170
227
|
}
|
|
171
228
|
|
|
172
|
-
|
|
229
|
+
export function shouldEventExecute(params: handlersProps) {
|
|
173
230
|
const startEvent = params.config?.events?.filter(e => e.eventType === "onStart");
|
|
231
|
+
|
|
174
232
|
if (startEvent?.length > 0) {
|
|
175
|
-
|
|
176
|
-
|
|
233
|
+
if (startEvent[0]?.isSync !== "Yes") {
|
|
234
|
+
return executeEventsHandler({ ...params, config: startEvent[0] }).then((response) => {
|
|
235
|
+
return response;
|
|
236
|
+
});
|
|
237
|
+
} else {
|
|
238
|
+
return executeEventsHandler({ ...params, config: startEvent[0] })
|
|
239
|
+
}
|
|
177
240
|
} else {
|
|
178
|
-
|
|
241
|
+
if (params.config.isSync !== "Yes") {
|
|
242
|
+
return Promise.resolve(true)
|
|
243
|
+
} else {
|
|
244
|
+
return true
|
|
245
|
+
}
|
|
179
246
|
}
|
|
180
247
|
}
|
|
181
248
|
|
|
182
|
-
export async function buildApiPayload(compConfig: any, body: any, headers: any, store: any, dynamicData: any, userValue: any, service) {
|
|
183
|
-
if (compConfig?.headers) {
|
|
184
|
-
headers = buildHeadersFormat(compConfig.headers)
|
|
185
249
|
|
|
250
|
+
export function buildApiPayload(compConfig: any, body: any, headers: any, store: any, dynamicData: any, userValue: any, service) {
|
|
251
|
+
if (compConfig?.headers) {
|
|
252
|
+
headers = buildHeadersFormat(compConfig.headers);
|
|
186
253
|
}
|
|
254
|
+
|
|
187
255
|
if (compConfig.body) {
|
|
188
256
|
body = { ...buildBodyFormat(compConfig.body, store.newData || store?.ctx?.core?.data || store.formData, userValue) };
|
|
189
257
|
}
|
|
190
|
-
if (compConfig.apiBody) {
|
|
191
|
-
const makeFunc = eval(compConfig.apiBody);
|
|
192
|
-
const data = await makeFunc(store, dynamicData, userValue, body);
|
|
193
|
-
body = data
|
|
194
|
-
}
|
|
195
|
-
return { body, headers };
|
|
196
|
-
}
|
|
197
258
|
|
|
198
|
-
|
|
199
|
-
let result: string[] = [];
|
|
200
|
-
if (eventConfig?.refreshElements?.length > 0) {
|
|
201
|
-
result = eventConfig.refreshElements.map((e) => {
|
|
202
|
-
return e.value
|
|
203
|
-
})
|
|
259
|
+
const promiseChain = { body, headers };
|
|
204
260
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
261
|
+
|
|
262
|
+
if (compConfig.apiBody) {
|
|
263
|
+
const makeFunc = eval(compConfig.apiBody);
|
|
264
|
+
return { body: makeFunc(store, dynamicData, userValue, promiseChain.body), headers: promiseChain.headers };
|
|
210
265
|
}
|
|
211
|
-
|
|
212
|
-
return result;
|
|
266
|
+
return promiseChain;
|
|
213
267
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
function asyncOperation() {
|
|
268
|
+
export function asyncOperation() {
|
|
217
269
|
return new Promise((resolve, reject) => {
|
|
218
270
|
setTimeout(() => {
|
|
219
271
|
const success = true;
|
|
@@ -223,4 +275,4 @@ function asyncOperation() {
|
|
|
223
275
|
}
|
|
224
276
|
}, 50);
|
|
225
277
|
});
|
|
226
|
-
}
|
|
278
|
+
}
|
|
@@ -13,6 +13,15 @@ const notifyUiSchema = {
|
|
|
13
13
|
layout: 6,
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
+
interface funcParamsProps {
|
|
17
|
+
store: any,
|
|
18
|
+
dynamicData: any,
|
|
19
|
+
service: any,
|
|
20
|
+
userValue: any,
|
|
21
|
+
pageDataProvider: any,
|
|
22
|
+
functionsProvider?: Record<string, any>
|
|
23
|
+
}
|
|
24
|
+
let pageData: any = false;
|
|
16
25
|
export const extractEvents = (eventConfig: any) => {
|
|
17
26
|
function extractsConfigEvents(eventConfigObj: any) {
|
|
18
27
|
if (eventConfigObj.events) {
|
|
@@ -30,9 +39,15 @@ export const extractEvents = (eventConfig: any) => {
|
|
|
30
39
|
return elem.eventType === "Success"
|
|
31
40
|
})
|
|
32
41
|
if (!(!!SuccessEvent) && event.eventType === "onLoad") {
|
|
42
|
+
if (!(!!event.events)) {
|
|
43
|
+
event.events = [];
|
|
44
|
+
}
|
|
33
45
|
event.events.push({ Handler: "mergeFormdata", eventType: "Success", type: compType, lazyLoading: eventConfig.lazyLoading === "YES" ? true : false })
|
|
34
46
|
}
|
|
35
|
-
if (!(!!SuccessEvent) && (event.eventType === "onBack" || event.eventType === "onNext"|| event.eventType === "onReset")) {
|
|
47
|
+
if (!(!!SuccessEvent) && (event.eventType === "onBack" || event.eventType === "onNext" || event.eventType === "onReset")) {
|
|
48
|
+
if (!(!!event.events)) {
|
|
49
|
+
event.events = [];
|
|
50
|
+
}
|
|
36
51
|
event.events.push({ Handler: `${event.eventType}Handler`, eventType: "Success", type: compType, lazyLoading: eventConfig.lazyLoading === "YES" ? true : false })
|
|
37
52
|
}
|
|
38
53
|
eventGroups[event.eventType][eventConfigObj.name].push({ ...event, type: compType })
|
|
@@ -46,58 +61,91 @@ export const extractEvents = (eventConfig: any) => {
|
|
|
46
61
|
}
|
|
47
62
|
return eventGroups;
|
|
48
63
|
};
|
|
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
64
|
export default (funcParams: funcParamsProps) => {
|
|
60
65
|
eventGroups = {}
|
|
61
|
-
|
|
66
|
+
if (pageData) {
|
|
67
|
+
if ((!isEmpty(pageData)) && typeof pageData === "object") {
|
|
68
|
+
eventGroups = extractEvents(pageData?.config)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
62
71
|
let executeEventsParameters: handlersProps = {
|
|
63
72
|
config: {}, componentName: "",
|
|
64
73
|
store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
|
|
65
|
-
serviceHolder: { downloadFile,download:doDownload }, eventGroups
|
|
74
|
+
serviceHolder: { downloadFile, download: doDownload, ...funcParams.functionsProvider }, eventGroups,
|
|
75
|
+
functionsProvider: funcParams.functionsProvider,
|
|
66
76
|
};
|
|
67
77
|
return {
|
|
68
78
|
setPage: async function () {
|
|
69
|
-
funcParams.store.setFormdata({})
|
|
79
|
+
funcParams.store.setFormdata({})
|
|
80
|
+
|
|
81
|
+
const pageBasicDetailString = localStorage.getItem("pagemasterMetaData")
|
|
82
|
+
if (pageBasicDetailString) {
|
|
83
|
+
pageData = JSON.parse(pageBasicDetailString)
|
|
84
|
+
} else {
|
|
85
|
+
pageData = await funcParams.pageDataProvider();
|
|
86
|
+
localStorage.setItem("pagemasterMetaData", JSON.stringify({
|
|
87
|
+
schema: pageData?.schema,
|
|
88
|
+
uiSchema: pageData?.uiSchema, config: pageData?.config
|
|
89
|
+
}))
|
|
90
|
+
}
|
|
91
|
+
const config = pageData?.config;
|
|
92
|
+
const uiSchema = pageData?.uiSchema;
|
|
93
|
+
const schema = pageData?.schema ?? { type: "object", properties: {} };
|
|
94
|
+
eventGroups = {}
|
|
95
|
+
eventGroups = extractEvents(config);
|
|
70
96
|
executeEventsParameters = {
|
|
71
97
|
config: {}, componentName: "",
|
|
72
98
|
store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
|
|
99
|
+
functionsProvider: funcParams.functionsProvider,
|
|
73
100
|
serviceHolder: this, eventGroups
|
|
74
101
|
}
|
|
102
|
+
await executeRefreshHandler({
|
|
103
|
+
config: {}, componentName: "",
|
|
104
|
+
store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
|
|
105
|
+
serviceHolder: this, eventGroups
|
|
106
|
+
})
|
|
75
107
|
funcParams.store.setSchema(
|
|
76
108
|
(pre: any) => {
|
|
77
109
|
return {
|
|
78
|
-
...
|
|
79
|
-
{ ...
|
|
110
|
+
...schema, properties:
|
|
111
|
+
{ ...schema.properties, ...pre.properties, }
|
|
80
112
|
}
|
|
81
113
|
}
|
|
82
114
|
)
|
|
83
|
-
|
|
84
|
-
funcParams.store.setUiSchema(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
115
|
+
uiSchema.elements.push(notifyUiSchema);
|
|
116
|
+
funcParams.store.setUiSchema(uiSchema);
|
|
117
|
+
|
|
118
|
+
},
|
|
119
|
+
onCellRenderer: (cellParams) => {
|
|
120
|
+
if (eventGroups.onCellRenderer) {
|
|
121
|
+
let finalResponse = {};
|
|
122
|
+
const path = funcParams.dynamicData?.tableButtonPath || funcParams?.dynamicData?.path?.split(".")[0];
|
|
123
|
+
for (const eventConfig of eventGroups?.onCellRenderer[path]) {
|
|
124
|
+
executeEventsParameters.store.functionParameters = cellParams
|
|
125
|
+
finalResponse = executeEvents({
|
|
126
|
+
...executeEventsParameters,
|
|
127
|
+
config: eventConfig,
|
|
128
|
+
componentName: path
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
return finalResponse
|
|
132
|
+
}
|
|
133
|
+
return {}
|
|
134
|
+
},
|
|
135
|
+
onClick: function () {
|
|
136
|
+
this.callHandler("onClick")
|
|
137
|
+
},
|
|
138
|
+
onMount: function () {
|
|
139
|
+
this.callHandler("onMount")
|
|
90
140
|
},
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
await this.callHandler("onClick")
|
|
94
|
-
funcParams.dynamicData?.setLoading(false);
|
|
141
|
+
onFileDownload: function () {
|
|
142
|
+
this.callHandler("onDownload")
|
|
95
143
|
},
|
|
96
|
-
|
|
97
|
-
|
|
144
|
+
onFileUpload: function () {
|
|
145
|
+
this.callHandler("onUpload")
|
|
98
146
|
},
|
|
99
|
-
|
|
100
|
-
|
|
147
|
+
backHandler: function () {
|
|
148
|
+
funcParams.store.navigate(-1)
|
|
101
149
|
},
|
|
102
150
|
onPaginationChange: async function (paginationValues) {
|
|
103
151
|
const apiBody = [
|
|
@@ -116,12 +164,12 @@ export default (funcParams: funcParamsProps) => {
|
|
|
116
164
|
{ key: "searchValue", value: param.serachValue },
|
|
117
165
|
{ key: "currentValue", value: param.currentValue }
|
|
118
166
|
]
|
|
119
|
-
|
|
167
|
+
const response = await this.updateConfigApiBody(param, apiBody);
|
|
168
|
+
return response?.data;
|
|
120
169
|
}
|
|
121
170
|
},
|
|
122
171
|
onChange: async function () {
|
|
123
172
|
if (eventGroups.onChange) {
|
|
124
|
-
funcParams.dynamicData?.setLoading(true);
|
|
125
173
|
const ChangeEventsKeysArray = Object.keys(eventGroups.onChange);
|
|
126
174
|
Promise.all(ChangeEventsKeysArray.map(async (componentName: string) => {
|
|
127
175
|
if (
|
|
@@ -136,8 +184,9 @@ export default (funcParams: funcParamsProps) => {
|
|
|
136
184
|
})
|
|
137
185
|
}
|
|
138
186
|
}
|
|
139
|
-
}))
|
|
140
|
-
|
|
187
|
+
})).then((res) => {
|
|
188
|
+
funcParams.store.setFormdata(funcParams.store.ctx.core.data)
|
|
189
|
+
})
|
|
141
190
|
}
|
|
142
191
|
},
|
|
143
192
|
updateConfigApiBody: async function (paramValue, apiBody) {
|
|
@@ -185,28 +234,22 @@ export default (funcParams: funcParamsProps) => {
|
|
|
185
234
|
callHandler: async function (eventType: string, functionParameters?: any) {
|
|
186
235
|
const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[0];
|
|
187
236
|
if (eventGroups?.[eventType]?.[path] !== undefined) {
|
|
188
|
-
|
|
237
|
+
Promise.all(eventGroups?.[eventType]?.[path].map((eventConfig) => {
|
|
189
238
|
executeEventsParameters.store.functionParameters = functionParameters
|
|
190
|
-
|
|
239
|
+
executeEvents({
|
|
191
240
|
...executeEventsParameters,
|
|
192
241
|
config: eventConfig,
|
|
193
242
|
componentName: path
|
|
194
243
|
})
|
|
195
|
-
}
|
|
244
|
+
})).then((res) => {
|
|
245
|
+
funcParams.store.setFormdata(funcParams.store.ctx.core.data)
|
|
246
|
+
})
|
|
247
|
+
|
|
196
248
|
}
|
|
197
249
|
},
|
|
250
|
+
|
|
198
251
|
downloadFile: downloadFile,
|
|
199
|
-
download:doDownload,
|
|
252
|
+
download: doDownload,
|
|
253
|
+
...funcParams.functionsProvider
|
|
200
254
|
};
|
|
201
255
|
};
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|