impaktapps-ui-builder 1.0.105 → 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.
@@ -10026,7 +10026,6 @@ function executeEventsHandler(params2) {
10026
10026
  params2.componentName,
10027
10027
  params2.config,
10028
10028
  params2.store,
10029
- params2.service,
10030
10029
  params2.formDataHolder
10031
10030
  );
10032
10031
  } else if (params2.config.Handler === "onBackHandler") {
@@ -10098,7 +10097,7 @@ function executeCustomHandler(params) {
10098
10097
  return response;
10099
10098
  }
10100
10099
  }
10101
- function mergeFormdata(handlerResponse, componentName, eventConfig, store2, service2, formDataHolder) {
10100
+ function mergeFormdata(handlerResponse, componentName, eventConfig, store2, formDataHolder) {
10102
10101
  var _a, _b, _c;
10103
10102
  if (eventConfig.type === "Select" && (handlerResponse == null ? void 0 : handlerResponse.data)) {
10104
10103
  if (!_.isEmpty(handlerResponse == null ? void 0 : handlerResponse.data)) {
@@ -10141,24 +10140,16 @@ function mergeFormdata(handlerResponse, componentName, eventConfig, store2, serv
10141
10140
  ...store2.newData,
10142
10141
  ...handlerResponse == null ? void 0 : handlerResponse.data
10143
10142
  };
10144
- store2.setFormdata((pre) => {
10145
- return { ...pre, ...handlerResponse == null ? void 0 : handlerResponse.data };
10146
- });
10143
+ formDataHolder = { ...formDataHolder, ...handlerResponse == null ? void 0 : handlerResponse.data };
10147
10144
  }
10148
10145
  } else if (eventConfig.type === "Table" && eventConfig.lazyLoading) {
10149
10146
  if (handlerResponse && (handlerResponse == null ? void 0 : handlerResponse.data)) {
10150
10147
  formDataHolder[componentName] = (_a = handlerResponse.data) == null ? void 0 : _a.data;
10151
10148
  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
- });
10155
10149
  }
10156
10150
  } else {
10157
10151
  if (handlerResponse) {
10158
10152
  formDataHolder[componentName] = handlerResponse.data;
10159
- store2.setFormdata((pre) => {
10160
- return { ...pre, ...formDataHolder };
10161
- });
10162
10153
  }
10163
10154
  }
10164
10155
  }
@@ -10349,8 +10340,9 @@ var service = (funcParams) => {
10349
10340
  service: funcParams.service,
10350
10341
  serviceHolder: this,
10351
10342
  eventGroups,
10352
- formDataHolder: {}
10343
+ formDataHolder
10353
10344
  });
10345
+ funcParams.store.setFormdata((pre) => ({ ...pre, ...formDataHolder }));
10354
10346
  uiSchema.elements.push(notifyUiSchema);
10355
10347
  funcParams.store.setUiSchema(uiSchema);
10356
10348
  },
@@ -10498,13 +10490,23 @@ var service = (funcParams) => {
10498
10490
  var _a, _b, _c;
10499
10491
  const path = ((_a = funcParams.dynamicData) == null ? void 0 : _a.tableButtonPath) || funcParams.dynamicData.path.split(".")[funcParams.dynamicData.path.split(".").length - 1];
10500
10492
  if (((_b = eventGroups == null ? void 0 : eventGroups[eventType]) == null ? void 0 : _b[path]) !== void 0) {
10501
- Promise.all((_c = eventGroups == null ? void 0 : eventGroups[eventType]) == null ? void 0 : _c[path].map((eventConfig) => {
10493
+ await Promise.all((_c = eventGroups == null ? void 0 : eventGroups[eventType]) == null ? void 0 : _c[path].map(async (eventConfig) => {
10502
10494
  executeEventsParameters.store.functionParameters = functionParameters;
10503
- executeEvents({
10504
- ...executeEventsParameters,
10505
- config: eventConfig,
10506
- componentName: path
10507
- });
10495
+ if (eventConfig.Handler === "refresh") {
10496
+ await executeRefreshHandler({
10497
+ ...executeEventsParameters,
10498
+ config: eventConfig,
10499
+ componentName: path,
10500
+ formDataHolder
10501
+ });
10502
+ funcParams.store.setFormdata((pre) => ({ ...pre, ...formDataHolder }));
10503
+ } else {
10504
+ executeEvents({
10505
+ ...executeEventsParameters,
10506
+ config: eventConfig,
10507
+ componentName: path
10508
+ });
10509
+ }
10508
10510
  }));
10509
10511
  }
10510
10512
  },
@@ -12318,94 +12320,67 @@ let schema = {
12318
12320
  properties: {},
12319
12321
  required: []
12320
12322
  };
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)
12323
+ function buildSchemaFromConfig(config2, parentSchema) {
12324
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
12325
+ if (config2.elements) {
12326
+ if (config2.type === "Array") {
12327
+ (_a = parentSchema.properties) != null ? _a : parentSchema.properties = {};
12328
+ (_d = (_b = parentSchema.properties)[_c = config2.name]) != null ? _d : _b[_c] = {
12329
+ type: "array",
12330
+ items: {
12331
+ type: "object",
12332
+ properties: {},
12333
+ required: []
12334
+ }
12373
12335
  };
12336
+ const arrayItemSchema = parentSchema.properties[config2.name].items;
12337
+ (_e = config2.elements) == null ? void 0 : _e.forEach(
12338
+ (child) => buildSchemaFromConfig(child, arrayItemSchema)
12339
+ );
12340
+ return;
12341
+ } else {
12342
+ (_f = config2.elements) == null ? void 0 : _f.forEach(
12343
+ (child) => buildSchemaFromConfig(child, parentSchema)
12344
+ );
12345
+ return;
12374
12346
  }
12375
12347
  }
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) => {
12348
+ (_g = parentSchema.properties) != null ? _g : parentSchema.properties = {};
12349
+ (_j = (_h = parentSchema.properties)[_i = config2.name]) != null ? _j : _h[_i] = {};
12350
+ const fieldSchema = parentSchema.properties[config2.name];
12351
+ (_k = config2.validation) == null ? void 0 : _k.forEach((v) => {
12395
12352
  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);
12353
+ if (v.validationType === "required") {
12354
+ (_a2 = parentSchema.required) != null ? _a2 : parentSchema.required = [];
12355
+ parentSchema.required.push(config2.name);
12356
+ } else if (v.validationType === "readOnly") {
12357
+ fieldSchema.type = "string";
12358
+ fieldSchema.disabled = true;
12359
+ } else {
12360
+ fieldSchema.type = "string";
12361
+ fieldSchema[v.validationType] = isNaN(v.validationValue) ? v.validationValue : Number(v.validationValue);
12402
12362
  }
12403
12363
  });
12404
- if (schema2.required.length === 0) {
12405
- delete schema2.required;
12364
+ if (config2.type === "Select" && ((_l = config2.value) == null ? void 0 : _l.length)) {
12365
+ fieldSchema.oneOf = config2.value.map((v) => ({
12366
+ const: v.value,
12367
+ title: v.label
12368
+ }));
12369
+ }
12370
+ if (config2.type === "MultipleSelect" && ((_m = config2.value) == null ? void 0 : _m.length)) {
12371
+ fieldSchema.type = "array";
12372
+ fieldSchema.items = {
12373
+ oneOf: config2.value.map((v) => ({
12374
+ const: v.value,
12375
+ title: v.label
12376
+ }))
12377
+ };
12406
12378
  }
12407
- return schema2;
12408
12379
  }
12380
+ const buildSchema = (config2) => {
12381
+ buildSchemaFromConfig(config2, schema);
12382
+ return schema;
12383
+ };
12409
12384
  const buildUiSchema = (config2, store2) => {
12410
12385
  let elements = {};
12411
12386
  const componentScope2 = `#/properties/${config2.name}`;