impaktapps-ui-builder 1.0.80-schema.0 → 1.0.80-schema.2
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 +9 -12
- package/dist/impaktapps-ui-builder.es.js.map +1 -1
- package/dist/impaktapps-ui-builder.umd.js +1 -1
- package/dist/impaktapps-ui-builder.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/impaktapps-ui-builder/runtime/services/service.ts +10 -14
- package/src/impaktapps-ui-builder/runtime/services/serviceTest.tsx +265 -0
package/package.json
CHANGED
|
@@ -92,25 +92,21 @@ export default (funcParams: funcParamsProps) => {
|
|
|
92
92
|
functionsProvider: funcParams.functionsProvider,
|
|
93
93
|
serviceHolder: this, eventGroups, formDataHolder
|
|
94
94
|
}
|
|
95
|
+
|
|
96
|
+
funcParams.store.setSchema(
|
|
97
|
+
(pre: any) => {
|
|
98
|
+
return {
|
|
99
|
+
...schema, ...pre, properties:
|
|
100
|
+
{ ...schema.properties, ...pre.properties, }
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
)
|
|
95
104
|
await executeRefreshHandler({
|
|
96
105
|
config: {}, componentName: "",
|
|
97
106
|
store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
|
|
98
107
|
serviceHolder: this, eventGroups, formDataHolder: {}
|
|
99
108
|
})
|
|
100
|
-
|
|
101
|
-
const updatedSchema = {
|
|
102
|
-
...schema,
|
|
103
|
-
...pre,
|
|
104
|
-
properties: {
|
|
105
|
-
...schema.properties,
|
|
106
|
-
...pre.properties,
|
|
107
|
-
},
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
funcParams.store.tempSchema = updatedSchema;
|
|
111
|
-
|
|
112
|
-
return updatedSchema;
|
|
113
|
-
});
|
|
109
|
+
|
|
114
110
|
uiSchema.elements.push(notifyUiSchema);
|
|
115
111
|
funcParams.store.setUiSchema(uiSchema);
|
|
116
112
|
},
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import _, { isEmpty } from "lodash";
|
|
2
|
+
import { doDownload, downloadFile } from "./downloadFile";
|
|
3
|
+
import { executeEvents, executeRefreshHandler } from "./events";
|
|
4
|
+
import { handlersProps } from "./interface";
|
|
5
|
+
let compType: string;
|
|
6
|
+
let eventGroups: any = {};
|
|
7
|
+
const notifyUiSchema = {
|
|
8
|
+
type: "Control",
|
|
9
|
+
scope: "#/properties/notify",
|
|
10
|
+
options: {
|
|
11
|
+
widget: "Notify",
|
|
12
|
+
},
|
|
13
|
+
layout: 6,
|
|
14
|
+
};
|
|
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
|
+
initFormData?: any
|
|
24
|
+
}
|
|
25
|
+
let pageData: any = false;
|
|
26
|
+
export const extractEvents = (eventConfig: any) => {
|
|
27
|
+
function extractsConfigEvents(eventConfigObj: any) {
|
|
28
|
+
if (eventConfigObj.events) {
|
|
29
|
+
eventConfigObj.events.forEach((event: any) => {
|
|
30
|
+
if (eventConfigObj.type) {
|
|
31
|
+
compType = eventConfigObj.type;
|
|
32
|
+
}
|
|
33
|
+
if (!eventGroups[event.eventType]) {
|
|
34
|
+
eventGroups[event.eventType] = {};
|
|
35
|
+
}
|
|
36
|
+
if (!eventGroups[event.eventType][eventConfigObj.name]) {
|
|
37
|
+
eventGroups[event.eventType][eventConfigObj.name] = [];
|
|
38
|
+
}
|
|
39
|
+
const SuccessEvent = event?.events?.find((elem) => {
|
|
40
|
+
return elem.eventType === "Success"
|
|
41
|
+
})
|
|
42
|
+
if (!(!!SuccessEvent) && event.eventType === "onLoad") {
|
|
43
|
+
if (!(!!event.events)) {
|
|
44
|
+
event.events = [];
|
|
45
|
+
}
|
|
46
|
+
event.events.push({ Handler: "mergeFormdata", eventType: "Success", type: compType, lazyLoading: eventConfig.lazyLoading === "YES" ? true : false })
|
|
47
|
+
}
|
|
48
|
+
if (!(!!SuccessEvent) && (event.eventType === "onBack" || event.eventType === "onNext" || event.eventType === "onReset")) {
|
|
49
|
+
if (!(!!event.events)) {
|
|
50
|
+
event.events = [];
|
|
51
|
+
}
|
|
52
|
+
event.events.push({ Handler: `${event.eventType}Handler`, eventType: "Success", type: compType, lazyLoading: eventConfig.lazyLoading === "YES" ? true : false })
|
|
53
|
+
}
|
|
54
|
+
eventGroups[event.eventType][eventConfigObj.name].push({ ...event, type: compType })
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
extractsConfigEvents(eventConfig)
|
|
59
|
+
if (eventConfig?.elements) {
|
|
60
|
+
eventConfig.elements.forEach(extractEvents);
|
|
61
|
+
}
|
|
62
|
+
return eventGroups;
|
|
63
|
+
};
|
|
64
|
+
export default (funcParams: funcParamsProps) => {
|
|
65
|
+
const formDataHolder = {}
|
|
66
|
+
let executeEventsParameters: handlersProps = {
|
|
67
|
+
config: {}, componentName: "",
|
|
68
|
+
store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
|
|
69
|
+
serviceHolder: { downloadFile, download: doDownload, ...funcParams.functionsProvider }, eventGroups,
|
|
70
|
+
functionsProvider: funcParams.functionsProvider, formDataHolder
|
|
71
|
+
};
|
|
72
|
+
return {
|
|
73
|
+
setPage: async function () {
|
|
74
|
+
funcParams.store.setAdditionalErrors([]);
|
|
75
|
+
funcParams.store.setFormdata(funcParams?.initFormData() || {});
|
|
76
|
+
funcParams.store.setSchema({ type: "object", properties: {} });
|
|
77
|
+
funcParams.store.newData = {};
|
|
78
|
+
eventGroups = {};
|
|
79
|
+
pageData = await funcParams.pageDataProvider();
|
|
80
|
+
const config = pageData?.config;
|
|
81
|
+
const uiSchema = pageData?.uiSchema;
|
|
82
|
+
const event = new CustomEvent('pageNameChanged', {
|
|
83
|
+
detail: { pageName: config.label, hasBackIcon: config.hasBackIcon === "NO" ? false : true }
|
|
84
|
+
});
|
|
85
|
+
window.dispatchEvent(event)
|
|
86
|
+
const theme = funcParams?.store?.theme?.myTheme;
|
|
87
|
+
const schema = pageData?.schema ?? { type: "object", properties: {} };
|
|
88
|
+
eventGroups = extractEvents(config);
|
|
89
|
+
executeEventsParameters = {
|
|
90
|
+
config: {}, componentName: "",
|
|
91
|
+
store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
|
|
92
|
+
functionsProvider: funcParams.functionsProvider,
|
|
93
|
+
serviceHolder: this, eventGroups, formDataHolder
|
|
94
|
+
}
|
|
95
|
+
await executeRefreshHandler({
|
|
96
|
+
config: {}, componentName: "",
|
|
97
|
+
store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
|
|
98
|
+
serviceHolder: this, eventGroups, formDataHolder: {}
|
|
99
|
+
})
|
|
100
|
+
funcParams.store.setSchema((pre: any) => {
|
|
101
|
+
const updatedSchema = {
|
|
102
|
+
required: [...(schema.required||[]), ...(pre.required||[])],
|
|
103
|
+
properties: {
|
|
104
|
+
...schema.properties,
|
|
105
|
+
...pre.properties,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
funcParams.store.tempSchema = updatedSchema;
|
|
110
|
+
|
|
111
|
+
return updatedSchema;
|
|
112
|
+
});
|
|
113
|
+
uiSchema.elements.push(notifyUiSchema);
|
|
114
|
+
funcParams.store.setUiSchema(uiSchema);
|
|
115
|
+
},
|
|
116
|
+
onCellRenderer: (cellParams) => {
|
|
117
|
+
if (eventGroups.onCellRenderer) {
|
|
118
|
+
let finalResponse = {};
|
|
119
|
+
const path = funcParams.dynamicData?.tableButtonPath || funcParams?.dynamicData?.path?.split(".")[0];
|
|
120
|
+
|
|
121
|
+
for (const eventConfig of eventGroups?.onCellRenderer?.[path]) {
|
|
122
|
+
executeEventsParameters.store.functionParameters = cellParams
|
|
123
|
+
finalResponse = executeEvents({
|
|
124
|
+
...executeEventsParameters,
|
|
125
|
+
config: eventConfig,
|
|
126
|
+
componentName: path
|
|
127
|
+
})
|
|
128
|
+
}
|
|
129
|
+
return finalResponse
|
|
130
|
+
}
|
|
131
|
+
return {}
|
|
132
|
+
},
|
|
133
|
+
onClick: function () {
|
|
134
|
+
this.callHandler("onClick")
|
|
135
|
+
},
|
|
136
|
+
onKeyDown: function () {
|
|
137
|
+
this.callHandler("onKeyDown")
|
|
138
|
+
},
|
|
139
|
+
onFileDelete: async function () {
|
|
140
|
+
this.callHandler("onFileDelete")
|
|
141
|
+
},
|
|
142
|
+
onMount: function () {
|
|
143
|
+
this.callHandler("onMount")
|
|
144
|
+
},
|
|
145
|
+
onFileDownload: function () {
|
|
146
|
+
this.callHandler("onDownload")
|
|
147
|
+
},
|
|
148
|
+
onFileUpload: function () {
|
|
149
|
+
this.callHandler("onUpload")
|
|
150
|
+
},
|
|
151
|
+
backHandler: function () {
|
|
152
|
+
funcParams.store.navigate(-1)
|
|
153
|
+
},
|
|
154
|
+
onRowMovement: async function (paginationValues) {
|
|
155
|
+
const apiBody = [
|
|
156
|
+
{ key: "direction", value: paginationValues.rowMovement.direction },
|
|
157
|
+
{ key: "movedRowId", value: paginationValues.rowMovement.movedRowId },
|
|
158
|
+
{ key: "targetRowId", value: paginationValues.rowMovement.targetRowId || [] }
|
|
159
|
+
]
|
|
160
|
+
await this.callExecuteEvents({ path: paginationValues?.path }, apiBody, "onRowMovement");
|
|
161
|
+
const response = await this.callExecuteEvents({ path: paginationValues?.path }, apiBody, "onLoad");
|
|
162
|
+
return response?.data;
|
|
163
|
+
},
|
|
164
|
+
onPaginationChange: async function (paginationValues) {
|
|
165
|
+
const apiBody = [
|
|
166
|
+
{ key: "size", value: paginationValues.pagination.pageSize },
|
|
167
|
+
{ key: "pageIndex", value: paginationValues.pagination.pageIndex },
|
|
168
|
+
{ key: "sorting", value: paginationValues.sorting || [] },
|
|
169
|
+
{ key: "filters", value: paginationValues.tableColumnConfig || [] },
|
|
170
|
+
{ key: "globalFilter", value: paginationValues.globalFilter ?? '' },
|
|
171
|
+
{ key: "expandedRowIds", value: paginationValues.expandedRowIds ?? []}
|
|
172
|
+
]
|
|
173
|
+
const response = await this.callExecuteEvents(paginationValues, apiBody, "onLoad");
|
|
174
|
+
return response?.data;
|
|
175
|
+
},
|
|
176
|
+
getSelectOptions: async function (param) {
|
|
177
|
+
if (param.serachValue !== "" && param.serachValue !== undefined) {
|
|
178
|
+
const apiBody = [
|
|
179
|
+
{ key: "searchValue", value: param.serachValue },
|
|
180
|
+
{ key: "currentValue", value: param.currentValue }
|
|
181
|
+
]
|
|
182
|
+
const response = await this.callExecuteEvents(param, apiBody, "onLoad");
|
|
183
|
+
return response?.data;
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
onChange: async function () {
|
|
187
|
+
if (eventGroups.onChange) {
|
|
188
|
+
const ChangeEventsKeysArray = Object.keys(eventGroups.onChange);
|
|
189
|
+
Promise.all(ChangeEventsKeysArray.map(async (componentName: string) => {
|
|
190
|
+
if (
|
|
191
|
+
funcParams.store?.formData[componentName] !== funcParams.store.newData[componentName] &&
|
|
192
|
+
funcParams.store?.newData[componentName] !== undefined
|
|
193
|
+
) {
|
|
194
|
+
for (const eventConfig of eventGroups.onChange[componentName]) {
|
|
195
|
+
await executeEvents({
|
|
196
|
+
...executeEventsParameters,
|
|
197
|
+
config: eventConfig,
|
|
198
|
+
componentName
|
|
199
|
+
})
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}))
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
callExecuteEvents: async function (paramValue, apiBody, eventType: string) {
|
|
206
|
+
let LastCallResponse = undefined;
|
|
207
|
+
const cloneEventGroup = _.cloneDeep(eventGroups)
|
|
208
|
+
for (const eventConfig of cloneEventGroup?.[eventType]?.[paramValue.path]) {
|
|
209
|
+
if (eventConfig.body) {
|
|
210
|
+
eventConfig.body = [
|
|
211
|
+
...eventConfig.body,
|
|
212
|
+
...apiBody
|
|
213
|
+
]
|
|
214
|
+
} else { eventConfig.body = apiBody; };
|
|
215
|
+
const responseEvent = eventConfig?.events?.filter((elem) => {
|
|
216
|
+
return elem.Handler !== "mergeFormdata"
|
|
217
|
+
})
|
|
218
|
+
eventConfig.events = responseEvent ?? []
|
|
219
|
+
LastCallResponse = await executeEvents({
|
|
220
|
+
...executeEventsParameters,
|
|
221
|
+
config: eventConfig,
|
|
222
|
+
componentName: paramValue.path
|
|
223
|
+
})
|
|
224
|
+
}
|
|
225
|
+
return LastCallResponse
|
|
226
|
+
},
|
|
227
|
+
onBack: async function (functionParameters) {
|
|
228
|
+
const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[0];
|
|
229
|
+
await this.callHandler("onBack", functionParameters)
|
|
230
|
+
if (eventGroups?.["onBack"]?.[path] === undefined) {
|
|
231
|
+
functionParameters?.handleBack()
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
onNext: async function (functionParameters) {
|
|
235
|
+
const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[0];
|
|
236
|
+
await this.callHandler("onNext", functionParameters)
|
|
237
|
+
if (eventGroups?.["onNext"]?.[path] === undefined) {
|
|
238
|
+
functionParameters?.handleNext()
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
onReset: async function (functionParameters) {
|
|
242
|
+
const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[0];
|
|
243
|
+
await this.callHandler("onReset", functionParameters)
|
|
244
|
+
if (eventGroups?.["onReset"]?.[path] === undefined) {
|
|
245
|
+
functionParameters?.handleReset()
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
callHandler: async function (eventType: string, functionParameters?: any) {
|
|
249
|
+
const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[funcParams.dynamicData.path.split(".").length - 1];
|
|
250
|
+
if (eventGroups?.[eventType]?.[path] !== undefined) {
|
|
251
|
+
Promise.all(eventGroups?.[eventType]?.[path].map((eventConfig) => {
|
|
252
|
+
executeEventsParameters.store.functionParameters = functionParameters
|
|
253
|
+
executeEvents({
|
|
254
|
+
...executeEventsParameters,
|
|
255
|
+
config: eventConfig,
|
|
256
|
+
componentName: path
|
|
257
|
+
})
|
|
258
|
+
}))
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
downloadFile: downloadFile,
|
|
262
|
+
download: doDownload,
|
|
263
|
+
...funcParams.functionsProvider
|
|
264
|
+
};
|
|
265
|
+
};
|