tuain-ng-forms-lib 13.0.9 → 13.0.11
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/esm2020/lib/classes/forms/field.mjs +2 -3
- package/esm2020/lib/components/forms/basic-form.mjs +135 -99
- package/fesm2015/tuain-ng-forms-lib.mjs +142 -100
- package/fesm2015/tuain-ng-forms-lib.mjs.map +1 -1
- package/fesm2020/tuain-ng-forms-lib.mjs +135 -100
- package/fesm2020/tuain-ng-forms-lib.mjs.map +1 -1
- package/lib/components/forms/basic-form.d.ts +20 -20
- package/package.json +1 -1
|
@@ -666,8 +666,7 @@ class FieldDescriptor extends FormElement {
|
|
|
666
666
|
get value() { return this.getValue(); }
|
|
667
667
|
set value(newValue) { this.setValue(newValue); }
|
|
668
668
|
notifyEditionPartial() {
|
|
669
|
-
|
|
670
|
-
this._editionPartial.next({ code: this.fieldCode, intrinsicValidation });
|
|
669
|
+
this._editionPartial.next({ code: this.fieldCode, intrinsicValidation: true });
|
|
671
670
|
}
|
|
672
671
|
notifyEditionFinish() {
|
|
673
672
|
let intrinsicValidation = true;
|
|
@@ -2692,40 +2691,40 @@ class BasicFormComponent {
|
|
|
2692
2691
|
/**
|
|
2693
2692
|
* Manejo de event handlers para acciones sobre el formulario
|
|
2694
2693
|
*/
|
|
2695
|
-
addSectionActivation(codes,
|
|
2694
|
+
addSectionActivation(codes, callback, properties = null) {
|
|
2696
2695
|
const sectionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
2697
2696
|
sectionSet.forEach((sectionName) => {
|
|
2698
2697
|
if (!this._formSectionsActivate[sectionName]) {
|
|
2699
2698
|
this._formSectionsActivate[sectionName] = [];
|
|
2700
2699
|
}
|
|
2701
|
-
this._formSectionsActivate[sectionName].push(
|
|
2700
|
+
this._formSectionsActivate[sectionName].push({ callback, properties });
|
|
2702
2701
|
});
|
|
2703
2702
|
}
|
|
2704
|
-
addSectionInactivation(codes,
|
|
2703
|
+
addSectionInactivation(codes, callback, properties = null) {
|
|
2705
2704
|
const sectionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
2706
2705
|
sectionSet.forEach((sectionName) => {
|
|
2707
2706
|
if (!this._formSectionsInactivate[sectionName]) {
|
|
2708
2707
|
this._formSectionsInactivate[sectionName] = [];
|
|
2709
2708
|
}
|
|
2710
|
-
this._formSectionsInactivate[sectionName].push(
|
|
2709
|
+
this._formSectionsInactivate[sectionName].push({ callback, properties });
|
|
2711
2710
|
});
|
|
2712
2711
|
}
|
|
2713
|
-
addActionMethodStart(codes,
|
|
2712
|
+
addActionMethodStart(codes, callback, properties = null) {
|
|
2714
2713
|
const actionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
2715
2714
|
actionSet.forEach((actionName) => {
|
|
2716
2715
|
if (!this._formActionsStart[actionName]) {
|
|
2717
2716
|
this._formActionsStart[actionName] = [];
|
|
2718
2717
|
}
|
|
2719
|
-
this._formActionsStart[actionName].push(
|
|
2718
|
+
this._formActionsStart[actionName].push({ callback, properties });
|
|
2720
2719
|
});
|
|
2721
2720
|
}
|
|
2722
|
-
addActionMethodFinish(codes,
|
|
2721
|
+
addActionMethodFinish(codes, callback, properties = null) {
|
|
2723
2722
|
const actionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
2724
2723
|
actionSet.forEach((actionName) => {
|
|
2725
2724
|
if (!this._formActionsFinish[actionName]) {
|
|
2726
2725
|
this._formActionsFinish[actionName] = [];
|
|
2727
2726
|
}
|
|
2728
|
-
this._formActionsFinish[actionName].push(
|
|
2727
|
+
this._formActionsFinish[actionName].push({ callback, properties });
|
|
2729
2728
|
});
|
|
2730
2729
|
}
|
|
2731
2730
|
async launchSectionActivation(code) {
|
|
@@ -2736,7 +2735,8 @@ class BasicFormComponent {
|
|
|
2736
2735
|
const clientSectionMethods = this._formSectionsActivate[code];
|
|
2737
2736
|
if (clientSectionMethods) {
|
|
2738
2737
|
for (const clientSectionMethod of clientSectionMethods) {
|
|
2739
|
-
clientSectionMethod
|
|
2738
|
+
const { callback, properties } = clientSectionMethod;
|
|
2739
|
+
callback(sectionObject);
|
|
2740
2740
|
}
|
|
2741
2741
|
}
|
|
2742
2742
|
}
|
|
@@ -2748,7 +2748,8 @@ class BasicFormComponent {
|
|
|
2748
2748
|
const clientSectionMethods = this._formSectionsInactivate[code];
|
|
2749
2749
|
if (clientSectionMethods) {
|
|
2750
2750
|
for (const clientSectionMethod of clientSectionMethods) {
|
|
2751
|
-
clientSectionMethod
|
|
2751
|
+
const { callback, properties } = clientSectionMethod;
|
|
2752
|
+
callback(sectionObject);
|
|
2752
2753
|
}
|
|
2753
2754
|
}
|
|
2754
2755
|
}
|
|
@@ -2763,11 +2764,12 @@ class BasicFormComponent {
|
|
|
2763
2764
|
if (clientActionMethods) {
|
|
2764
2765
|
const clientActionPromises = [];
|
|
2765
2766
|
for (const clientActionMethod of clientActionMethods) {
|
|
2766
|
-
const
|
|
2767
|
+
const { callback, properties } = clientActionMethod;
|
|
2768
|
+
const continueActionPromise = callback(actionObject);
|
|
2767
2769
|
clientActionPromises.push(continueActionPromise);
|
|
2768
2770
|
}
|
|
2769
2771
|
const clientActionResults = await Promise.all(clientActionPromises);
|
|
2770
|
-
const continueAction = clientActionResults.reduce((total, curr) => (total && curr), true);
|
|
2772
|
+
const continueAction = clientActionResults.reduce((total, curr) => (total && (curr !== false)), true);
|
|
2771
2773
|
if (!continueAction) {
|
|
2772
2774
|
actionObject.stop();
|
|
2773
2775
|
return;
|
|
@@ -2778,14 +2780,14 @@ class BasicFormComponent {
|
|
|
2778
2780
|
async startServerAction(actionInput) {
|
|
2779
2781
|
const action = (typeof actionInput === 'string')
|
|
2780
2782
|
? this.getAction(actionInput) : actionInput;
|
|
2781
|
-
let
|
|
2783
|
+
let serverError = false;
|
|
2782
2784
|
let actionResult = null;
|
|
2783
2785
|
if (action.backend) {
|
|
2784
2786
|
actionResult = await this.requestFormAction(action.actionCode);
|
|
2785
|
-
|
|
2787
|
+
serverError = !!this.errorOccured();
|
|
2786
2788
|
}
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
+
await this.finishAction(action, actionResult, serverError);
|
|
2790
|
+
if (!serverError) {
|
|
2789
2791
|
action.newState && this.changeState(action.newState);
|
|
2790
2792
|
}
|
|
2791
2793
|
else {
|
|
@@ -2793,12 +2795,16 @@ class BasicFormComponent {
|
|
|
2793
2795
|
}
|
|
2794
2796
|
action.stop();
|
|
2795
2797
|
}
|
|
2796
|
-
async finishAction(action, actionResult) {
|
|
2798
|
+
async finishAction(action, actionResult, serverError = false) {
|
|
2797
2799
|
const finishActionMethods = this._formActionsFinish[action.actionCode];
|
|
2798
2800
|
if (finishActionMethods) {
|
|
2799
2801
|
const clientActionPromises = [];
|
|
2800
2802
|
for (const clientActionMethod of finishActionMethods) {
|
|
2801
|
-
|
|
2803
|
+
const { callback, properties } = clientActionMethod;
|
|
2804
|
+
const continueOnError = properties?.continueOnError ?? false;
|
|
2805
|
+
if (!serverError || continueOnError) {
|
|
2806
|
+
clientActionPromises.push(callback(action, actionResult));
|
|
2807
|
+
}
|
|
2802
2808
|
}
|
|
2803
2809
|
await Promise.all(clientActionPromises);
|
|
2804
2810
|
}
|
|
@@ -2809,31 +2815,31 @@ class BasicFormComponent {
|
|
|
2809
2815
|
/**
|
|
2810
2816
|
* Manejadores de eventos para validaciones sobre campos
|
|
2811
2817
|
*/
|
|
2812
|
-
addFieldInputValidation(codes,
|
|
2818
|
+
addFieldInputValidation(codes, callback, properties = null) {
|
|
2813
2819
|
const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
2814
2820
|
fieldSet.forEach((fieldCode) => {
|
|
2815
2821
|
if (!this._fieldInputValidation[fieldCode]) {
|
|
2816
2822
|
this._fieldInputValidation[fieldCode] = [];
|
|
2817
2823
|
}
|
|
2818
|
-
this._fieldInputValidation[fieldCode].push(
|
|
2824
|
+
this._fieldInputValidation[fieldCode].push({ callback, properties });
|
|
2819
2825
|
});
|
|
2820
2826
|
}
|
|
2821
|
-
addFieldValidationStart(codes,
|
|
2827
|
+
addFieldValidationStart(codes, callback, properties = null) {
|
|
2822
2828
|
const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
2823
2829
|
fieldSet.forEach((fieldCode) => {
|
|
2824
2830
|
if (!this._fieldValidationsStart[fieldCode]) {
|
|
2825
2831
|
this._fieldValidationsStart[fieldCode] = [];
|
|
2826
2832
|
}
|
|
2827
|
-
this._fieldValidationsStart[fieldCode].push(
|
|
2833
|
+
this._fieldValidationsStart[fieldCode].push({ callback, properties });
|
|
2828
2834
|
});
|
|
2829
2835
|
}
|
|
2830
|
-
addFieldValidationFinish(codes,
|
|
2836
|
+
addFieldValidationFinish(codes, callback, properties = null) {
|
|
2831
2837
|
const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
2832
2838
|
fieldSet.forEach((fieldCode) => {
|
|
2833
2839
|
if (!this._fieldValidationsFinish[fieldCode]) {
|
|
2834
2840
|
this._fieldValidationsFinish[fieldCode] = [];
|
|
2835
2841
|
}
|
|
2836
|
-
this._fieldValidationsFinish[fieldCode].push(
|
|
2842
|
+
this._fieldValidationsFinish[fieldCode].push({ callback, properties });
|
|
2837
2843
|
});
|
|
2838
2844
|
}
|
|
2839
2845
|
async startFieldInputValidation(fieldCode, intrinsicValidation = true) {
|
|
@@ -2846,7 +2852,8 @@ class BasicFormComponent {
|
|
|
2846
2852
|
if (validationCallbacks) {
|
|
2847
2853
|
const clientValidationPromises = [];
|
|
2848
2854
|
for (const validationMethod of validationCallbacks) {
|
|
2849
|
-
const
|
|
2855
|
+
const { callback, properties } = validationMethod;
|
|
2856
|
+
const continueValidationPromise = callback(fieldToValidate);
|
|
2850
2857
|
clientValidationPromises.push(continueValidationPromise);
|
|
2851
2858
|
}
|
|
2852
2859
|
await Promise.all(clientValidationPromises);
|
|
@@ -2855,7 +2862,7 @@ class BasicFormComponent {
|
|
|
2855
2862
|
}
|
|
2856
2863
|
async startFieldValidation(fieldCode, intrinsicValidation = true) {
|
|
2857
2864
|
const fieldToValidate = this.getField(fieldCode);
|
|
2858
|
-
if (!fieldToValidate
|
|
2865
|
+
if (!fieldToValidate) {
|
|
2859
2866
|
return;
|
|
2860
2867
|
}
|
|
2861
2868
|
fieldToValidate.resetError();
|
|
@@ -2863,44 +2870,49 @@ class BasicFormComponent {
|
|
|
2863
2870
|
if (validationCallbacks) {
|
|
2864
2871
|
const clientValidationPromises = [];
|
|
2865
2872
|
for (const validationMethod of validationCallbacks) {
|
|
2866
|
-
const
|
|
2873
|
+
const { callback, properties } = validationMethod;
|
|
2874
|
+
const clientValidationPromise = callback(fieldToValidate);
|
|
2867
2875
|
clientValidationPromises.push(clientValidationPromise);
|
|
2868
2876
|
}
|
|
2869
2877
|
const clientValidationResults = await Promise.all(clientValidationPromises);
|
|
2870
|
-
const continueValidation = clientValidationResults.reduce((total, curr) => (total && curr), true);
|
|
2878
|
+
const continueValidation = clientValidationResults.reduce((total, curr) => (total && (curr !== false)), true);
|
|
2871
2879
|
if (!continueValidation) {
|
|
2872
2880
|
return;
|
|
2873
2881
|
}
|
|
2874
2882
|
}
|
|
2875
|
-
|
|
2883
|
+
if (intrinsicValidation) {
|
|
2884
|
+
this.startServerFieldValidation(fieldToValidate);
|
|
2885
|
+
}
|
|
2876
2886
|
}
|
|
2877
2887
|
async startServerFieldValidation(inputField) {
|
|
2878
2888
|
const fieldObj = (typeof inputField === 'string')
|
|
2879
2889
|
? this.getField(inputField) : inputField;
|
|
2880
|
-
let
|
|
2881
|
-
let validationResult =
|
|
2890
|
+
let serverError = false;
|
|
2891
|
+
let validationResult = true;
|
|
2882
2892
|
if (fieldObj.backend) {
|
|
2883
2893
|
fieldObj.validating = true;
|
|
2884
2894
|
validationResult = await this
|
|
2885
2895
|
.requestFormAction(formActions.validate, fieldObj.fieldCode);
|
|
2886
|
-
|
|
2887
|
-
}
|
|
2888
|
-
if (finish) {
|
|
2889
|
-
await this.finishFieldValidation(fieldObj, validationResult);
|
|
2896
|
+
serverError = !!this.errorOccured();
|
|
2890
2897
|
}
|
|
2891
|
-
|
|
2898
|
+
await this.finishFieldValidation(fieldObj, validationResult, serverError);
|
|
2899
|
+
if (serverError) {
|
|
2892
2900
|
fieldObj.setErrorCode(this.errorCode);
|
|
2893
2901
|
fieldObj.setErrorMessage(this.errorMessage);
|
|
2894
2902
|
this.displayValidationServerError();
|
|
2895
2903
|
}
|
|
2896
2904
|
fieldObj.validating = false;
|
|
2897
2905
|
}
|
|
2898
|
-
async finishFieldValidation(fieldObject, validationResult) {
|
|
2906
|
+
async finishFieldValidation(fieldObject, validationResult, serverError = false) {
|
|
2899
2907
|
const validationCallbacks = this._fieldValidationsFinish[fieldObject.fieldCode];
|
|
2900
2908
|
if (validationCallbacks) {
|
|
2901
2909
|
const clientActionPromises = [];
|
|
2902
2910
|
for (const validationMethod of validationCallbacks) {
|
|
2903
|
-
|
|
2911
|
+
const { callback, properties } = validationMethod;
|
|
2912
|
+
const continueOnError = properties?.continueOnError ?? false;
|
|
2913
|
+
if (!serverError || continueOnError) {
|
|
2914
|
+
clientActionPromises.push(callback(fieldObject, validationResult));
|
|
2915
|
+
}
|
|
2904
2916
|
}
|
|
2905
2917
|
await Promise.all(clientActionPromises);
|
|
2906
2918
|
}
|
|
@@ -2911,7 +2923,7 @@ class BasicFormComponent {
|
|
|
2911
2923
|
/**
|
|
2912
2924
|
* Manejadores de eventos para acciones sobre Tablas
|
|
2913
2925
|
*/
|
|
2914
|
-
addTableActionStart(code, actionCode,
|
|
2926
|
+
addTableActionStart(code, actionCode, callback, properties = null) {
|
|
2915
2927
|
const tableObject = this.getTable(code);
|
|
2916
2928
|
if (!tableObject) {
|
|
2917
2929
|
return;
|
|
@@ -2920,7 +2932,7 @@ class BasicFormComponent {
|
|
|
2920
2932
|
if (!inlineActionObject) {
|
|
2921
2933
|
return;
|
|
2922
2934
|
}
|
|
2923
|
-
let tableEventHandlers
|
|
2935
|
+
let tableEventHandlers;
|
|
2924
2936
|
if (this._tableActionsStart[code]) {
|
|
2925
2937
|
tableEventHandlers = this._tableActionsStart[code];
|
|
2926
2938
|
}
|
|
@@ -2931,9 +2943,9 @@ class BasicFormComponent {
|
|
|
2931
2943
|
if (!tableEventHandlers[actionCode]) {
|
|
2932
2944
|
tableEventHandlers[actionCode] = [];
|
|
2933
2945
|
}
|
|
2934
|
-
tableEventHandlers[actionCode].push(
|
|
2946
|
+
tableEventHandlers[actionCode].push({ callback, properties });
|
|
2935
2947
|
}
|
|
2936
|
-
addTableActionFinish(code, actionCode,
|
|
2948
|
+
addTableActionFinish(code, actionCode, callback, properties = null) {
|
|
2937
2949
|
const tableObject = this.getTable(code);
|
|
2938
2950
|
if (!tableObject) {
|
|
2939
2951
|
return;
|
|
@@ -2942,7 +2954,7 @@ class BasicFormComponent {
|
|
|
2942
2954
|
if (!inlineActionObject) {
|
|
2943
2955
|
return;
|
|
2944
2956
|
}
|
|
2945
|
-
let tableEventHandlers
|
|
2957
|
+
let tableEventHandlers;
|
|
2946
2958
|
if (this._tableActionsFinish[code]) {
|
|
2947
2959
|
tableEventHandlers = this._tableActionsFinish[code];
|
|
2948
2960
|
}
|
|
@@ -2953,14 +2965,14 @@ class BasicFormComponent {
|
|
|
2953
2965
|
if (!tableEventHandlers[actionCode]) {
|
|
2954
2966
|
tableEventHandlers[actionCode] = [];
|
|
2955
2967
|
}
|
|
2956
|
-
tableEventHandlers[actionCode].push(
|
|
2968
|
+
tableEventHandlers[actionCode].push({ callback, properties });
|
|
2957
2969
|
}
|
|
2958
|
-
addTableSelectionStart(code,
|
|
2970
|
+
addTableSelectionStart(code, callback, properties = null) {
|
|
2959
2971
|
const tableObject = this.getTable(code);
|
|
2960
2972
|
if (!tableObject) {
|
|
2961
2973
|
return;
|
|
2962
2974
|
}
|
|
2963
|
-
let tableEventHandlers
|
|
2975
|
+
let tableEventHandlers;
|
|
2964
2976
|
if (this._tableSelectionsStart[code]) {
|
|
2965
2977
|
tableEventHandlers = this._tableSelectionsStart[code];
|
|
2966
2978
|
}
|
|
@@ -2968,14 +2980,14 @@ class BasicFormComponent {
|
|
|
2968
2980
|
tableEventHandlers = [];
|
|
2969
2981
|
this._tableSelectionsStart[code] = tableEventHandlers;
|
|
2970
2982
|
}
|
|
2971
|
-
tableEventHandlers.push(
|
|
2983
|
+
tableEventHandlers.push({ callback, properties });
|
|
2972
2984
|
}
|
|
2973
|
-
addTableSelectionFinish(code,
|
|
2985
|
+
addTableSelectionFinish(code, callback, properties = null) {
|
|
2974
2986
|
const tableObject = this.getTable(code);
|
|
2975
2987
|
if (!tableObject) {
|
|
2976
2988
|
return;
|
|
2977
2989
|
}
|
|
2978
|
-
let tableEventHandlers
|
|
2990
|
+
let tableEventHandlers;
|
|
2979
2991
|
if (this._tableSelectionsFinish[code]) {
|
|
2980
2992
|
tableEventHandlers = this._tableSelectionsFinish[code];
|
|
2981
2993
|
}
|
|
@@ -2983,14 +2995,14 @@ class BasicFormComponent {
|
|
|
2983
2995
|
tableEventHandlers = [];
|
|
2984
2996
|
this._tableSelectionsFinish[code] = tableEventHandlers;
|
|
2985
2997
|
}
|
|
2986
|
-
tableEventHandlers.push(
|
|
2998
|
+
tableEventHandlers.push({ callback, properties });
|
|
2987
2999
|
}
|
|
2988
|
-
addTableGetDataStart(code,
|
|
3000
|
+
addTableGetDataStart(code, callback, properties = null) {
|
|
2989
3001
|
const tableObject = this.getTable(code);
|
|
2990
3002
|
if (!tableObject) {
|
|
2991
3003
|
return;
|
|
2992
3004
|
}
|
|
2993
|
-
let tableEventHandlers
|
|
3005
|
+
let tableEventHandlers;
|
|
2994
3006
|
if (this._tableGetDataStart[code]) {
|
|
2995
3007
|
tableEventHandlers = this._tableGetDataStart[code];
|
|
2996
3008
|
}
|
|
@@ -2998,14 +3010,14 @@ class BasicFormComponent {
|
|
|
2998
3010
|
tableEventHandlers = [];
|
|
2999
3011
|
this._tableGetDataStart[code] = tableEventHandlers;
|
|
3000
3012
|
}
|
|
3001
|
-
tableEventHandlers.push(
|
|
3013
|
+
tableEventHandlers.push({ callback, properties });
|
|
3002
3014
|
}
|
|
3003
|
-
addTableGetDataFinish(code,
|
|
3015
|
+
addTableGetDataFinish(code, callback, properties = null) {
|
|
3004
3016
|
const tableObject = this.getTable(code);
|
|
3005
3017
|
if (!tableObject) {
|
|
3006
3018
|
return;
|
|
3007
3019
|
}
|
|
3008
|
-
let tableEventHandlers
|
|
3020
|
+
let tableEventHandlers;
|
|
3009
3021
|
if (this._tableGetDataFinish[code]) {
|
|
3010
3022
|
tableEventHandlers = this._tableGetDataFinish[code];
|
|
3011
3023
|
}
|
|
@@ -3013,7 +3025,7 @@ class BasicFormComponent {
|
|
|
3013
3025
|
tableEventHandlers = {};
|
|
3014
3026
|
this._tableGetDataFinish[code] = tableEventHandlers;
|
|
3015
3027
|
}
|
|
3016
|
-
tableEventHandlers[GET_DATA_ACTION] =
|
|
3028
|
+
tableEventHandlers[GET_DATA_ACTION] = { callback, properties };
|
|
3017
3029
|
}
|
|
3018
3030
|
async startTableGlobalAction(tableActionEvent) {
|
|
3019
3031
|
const { tableCode, actionCode } = tableActionEvent;
|
|
@@ -3037,11 +3049,12 @@ class BasicFormComponent {
|
|
|
3037
3049
|
if (tableActionMethods) {
|
|
3038
3050
|
const clientActionPromises = [];
|
|
3039
3051
|
for (const tableActionMethod of tableActionMethods) {
|
|
3040
|
-
const
|
|
3052
|
+
const { callback, properties } = tableActionMethod;
|
|
3053
|
+
const clientActionPromise = callback(tableActionDetail);
|
|
3041
3054
|
clientActionPromises.push(clientActionPromise);
|
|
3042
3055
|
}
|
|
3043
3056
|
const clientActionResults = await Promise.all(clientActionPromises);
|
|
3044
|
-
const continueAction = clientActionResults.reduce((total, curr) => (total && curr), true);
|
|
3057
|
+
const continueAction = clientActionResults.reduce((total, curr) => (total && (curr !== false)), true);
|
|
3045
3058
|
if (!continueAction) {
|
|
3046
3059
|
return;
|
|
3047
3060
|
}
|
|
@@ -3054,7 +3067,7 @@ class BasicFormComponent {
|
|
|
3054
3067
|
return;
|
|
3055
3068
|
}
|
|
3056
3069
|
tableObject.putOnWait();
|
|
3057
|
-
let
|
|
3070
|
+
let serverError = false;
|
|
3058
3071
|
let actionResult = null;
|
|
3059
3072
|
if (action.backend) {
|
|
3060
3073
|
const actionSubject = {
|
|
@@ -3064,10 +3077,10 @@ class BasicFormComponent {
|
|
|
3064
3077
|
};
|
|
3065
3078
|
actionResult = await this
|
|
3066
3079
|
.requestFormAction(formActions.tableAction, actionSubject);
|
|
3067
|
-
|
|
3080
|
+
serverError = !!this.errorOccured();
|
|
3068
3081
|
}
|
|
3069
|
-
|
|
3070
|
-
|
|
3082
|
+
await this.finishTableGlobalAction(tableActionDetail, actionResult, serverError);
|
|
3083
|
+
if (!serverError) {
|
|
3071
3084
|
action.newState && this.changeState(action.newState);
|
|
3072
3085
|
}
|
|
3073
3086
|
else {
|
|
@@ -3075,14 +3088,18 @@ class BasicFormComponent {
|
|
|
3075
3088
|
}
|
|
3076
3089
|
tableObject.freeWaiting();
|
|
3077
3090
|
}
|
|
3078
|
-
async finishTableGlobalAction(tableActionDetail, actionResult) {
|
|
3091
|
+
async finishTableGlobalAction(tableActionDetail, actionResult, serverError = false) {
|
|
3079
3092
|
const { tableCode, actionCode } = tableActionDetail;
|
|
3080
3093
|
const tableEventHandlers = this._tableActionsFinish[tableCode];
|
|
3081
3094
|
const tableActionMethods = (tableEventHandlers) ? tableEventHandlers[actionCode] : null;
|
|
3082
3095
|
if (tableActionMethods) {
|
|
3083
3096
|
const clientActionPromises = [];
|
|
3084
3097
|
for (const tableActionMethod of tableActionMethods) {
|
|
3085
|
-
|
|
3098
|
+
const { callback, properties } = tableActionMethod;
|
|
3099
|
+
const continueOnError = properties?.continueOnError ?? false;
|
|
3100
|
+
if (!serverError || continueOnError) {
|
|
3101
|
+
clientActionPromises.push(callback(tableActionDetail, actionResult));
|
|
3102
|
+
}
|
|
3086
3103
|
}
|
|
3087
3104
|
await Promise.all(clientActionPromises);
|
|
3088
3105
|
}
|
|
@@ -3112,11 +3129,12 @@ class BasicFormComponent {
|
|
|
3112
3129
|
if (tableActionMethods) {
|
|
3113
3130
|
const clientActionPromises = [];
|
|
3114
3131
|
for (const tableActionMethod of tableActionMethods) {
|
|
3115
|
-
const
|
|
3132
|
+
const { callback, properties } = tableActionMethod;
|
|
3133
|
+
const clientActionPromise = callback(tableActionDetail);
|
|
3116
3134
|
clientActionPromises.push(clientActionPromise);
|
|
3117
3135
|
}
|
|
3118
3136
|
const clientActionResults = await Promise.all(clientActionPromises);
|
|
3119
|
-
const continueAction = clientActionResults.reduce((total, curr) => (total && curr), true);
|
|
3137
|
+
const continueAction = clientActionResults.reduce((total, curr) => (total && (curr !== false)), true);
|
|
3120
3138
|
if (!continueAction) {
|
|
3121
3139
|
return;
|
|
3122
3140
|
}
|
|
@@ -3129,7 +3147,7 @@ class BasicFormComponent {
|
|
|
3129
3147
|
return;
|
|
3130
3148
|
}
|
|
3131
3149
|
tableObject.putOnWait();
|
|
3132
|
-
let
|
|
3150
|
+
let serverError = false;
|
|
3133
3151
|
let actionResult = null;
|
|
3134
3152
|
if (action.backend) {
|
|
3135
3153
|
const actionSubject = {
|
|
@@ -3141,10 +3159,10 @@ class BasicFormComponent {
|
|
|
3141
3159
|
};
|
|
3142
3160
|
actionResult = await this
|
|
3143
3161
|
.requestFormAction(formActions.tableAction, actionSubject);
|
|
3144
|
-
|
|
3162
|
+
serverError = !!this.errorOccured();
|
|
3145
3163
|
}
|
|
3146
|
-
|
|
3147
|
-
|
|
3164
|
+
await this.finishTableAction(tableActionDetail, actionResult, serverError);
|
|
3165
|
+
if (!serverError) {
|
|
3148
3166
|
action.newState && this.changeState(action.newState);
|
|
3149
3167
|
}
|
|
3150
3168
|
else {
|
|
@@ -3155,14 +3173,18 @@ class BasicFormComponent {
|
|
|
3155
3173
|
completeInlineAction(tableAction) {
|
|
3156
3174
|
return this.startTableServerAction(tableAction);
|
|
3157
3175
|
}
|
|
3158
|
-
async finishTableAction(tableActionDetail, actionResult) {
|
|
3176
|
+
async finishTableAction(tableActionDetail, actionResult, serverError = false) {
|
|
3159
3177
|
const { tableCode, actionCode } = tableActionDetail;
|
|
3160
3178
|
const tableEventHandlers = this._tableActionsFinish[tableCode];
|
|
3161
3179
|
const tableActionMethods = (tableEventHandlers) ? tableEventHandlers[actionCode] : null;
|
|
3162
3180
|
if (tableActionMethods) {
|
|
3163
3181
|
const clientActionPromises = [];
|
|
3164
3182
|
for (const tableActionMethod of tableActionMethods) {
|
|
3165
|
-
|
|
3183
|
+
const { callback, properties } = tableActionMethod;
|
|
3184
|
+
const continueOnError = properties?.continueOnError ?? false;
|
|
3185
|
+
if (!serverError || continueOnError) {
|
|
3186
|
+
clientActionPromises.push(callback(tableActionDetail, actionResult));
|
|
3187
|
+
}
|
|
3166
3188
|
}
|
|
3167
3189
|
await Promise.all(clientActionPromises);
|
|
3168
3190
|
}
|
|
@@ -3185,11 +3207,12 @@ class BasicFormComponent {
|
|
|
3185
3207
|
if (tableEventHandlers) {
|
|
3186
3208
|
const clientActionPromises = [];
|
|
3187
3209
|
for (const tableSelectionMethod of tableEventHandlers) {
|
|
3188
|
-
const
|
|
3210
|
+
const { callback, properties } = tableSelectionMethod;
|
|
3211
|
+
const clientActionPromise = callback(tableSelectionDetail);
|
|
3189
3212
|
clientActionPromises.push(clientActionPromise);
|
|
3190
3213
|
}
|
|
3191
3214
|
const clientActionResults = await Promise.all(clientActionPromises);
|
|
3192
|
-
const continueAction = clientActionResults.reduce((total, curr) => (total && curr), true);
|
|
3215
|
+
const continueAction = clientActionResults.reduce((total, curr) => (total && (curr !== false)), true);
|
|
3193
3216
|
if (!continueAction) {
|
|
3194
3217
|
return;
|
|
3195
3218
|
}
|
|
@@ -3202,7 +3225,7 @@ class BasicFormComponent {
|
|
|
3202
3225
|
return;
|
|
3203
3226
|
}
|
|
3204
3227
|
tableObject.putOnWait();
|
|
3205
|
-
let
|
|
3228
|
+
let serverError = false;
|
|
3206
3229
|
let actionResult = null;
|
|
3207
3230
|
if (tableObject.selectionBackend) {
|
|
3208
3231
|
const actionSubject = {
|
|
@@ -3214,23 +3237,25 @@ class BasicFormComponent {
|
|
|
3214
3237
|
};
|
|
3215
3238
|
actionResult = await this
|
|
3216
3239
|
.requestFormAction(formActions.tableAction, actionSubject);
|
|
3217
|
-
|
|
3240
|
+
serverError = !!this.errorOccured();
|
|
3218
3241
|
}
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
}
|
|
3222
|
-
else {
|
|
3242
|
+
await this.finishTableRecordSelection(tableSelectionDetail, actionResult, serverError);
|
|
3243
|
+
if (serverError) {
|
|
3223
3244
|
this.displayTableServerError();
|
|
3224
3245
|
}
|
|
3225
3246
|
tableObject.freeWaiting();
|
|
3226
3247
|
}
|
|
3227
|
-
async finishTableRecordSelection(tableSelectionDetail, actionResult) {
|
|
3248
|
+
async finishTableRecordSelection(tableSelectionDetail, actionResult, serverError = false) {
|
|
3228
3249
|
const { tableCode } = tableSelectionDetail;
|
|
3229
3250
|
const tableEventHandlers = this._tableSelectionsFinish[tableCode];
|
|
3230
3251
|
if (tableEventHandlers) {
|
|
3231
3252
|
const clientActionPromises = [];
|
|
3232
3253
|
for (const tableSelectionMethod of tableEventHandlers) {
|
|
3233
|
-
|
|
3254
|
+
const { callback, properties } = tableSelectionMethod;
|
|
3255
|
+
const continueOnError = properties?.continueOnError ?? false;
|
|
3256
|
+
if (!serverError || continueOnError) {
|
|
3257
|
+
clientActionPromises.push(callback(tableSelectionDetail, actionResult));
|
|
3258
|
+
}
|
|
3234
3259
|
}
|
|
3235
3260
|
await Promise.all(clientActionPromises);
|
|
3236
3261
|
}
|
|
@@ -3259,11 +3284,12 @@ class BasicFormComponent {
|
|
|
3259
3284
|
if (tableActionMethods) {
|
|
3260
3285
|
const clientActionPromises = [];
|
|
3261
3286
|
for (const tableActionMethod of tableActionMethods) {
|
|
3262
|
-
const
|
|
3287
|
+
const { callback, properties } = tableActionMethod;
|
|
3288
|
+
const clientActionPromise = callback(tableActionDetail);
|
|
3263
3289
|
clientActionPromises.push(clientActionPromise);
|
|
3264
3290
|
}
|
|
3265
3291
|
const clientActionResults = await Promise.all(clientActionPromises);
|
|
3266
|
-
const continueAction = clientActionResults.reduce((total, curr) => (total && curr), true);
|
|
3292
|
+
const continueAction = clientActionResults.reduce((total, curr) => (total && (curr !== false)), true);
|
|
3267
3293
|
if (!continueAction) {
|
|
3268
3294
|
return;
|
|
3269
3295
|
}
|
|
@@ -3276,7 +3302,7 @@ class BasicFormComponent {
|
|
|
3276
3302
|
return;
|
|
3277
3303
|
}
|
|
3278
3304
|
tableObject.putOnWait();
|
|
3279
|
-
let
|
|
3305
|
+
let serverError = false;
|
|
3280
3306
|
let actionResult = null;
|
|
3281
3307
|
if (action.backend) {
|
|
3282
3308
|
const actionSubject = {
|
|
@@ -3287,10 +3313,10 @@ class BasicFormComponent {
|
|
|
3287
3313
|
};
|
|
3288
3314
|
actionResult = await this
|
|
3289
3315
|
.requestFormAction(formActions.tableAction, actionSubject);
|
|
3290
|
-
|
|
3316
|
+
serverError = !!this.errorOccured();
|
|
3291
3317
|
}
|
|
3292
|
-
|
|
3293
|
-
|
|
3318
|
+
await this.finishTableSelectionAction(tableActionDetail, actionResult, serverError);
|
|
3319
|
+
if (!serverError) {
|
|
3294
3320
|
action.newState && this.changeState(action.newState);
|
|
3295
3321
|
}
|
|
3296
3322
|
else {
|
|
@@ -3298,14 +3324,18 @@ class BasicFormComponent {
|
|
|
3298
3324
|
}
|
|
3299
3325
|
tableObject.freeWaiting();
|
|
3300
3326
|
}
|
|
3301
|
-
async finishTableSelectionAction(tableActionDetail, actionResult) {
|
|
3327
|
+
async finishTableSelectionAction(tableActionDetail, actionResult, serverError = false) {
|
|
3302
3328
|
const { tableCode, actionCode } = tableActionDetail;
|
|
3303
3329
|
const tableEventHandlers = this._tableActionsFinish[tableCode];
|
|
3304
3330
|
const tableActionMethods = (tableEventHandlers) ? tableEventHandlers[actionCode] : null;
|
|
3305
3331
|
if (tableActionMethods) {
|
|
3306
3332
|
const clientActionPromises = [];
|
|
3307
3333
|
for (const tableActionMethod of tableActionMethods) {
|
|
3308
|
-
|
|
3334
|
+
const { callback, properties } = tableActionMethod;
|
|
3335
|
+
const continueOnError = properties?.continueOnError ?? false;
|
|
3336
|
+
if (!serverError || continueOnError) {
|
|
3337
|
+
clientActionPromises.push(callback(tableActionDetail, actionResult));
|
|
3338
|
+
}
|
|
3309
3339
|
}
|
|
3310
3340
|
await Promise.all(clientActionPromises);
|
|
3311
3341
|
}
|
|
@@ -3322,11 +3352,12 @@ class BasicFormComponent {
|
|
|
3322
3352
|
if (tableEventHandlers) {
|
|
3323
3353
|
const clientActionPromises = [];
|
|
3324
3354
|
for (const tableActionMethod of tableEventHandlers) {
|
|
3325
|
-
const
|
|
3355
|
+
const { callback, properties } = tableActionMethod;
|
|
3356
|
+
const clientActionPromise = callback(tableActionDetail);
|
|
3326
3357
|
clientActionPromises.push(clientActionPromise);
|
|
3327
3358
|
}
|
|
3328
3359
|
const clientActionResults = await Promise.all(clientActionPromises);
|
|
3329
|
-
const continueAction = clientActionResults.reduce((total, curr) => (total && curr), true);
|
|
3360
|
+
const continueAction = clientActionResults.reduce((total, curr) => (total && (curr !== false)), true);
|
|
3330
3361
|
if (!continueAction) {
|
|
3331
3362
|
return;
|
|
3332
3363
|
}
|
|
@@ -3336,25 +3367,29 @@ class BasicFormComponent {
|
|
|
3336
3367
|
async startTableServerGetData(tableActionDetail) {
|
|
3337
3368
|
const { tableObject, tableCode } = tableActionDetail;
|
|
3338
3369
|
tableObject.putOnWait();
|
|
3370
|
+
let serverError = false;
|
|
3339
3371
|
const actionSubject = { tableCode };
|
|
3340
3372
|
const actionResult = await this
|
|
3341
3373
|
.requestFormAction(formActions.getTableData, actionSubject);
|
|
3342
|
-
|
|
3374
|
+
serverError = !!this.errorOccured();
|
|
3375
|
+
await this.finishTableGetData(tableActionDetail, actionResult, serverError);
|
|
3376
|
+
if (serverError) {
|
|
3343
3377
|
this.displayTableServerError();
|
|
3344
3378
|
}
|
|
3345
|
-
else {
|
|
3346
|
-
this.finishTableGetData(tableActionDetail, actionResult);
|
|
3347
|
-
}
|
|
3348
3379
|
tableObject.freeWaiting();
|
|
3349
3380
|
}
|
|
3350
|
-
async finishTableGetData(tableActionDetail, actionResult) {
|
|
3381
|
+
async finishTableGetData(tableActionDetail, actionResult, serverError = false) {
|
|
3351
3382
|
const { tableCode, tableActionCode } = tableActionDetail;
|
|
3352
3383
|
const tableEventHandlers = this._tableActionsFinish[tableCode];
|
|
3353
3384
|
const tableActionMethods = (tableEventHandlers) ? tableEventHandlers[tableActionCode] : null;
|
|
3354
3385
|
if (tableActionMethods) {
|
|
3355
3386
|
const clientActionPromises = [];
|
|
3356
3387
|
for (const tableActionMethod of tableActionMethods) {
|
|
3357
|
-
|
|
3388
|
+
const { callback, properties } = tableActionMethod;
|
|
3389
|
+
const continueOnError = properties?.continueOnError ?? false;
|
|
3390
|
+
if (!serverError || continueOnError) {
|
|
3391
|
+
clientActionPromises.push(callback(tableActionDetail, actionResult));
|
|
3392
|
+
}
|
|
3358
3393
|
}
|
|
3359
3394
|
await Promise.all(clientActionPromises);
|
|
3360
3395
|
}
|