impaktapps-ui-builder 0.0.408 → 0.0.409-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 +268 -198
- package/dist/impaktapps-ui-builder.es.js.map +1 -1
- package/dist/impaktapps-ui-builder.umd.js +8 -8
- package/dist/impaktapps-ui-builder.umd.js.map +1 -1
- package/dist/src/impaktapps-ui-builder/builder/build/uischema/buildPropertiesSection.d.ts +19 -0
- package/dist/src/impaktapps-ui-builder/runtime/services/events.d.ts +7 -6
- package/dist/src/impaktapps-ui-builder/runtime/services/service.d.ts +6 -8
- package/package.json +1 -1
- package/src/impaktapps-ui-builder/builder/build/uischema/buildPropertiesSection.ts +1 -1
- package/src/impaktapps-ui-builder/builder/build/uischema/graph.ts +0 -1
- package/src/impaktapps-ui-builder/builder/elements/UiSchema/event/schema.ts +1 -1
- package/src/impaktapps-ui-builder/builder/services/event.ts +3 -2
- package/src/impaktapps-ui-builder/runtime/services/downloadFile.ts +2 -1
- package/src/impaktapps-ui-builder/runtime/services/events.ts +124 -99
- package/src/impaktapps-ui-builder/runtime/services/service.ts +77 -40
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
export declare const getRadioInputField: (scope: String, label: String, options: string[]) => {
|
|
2
|
+
type: string;
|
|
3
|
+
scope: string;
|
|
4
|
+
options: {
|
|
5
|
+
widget: string;
|
|
6
|
+
};
|
|
7
|
+
config: {
|
|
8
|
+
layout: {
|
|
9
|
+
xs: number;
|
|
10
|
+
sm: number;
|
|
11
|
+
md: number;
|
|
12
|
+
lg: number;
|
|
13
|
+
};
|
|
14
|
+
main: {
|
|
15
|
+
label: String;
|
|
16
|
+
options: string[];
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
};
|
|
1
20
|
export declare const getTextArea: (scope: string, heading: string, hideButton: boolean, layout?: any) => {
|
|
2
21
|
type: string;
|
|
3
22
|
scope: string;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { handlersProps } from "./interface";
|
|
2
|
-
export declare const executeEvents: (params: handlersProps) =>
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
2
|
+
export declare const executeEvents: (params: handlersProps) => any;
|
|
3
|
+
export declare function getRefreshElements(eventConfig: any, eventGropus: any): string[];
|
|
4
|
+
export declare function executeRefreshHandler(params: handlersProps): Promise<any[][]>;
|
|
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): {
|
|
5
8
|
body: any;
|
|
6
9
|
headers: any;
|
|
7
|
-
}
|
|
8
|
-
export declare function getRefreshElements(eventConfig: any, eventGropus: any): string[];
|
|
9
|
-
export declare function asyncOperation(): Promise<unknown>;
|
|
10
|
+
};
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
export declare const extractEvents: (eventConfig: any) => any;
|
|
2
1
|
interface funcParamsProps {
|
|
3
2
|
store: any;
|
|
4
3
|
dynamicData: any;
|
|
5
|
-
config: any;
|
|
6
|
-
uiSchema: any;
|
|
7
|
-
schema: any;
|
|
8
4
|
service: any;
|
|
9
5
|
userValue: any;
|
|
10
6
|
functionsProvider?: Record<string, any>;
|
|
11
7
|
}
|
|
8
|
+
export declare const extractEvents: (eventConfig: any) => any;
|
|
12
9
|
declare const _default: (funcParams: funcParamsProps) => {
|
|
13
10
|
setPage: () => Promise<void>;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
onCellRenderer: (cellParams: any) => {};
|
|
12
|
+
onClick: () => void;
|
|
13
|
+
onMount: () => void;
|
|
14
|
+
onFileDownload: () => void;
|
|
15
|
+
onFileUpload: () => void;
|
|
18
16
|
backHandler: () => void;
|
|
19
17
|
onPaginationChange: (paginationValues: any) => Promise<any>;
|
|
20
18
|
getSelectOptions: (param: any) => Promise<any>;
|
package/package.json
CHANGED
|
@@ -151,7 +151,7 @@ const getInputField = (scope: String, label: String) => {
|
|
|
151
151
|
};
|
|
152
152
|
};
|
|
153
153
|
|
|
154
|
-
const getRadioInputField = (scope: String, label: String, options: string[]) => {
|
|
154
|
+
export const getRadioInputField = (scope: String, label: String, options: string[]) => {
|
|
155
155
|
return {
|
|
156
156
|
type: "Control",
|
|
157
157
|
scope: `#/properties/${scope}`,
|
|
@@ -44,7 +44,7 @@ export const EventSchema = {
|
|
|
44
44
|
{ title: "Mount Event", const: "onMount" },
|
|
45
45
|
{ title: "Success", const: "Success" },
|
|
46
46
|
{ title: "onStart", const: "onStart" },
|
|
47
|
-
|
|
47
|
+
{ title: "Cell Renderer", const: "onCellRenderer" },
|
|
48
48
|
{ title: "File Upload Event", const: "onUpload" },
|
|
49
49
|
{ title: "Back Event", const: "onBack" },
|
|
50
50
|
{ title: "Next Event", const: "onNext" },
|
|
@@ -3,7 +3,7 @@ import { EventUiSchema } from "../elements/UiSchema/event/uiSchema";
|
|
|
3
3
|
import Component from "./component";
|
|
4
4
|
import { okHandler, saveFormdataInLocalStorage, saveHandler } from "./utils";
|
|
5
5
|
import { APISection } from "../build/uischema/apiSection";
|
|
6
|
-
import { getSelectField, getTextArea } from "../build/uischema/buildPropertiesSection";
|
|
6
|
+
import { getRadioInputField, getSelectField, getTextArea } from "../build/uischema/buildPropertiesSection";
|
|
7
7
|
import { refreshSectionUiSchema } from "../build/uischema/refresh";
|
|
8
8
|
import _ from "lodash";
|
|
9
9
|
|
|
@@ -27,7 +27,8 @@ export default (
|
|
|
27
27
|
const schema: any = _.cloneDeep(EventSchema)
|
|
28
28
|
if (handlerType) {
|
|
29
29
|
if (handlerType === "custom") {
|
|
30
|
-
uiSchema.elements[1].elements[0].elements[2] =
|
|
30
|
+
uiSchema.elements[1].elements[0].elements[2] = getRadioInputField("isSync","Run in Sync",["Yes","No"])
|
|
31
|
+
uiSchema.elements[1].elements[0].elements[3] = getTextArea("eventCode", "Write Custom Code", false)
|
|
31
32
|
schema.required = ["eventType", "Handler", "eventCode"]
|
|
32
33
|
|
|
33
34
|
} else if (handlerType === "api") {
|
|
@@ -1,87 +1,126 @@
|
|
|
1
|
-
import _
|
|
1
|
+
import _ from "lodash";
|
|
2
2
|
import { handlersProps } from "./interface";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
export const executeEvents = async (
|
|
6
|
-
params: handlersProps
|
|
7
|
-
) => {
|
|
4
|
+
export const executeEvents = (params: handlersProps) => {
|
|
8
5
|
let nextEvent = [];
|
|
9
6
|
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
|
+
}
|
|
10
39
|
try {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
return { response: undefined, events: undefined };
|
|
14
|
-
}
|
|
15
|
-
const response = await executeEventsHandler(params)
|
|
16
|
-
finalResponse = response;
|
|
40
|
+
const eventsResponse = executeEventsHandler(params);
|
|
41
|
+
finalResponse = eventsResponse;
|
|
17
42
|
const SuccessEvent = params.config?.events.filter(e => e.eventType === "Success");
|
|
18
43
|
nextEvent = SuccessEvent;
|
|
19
|
-
} catch
|
|
20
|
-
const FailEvent = params.config?.events?.filter(e => e.eventType === "Fail")
|
|
21
|
-
const setEvent = FailEvent?.length > 0 ? FailEvent : []
|
|
44
|
+
} catch {
|
|
45
|
+
const FailEvent = params.config?.events?.filter(e => e.eventType === "Fail");
|
|
46
|
+
const setEvent = FailEvent?.length > 0 ? FailEvent : [];
|
|
22
47
|
nextEvent = setEvent;
|
|
23
48
|
}
|
|
24
49
|
if (nextEvent?.length > 0) {
|
|
25
50
|
for (const actionConfig of nextEvent) {
|
|
26
|
-
|
|
51
|
+
executeEvents({ ...params, config: actionConfig, parentEventOutput: finalResponse })
|
|
27
52
|
}
|
|
28
53
|
}
|
|
29
54
|
return finalResponse;
|
|
30
55
|
}
|
|
31
|
-
|
|
32
|
-
async function executeEventsHandler(params: handlersProps) {
|
|
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
|
+
return result;
|
|
67
96
|
}
|
|
68
|
-
|
|
97
|
+
export function executeRefreshHandler(params: handlersProps) {
|
|
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) {
|
|
69
107
|
const initialBody = { ...params.userValue?.payload };
|
|
70
108
|
const initialHeaders = {
|
|
71
109
|
"X-Requested-With": "XMLHttpRequest",
|
|
72
110
|
"Access-Control-Allow-Origin": "*"
|
|
73
111
|
};
|
|
74
|
-
const { body, headers } = await buildApiPayload(params.config, initialBody, initialHeaders, params.store, params.dynamicData, params.userValue, params.service)
|
|
75
112
|
|
|
76
|
-
const
|
|
113
|
+
const payloadApi = buildApiPayload(params.config, initialBody, initialHeaders, params.store, params.dynamicData, params.userValue, params.service)
|
|
114
|
+
return params.service[params.config.method](
|
|
77
115
|
params.config.path,
|
|
78
|
-
body,
|
|
79
|
-
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
}
|
|
116
|
+
payloadApi.body,
|
|
117
|
+
{ headers: payloadApi.headers }
|
|
118
|
+
).then((response) => {
|
|
119
|
+
return response;
|
|
120
|
+
});
|
|
121
|
+
};
|
|
83
122
|
|
|
84
|
-
|
|
123
|
+
function executeInBuiltFunctionHandler(params: handlersProps) {
|
|
85
124
|
let parameter = {};
|
|
86
125
|
if (params.config.funcParametersCode) {
|
|
87
126
|
const makeFunc = eval(params.config.funcParametersCode)
|
|
@@ -92,13 +131,18 @@ async function executeInBuiltFunctionHandler(params: handlersProps) {
|
|
|
92
131
|
}
|
|
93
132
|
}
|
|
94
133
|
|
|
95
|
-
|
|
134
|
+
function executeCustomHandler(params: handlersProps) {
|
|
96
135
|
const makeFunc = eval(params.config.eventCode)
|
|
97
|
-
|
|
98
|
-
|
|
136
|
+
if (params.config.isSync !== "Yes") {
|
|
137
|
+
makeFunc(params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service, params.componentName).then((res) => res)
|
|
138
|
+
} else {
|
|
139
|
+
const response = makeFunc(params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service, params.componentName)
|
|
140
|
+
return response;
|
|
141
|
+
}
|
|
142
|
+
|
|
99
143
|
}
|
|
100
144
|
|
|
101
|
-
|
|
145
|
+
function mergeFormdata(handlerResponse: any, componentName: string, eventConfig: any, store: any, service: any) {
|
|
102
146
|
if (eventConfig.type === "Select" && !(_.isEmpty(handlerResponse?.data) && handlerResponse?.data)) {
|
|
103
147
|
store.setSchema((pre) => {
|
|
104
148
|
return {
|
|
@@ -134,7 +178,6 @@ async function mergeFormdata(handlerResponse: any, componentName: string, eventC
|
|
|
134
178
|
else {
|
|
135
179
|
if (handlerResponse) {
|
|
136
180
|
store.setFormdata((pre) => { return { ...pre, [componentName]: eventConfig.lazyLoading ? handlerResponse?.data?.data : handlerResponse.data } });
|
|
137
|
-
const demoData = await asyncOperation();
|
|
138
181
|
}
|
|
139
182
|
}
|
|
140
183
|
}
|
|
@@ -176,58 +219,40 @@ const buildHeadersFormat = (headers: any[]) => {
|
|
|
176
219
|
return headerObj;
|
|
177
220
|
}
|
|
178
221
|
|
|
179
|
-
|
|
222
|
+
export function shouldEventExecute(params: handlersProps) {
|
|
180
223
|
const startEvent = params.config?.events?.filter(e => e.eventType === "onStart");
|
|
224
|
+
|
|
181
225
|
if (startEvent?.length > 0) {
|
|
182
|
-
|
|
183
|
-
|
|
226
|
+
return executeEventsHandler({ ...params, config: startEvent[0] }).then((response) => {
|
|
227
|
+
return response;
|
|
228
|
+
});
|
|
184
229
|
} else {
|
|
185
|
-
|
|
230
|
+
if (params.config.isSync !== "Yes") {
|
|
231
|
+
return Promise.resolve(true)
|
|
232
|
+
} else {
|
|
233
|
+
return true
|
|
234
|
+
}
|
|
186
235
|
}
|
|
187
236
|
}
|
|
188
237
|
|
|
189
|
-
export async function buildApiPayload(compConfig: any, body: any, headers: any, store: any, dynamicData: any, userValue: any, service) {
|
|
190
|
-
if (compConfig?.headers) {
|
|
191
|
-
headers = buildHeadersFormat(compConfig.headers)
|
|
192
238
|
|
|
239
|
+
export function buildApiPayload(compConfig: any, body: any, headers: any, store: any, dynamicData: any, userValue: any, service) {
|
|
240
|
+
if (compConfig?.headers) {
|
|
241
|
+
headers = buildHeadersFormat(compConfig.headers);
|
|
193
242
|
}
|
|
243
|
+
|
|
194
244
|
if (compConfig.body) {
|
|
195
245
|
body = { ...buildBodyFormat(compConfig.body, store.newData || store?.ctx?.core?.data || store.formData, userValue) };
|
|
196
246
|
}
|
|
197
|
-
if (compConfig.apiBody) {
|
|
198
|
-
const makeFunc = eval(compConfig.apiBody);
|
|
199
|
-
const data = await makeFunc(store, dynamicData, userValue, body);
|
|
200
|
-
body = data
|
|
201
|
-
}
|
|
202
|
-
return { body, headers };
|
|
203
|
-
}
|
|
204
247
|
|
|
205
|
-
|
|
206
|
-
let result: string[] = [];
|
|
207
|
-
if (eventConfig?.refreshElements?.length > 0) {
|
|
208
|
-
result = eventConfig.refreshElements.map((e) => {
|
|
209
|
-
return e.value
|
|
210
|
-
})
|
|
248
|
+
const promiseChain = { body, headers };
|
|
211
249
|
|
|
212
|
-
} else {
|
|
213
|
-
if (eventGropus?.onLoad) {
|
|
214
|
-
result = Object.keys(eventGropus?.onLoad)
|
|
215
|
-
result.push(result[0]);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
console.log(result);
|
|
219
|
-
return result;
|
|
220
|
-
}
|
|
221
250
|
|
|
251
|
+
if (compConfig.apiBody) {
|
|
252
|
+
const makeFunc = eval(compConfig.apiBody);
|
|
253
|
+
return { body: makeFunc(store, dynamicData, userValue, promiseChain.body), headers: promiseChain.headers };
|
|
254
|
+
// return result;
|
|
222
255
|
|
|
223
|
-
|
|
224
|
-
return
|
|
225
|
-
setTimeout(() => {
|
|
226
|
-
const success = true;
|
|
227
|
-
if (success) {
|
|
228
|
-
resolve("Operation completed successfully!");
|
|
229
|
-
reject(new Error("Operation failed!"));
|
|
230
|
-
}
|
|
231
|
-
}, 50);
|
|
232
|
-
});
|
|
256
|
+
}
|
|
257
|
+
return promiseChain;
|
|
233
258
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _, { isEmpty } from "lodash";
|
|
2
2
|
import { doDownload, downloadFile } from "./downloadFile";
|
|
3
|
-
import {
|
|
3
|
+
import { executeEvents, executeRefreshHandler } from "./events";
|
|
4
4
|
import { handlersProps } from "./interface";
|
|
5
5
|
let compType: string;
|
|
6
6
|
let eventGroups: any = {};
|
|
@@ -13,6 +13,14 @@ 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
|
+
functionsProvider?: Record<string, any>
|
|
22
|
+
}
|
|
23
|
+
|
|
16
24
|
export const extractEvents = (eventConfig: any) => {
|
|
17
25
|
function extractsConfigEvents(eventConfigObj: any) {
|
|
18
26
|
if (eventConfigObj.events) {
|
|
@@ -46,30 +54,49 @@ export const extractEvents = (eventConfig: any) => {
|
|
|
46
54
|
}
|
|
47
55
|
return eventGroups;
|
|
48
56
|
};
|
|
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
|
-
functionsProvider?: Record<string, any>
|
|
59
|
-
}
|
|
60
57
|
export default (funcParams: funcParamsProps) => {
|
|
61
|
-
eventGroups = {}
|
|
62
|
-
eventGroups = extractEvents(funcParams.config)
|
|
63
58
|
let executeEventsParameters: handlersProps = {
|
|
64
59
|
config: {}, componentName: "",
|
|
65
60
|
store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
|
|
66
|
-
serviceHolder: { downloadFile, download: doDownload
|
|
61
|
+
serviceHolder: { downloadFile, download: doDownload, ...funcParams.functionsProvider }, eventGroups,
|
|
67
62
|
functionsProvider: funcParams.functionsProvider,
|
|
68
63
|
};
|
|
69
64
|
return {
|
|
70
65
|
setPage: async function () {
|
|
71
|
-
funcParams.store.setFormdata({})
|
|
72
|
-
const
|
|
66
|
+
funcParams.store.setFormdata({})
|
|
67
|
+
const data = JSON.stringify({
|
|
68
|
+
pageName: funcParams.store.pageName
|
|
69
|
+
});
|
|
70
|
+
let pageData;
|
|
71
|
+
const pageBasicDetailString = localStorage.getItem("pagemasterMetaData")
|
|
72
|
+
if (pageBasicDetailString) {
|
|
73
|
+
pageData = JSON.parse(pageBasicDetailString)
|
|
74
|
+
} else {
|
|
75
|
+
const pageId = await funcParams.service
|
|
76
|
+
.post("/page/getByName", data, {
|
|
77
|
+
headers: {
|
|
78
|
+
"Content-Type": "application/json",
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
const response = await funcParams.service.get(
|
|
82
|
+
`/page/getById?id=${pageId?.data?.id}`,
|
|
83
|
+
{
|
|
84
|
+
headers: {
|
|
85
|
+
"Content-Type": "application/json",
|
|
86
|
+
},
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
pageData = response.data;
|
|
90
|
+
localStorage.setItem("pagemasterMetaData", JSON.stringify({
|
|
91
|
+
schema: pageData?.schema,
|
|
92
|
+
uiSchema: pageData?.uiSchema, config: pageData?.config
|
|
93
|
+
}))
|
|
94
|
+
}
|
|
95
|
+
const config = pageData?.config;
|
|
96
|
+
const uiSchema = pageData?.uiSchema;
|
|
97
|
+
const schema = pageData?.schema ?? { type: "object", properties: {} };
|
|
98
|
+
eventGroups = {}
|
|
99
|
+
eventGroups = extractEvents(config);
|
|
73
100
|
executeEventsParameters = {
|
|
74
101
|
config: {}, componentName: "",
|
|
75
102
|
store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
|
|
@@ -81,33 +108,47 @@ export default (funcParams: funcParamsProps) => {
|
|
|
81
108
|
store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
|
|
82
109
|
serviceHolder: this, eventGroups
|
|
83
110
|
})
|
|
84
|
-
const demoData2 = await asyncOperation();
|
|
85
111
|
funcParams.store.setSchema(
|
|
86
112
|
(pre: any) => {
|
|
87
113
|
return {
|
|
88
|
-
...
|
|
89
|
-
{ ...
|
|
114
|
+
...schema, properties:
|
|
115
|
+
{ ...schema.properties, ...pre.properties, }
|
|
90
116
|
}
|
|
91
117
|
}
|
|
92
118
|
)
|
|
93
|
-
|
|
94
|
-
funcParams.store.setUiSchema(
|
|
95
|
-
|
|
119
|
+
uiSchema.elements.push(notifyUiSchema);
|
|
120
|
+
funcParams.store.setUiSchema(uiSchema);
|
|
121
|
+
|
|
96
122
|
},
|
|
97
|
-
|
|
98
|
-
|
|
123
|
+
onCellRenderer: (cellParams) => {
|
|
124
|
+
let finalResponse = {};
|
|
125
|
+
cellParams.spanRef.current.style.color = "yellow";
|
|
126
|
+
const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[0];
|
|
127
|
+
for (const eventConfig of eventGroups?.onCellRenderer[path]) {
|
|
128
|
+
executeEventsParameters.store.functionParameters = cellParams
|
|
129
|
+
finalResponse = executeEvents({
|
|
130
|
+
...executeEventsParameters,
|
|
131
|
+
config: eventConfig,
|
|
132
|
+
componentName: path
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
console.log("finalResponse >> >> >> ", finalResponse)
|
|
136
|
+
return finalResponse
|
|
99
137
|
},
|
|
100
|
-
|
|
101
|
-
|
|
138
|
+
onClick: function () {
|
|
139
|
+
this.callHandler("onClick")
|
|
102
140
|
},
|
|
103
|
-
|
|
104
|
-
|
|
141
|
+
onMount: function () {
|
|
142
|
+
this.callHandler("onMount")
|
|
105
143
|
},
|
|
106
|
-
|
|
107
|
-
|
|
144
|
+
onFileDownload: function () {
|
|
145
|
+
this.callHandler("onDownload")
|
|
108
146
|
},
|
|
109
|
-
|
|
110
|
-
|
|
147
|
+
onFileUpload: function () {
|
|
148
|
+
this.callHandler("onUpload")
|
|
149
|
+
},
|
|
150
|
+
backHandler: function () {
|
|
151
|
+
funcParams.store.navigate(-1)
|
|
111
152
|
},
|
|
112
153
|
onPaginationChange: async function (paginationValues) {
|
|
113
154
|
const apiBody = [
|
|
@@ -126,7 +167,8 @@ export default (funcParams: funcParamsProps) => {
|
|
|
126
167
|
{ key: "searchValue", value: param.serachValue },
|
|
127
168
|
{ key: "currentValue", value: param.currentValue }
|
|
128
169
|
]
|
|
129
|
-
|
|
170
|
+
const response = await this.updateConfigApiBody(param, apiBody);
|
|
171
|
+
return response?.data;
|
|
130
172
|
}
|
|
131
173
|
},
|
|
132
174
|
onChange: async function () {
|
|
@@ -203,6 +245,7 @@ export default (funcParams: funcParamsProps) => {
|
|
|
203
245
|
}
|
|
204
246
|
}
|
|
205
247
|
},
|
|
248
|
+
|
|
206
249
|
downloadFile: downloadFile,
|
|
207
250
|
download: doDownload,
|
|
208
251
|
...funcParams.functionsProvider
|
|
@@ -213,9 +256,3 @@ export default (funcParams: funcParamsProps) => {
|
|
|
213
256
|
|
|
214
257
|
|
|
215
258
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|