tuain-form-manager 1.1.30 → 1.2.1

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 +44 -14
  2. package/package.json +1 -1
package/lib/form.js CHANGED
@@ -26,7 +26,7 @@ const FIELD_ASSIGN_ATTRIBUTES = [
26
26
  'defaultEditable', 'defaultValue', 'alignment', 'required', 'errorCode', 'errorMessage', 'errorType',
27
27
  'tooltip', 'info', 'format', 'intrinsicErrorMessage', 'outputOnly', 'captureType', 'title', 'type',
28
28
  'maxLength', 'maxValue', 'minLength', 'minValue', 'validateOnServer', 'serverAction', 'visibleLabel',
29
- 'options',
29
+ 'options', 'editable',
30
30
  ];
31
31
 
32
32
  const SESSION_ATTRIBUTES = {
@@ -77,12 +77,12 @@ class Form {
77
77
  }
78
78
 
79
79
  importExchange(requestData, this);
80
- this.addActionMethod(START, () => this.start());
81
- this.addActionMethod(START_OPERATION, () => this.startOperation());
82
- this.addActionMethod(GETDATA, () => this.getData());
83
- this.addActionMethod(VALIDATE_FIELD, () => this.executeFieldValidation());
84
- this.addActionMethod(TABLE_ACCION, () => this.executeTableAction());
85
- this.addActionMethod(TABLE_GET_DATA, () => this.executeTablePopulate());
80
+ this.onAction(START, () => this.start());
81
+ this.onAction(START_OPERATION, () => this.startOperation());
82
+ this.onAction(GETDATA, () => this.getData());
83
+ this.onAction(VALIDATE_FIELD, () => this.executeFieldValidation());
84
+ this.onAction(TABLE_ACCION, () => this.executeTableAction());
85
+ this.onAction(TABLE_GET_DATA, () => this.executeTablePopulate());
86
86
  }
87
87
 
88
88
  // eslint-disable-next-line class-methods-use-this
@@ -196,7 +196,7 @@ class Form {
196
196
  hideAction(code) { this.setActionAttribute(code, VISIBLE, false); }
197
197
  enableAction(code) { this.setActionAttribute(code, DISABLED, false); }
198
198
  disableAction(code) { this.setActionAttribute(code, DISABLED, true); }
199
- addActionMethod(code, callback) { this._formActions[code] = callback; }
199
+ onAction(code, callback) { this._formActions[code] = callback; }
200
200
 
201
201
  showActions(actionArray) {
202
202
  const actionNames = (Array.isArray(actionArray)) ? actionArray : [actionArray];
@@ -269,12 +269,12 @@ class Form {
269
269
  getFieldValue(code) { return this.getField(code)?.fieldValue ?? null; }
270
270
  demandField(code) { this.setFieldAttribute(code, REQUIRED, true); }
271
271
  giveUpField(code) { this.setFieldAttribute(code, REQUIRED, false); }
272
- addFieldValidation(code, callback) { this._fieldValidations[code] = callback; }
272
+ onFieldValidation(code, callback) { this._fieldValidations[code] = callback; }
273
273
 
274
- addFieldsValidation(fields, callback) {
274
+ onFieldsValidation(fields, callback) {
275
275
  if (!Array.isArray(fields) || fields?.length === 0 || !callback) { return; }
276
276
  fields?.forEach((code) => {
277
- this.addFieldValidation(code, callback);
277
+ this.onFieldValidation(code, callback);
278
278
  });
279
279
  }
280
280
 
@@ -351,9 +351,9 @@ class Form {
351
351
 
352
352
  getTableDefinition(code) { return this._formDefinition?.tables.find(tbl => tbl.tableCode === code) ?? null; }
353
353
  getTableConstraints(tableCode) { return this.getTableDefinition(tableCode)?.constraints ?? null; }
354
- addTableRowSelection(code, callback) { this.addTableAction(code, ROWSELECTION, callback); }
355
- addTablePopulate(code, callback) { this._tablePopulate[code] = callback; }
356
- addTableAction(tableCode, actionCode, callback) {
354
+ onTableRowSelection(code, callback) { this.onTableAction(code, ROWSELECTION, callback); }
355
+ onTablePopulate(code, callback) { this._tablePopulate[code] = callback; }
356
+ onTableAction(tableCode, actionCode, callback) {
357
357
  if (!this._tableActions[tableCode]) { this._tableActions[tableCode] = {}; }
358
358
  this._tableActions[tableCode][actionCode] = callback;
359
359
  }
@@ -690,6 +690,36 @@ class Form {
690
690
  }
691
691
  return errorObject;
692
692
  }
693
+
694
+ /**
695
+ * @deprecated Use onAction
696
+ */
697
+ addActionMethod(code, callback) { return this.onAction(code, callback); }
698
+
699
+ /**
700
+ * @deprecated Use onFieldValidation
701
+ */
702
+ addFieldValidation(code, callback) { return this.onFieldValidation(code, callback); }
703
+
704
+ /**
705
+ * @deprecated Use onFieldsValidation
706
+ */
707
+ addFieldsValidation(fields, callback) { return this.onFieldsValidation(fields, callback); }
708
+
709
+ /**
710
+ * @deprecated Use onTableRowSelection
711
+ */
712
+ addTableRowSelection(code, callback) { return this.onTableRowSelection(code, callback); }
713
+
714
+ /**
715
+ * @deprecated Use onTablePopulate
716
+ */
717
+ addTablePopulate(code, callback) { return this.onTablePopulate(code, callback); }
718
+
719
+ /**
720
+ * @deprecated Use onTableAction
721
+ */
722
+ addTableAction(tableCode, actionCode, callback) { return this.onTableAction(tableCode, actionCode, callback); }
693
723
  }
694
724
 
695
725
  module.exports = Form;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tuain-form-manager",
3
- "version": "1.1.30",
3
+ "version": "1.2.1",
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": {