tuain-form-manager 1.4.5 → 1.4.8

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.
@@ -151,6 +151,18 @@ class FormManager {
151
151
  errorObj = this.errMgr.get(modErrs.formActionExec.formNotFound, message);
152
152
  return [errorObj, null];
153
153
  }
154
+ const requireSession = formDefinition.form.requireSession ?? false;
155
+ if (requireSession) {
156
+ const { currentSession } = requestContext ?? {};
157
+ const { sessionDetail } = currentSession ?? {};
158
+ if (!currentSession || !sessionDetail) {
159
+ // El formulario requiere de la existencia de una sesión
160
+ message = `No existe una sesión válida para procesar la solicitud del formulario ${formCode}`;
161
+ this.logger.log({ level: 'error', label: 'FormManager', action: 'executeFormAction', message });
162
+ errorObj = this.errMgr.get(modErrs.formActionExec.sessionNotFound, message);
163
+ return [errorObj, null];
164
+ }
165
+ }
154
166
  [errorObj, resultForm] = await formCustomObject.executeFormAction(actionCode);
155
167
  message = `END FORM ACTION ${formCode} / ${actionCode} / ${errorObj?.errorCode ?? ''}`;
156
168
  this.logger.log({ level: 'info', label: 'FormManager', action: 'executeFormAction', message });
package/lib/form.js CHANGED
@@ -162,6 +162,7 @@ class Form {
162
162
  set currentMode(state) { this.state = state; }
163
163
 
164
164
  get formCode() { return this._formDefinition.form.formCode; }
165
+ get requireSession() { return this._formDefinition.form.requireSession ?? false; }
165
166
  get globalFunctions() { return this._formDefinition?.bussinesFunctionsRequired ?? []; }
166
167
  get responseData() { return this._responseData; }
167
168
  set returnedFile(fileContent) { this._responseData.returnedFile = fileContent; }
@@ -366,7 +367,7 @@ class Form {
366
367
  }
367
368
 
368
369
  getTableDefinition(code) { return this._formDefinition?.tables.find(tbl => tbl.tableCode === code) ?? null; }
369
- getTableConstraints(tableCode) { return this.getTableDefinition(tableCode)?.constraints ?? null; }
370
+ getTableConstraints(tableCode) { return this._requestData.formData.tables[tableCode]; }
370
371
  onTableRowSelection(code, callback) { this.onTableAction(code, ROWSELECTION, callback); }
371
372
  onTablePopulate(code, callback) { this._tablePopulate[code] = callback; }
372
373
  onTableAction(tableCode, actionCode, callback) {
@@ -416,6 +417,9 @@ class Form {
416
417
  case 'sortingDirection':
417
418
  responseTable.sortingDirection = constraints[constraint];
418
419
  break;
420
+ case 'totalRecordsNumber':
421
+ responseTable.totalRecordsNumber = constraints[constraint];
422
+ break;
419
423
  default:
420
424
  break;
421
425
  }
@@ -8,6 +8,7 @@ module.exports = {
8
8
  formNotFound: ['01', 'Formulario no encontrado', 404],
9
9
  actionNotDefined: ['02', 'Acción no definida', 404],
10
10
  exceptionNotHandled: ['03', 'Excepción no controlada', 400],
11
+ sessionNotFound: ['04', 'Excepción no controlada', 400],
11
12
  },
12
13
  fieldValidation: {
13
14
  NoValidationCallback: ['01', 'Función de validación no existe', 405],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tuain-form-manager",
3
- "version": "1.4.5",
3
+ "version": "1.4.8",
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": {