tuain-form-manager 1.4.4 → 1.4.7

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 +30 -19
  2. package/package.json +1 -1
package/lib/form.js CHANGED
@@ -366,7 +366,7 @@ class Form {
366
366
  }
367
367
 
368
368
  getTableDefinition(code) { return this._formDefinition?.tables.find(tbl => tbl.tableCode === code) ?? null; }
369
- getTableConstraints(tableCode) { return this.getTableDefinition(tableCode)?.constraints ?? null; }
369
+ getTableConstraints(tableCode) { return this._requestData.formData.tables[tableCode]; }
370
370
  onTableRowSelection(code, callback) { this.onTableAction(code, ROWSELECTION, callback); }
371
371
  onTablePopulate(code, callback) { this._tablePopulate[code] = callback; }
372
372
  onTableAction(tableCode, actionCode, callback) {
@@ -394,24 +394,35 @@ class Form {
394
394
  */
395
395
 
396
396
  setTableConstraints(tableCode, constraints) {
397
- const {
398
- visible = true, currentPage = 1, requestedPage = 1,
399
- recordsPerPage = DEFAULT_RECORDS_PAGE,
400
- sortingColumn, sortingDirection, currentFilter,
401
- } = constraints;
402
- const tableDef = this.getTableDefinition(tableCode);
403
- if (!tableDef) { return; }
404
- tableDef.constraints = {
405
- visible,
406
- currentPage,
407
- requestedPage,
408
- recordsPerPage,
409
- sortingColumn,
410
- sortingDirection,
411
- totalRecordsNumber: 0,
412
- recordsNumber: 0,
413
- currentFilter,
414
- };
397
+ const responseTable = this.getResponseTable(tableCode);
398
+ if (!responseTable || !constraints) { return; }
399
+ Object.keys(constraints)?.forEach((constraint) => {
400
+ switch (constraint) {
401
+ case 'visible':
402
+ responseTable.visible = constraints[constraint];
403
+ break;
404
+ case 'currentPage':
405
+ responseTable.currentPage = constraints[constraint];
406
+ break;
407
+ case 'requestedPage':
408
+ responseTable.requestedPage = constraints[constraint];
409
+ break;
410
+ case 'recordsPerPage':
411
+ responseTable.recordsPerPage = constraints[constraint];
412
+ break;
413
+ case 'sortingColumn':
414
+ responseTable.sortingColumn = constraints[constraint];
415
+ break;
416
+ case 'sortingDirection':
417
+ responseTable.sortingDirection = constraints[constraint];
418
+ break;
419
+ case 'totalRecordsNumber':
420
+ responseTable.totalRecordsNumber = constraints[constraint];
421
+ break;
422
+ default:
423
+ break;
424
+ }
425
+ });
415
426
  }
416
427
 
417
428
  async actionAllowed(actionCode) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tuain-form-manager",
3
- "version": "1.4.4",
3
+ "version": "1.4.7",
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": {