impaktapps-ui-builder 1.0.105 → 1.0.106

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.
@@ -10027,7 +10027,8 @@ function executeEventsHandler(params2) {
10027
10027
  params2.config,
10028
10028
  params2.store,
10029
10029
  params2.service,
10030
- params2.formDataHolder
10030
+ params2.formDataHolder,
10031
+ params2.pageLoad
10031
10032
  );
10032
10033
  } else if (params2.config.Handler === "onBackHandler") {
10033
10034
  return (_a = params2.store.functionParameters) == null ? void 0 : _a.handleBack();
@@ -10098,7 +10099,7 @@ function executeCustomHandler(params) {
10098
10099
  return response;
10099
10100
  }
10100
10101
  }
10101
- function mergeFormdata(handlerResponse, componentName, eventConfig, store2, service2, formDataHolder) {
10102
+ function mergeFormdata(handlerResponse, componentName, eventConfig, store2, service2, formDataHolder, pageLoad) {
10102
10103
  var _a, _b, _c;
10103
10104
  if (eventConfig.type === "Select" && (handlerResponse == null ? void 0 : handlerResponse.data)) {
10104
10105
  if (!_.isEmpty(handlerResponse == null ? void 0 : handlerResponse.data)) {
@@ -10141,24 +10142,36 @@ function mergeFormdata(handlerResponse, componentName, eventConfig, store2, serv
10141
10142
  ...store2.newData,
10142
10143
  ...handlerResponse == null ? void 0 : handlerResponse.data
10143
10144
  };
10144
- store2.setFormdata((pre) => {
10145
- return { ...pre, ...handlerResponse == null ? void 0 : handlerResponse.data };
10146
- });
10145
+ formDataHolder = { ...formDataHolder, ...handlerResponse == null ? void 0 : handlerResponse.data };
10146
+ if (!pageLoad) {
10147
+ store2.setFormdata((pre) => {
10148
+ return { ...pre, ...handlerResponse == null ? void 0 : handlerResponse.data };
10149
+ });
10150
+ }
10147
10151
  }
10148
10152
  } else if (eventConfig.type === "Table" && eventConfig.lazyLoading) {
10149
10153
  if (handlerResponse && (handlerResponse == null ? void 0 : handlerResponse.data)) {
10150
10154
  formDataHolder[componentName] = (_a = handlerResponse.data) == null ? void 0 : _a.data;
10151
10155
  formDataHolder[`${componentName}_RowCount`] = (_c = (_b = handlerResponse.data) == null ? void 0 : _b.meta) == null ? void 0 : _c.totalRowCount;
10152
- store2.setFormdata((pre) => {
10153
- return { ...pre, ...formDataHolder };
10154
- });
10156
+ if (!pageLoad) {
10157
+ store2.setFormdata((pre) => {
10158
+ var _a2, _b2, _c2;
10159
+ return {
10160
+ ...pre,
10161
+ [componentName]: (_a2 = handlerResponse.data) == null ? void 0 : _a2.data,
10162
+ [`${componentName}_RowCount`]: (_c2 = (_b2 = handlerResponse.data) == null ? void 0 : _b2.meta) == null ? void 0 : _c2.totalRowCount
10163
+ };
10164
+ });
10165
+ }
10155
10166
  }
10156
10167
  } else {
10157
10168
  if (handlerResponse) {
10158
10169
  formDataHolder[componentName] = handlerResponse.data;
10159
- store2.setFormdata((pre) => {
10160
- return { ...pre, ...formDataHolder };
10161
- });
10170
+ if (!pageLoad) {
10171
+ store2.setFormdata((pre) => {
10172
+ return { ...pre, [componentName]: handlerResponse.data };
10173
+ });
10174
+ }
10162
10175
  }
10163
10176
  }
10164
10177
  }
@@ -10349,8 +10362,10 @@ var service = (funcParams) => {
10349
10362
  service: funcParams.service,
10350
10363
  serviceHolder: this,
10351
10364
  eventGroups,
10352
- formDataHolder: {}
10365
+ formDataHolder,
10366
+ pageLoad: true
10353
10367
  });
10368
+ funcParams.store.setFormdata((pre) => ({ ...pre, ...formDataHolder }));
10354
10369
  uiSchema.elements.push(notifyUiSchema);
10355
10370
  funcParams.store.setUiSchema(uiSchema);
10356
10371
  },
@@ -12318,94 +12333,64 @@ let schema = {
12318
12333
  properties: {},
12319
12334
  required: []
12320
12335
  };
12321
- function buildOneOf(values) {
12322
- return values.map((e) => ({
12323
- const: e.value,
12324
- title: e.label
12325
- }));
12326
- }
12327
- function applyValidations(schemaNode, validations = [], requiredArr, fieldName) {
12328
- validations.forEach((rule) => {
12329
- if (rule.validationType === "readOnly") {
12330
- schemaNode.disabled = true;
12331
- }
12332
- if (rule.validationType === "required") {
12333
- if (requiredArr && fieldName) {
12334
- requiredArr.push(fieldName);
12335
- }
12336
- } else {
12337
- schemaNode.type = "string";
12338
- schemaNode[rule.validationType] = isNaN(rule.validationValue) ? rule.validationValue : Number(rule.validationValue);
12339
- }
12340
- });
12341
- }
12342
- function buildNode(config2) {
12343
- var _a, _b, _c;
12344
- if (config2.type === "Array") {
12345
- const arraySchema = {
12346
- type: "array",
12347
- items: {
12348
- type: "object",
12349
- properties: {},
12350
- required: []
12351
- }
12352
- };
12353
- (_a = config2.elements) == null ? void 0 : _a.forEach((child) => {
12354
- var _a2;
12355
- const childNode = buildNode(child);
12356
- if (!childNode)
12357
- return;
12358
- arraySchema.items.properties[child.name] = childNode.schema;
12359
- if ((_a2 = childNode.required) == null ? void 0 : _a2.length) {
12360
- arraySchema.items.required.push(child.name);
12361
- }
12362
- });
12363
- return { schema: arraySchema };
12364
- }
12365
- let fieldSchema = {};
12366
- if ((config2.type === "Select" || config2.type === "MultipleSelect") && ((_b = config2.value) == null ? void 0 : _b.length) > 0) {
12367
- if (config2.type === "Select") {
12368
- fieldSchema.oneOf = buildOneOf(config2.value);
12369
- } else {
12370
- fieldSchema.type = "array";
12371
- fieldSchema.items = {
12372
- oneOf: buildOneOf(config2.value)
12336
+ function buildSchemaFromConfig(config2, parentSchema) {
12337
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
12338
+ if (config2.elements) {
12339
+ if (config2.type === "Array") {
12340
+ (_a = parentSchema.properties) != null ? _a : parentSchema.properties = {};
12341
+ (_d = (_b = parentSchema.properties)[_c = config2.name]) != null ? _d : _b[_c] = {
12342
+ type: "array",
12343
+ items: {
12344
+ type: "object",
12345
+ properties: {},
12346
+ required: []
12347
+ }
12373
12348
  };
12349
+ const arrayItemSchema = parentSchema.properties[config2.name].items;
12350
+ (_e = config2.elements) == null ? void 0 : _e.forEach(
12351
+ (child) => buildSchemaFromConfig(child, arrayItemSchema)
12352
+ );
12353
+ return;
12354
+ } else {
12355
+ (_f = config2.elements) == null ? void 0 : _f.forEach(
12356
+ (child) => buildSchemaFromConfig(child, parentSchema)
12357
+ );
12358
+ return;
12374
12359
  }
12375
12360
  }
12376
- if (config2.validation) {
12377
- applyValidations(fieldSchema, config2.validation);
12378
- }
12379
- const required = ((_c = config2.validation) == null ? void 0 : _c.some(
12380
- (v) => v.validationType === "required"
12381
- )) ? [config2.name] : [];
12382
- return {
12383
- schema: fieldSchema,
12384
- required
12385
- };
12386
- }
12387
- function buildSchema(config2) {
12388
- var _a;
12389
- const schema2 = {
12390
- type: "object",
12391
- properties: {},
12392
- required: []
12393
- };
12394
- (_a = config2.elements) == null ? void 0 : _a.forEach((element) => {
12361
+ (_g = parentSchema.properties) != null ? _g : parentSchema.properties = {};
12362
+ (_j = (_h = parentSchema.properties)[_i = config2.name]) != null ? _j : _h[_i] = {};
12363
+ const fieldSchema = parentSchema.properties[config2.name];
12364
+ (_k = config2.validation) == null ? void 0 : _k.forEach((v) => {
12395
12365
  var _a2;
12396
- const node = buildNode(element);
12397
- if (!node)
12398
- return;
12399
- schema2.properties[element.name] = node.schema;
12400
- if ((_a2 = node.required) == null ? void 0 : _a2.length) {
12401
- schema2.required.push(element.name);
12366
+ if (v.validationType === "required") {
12367
+ (_a2 = parentSchema.required) != null ? _a2 : parentSchema.required = [];
12368
+ parentSchema.required.push(config2.name);
12369
+ } else {
12370
+ fieldSchema.type = "string";
12371
+ fieldSchema[v.validationType] = isNaN(v.validationValue) ? v.validationValue : Number(v.validationValue);
12402
12372
  }
12403
12373
  });
12404
- if (schema2.required.length === 0) {
12405
- delete schema2.required;
12374
+ if (config2.type === "Select" && ((_l = config2.value) == null ? void 0 : _l.length)) {
12375
+ fieldSchema.oneOf = config2.value.map((v) => ({
12376
+ const: v.value,
12377
+ title: v.label
12378
+ }));
12379
+ }
12380
+ if (config2.type === "MultipleSelect" && ((_m = config2.value) == null ? void 0 : _m.length)) {
12381
+ fieldSchema.type = "array";
12382
+ fieldSchema.items = {
12383
+ oneOf: config2.value.map((v) => ({
12384
+ const: v.value,
12385
+ title: v.label
12386
+ }))
12387
+ };
12406
12388
  }
12407
- return schema2;
12408
12389
  }
12390
+ const buildSchema = (config2) => {
12391
+ buildSchemaFromConfig(config2, schema);
12392
+ return schema;
12393
+ };
12409
12394
  const buildUiSchema = (config2, store2) => {
12410
12395
  let elements = {};
12411
12396
  const componentScope2 = `#/properties/${config2.name}`;