tuain-form-manager 1.2.1 → 1.2.3

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.
Files changed (2) hide show
  1. package/lib/form.js +21 -5
  2. package/package.json +1 -1
package/lib/form.js CHANGED
@@ -130,7 +130,13 @@ class Form {
130
130
  const content = JSON.stringify({ name, value });
131
131
  const signatureKey = this._requestContext.signatureKey ?? this._requestContext.deviceKey ?? '1234567890';
132
132
  const checkSignature = crypto.createHmac('sha256', signatureKey).update(content).digest('hex');
133
- return (signature === checkSignature) ? value : null;
133
+ let requiredData = value;
134
+ try {
135
+ requiredData = (typeof value === 'object') ? JSON.parse(JSON.stringify(value)) : value;
136
+ } catch (e) {
137
+ requiredData = value;
138
+ }
139
+ return (signature === checkSignature) ? requiredData : null;
134
140
  }
135
141
 
136
142
  get requestVersion() { return this._requestData.requestVersion; }
@@ -229,7 +235,9 @@ class Form {
229
235
  recordsPerPage, sortingColumn, sortingDirection,
230
236
  } = tableRequest;
231
237
  this._requestData.formData.tables[tableCode] = tableRequest;
232
- const constraints = { visible, currentPage, requestedPage, recordsPerPage, sortingColumn, sortingDirection, currentFilter };
238
+ const constraints = {
239
+ visible, currentPage, requestedPage, recordsPerPage, sortingColumn, sortingDirection, currentFilter,
240
+ };
233
241
  this.setTableConstraints(tableCode, constraints);
234
242
  }
235
243
 
@@ -448,12 +456,20 @@ class Form {
448
456
  const fieldObject = this.getField(code);
449
457
  if (!fieldObject) { return; }
450
458
  fieldObject.fieldOptions = [];
459
+ const numSeparators = (Array.isArray(valueField)) ? (valueField.length - 1) : 0;
451
460
  for (let i = 0; i < options?.length; i++) {
452
461
  const optionObj = options[i];
453
462
  const fieldOptionId = optionObj?.[idField];
454
- const fieldOptionValue = Array.isArray(valueField)
455
- ? valueField.reduce((acum, valFld) => `${acum}${optionObj?.[valFld] ?? ''}${saparator}`, '')
456
- : optionObj?.[valueField] ?? null;
463
+ let fieldOptionValue = '';
464
+ if (Array.isArray(valueField)) {
465
+ for (let index = 0; index < valueField.length; index++) {
466
+ const textPart = valueField[index];
467
+ fieldOptionValue += (index < numSeparators)
468
+ ? `${optionObj?.[textPart]} ${saparator} ` : optionObj?.[textPart];
469
+ }
470
+ } else {
471
+ fieldOptionValue = optionObj?.[valueField];
472
+ }
457
473
  if (fieldOptionId && fieldOptionValue) {
458
474
  fieldObject.fieldOptions.push({ fieldOptionId, fieldOptionValue });
459
475
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tuain-form-manager",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "Component library to perform operations on Tuain Development Framework forms to interchange information on web or mobile applications based on the data interchange of abstract forms making trnasformation on the data upon actions required on both sides (front and back)",
5
5
  "main": "index.js",
6
6
  "scripts": {