impaktapps-ui-builder 0.0.285 → 0.0.287
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 +52 -44
- 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/runtime/services/events.d.ts +1 -0
- package/dist/src/impaktapps-ui-builder/runtime/services/service.d.ts +2 -0
- package/package.json +1 -1
- package/src/impaktapps-ui-builder/runtime/services/events.ts +12 -23
- package/src/impaktapps-ui-builder/runtime/services/service.ts +42 -34
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { handlersProps } from "./interface";
|
|
2
2
|
export declare const executeEvents: (params: handlersProps) => Promise<any>;
|
|
3
|
+
export declare function executeRefreshHandler(params: handlersProps): Promise<void>;
|
|
3
4
|
export declare function buildApiPayload(compConfig: any, body: any, headers: any, store: any, dynamicData: any, userValue: any, service: any): Promise<{
|
|
4
5
|
body: any;
|
|
5
6
|
headers: any;
|
|
@@ -12,7 +12,9 @@ declare const _default: (funcParams: funcParamsProps) => {
|
|
|
12
12
|
setPage: () => Promise<void>;
|
|
13
13
|
onClick: () => Promise<void>;
|
|
14
14
|
onPaginationChange: (paginationValues: any) => Promise<any>;
|
|
15
|
+
getSelectOptions: (param: any) => Promise<any>;
|
|
15
16
|
onChange: () => Promise<void>;
|
|
17
|
+
updateConfigApiBody: (paramValue: any, apiBody: any) => Promise<any>;
|
|
16
18
|
downloadFile: (obj: any) => void;
|
|
17
19
|
};
|
|
18
20
|
export default _default;
|
package/package.json
CHANGED
|
@@ -49,11 +49,11 @@ async function executeEventsHandler(params:handlersProps) {
|
|
|
49
49
|
params.parentEventOutput, params.componentName, params.config, params.store)
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
async function executeRefreshHandler(params:handlersProps) {
|
|
52
|
+
export async function executeRefreshHandler(params:handlersProps) {
|
|
53
53
|
const compToRefresh: string[] = getRefreshElements(params.config, params.eventGroups)
|
|
54
54
|
for (const componentName of compToRefresh) {
|
|
55
55
|
for (const compEventConfig of params.eventGroups.onLoad[componentName]) {
|
|
56
|
-
await executeEvents({...params,config:compEventConfig});
|
|
56
|
+
await executeEvents({...params,config:compEventConfig,componentName});
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -64,24 +64,12 @@ async function executeApiEventHandler(params:handlersProps) {
|
|
|
64
64
|
"Access-Control-Allow-Origin": "*"
|
|
65
65
|
};
|
|
66
66
|
const { body, headers } = await buildApiPayload(params.config, initialBody, initialHeaders, params.store, params.dynamicData, params.userValue, params.service)
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
body: JSON.stringify(body)
|
|
74
|
-
})
|
|
75
|
-
response = await dataJSON.json();
|
|
76
|
-
// if(params.config.returnResponse){
|
|
77
|
-
// return {response}
|
|
78
|
-
// }
|
|
79
|
-
// return response;
|
|
80
|
-
// response = await params.service[params.config.method](
|
|
81
|
-
// params.config.path,
|
|
82
|
-
// body,
|
|
83
|
-
// headers && { headers: headers }
|
|
84
|
-
// );
|
|
67
|
+
|
|
68
|
+
const response = await params.service[params.config.method](
|
|
69
|
+
params.config.path,
|
|
70
|
+
body,
|
|
71
|
+
headers && { headers: headers }
|
|
72
|
+
);
|
|
85
73
|
return response;
|
|
86
74
|
}
|
|
87
75
|
|
|
@@ -106,7 +94,8 @@ async function mergeFormdata(handlerResponse: any, componentName: string, eventC
|
|
|
106
94
|
return {
|
|
107
95
|
...pre, properties: {
|
|
108
96
|
...pre.properties, [componentName]: {
|
|
109
|
-
|
|
97
|
+
...pre.properties?.[componentName],
|
|
98
|
+
oneOf: handlerResponse.data
|
|
110
99
|
}
|
|
111
100
|
}
|
|
112
101
|
}
|
|
@@ -157,8 +146,8 @@ const buildHeadersFormat = (headers: any[]) => {
|
|
|
157
146
|
async function shouldEventExecute(params:handlersProps) {
|
|
158
147
|
const startEvent = params.config?.events?.filter(e => e.eventType === "onStart");
|
|
159
148
|
if (startEvent?.length > 0) {
|
|
160
|
-
const
|
|
161
|
-
return response
|
|
149
|
+
const response = await executeEventsHandler({...params,config:startEvent[0]});
|
|
150
|
+
return response;
|
|
162
151
|
}
|
|
163
152
|
}
|
|
164
153
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _ from "lodash";
|
|
2
2
|
import { downloadFile } from "./downloadFile";
|
|
3
|
-
import { executeEvents } from "./events";
|
|
3
|
+
import { executeEvents, executeRefreshHandler } from "./events";
|
|
4
4
|
import { handlersProps } from "./interface";
|
|
5
5
|
let compType: string;
|
|
6
6
|
let eventGroups: any = {};
|
|
@@ -29,10 +29,10 @@ export const extractEvents = (eventConfig: any) => {
|
|
|
29
29
|
const SuccessEvent = event?.events?.find((elem) => {
|
|
30
30
|
return elem.eventType === "Success"
|
|
31
31
|
})
|
|
32
|
-
if (!(!!SuccessEvent) && event.eventType === "onLoad"
|
|
32
|
+
if (!(!!SuccessEvent) && event.eventType === "onLoad") {
|
|
33
33
|
event.events.push({ Handler: "mergeFormdata", eventType: "Success", type: compType })
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
}
|
|
35
|
+
eventGroups[event.eventType][eventConfigObj.name].push({ ...event, type: compType })
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -69,12 +69,7 @@ export default (funcParams: funcParamsProps) => {
|
|
|
69
69
|
store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
|
|
70
70
|
serviceHolder: this, eventGroups
|
|
71
71
|
}
|
|
72
|
-
await
|
|
73
|
-
...executeEventsParameters,
|
|
74
|
-
config: { Handler: "refresh", eventType: "onPageRefresh" },
|
|
75
|
-
componentName: "all"
|
|
76
|
-
})
|
|
77
|
-
|
|
72
|
+
await executeRefreshHandler(executeEventsParameters)
|
|
78
73
|
funcParams.store.setSchema(
|
|
79
74
|
(pre: any) => {
|
|
80
75
|
return {
|
|
@@ -95,31 +90,23 @@ export default (funcParams: funcParamsProps) => {
|
|
|
95
90
|
})
|
|
96
91
|
}
|
|
97
92
|
},
|
|
98
|
-
onPaginationChange: async (paginationValues)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
93
|
+
onPaginationChange: async function (paginationValues) {
|
|
94
|
+
const apiBody = [
|
|
95
|
+
{ key: "size", value: paginationValues.pagination.pageSize },
|
|
96
|
+
{ key: "start", value: paginationValues.pagination.pageIndex * paginationValues.pagination.pageSize },
|
|
97
|
+
{ key: "sorting", value: paginationValues.sorting || [] },
|
|
98
|
+
{ key: "filters", value: paginationValues.columnFilters || [] },
|
|
99
|
+
{ key: "globalFilter", value: paginationValues.globalFilter ?? '' }
|
|
100
|
+
]
|
|
101
|
+
return await this.updateConfigApiBody(paginationValues, apiBody)
|
|
102
|
+
},
|
|
103
|
+
getSelectOptions: async function (param) {
|
|
104
|
+
if (param.serachValue !== "" && param.serachValue !== undefined) {
|
|
105
|
+
const apiBody = [
|
|
106
|
+
{ key: "serachValue", value: param.serachValue },
|
|
107
|
+
{ key: "currentValue", value: param.currentValue }
|
|
106
108
|
]
|
|
107
|
-
|
|
108
|
-
eventConfig.body = [
|
|
109
|
-
...eventConfig.body,
|
|
110
|
-
...bodyValues
|
|
111
|
-
]
|
|
112
|
-
} else { eventConfig.body = bodyValues; };
|
|
113
|
-
const responseEvent = eventConfig?.events?.filter((elem) => {
|
|
114
|
-
return elem.Handler !== "mergeFormdata"
|
|
115
|
-
})
|
|
116
|
-
eventConfig.events = responseEvent??[]
|
|
117
|
-
const data = await executeEvents({
|
|
118
|
-
...executeEventsParameters,
|
|
119
|
-
config: eventConfig,
|
|
120
|
-
componentName: paginationValues.path
|
|
121
|
-
})
|
|
122
|
-
return data;
|
|
109
|
+
return await this.updateConfigApiBody(param, apiBody)
|
|
123
110
|
}
|
|
124
111
|
},
|
|
125
112
|
onChange: async function () {
|
|
@@ -141,6 +128,27 @@ export default (funcParams: funcParamsProps) => {
|
|
|
141
128
|
}))
|
|
142
129
|
}
|
|
143
130
|
},
|
|
131
|
+
updateConfigApiBody: async function (paramValue, apiBody) {
|
|
132
|
+
let LastCallResponse = undefined;
|
|
133
|
+
for (const eventConfig of eventGroups?.onLoad[paramValue.path]) {
|
|
134
|
+
if (eventConfig.body) {
|
|
135
|
+
eventConfig.body = [
|
|
136
|
+
...eventConfig.body,
|
|
137
|
+
...apiBody
|
|
138
|
+
]
|
|
139
|
+
} else { eventConfig.body = apiBody; };
|
|
140
|
+
const responseEvent = eventConfig?.events?.filter((elem) => {
|
|
141
|
+
return elem.Handler !== "mergeFormdata"
|
|
142
|
+
})
|
|
143
|
+
eventConfig.events = responseEvent ?? []
|
|
144
|
+
LastCallResponse = await executeEvents({
|
|
145
|
+
...executeEventsParameters,
|
|
146
|
+
config: eventConfig,
|
|
147
|
+
componentName: paramValue.path
|
|
148
|
+
})
|
|
149
|
+
}
|
|
150
|
+
return LastCallResponse
|
|
151
|
+
},
|
|
144
152
|
downloadFile: downloadFile
|
|
145
153
|
};
|
|
146
154
|
};
|