impaktapps-ui-builder 1.0.106 → 1.0.107
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 +22 -32
- package/dist/impaktapps-ui-builder.es.js.map +1 -1
- package/dist/impaktapps-ui-builder.umd.js +5 -5
- package/dist/impaktapps-ui-builder.umd.js.map +1 -1
- package/dist/src/impaktapps-ui-builder/runtime/services/interface.d.ts +0 -1
- package/package.json +1 -1
- package/src/impaktapps-ui-builder/builder/build/buildUiSchema.ts +5 -94
- package/src/impaktapps-ui-builder/runtime/services/events.ts +1 -18
- package/src/impaktapps-ui-builder/runtime/services/interface.ts +0 -1
- package/src/impaktapps-ui-builder/runtime/services/service.ts +18 -8
package/package.json
CHANGED
|
@@ -51,91 +51,8 @@ function buildOneOf(values: any[]) {
|
|
|
51
51
|
title: e.label
|
|
52
52
|
}));
|
|
53
53
|
}
|
|
54
|
-
function applyValidations(
|
|
55
|
-
schemaNode: any,
|
|
56
|
-
validations: any[] = [],
|
|
57
|
-
requiredArr?: string[],
|
|
58
|
-
fieldName?: string
|
|
59
|
-
) {
|
|
60
|
-
validations.forEach((rule) => {
|
|
61
|
-
if (rule.validationType === "readOnly") {
|
|
62
|
-
schemaNode.disabled = true
|
|
63
|
-
}
|
|
64
|
-
if (rule.validationType === "required") {
|
|
65
|
-
if (requiredArr && fieldName) {
|
|
66
|
-
requiredArr.push(fieldName);
|
|
67
|
-
}
|
|
68
|
-
} else {
|
|
69
|
-
schemaNode.type = "string";
|
|
70
|
-
schemaNode[rule.validationType] =
|
|
71
|
-
isNaN(rule.validationValue)
|
|
72
|
-
? rule.validationValue
|
|
73
|
-
: Number(rule.validationValue);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function buildNode(config: any): any {
|
|
79
|
-
if (config.type === "Array") {
|
|
80
|
-
const arraySchema: any = {
|
|
81
|
-
type: "array",
|
|
82
|
-
items: {
|
|
83
|
-
type: "object",
|
|
84
|
-
properties: {},
|
|
85
|
-
required: []
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
config.elements?.forEach((child: any) => {
|
|
90
|
-
const childNode = buildNode(child);
|
|
91
|
-
if (!childNode) return;
|
|
92
|
-
|
|
93
|
-
arraySchema.items.properties[child.name] = childNode.schema;
|
|
94
|
-
|
|
95
|
-
if (childNode.required?.length) {
|
|
96
|
-
arraySchema.items.required.push(child.name);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
return { schema: arraySchema };
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
let fieldSchema: any = {};
|
|
104
|
-
if (
|
|
105
|
-
(config.type === "Select" || config.type === "MultipleSelect") &&
|
|
106
|
-
config.value?.length > 0
|
|
107
|
-
) {
|
|
108
|
-
if (config.type === "Select") {
|
|
109
|
-
fieldSchema.oneOf = buildOneOf(config.value);
|
|
110
|
-
} else {
|
|
111
|
-
fieldSchema.type = "array";
|
|
112
|
-
fieldSchema.items = {
|
|
113
|
-
oneOf: buildOneOf(config.value)
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (config.validation) {
|
|
119
|
-
applyValidations(fieldSchema, config.validation);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const required =
|
|
123
|
-
config.validation?.some(
|
|
124
|
-
(v: any) => v.validationType === "required"
|
|
125
|
-
)
|
|
126
|
-
? [config.name]
|
|
127
|
-
: [];
|
|
128
|
-
|
|
129
|
-
return {
|
|
130
|
-
schema: fieldSchema,
|
|
131
|
-
required
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
|
|
135
54
|
export function buildSchemaFromConfig(config: any, parentSchema: any) {
|
|
136
|
-
|
|
137
55
|
if (config.elements) {
|
|
138
|
-
// 2️⃣ Handle Array component
|
|
139
56
|
if (config.type === "Array") {
|
|
140
57
|
parentSchema.properties ??= {};
|
|
141
58
|
parentSchema.properties[config.name] ??= {
|
|
@@ -160,17 +77,16 @@ export function buildSchemaFromConfig(config: any, parentSchema: any) {
|
|
|
160
77
|
return;
|
|
161
78
|
}
|
|
162
79
|
}
|
|
163
|
-
// 3️⃣ Handle normal field components
|
|
164
80
|
parentSchema.properties ??= {};
|
|
165
81
|
parentSchema.properties[config.name] ??= {};
|
|
166
|
-
|
|
167
82
|
const fieldSchema = parentSchema.properties[config.name];
|
|
168
|
-
|
|
169
|
-
// Required validation
|
|
170
83
|
config.validation?.forEach((v: any) => {
|
|
171
84
|
if (v.validationType === "required") {
|
|
172
85
|
parentSchema.required ??= [];
|
|
173
86
|
parentSchema.required.push(config.name);
|
|
87
|
+
} else if (v.validationType === "readOnly") {
|
|
88
|
+
fieldSchema.type = "string";
|
|
89
|
+
fieldSchema.disabled = true;
|
|
174
90
|
} else {
|
|
175
91
|
fieldSchema.type = "string";
|
|
176
92
|
fieldSchema[v.validationType] = isNaN(v.validationValue)
|
|
@@ -178,16 +94,12 @@ export function buildSchemaFromConfig(config: any, parentSchema: any) {
|
|
|
178
94
|
: Number(v.validationValue);
|
|
179
95
|
}
|
|
180
96
|
});
|
|
181
|
-
|
|
182
|
-
// Select
|
|
183
97
|
if (config.type === "Select" && config.value?.length) {
|
|
184
98
|
fieldSchema.oneOf = config.value.map((v: any) => ({
|
|
185
99
|
const: v.value,
|
|
186
100
|
title: v.label,
|
|
187
101
|
}));
|
|
188
102
|
}
|
|
189
|
-
|
|
190
|
-
// MultipleSelect
|
|
191
103
|
if (config.type === "MultipleSelect" && config.value?.length) {
|
|
192
104
|
fieldSchema.type = "array";
|
|
193
105
|
fieldSchema.items = {
|
|
@@ -199,10 +111,9 @@ export function buildSchemaFromConfig(config: any, parentSchema: any) {
|
|
|
199
111
|
}
|
|
200
112
|
}
|
|
201
113
|
|
|
202
|
-
export const buildSchema = (config) =>{
|
|
203
|
-
buildSchemaFromConfig(config,schema)
|
|
114
|
+
export const buildSchema = (config) => {
|
|
115
|
+
buildSchemaFromConfig(config, schema)
|
|
204
116
|
return schema;
|
|
205
|
-
|
|
206
117
|
}
|
|
207
118
|
|
|
208
119
|
const buildUiSchema = (config: any, store?: any) => {
|
|
@@ -68,9 +68,7 @@ function executeEventsHandler(params: handlersProps) {
|
|
|
68
68
|
params.componentName,
|
|
69
69
|
params.config,
|
|
70
70
|
params.store,
|
|
71
|
-
params.service,
|
|
72
71
|
params.formDataHolder,
|
|
73
|
-
params.pageLoad
|
|
74
72
|
);
|
|
75
73
|
} else if (params.config.Handler === "onBackHandler") {
|
|
76
74
|
return params.store.functionParameters?.handleBack();
|
|
@@ -145,7 +143,7 @@ function executeCustomHandler(params: handlersProps) {
|
|
|
145
143
|
}
|
|
146
144
|
|
|
147
145
|
}
|
|
148
|
-
function mergeFormdata(handlerResponse: any, componentName: string, eventConfig: any, store: any,
|
|
146
|
+
function mergeFormdata(handlerResponse: any, componentName: string, eventConfig: any, store: any, formDataHolder: any) {
|
|
149
147
|
if (eventConfig.type === "Select" && handlerResponse?.data) {
|
|
150
148
|
if (!_.isEmpty(handlerResponse?.data)) {
|
|
151
149
|
store.setSchema((pre) => {
|
|
@@ -184,32 +182,17 @@ function mergeFormdata(handlerResponse: any, componentName: string, eventConfig:
|
|
|
184
182
|
...handlerResponse?.data
|
|
185
183
|
}
|
|
186
184
|
formDataHolder = { ...formDataHolder, ...handlerResponse?.data }
|
|
187
|
-
if (!pageLoad) {
|
|
188
|
-
store.setFormdata((pre: any) => { return { ...pre, ...handlerResponse?.data } })
|
|
189
|
-
}
|
|
190
185
|
}
|
|
191
186
|
}
|
|
192
187
|
else if (eventConfig.type === "Table" && eventConfig.lazyLoading) {
|
|
193
188
|
if (handlerResponse && handlerResponse?.data) {
|
|
194
189
|
formDataHolder[componentName] = handlerResponse.data?.data
|
|
195
190
|
formDataHolder[`${componentName}_RowCount`] = handlerResponse.data?.meta?.totalRowCount
|
|
196
|
-
if (!pageLoad) {
|
|
197
|
-
store.setFormdata((pre: any) => {
|
|
198
|
-
return {
|
|
199
|
-
...pre,
|
|
200
|
-
[componentName]: handlerResponse.data?.data,
|
|
201
|
-
[`${componentName}_RowCount`]: handlerResponse.data?.meta?.totalRowCount
|
|
202
|
-
}
|
|
203
|
-
})
|
|
204
|
-
}
|
|
205
191
|
}
|
|
206
192
|
}
|
|
207
193
|
else {
|
|
208
194
|
if (handlerResponse) {
|
|
209
195
|
formDataHolder[componentName] = handlerResponse.data
|
|
210
|
-
if (!pageLoad) {
|
|
211
|
-
store.setFormdata((pre) => { return { ...pre, [componentName]: handlerResponse.data } });
|
|
212
|
-
}
|
|
213
196
|
}
|
|
214
197
|
}
|
|
215
198
|
};
|
|
@@ -92,7 +92,7 @@ export default (funcParams: funcParamsProps) => {
|
|
|
92
92
|
functionsProvider: funcParams.functionsProvider,
|
|
93
93
|
serviceHolder: this, eventGroups, formDataHolder,
|
|
94
94
|
}
|
|
95
|
-
|
|
95
|
+
|
|
96
96
|
funcParams.store.setSchema(
|
|
97
97
|
(pre: any) => {
|
|
98
98
|
return {
|
|
@@ -104,7 +104,7 @@ export default (funcParams: funcParamsProps) => {
|
|
|
104
104
|
await executeRefreshHandler({
|
|
105
105
|
config: {}, componentName: "",
|
|
106
106
|
store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
|
|
107
|
-
serviceHolder: this, eventGroups, formDataHolder: formDataHolder
|
|
107
|
+
serviceHolder: this, eventGroups, formDataHolder: formDataHolder
|
|
108
108
|
})
|
|
109
109
|
funcParams.store.setFormdata((pre) => ({ ...pre, ...formDataHolder }))
|
|
110
110
|
uiSchema.elements.push(notifyUiSchema);
|
|
@@ -247,13 +247,23 @@ export default (funcParams: funcParamsProps) => {
|
|
|
247
247
|
callHandler: async function (eventType: string, functionParameters?: any) {
|
|
248
248
|
const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[funcParams.dynamicData.path.split(".").length - 1];
|
|
249
249
|
if (eventGroups?.[eventType]?.[path] !== undefined) {
|
|
250
|
-
|
|
250
|
+
await Promise.all(eventGroups?.[eventType]?.[path].map(async (eventConfig) => {
|
|
251
251
|
executeEventsParameters.store.functionParameters = functionParameters
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
252
|
+
if (eventConfig.Handler === "refresh") {
|
|
253
|
+
await executeRefreshHandler({
|
|
254
|
+
...executeEventsParameters,
|
|
255
|
+
config: eventConfig,
|
|
256
|
+
componentName: path,
|
|
257
|
+
formDataHolder: formDataHolder
|
|
258
|
+
})
|
|
259
|
+
funcParams.store.setFormdata((pre) => ({ ...pre, ...formDataHolder }));
|
|
260
|
+
} else {
|
|
261
|
+
executeEvents({
|
|
262
|
+
...executeEventsParameters,
|
|
263
|
+
config: eventConfig,
|
|
264
|
+
componentName: path
|
|
265
|
+
})
|
|
266
|
+
}
|
|
257
267
|
}))
|
|
258
268
|
}
|
|
259
269
|
},
|