impaktapps-ui-builder 0.0.409-j → 0.0.409-k
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 +277 -363
- package/dist/impaktapps-ui-builder.es.js.map +1 -1
- package/dist/impaktapps-ui-builder.umd.js +12 -12
- package/dist/impaktapps-ui-builder.umd.js.map +1 -1
- package/dist/src/impaktapps-ui-builder/runtime/services/events.d.ts +6 -7
- package/dist/src/impaktapps-ui-builder/runtime/services/service.d.ts +7 -8
- package/package.json +1 -1
- package/src/impaktapps-ui-builder/builder/build/buildUiSchema.ts +47 -1
- package/src/impaktapps-ui-builder/builder/services/component.ts +54 -54
- package/src/impaktapps-ui-builder/runtime/services/events.ts +103 -135
- package/src/impaktapps-ui-builder/runtime/services/service.ts +39 -88
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { handlersProps } from "./interface";
|
|
2
|
-
export declare const executeEvents: (params: handlersProps) => any
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function executeApiRequest(params: any): any;
|
|
6
|
-
export declare function shouldEventExecute(params: handlersProps): any;
|
|
7
|
-
export declare function buildApiPayload(compConfig: any, body: any, headers: any, store: any, dynamicData: any, userValue: any, service: any): {
|
|
2
|
+
export declare const executeEvents: (params: handlersProps) => Promise<any>;
|
|
3
|
+
export declare function executeRefreshHandler(params: handlersProps): Promise<void>;
|
|
4
|
+
export declare function buildApiPayload(compConfig: any, body: any, headers: any, store: any, dynamicData: any, userValue: any, service: any): Promise<{
|
|
8
5
|
body: any;
|
|
9
6
|
headers: any;
|
|
10
|
-
}
|
|
7
|
+
}>;
|
|
8
|
+
export declare function getRefreshElements(eventConfig: any, eventGropus: any): string[];
|
|
9
|
+
export declare function asyncOperation(): Promise<unknown>;
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
+
export declare const extractEvents: (eventConfig: any) => any;
|
|
1
2
|
interface funcParamsProps {
|
|
2
3
|
store: any;
|
|
3
4
|
dynamicData: any;
|
|
5
|
+
config: any;
|
|
6
|
+
uiSchema: any;
|
|
7
|
+
schema: any;
|
|
4
8
|
service: any;
|
|
5
9
|
userValue: any;
|
|
6
|
-
functionsProvider?: Record<string, any>;
|
|
7
10
|
}
|
|
8
|
-
export declare const extractEvents: (eventConfig: any) => any;
|
|
9
11
|
declare const _default: (funcParams: funcParamsProps) => {
|
|
10
12
|
setPage: () => Promise<void>;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
onFileDownload: () => void;
|
|
15
|
-
onFileUpload: () => void;
|
|
16
|
-
backHandler: () => void;
|
|
13
|
+
onClick: () => Promise<void>;
|
|
14
|
+
onFileDownload: () => Promise<void>;
|
|
15
|
+
onFileUpload: () => Promise<void>;
|
|
17
16
|
onPaginationChange: (paginationValues: any) => Promise<any>;
|
|
18
17
|
getSelectOptions: (param: any) => Promise<any>;
|
|
19
18
|
onChange: () => Promise<void>;
|
package/package.json
CHANGED
|
@@ -316,7 +316,53 @@ const buildUiSchema = (config: any) => {
|
|
|
316
316
|
sizeMap[e.keyName] = e.value
|
|
317
317
|
});
|
|
318
318
|
}
|
|
319
|
-
|
|
319
|
+
function nodeProvider(element) {
|
|
320
|
+
if (element.type) {
|
|
321
|
+
return {
|
|
322
|
+
accessorKey: element.name,
|
|
323
|
+
type: element.columnFormat,
|
|
324
|
+
header: element.label || element.name,
|
|
325
|
+
size: sizeMap[element.name] || 180,
|
|
326
|
+
widget: buildUiSchema(element)
|
|
327
|
+
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
return {
|
|
331
|
+
accessorKey: element.name,
|
|
332
|
+
type: element.columnFormat,
|
|
333
|
+
header: element.label || element.name,
|
|
334
|
+
size: sizeMap[element.name] || 180,
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function buildHierarchy(elements, parentName = null) {
|
|
339
|
+
const result = [];
|
|
340
|
+
for (const element of elements) {
|
|
341
|
+
if (element?.parent === parentName) {
|
|
342
|
+
const children = buildHierarchy(elements, element.name);
|
|
343
|
+
const node: any = nodeProvider(element)
|
|
344
|
+
if (children.length > 0) {
|
|
345
|
+
node.columns = children;
|
|
346
|
+
node.type = "group";
|
|
347
|
+
}
|
|
348
|
+
result.push(node);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return result;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
function transformConfigToOutput(config) {
|
|
355
|
+
const output = [];
|
|
356
|
+
const hierarchy = buildHierarchy(config.elements, config.name);
|
|
357
|
+
for (const element of config.elements) {
|
|
358
|
+
const parentExists = config.elements.some(e => e.name === element.parent);
|
|
359
|
+
if (!parentExists && element.parent !== config.name) {
|
|
360
|
+
output.push(nodeProvider(element))
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
return [ ...hierarchy,...output,];
|
|
364
|
+
}
|
|
365
|
+
elements.elements = transformConfigToOutput(config)
|
|
320
366
|
}
|
|
321
367
|
else if (config.type == "Array") {
|
|
322
368
|
elements.options.detail.elements = config.elements.map((e: any, elemInd: number) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _ from "lodash";
|
|
2
|
-
import { ComponentSchema } from "../elements/UiSchema/Component/schema";
|
|
2
|
+
import { ComponentSchema } from "../elements/UiSchema/Component/schema";
|
|
3
3
|
import { componentBasicUiSchema } from "../elements/UiSchema/Component/uiSchema";
|
|
4
4
|
import { CoreSection } from "../build/uischema/coreSection";
|
|
5
5
|
import { EventSection } from "../build/uischema/eventSection";
|
|
@@ -10,57 +10,57 @@ import { ValueTab } from "../build/uischema/valueTab";
|
|
|
10
10
|
import { ValidationSection } from "../build/uischema/validationSections";
|
|
11
11
|
import { getFormdataFromLocalStorage, okHandler, saveFormdataInLocalStorage, saveHandler } from "./utils";
|
|
12
12
|
const sectionLabels = {
|
|
13
|
-
Select: ["Core", "Properties","Value", "
|
|
14
|
-
MultipleSelect: ["Core", "Properties","Value", "
|
|
15
|
-
Table: ["Core", "Components",
|
|
16
|
-
LeaderBoard: ["Core", "Components", "Properties", "
|
|
17
|
-
WrapperSection: ["Core", "Components","Properties", "
|
|
18
|
-
TabSection: ["Core", "Components", "Properties", "
|
|
19
|
-
SpeedoMeter:["Core", "Properties", "
|
|
20
|
-
card:["Core", "Properties", "
|
|
21
|
-
UploadFile:["Core",
|
|
22
|
-
Graph:["Core", "Properties", "
|
|
23
|
-
DownloadFile:["Core",
|
|
24
|
-
Box: ["Core", "
|
|
25
|
-
Properties: ["Core", "Properties", "
|
|
26
|
-
ProgressBarCard: ["Core", "Properties", "
|
|
27
|
-
RankCard: ["Core", "Properties", "
|
|
28
|
-
Slider: ["Core", "Components", "
|
|
29
|
-
Timer: ["Core", "
|
|
30
|
-
Rank: ["Core","
|
|
31
|
-
Button: ["Core", "Properties", "
|
|
32
|
-
Array:["Core","Components","Validation"],
|
|
33
|
-
Radio:["Core", "Properties", "
|
|
34
|
-
Text:["Core","Properties","
|
|
35
|
-
TextArea:["Core","Properties","
|
|
36
|
-
PopUp: ["Core", "Components","Properties", "
|
|
37
|
-
Stepper: ["Core", "Components","Properties","Event", "
|
|
38
|
-
DataGrid: ["Core", "Components","Properties","Event", "
|
|
39
|
-
InputSlider:["Core","Properties","
|
|
40
|
-
|
|
13
|
+
Select: ["Core", "Properties", "Value", "Event", "Style", "Validation"],
|
|
14
|
+
MultipleSelect: ["Core", "Properties", "Value", "Event", "Style", "Validation"],
|
|
15
|
+
Table: ["Core", "Components", "Properties", "Event", "Style", "Validation"],
|
|
16
|
+
LeaderBoard: ["Core", "Components", "Properties", "Event", "Style", "Validation"],
|
|
17
|
+
WrapperSection: ["Core", "Components", "Properties", "Style", "Validation"],
|
|
18
|
+
TabSection: ["Core", "Components", "Properties", "Style", "Validation"],
|
|
19
|
+
SpeedoMeter: ["Core", "Properties", "Event", "Style", "Validation"],
|
|
20
|
+
card: ["Core", "Properties", "Event", "Style", "Validation"],
|
|
21
|
+
UploadFile: ["Core", "Event", "Style", "Validation"],
|
|
22
|
+
Graph: ["Core", "Properties", "Event", "Style", "Validation"],
|
|
23
|
+
DownloadFile: ["Core", "Event", "Style", "Validation"],
|
|
24
|
+
Box: ["Core", "Event", "Style", "Validation"],
|
|
25
|
+
Properties: ["Core", "Properties", "Event", "Style", "Validation"],
|
|
26
|
+
ProgressBarCard: ["Core", "Properties", "Event", "Style", "Validation"],
|
|
27
|
+
RankCard: ["Core", "Properties", "Event", "Style", "Validation"],
|
|
28
|
+
Slider: ["Core", "Components", "Event", "Style", "Validation"],
|
|
29
|
+
Timer: ["Core", "Event", "Style", "Validation"],
|
|
30
|
+
Rank: ["Core", "Event", "Style", "Validation"],
|
|
31
|
+
Button: ["Core", "Properties", "Event", "Style", "Validation"],
|
|
32
|
+
Array: ["Core", "Components", "Validation"],
|
|
33
|
+
Radio: ["Core", "Properties", "Event", "Style", "Validation"],
|
|
34
|
+
Text: ["Core", "Properties", "Event", "Style", "Validation"],
|
|
35
|
+
TextArea: ["Core", "Properties", "Event", "Style", "Validation"],
|
|
36
|
+
PopUp: ["Core", "Components", "Properties", "Style"],
|
|
37
|
+
Stepper: ["Core", "Components", "Properties", "Event", "Style"],
|
|
38
|
+
DataGrid: ["Core", "Components", "Properties", "Event", "Style"],
|
|
39
|
+
InputSlider: ["Core", "Properties", "Event", "Style", "Validation"],
|
|
40
|
+
TreeMap: ["Core", "Components", "Properties", "Event", "Style",],
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
export const refreshPage = (type:string,store:any) => {
|
|
45
|
+
export const refreshPage = (type: string, store: any) => {
|
|
46
46
|
const UiSchema = _.cloneDeep(componentBasicUiSchema)
|
|
47
|
-
if(type){
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
if (type) {
|
|
48
|
+
const sectionUiSchema = {
|
|
49
|
+
Core: CoreSection,
|
|
50
|
+
Value: ValueTab,
|
|
51
|
+
Style: StyleSection,
|
|
52
|
+
Event: EventSection,
|
|
53
|
+
Components: TableSection,
|
|
54
|
+
Properties: buildPropertiesSection(type),
|
|
55
|
+
Validation: ValidationSection
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
const elements = sectionLabels[type]?.map(e => sectionUiSchema[e]);
|
|
59
|
+
UiSchema.elements[1].config.main.tabLabels = sectionLabels[type] || ["Core", "style", "Event", "Validation"];
|
|
60
|
+
UiSchema.elements[1].elements = elements || [CoreSection, StyleSection, EventSection, ValidationSection];
|
|
61
|
+
|
|
57
62
|
}
|
|
58
|
-
|
|
59
|
-
UiSchema.elements[1].config.main.tabLabels = sectionLabels[type] || ["Core", "style","Event","Validation"];
|
|
60
|
-
UiSchema.elements[1].elements = elements || [CoreSection, StyleSection,EventSection,ValidationSection];
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
store.setUiSchema(UiSchema);
|
|
63
|
+
store.setUiSchema(UiSchema);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
export default (store: any, dynamicData: any, submitHandler: any, service: any) => {
|
|
@@ -69,26 +69,26 @@ export default (store: any, dynamicData: any, submitHandler: any, service: any)
|
|
|
69
69
|
const formdata = await this.getFormdata();
|
|
70
70
|
store.setFormdata(formdata);
|
|
71
71
|
const schema = this.getSchema();
|
|
72
|
-
store.setSchema(schema);
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
store.setSchema(schema);
|
|
73
|
+
this.refreshPage(formdata?.type, store);
|
|
74
|
+
|
|
75
75
|
},
|
|
76
|
-
refreshPage:refreshPage,
|
|
76
|
+
refreshPage: refreshPage,
|
|
77
77
|
getFormdata: function () {
|
|
78
78
|
const path = store.searchParams?.get("path");
|
|
79
|
-
return getFormdataFromLocalStorage(path)
|
|
79
|
+
return getFormdataFromLocalStorage(path)
|
|
80
80
|
},
|
|
81
81
|
getSchema: function () {
|
|
82
82
|
return ComponentSchema;
|
|
83
83
|
},
|
|
84
|
-
okHandler:()=>okHandler(store),
|
|
85
|
-
saveHandler: async ()=> await saveHandler(store,service,submitHandler,"PageMaster"),
|
|
84
|
+
okHandler: () => okHandler(store),
|
|
85
|
+
saveHandler: async () => await saveHandler(store, service, submitHandler, "PageMaster"),
|
|
86
86
|
onChange: function () {
|
|
87
87
|
if (
|
|
88
88
|
store?.formData?.type !== store?.newData?.type &&
|
|
89
89
|
store?.newData?.type !== undefined
|
|
90
90
|
) {
|
|
91
|
-
this.refreshPage(store?.newData?.type,store);
|
|
91
|
+
this.refreshPage(store?.newData?.type, store);
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
94
|
editComponents: function () {
|
|
@@ -1,148 +1,102 @@
|
|
|
1
|
-
import _ from "lodash";
|
|
1
|
+
import _, { cloneDeep } from "lodash";
|
|
2
2
|
import { handlersProps } from "./interface";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
export const executeEvents = async (
|
|
6
|
+
params: handlersProps
|
|
7
|
+
) => {
|
|
5
8
|
let nextEvent = [];
|
|
6
9
|
let finalResponse = null;
|
|
7
|
-
|
|
8
|
-
if (params.config.isSync !== "Yes") {
|
|
9
|
-
return shouldEventExecute(params)
|
|
10
|
-
.then((shouldExecute) => {
|
|
11
|
-
if (!shouldExecute) {
|
|
12
|
-
return { response: undefined, events: undefined };
|
|
13
|
-
}
|
|
14
|
-
return executeEventsHandler(params);
|
|
15
|
-
})
|
|
16
|
-
.then((response) => {
|
|
17
|
-
finalResponse = response;
|
|
18
|
-
const SuccessEvent = params.config?.events.filter(e => e.eventType === "Success");
|
|
19
|
-
nextEvent = SuccessEvent;
|
|
20
|
-
})
|
|
21
|
-
.catch((err) => {
|
|
22
|
-
const FailEvent = params.config?.events?.filter(e => e.eventType === "Fail");
|
|
23
|
-
const setEvent = FailEvent?.length > 0 ? FailEvent : [];
|
|
24
|
-
nextEvent = setEvent;
|
|
25
|
-
})
|
|
26
|
-
.then(() => {
|
|
27
|
-
if (nextEvent?.length > 0) {
|
|
28
|
-
return nextEvent.reduce((chain, actionConfig) => {
|
|
29
|
-
return chain.then(() => executeEvents({ ...params, config: actionConfig, parentEventOutput: finalResponse }));
|
|
30
|
-
}, Promise.resolve());
|
|
31
|
-
}
|
|
32
|
-
})
|
|
33
|
-
.then(() => finalResponse)
|
|
34
|
-
}
|
|
35
|
-
const shouldExecute = shouldEventExecute(params);
|
|
36
|
-
if (!shouldExecute) {
|
|
37
|
-
return { response: undefined, events: undefined };
|
|
38
|
-
}
|
|
39
10
|
try {
|
|
40
|
-
const
|
|
41
|
-
|
|
11
|
+
const shouldExecute = await shouldEventExecute(params)
|
|
12
|
+
if (!shouldExecute) {
|
|
13
|
+
return { response: undefined, events: undefined };
|
|
14
|
+
}
|
|
15
|
+
const response = await executeEventsHandler(params)
|
|
16
|
+
finalResponse = response;
|
|
42
17
|
const SuccessEvent = params.config?.events.filter(e => e.eventType === "Success");
|
|
43
18
|
nextEvent = SuccessEvent;
|
|
44
|
-
} catch {
|
|
45
|
-
const FailEvent = params.config?.events?.filter(e => e.eventType === "Fail")
|
|
46
|
-
const setEvent = FailEvent?.length > 0 ? FailEvent : []
|
|
19
|
+
} catch (err) {
|
|
20
|
+
const FailEvent = params.config?.events?.filter(e => e.eventType === "Fail")
|
|
21
|
+
const setEvent = FailEvent?.length > 0 ? FailEvent : []
|
|
47
22
|
nextEvent = setEvent;
|
|
48
23
|
}
|
|
49
24
|
if (nextEvent?.length > 0) {
|
|
50
25
|
for (const actionConfig of nextEvent) {
|
|
51
|
-
executeEvents({ ...params, config: actionConfig, parentEventOutput: finalResponse })
|
|
26
|
+
await executeEvents({ ...params, config: actionConfig, parentEventOutput: finalResponse })
|
|
52
27
|
}
|
|
53
28
|
}
|
|
54
29
|
return finalResponse;
|
|
55
30
|
}
|
|
56
|
-
|
|
31
|
+
|
|
32
|
+
async function executeEventsHandler(params: handlersProps) {
|
|
57
33
|
if (params.config.Handler === "api") {
|
|
58
|
-
return
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
params.service
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return params.store.functionParameters?.
|
|
34
|
+
return await executeApiEventHandler(params)
|
|
35
|
+
}
|
|
36
|
+
else if (params.config.Handler === "inBuiltFunction") {
|
|
37
|
+
return await executeInBuiltFunctionHandler(params)
|
|
38
|
+
}
|
|
39
|
+
else if (params.config.Handler === "custom") {
|
|
40
|
+
return await executeCustomHandler(params)
|
|
41
|
+
}
|
|
42
|
+
else if (params.config.Handler === "refresh") {
|
|
43
|
+
return await executeRefreshHandler(params)
|
|
44
|
+
}
|
|
45
|
+
else if (params.config.Handler === "mergeFormdata") {
|
|
46
|
+
const result = await mergeFormdata(
|
|
47
|
+
params.parentEventOutput, params.componentName, params.config, params.store, params.service)
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
else if (params.config.Handler === "onBackHandler") {
|
|
51
|
+
return params.store.functionParameters?.handleBack()
|
|
52
|
+
}
|
|
53
|
+
else if (params.config.Handler === "onNextHandler") {
|
|
54
|
+
return params.store.functionParameters?.handleNext()
|
|
55
|
+
}
|
|
56
|
+
else if (params.config.Handler === "onResetHandler") {
|
|
57
|
+
return params.store.functionParameters?.handleReset()
|
|
79
58
|
}
|
|
80
59
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return e.value
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
} else {
|
|
90
|
-
if (eventGropus?.onLoad) {
|
|
91
|
-
result = Object.keys(eventGropus?.onLoad)
|
|
92
|
-
result.push(result[0]);
|
|
60
|
+
export async function executeRefreshHandler(params: handlersProps) {
|
|
61
|
+
const compToRefresh: string[] = getRefreshElements(params.config, params.eventGroups)
|
|
62
|
+
for (const componentName of compToRefresh) {
|
|
63
|
+
for (const compEventConfig of params.eventGroups.onLoad[componentName]) {
|
|
64
|
+
await executeEvents({ ...params, config: compEventConfig, componentName });
|
|
93
65
|
}
|
|
94
66
|
}
|
|
95
|
-
return result;
|
|
96
67
|
}
|
|
97
|
-
|
|
98
|
-
const compToRefresh: string[] = getRefreshElements(params.config, params.eventGroups);
|
|
99
|
-
|
|
100
|
-
return Promise.all(compToRefresh.map(componentName => {
|
|
101
|
-
return Promise.all(params.eventGroups.onLoad[componentName].map(compEventConfig => {
|
|
102
|
-
return executeEvents({ ...params, config: compEventConfig, componentName });
|
|
103
|
-
}));
|
|
104
|
-
}))
|
|
105
|
-
};
|
|
106
|
-
export function executeApiRequest(params: any) {
|
|
68
|
+
async function executeApiEventHandler(params: handlersProps) {
|
|
107
69
|
const initialBody = { ...params.userValue?.payload };
|
|
108
70
|
const initialHeaders = {
|
|
109
71
|
"X-Requested-With": "XMLHttpRequest",
|
|
110
72
|
"Access-Control-Allow-Origin": "*"
|
|
111
73
|
};
|
|
74
|
+
const { body, headers } = await buildApiPayload(params.config, initialBody, initialHeaders, params.store, params.dynamicData, params.userValue, params.service)
|
|
112
75
|
|
|
113
|
-
const
|
|
114
|
-
return params.service[params.config.method](
|
|
76
|
+
const response = await params.service[params.config.method](
|
|
115
77
|
params.config.path,
|
|
116
|
-
|
|
117
|
-
{ headers:
|
|
118
|
-
)
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
};
|
|
78
|
+
body,
|
|
79
|
+
headers && { headers: headers }
|
|
80
|
+
);
|
|
81
|
+
return response;
|
|
82
|
+
}
|
|
122
83
|
|
|
123
|
-
function executeInBuiltFunctionHandler(params: handlersProps) {
|
|
84
|
+
async function executeInBuiltFunctionHandler(params: handlersProps) {
|
|
124
85
|
let parameter = {};
|
|
125
86
|
if (params.config.funcParametersCode) {
|
|
126
87
|
const makeFunc = eval(params.config.funcParametersCode)
|
|
127
88
|
parameter = makeFunc(params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service);
|
|
128
|
-
params.serviceHolder[params.config.inBuiltFunctionType](parameter, params.service)
|
|
129
|
-
} else {
|
|
130
|
-
params.serviceHolder[params.config.inBuiltFunctionType](params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service)
|
|
131
89
|
}
|
|
90
|
+
params.serviceHolder[params.config.inBuiltFunctionType](parameter)
|
|
132
91
|
}
|
|
133
92
|
|
|
134
|
-
function executeCustomHandler(params: handlersProps) {
|
|
93
|
+
async function executeCustomHandler(params: handlersProps) {
|
|
135
94
|
const makeFunc = eval(params.config.eventCode)
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
} else {
|
|
139
|
-
const response = makeFunc(params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service, params.componentName)
|
|
140
|
-
return response;
|
|
141
|
-
}
|
|
142
|
-
|
|
95
|
+
const response = await makeFunc(params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service, params.componentName);
|
|
96
|
+
return response;
|
|
143
97
|
}
|
|
144
98
|
|
|
145
|
-
function mergeFormdata(handlerResponse: any, componentName: string, eventConfig: any, store: any, service: any) {
|
|
99
|
+
async function mergeFormdata(handlerResponse: any, componentName: string, eventConfig: any, store: any, service: any) {
|
|
146
100
|
if (eventConfig.type === "Select" && !(_.isEmpty(handlerResponse?.data) && handlerResponse?.data)) {
|
|
147
101
|
store.setSchema((pre) => {
|
|
148
102
|
return {
|
|
@@ -177,13 +131,14 @@ function mergeFormdata(handlerResponse: any, componentName: string, eventConfig:
|
|
|
177
131
|
}
|
|
178
132
|
else {
|
|
179
133
|
if (handlerResponse) {
|
|
180
|
-
store.setFormdata((pre) => { return { ...pre, [componentName]: eventConfig.lazyLoading ? handlerResponse
|
|
134
|
+
store.setFormdata((pre) => { return { ...pre, [componentName]: eventConfig.lazyLoading ? handlerResponse.data.data : handlerResponse.data } });
|
|
135
|
+
const demoData = await asyncOperation();
|
|
181
136
|
}
|
|
182
137
|
}
|
|
183
138
|
}
|
|
184
139
|
|
|
185
140
|
const buildBodyFormat = (body: any[], formData: any, userValue: any) => {
|
|
186
|
-
|
|
141
|
+
const finalBody = { ...userValue?.payload };
|
|
187
142
|
body.map((elem) => {
|
|
188
143
|
if (typeof elem?.value !== "string") {
|
|
189
144
|
finalBody[elem.key] = elem.value;
|
|
@@ -195,12 +150,7 @@ const buildBodyFormat = (body: any[], formData: any, userValue: any) => {
|
|
|
195
150
|
else if (elem?.value?.startsWith("$")) {
|
|
196
151
|
const finalpath = elem.value.substring(1);
|
|
197
152
|
finalBody[elem.key] = _.get(formData, finalpath);;
|
|
198
|
-
} else
|
|
199
|
-
finalBody = { ...finalBody, ...formData };
|
|
200
|
-
} else if (elem?.value === "*") {
|
|
201
|
-
finalBody[elem.key] = formData;
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
153
|
+
} else {
|
|
204
154
|
finalBody[elem.key] = elem.value;
|
|
205
155
|
}
|
|
206
156
|
}
|
|
@@ -219,40 +169,58 @@ const buildHeadersFormat = (headers: any[]) => {
|
|
|
219
169
|
return headerObj;
|
|
220
170
|
}
|
|
221
171
|
|
|
222
|
-
|
|
172
|
+
async function shouldEventExecute(params: handlersProps) {
|
|
223
173
|
const startEvent = params.config?.events?.filter(e => e.eventType === "onStart");
|
|
224
|
-
|
|
225
174
|
if (startEvent?.length > 0) {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
});
|
|
175
|
+
const response = await executeEventsHandler({ ...params, config: startEvent[0] });
|
|
176
|
+
return response;
|
|
229
177
|
} else {
|
|
230
|
-
|
|
231
|
-
return Promise.resolve(true)
|
|
232
|
-
} else {
|
|
233
|
-
return true
|
|
234
|
-
}
|
|
178
|
+
return true
|
|
235
179
|
}
|
|
236
180
|
}
|
|
237
181
|
|
|
238
|
-
|
|
239
|
-
export function buildApiPayload(compConfig: any, body: any, headers: any, store: any, dynamicData: any, userValue: any, service) {
|
|
182
|
+
export async function buildApiPayload(compConfig: any, body: any, headers: any, store: any, dynamicData: any, userValue: any, service) {
|
|
240
183
|
if (compConfig?.headers) {
|
|
241
|
-
headers = buildHeadersFormat(compConfig.headers)
|
|
242
|
-
}
|
|
184
|
+
headers = buildHeadersFormat(compConfig.headers)
|
|
243
185
|
|
|
186
|
+
}
|
|
244
187
|
if (compConfig.body) {
|
|
245
188
|
body = { ...buildBodyFormat(compConfig.body, store.newData || store?.ctx?.core?.data || store.formData, userValue) };
|
|
246
189
|
}
|
|
247
|
-
|
|
248
|
-
const promiseChain = { body, headers };
|
|
249
|
-
|
|
250
|
-
|
|
251
190
|
if (compConfig.apiBody) {
|
|
252
191
|
const makeFunc = eval(compConfig.apiBody);
|
|
253
|
-
|
|
254
|
-
|
|
192
|
+
const data = await makeFunc(store, dynamicData, userValue, body);
|
|
193
|
+
body = data
|
|
194
|
+
}
|
|
195
|
+
return { body, headers };
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export function getRefreshElements(eventConfig: any, eventGropus: any) {
|
|
199
|
+
let result: string[] = [];
|
|
200
|
+
if (eventConfig?.refreshElements?.length > 0) {
|
|
201
|
+
result = eventConfig.refreshElements.map((e) => {
|
|
202
|
+
return e.value
|
|
203
|
+
})
|
|
255
204
|
|
|
205
|
+
} else {
|
|
206
|
+
if (eventGropus?.onLoad) {
|
|
207
|
+
result = Object.keys(eventGropus?.onLoad)
|
|
208
|
+
result.push(result[0]);
|
|
209
|
+
}
|
|
256
210
|
}
|
|
257
|
-
|
|
211
|
+
console.log(result);
|
|
212
|
+
return result;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
export function asyncOperation() {
|
|
217
|
+
return new Promise((resolve, reject) => {
|
|
218
|
+
setTimeout(() => {
|
|
219
|
+
const success = true;
|
|
220
|
+
if (success) {
|
|
221
|
+
resolve("Operation completed successfully!");
|
|
222
|
+
reject(new Error("Operation failed!"));
|
|
223
|
+
}
|
|
224
|
+
}, 50);
|
|
225
|
+
});
|
|
258
226
|
}
|