tuain-form-manager 1.1.30 → 1.2.0
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.
- package/lib/form.js +43 -13
- package/package.json +1 -1
package/lib/form.js
CHANGED
|
@@ -77,12 +77,12 @@ class Form {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
importExchange(requestData, this);
|
|
80
|
-
this.
|
|
81
|
-
this.
|
|
82
|
-
this.
|
|
83
|
-
this.
|
|
84
|
-
this.
|
|
85
|
-
this.
|
|
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
|
-
|
|
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
|
-
|
|
272
|
+
onFieldValidation(code, callback) { this._fieldValidations[code] = callback; }
|
|
273
273
|
|
|
274
|
-
|
|
274
|
+
onFieldsValidation(fields, callback) {
|
|
275
275
|
if (!Array.isArray(fields) || fields?.length === 0 || !callback) { return; }
|
|
276
276
|
fields?.forEach((code) => {
|
|
277
|
-
this.
|
|
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
|
-
|
|
355
|
-
|
|
356
|
-
|
|
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.
|
|
3
|
+
"version": "1.2.0",
|
|
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": {
|