@5minds/node-red-dashboard-2-processcube-dynamic-form 2.2.1-develop-a7c297-mesag5st → 2.2.1-feature-451281-mf6lqajn
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.
|
@@ -11,26 +11,6 @@
|
|
|
11
11
|
{{ action.label }}
|
|
12
12
|
</v-btn>
|
|
13
13
|
</div>
|
|
14
|
-
<div>
|
|
15
|
-
<v-btn
|
|
16
|
-
class="ui-dynamic-form-footer-action-button ui-dynamic-form-footer-action-secondary"
|
|
17
|
-
:disabled="formIsFinished"
|
|
18
|
-
@click="handleSuspend"
|
|
19
|
-
>
|
|
20
|
-
Suspend
|
|
21
|
-
</v-btn>
|
|
22
|
-
</div>
|
|
23
|
-
<div>
|
|
24
|
-
<v-btn
|
|
25
|
-
class="ui-dynamic-form-footer-action-terminate"
|
|
26
|
-
:disabled="formIsFinished"
|
|
27
|
-
@click="handleTerminate"
|
|
28
|
-
variant="text"
|
|
29
|
-
size="small"
|
|
30
|
-
>
|
|
31
|
-
Terminate
|
|
32
|
-
</v-btn>
|
|
33
|
-
</div>
|
|
34
14
|
</div>
|
|
35
15
|
<div class="ui-dynamic-form-footer-actions-right">
|
|
36
16
|
<div v-for="(action, index) in rightSideActions" :key="`right-${index}`">
|
|
@@ -69,8 +49,8 @@ export default {
|
|
|
69
49
|
leftSideActions() {
|
|
70
50
|
const leftActions = this.actions.filter((action) => action.alignment === 'left' || !action.alignment);
|
|
71
51
|
const sortPrimaryToLeft = (a, b) => {
|
|
72
|
-
const aPrimary = a.primary === '
|
|
73
|
-
const bPrimary = b.primary === '
|
|
52
|
+
const aPrimary = a.primary === 'primary';
|
|
53
|
+
const bPrimary = b.primary === 'primary';
|
|
74
54
|
if (aPrimary && !bPrimary) return -1;
|
|
75
55
|
if (!aPrimary && bPrimary) return 1;
|
|
76
56
|
return 0;
|
|
@@ -81,8 +61,8 @@ export default {
|
|
|
81
61
|
rightSideActions() {
|
|
82
62
|
const rightActions = this.actions.filter((action) => action.alignment === 'right');
|
|
83
63
|
const sortPrimaryToRight = (a, b) => {
|
|
84
|
-
const aPrimary = a.primary === '
|
|
85
|
-
const bPrimary = b.primary === '
|
|
64
|
+
const aPrimary = a.primary === 'primary';
|
|
65
|
+
const bPrimary = b.primary === 'primary';
|
|
86
66
|
if (!aPrimary && bPrimary) return -1;
|
|
87
67
|
if (aPrimary && !bPrimary) return 1;
|
|
88
68
|
return 0;
|
|
@@ -93,29 +73,15 @@ export default {
|
|
|
93
73
|
},
|
|
94
74
|
methods: {
|
|
95
75
|
getActionButtonClass(action) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
isTerminate: true,
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
this.actionCallback(terminateAction);
|
|
109
|
-
},
|
|
110
|
-
handleSuspend() {
|
|
111
|
-
const suspendAction = {
|
|
112
|
-
label: 'Suspend',
|
|
113
|
-
alignment: 'left',
|
|
114
|
-
primary: 'false',
|
|
115
|
-
isSuspend: true,
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
this.actionCallback(suspendAction);
|
|
76
|
+
switch (action.primary) {
|
|
77
|
+
case 'primary':
|
|
78
|
+
return 'ui-dynamic-form-footer-action-primary';
|
|
79
|
+
case 'destructive':
|
|
80
|
+
return 'ui-dynamic-form-footer-action-terminate';
|
|
81
|
+
case 'secondary':
|
|
82
|
+
default:
|
|
83
|
+
return 'ui-dynamic-form-footer-action-secondary';
|
|
84
|
+
}
|
|
119
85
|
},
|
|
120
86
|
},
|
|
121
87
|
};
|
|
@@ -235,12 +235,13 @@ export default {
|
|
|
235
235
|
return !!this.userTask;
|
|
236
236
|
},
|
|
237
237
|
totalOutputs() {
|
|
238
|
-
const
|
|
238
|
+
const confirmOutputs = this.props.handle_confirmation_dialogs
|
|
239
|
+
? (this.props.confirm_actions ? this.props.confirm_actions.length : 2)
|
|
240
|
+
: 0;
|
|
239
241
|
return (
|
|
240
242
|
this.props.options.length +
|
|
241
|
-
|
|
242
|
-
(this.props.trigger_on_change ? 1 : 0)
|
|
243
|
-
outputsConfirmTerminate
|
|
243
|
+
confirmOutputs +
|
|
244
|
+
(this.props.trigger_on_change ? 1 : 0)
|
|
244
245
|
);
|
|
245
246
|
},
|
|
246
247
|
isConfirmDialog() {
|
|
@@ -896,6 +897,9 @@ export default {
|
|
|
896
897
|
this.collapsed = this.props.collapse_when_finished;
|
|
897
898
|
}
|
|
898
899
|
|
|
900
|
+
// Check if we have a confirmation dialog field
|
|
901
|
+
const hasConfirmField = formFields.some((field) => field.type === 'confirm');
|
|
902
|
+
|
|
899
903
|
if (formFields) {
|
|
900
904
|
formFields.forEach((field) => {
|
|
901
905
|
this.formData[field.id] = field.defaultValue;
|
|
@@ -904,31 +908,63 @@ export default {
|
|
|
904
908
|
const customForm = field.customForm ? JSON.parse(JSON.stringify(field.customForm)) : {};
|
|
905
909
|
const confirmText = customForm.confirmButtonText ?? 'Confirm';
|
|
906
910
|
const declineText = customForm.declineButtonText ?? 'Decline';
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
911
|
+
|
|
912
|
+
const confirmActions = [
|
|
913
|
+
{
|
|
914
|
+
alignment: this.props.confirm_actions[1]?.alignment || 'left',
|
|
915
|
+
primary: this.props.confirm_actions[1]?.primary || 'destructive',
|
|
916
|
+
label: declineText,
|
|
917
|
+
condition: '',
|
|
918
|
+
isConfirmAction: true,
|
|
919
|
+
confirmFieldId: field.id,
|
|
920
|
+
confirmValue: false,
|
|
921
|
+
},
|
|
922
|
+
{
|
|
923
|
+
alignment: this.props.confirm_actions[0]?.alignment || 'right',
|
|
924
|
+
primary: this.props.confirm_actions[0]?.primary || 'primary',
|
|
925
|
+
label: confirmText,
|
|
926
|
+
condition: '',
|
|
927
|
+
isConfirmAction: true,
|
|
928
|
+
confirmFieldId: field.id,
|
|
929
|
+
confirmValue: true,
|
|
930
|
+
},
|
|
931
|
+
];
|
|
932
|
+
|
|
933
|
+
const filteredActions = this.props.options.filter(action => {
|
|
934
|
+
if (!action.condition) return true;
|
|
935
|
+
try {
|
|
936
|
+
const usertaskWithContext = {
|
|
937
|
+
...this.userTask,
|
|
938
|
+
isConfirmDialog: true
|
|
939
|
+
};
|
|
940
|
+
const func = Function('fields', 'usertask', 'msg', '"use strict"; return (' + action.condition + ')');
|
|
941
|
+
const result = func(this.formData, usertaskWithContext, this.msg);
|
|
942
|
+
return Boolean(result);
|
|
943
|
+
} catch (err) {
|
|
944
|
+
console.error('Error while evaluating condition: ' + err);
|
|
945
|
+
return false;
|
|
946
|
+
}
|
|
947
|
+
});
|
|
948
|
+
|
|
949
|
+
this.actions = [...filteredActions, ...confirmActions];
|
|
931
950
|
}
|
|
951
|
+
});
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
if (!hasConfirmField && this.props.handle_confirmation_dialogs) {
|
|
955
|
+
this.actions = this.props.options.filter(action => {
|
|
956
|
+
if (!action.condition) return true;
|
|
957
|
+
try {
|
|
958
|
+
const usertaskWithContext = {
|
|
959
|
+
...this.userTask,
|
|
960
|
+
isConfirmDialog: false
|
|
961
|
+
};
|
|
962
|
+
const func = Function('fields', 'usertask', 'msg', '"use strict"; return (' + action.condition + ')');
|
|
963
|
+
const result = func(this.formData, usertaskWithContext, this.msg);
|
|
964
|
+
return Boolean(result);
|
|
965
|
+
} catch (err) {
|
|
966
|
+
console.error('Error while evaluating condition: ' + err);
|
|
967
|
+
return false;
|
|
932
968
|
}
|
|
933
969
|
});
|
|
934
970
|
}
|
|
@@ -954,38 +990,6 @@ export default {
|
|
|
954
990
|
});
|
|
955
991
|
},
|
|
956
992
|
actionFn(action) {
|
|
957
|
-
if (action.isTerminate) {
|
|
958
|
-
this.showError('');
|
|
959
|
-
|
|
960
|
-
const msg = this.msg ?? {};
|
|
961
|
-
msg.payload = {
|
|
962
|
-
formData: this.formData,
|
|
963
|
-
userTask: this.userTask,
|
|
964
|
-
isTerminate: true,
|
|
965
|
-
};
|
|
966
|
-
|
|
967
|
-
const terminateOutputIndex = this.totalOutputs - 1;
|
|
968
|
-
|
|
969
|
-
this.send(msg, terminateOutputIndex);
|
|
970
|
-
return;
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
if (action.isSuspend) {
|
|
974
|
-
this.showError('');
|
|
975
|
-
|
|
976
|
-
const msg = this.msg ?? {};
|
|
977
|
-
msg.payload = {
|
|
978
|
-
formData: this.formData,
|
|
979
|
-
userTask: this.userTask,
|
|
980
|
-
isSuspend: true,
|
|
981
|
-
};
|
|
982
|
-
|
|
983
|
-
const suspendOutputIndex = this.totalOutputs - 2;
|
|
984
|
-
|
|
985
|
-
this.send(msg, suspendOutputIndex);
|
|
986
|
-
return;
|
|
987
|
-
}
|
|
988
|
-
|
|
989
993
|
if (action.isConfirmAction && action.confirmFieldId) {
|
|
990
994
|
this.formData[action.confirmFieldId] = action.confirmValue;
|
|
991
995
|
}
|
|
@@ -1006,7 +1010,7 @@ export default {
|
|
|
1006
1010
|
if (!allComplete) return;
|
|
1007
1011
|
}
|
|
1008
1012
|
|
|
1009
|
-
if (this.checkCondition(action.condition)) {
|
|
1013
|
+
if (this.checkCondition(action.condition, { isConfirmDialog: this.isConfirmDialog })) {
|
|
1010
1014
|
this.showError('');
|
|
1011
1015
|
|
|
1012
1016
|
const processedFormData = { ...this.formData };
|
|
@@ -1034,20 +1038,29 @@ export default {
|
|
|
1034
1038
|
|
|
1035
1039
|
const msg = this.msg ?? {};
|
|
1036
1040
|
msg.payload = { formData: processedFormData, userTask: this.userTask };
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1041
|
+
|
|
1042
|
+
let outputIndex;
|
|
1043
|
+
if (action.isConfirmAction) {
|
|
1044
|
+
const confirmActionIndex = action.confirmValue ? 1 : 0;
|
|
1045
|
+
outputIndex = this.props.options.length + confirmActionIndex;
|
|
1046
|
+
} else {
|
|
1047
|
+
outputIndex = this.props.options.findIndex((element) => element.label === action.label);
|
|
1048
|
+
}
|
|
1049
|
+
this.send(msg, outputIndex);
|
|
1042
1050
|
} else {
|
|
1043
1051
|
this.showError(action.errorMessage);
|
|
1044
1052
|
}
|
|
1045
1053
|
},
|
|
1046
|
-
checkCondition(condition) {
|
|
1054
|
+
checkCondition(condition, context = {}) {
|
|
1047
1055
|
if (condition === '') return true;
|
|
1048
1056
|
try {
|
|
1049
|
-
const
|
|
1050
|
-
|
|
1057
|
+
const usertaskWithContext = {
|
|
1058
|
+
...this.userTask,
|
|
1059
|
+
isConfirmDialog: context.isConfirmDialog || false
|
|
1060
|
+
};
|
|
1061
|
+
|
|
1062
|
+
const func = Function('fields', 'usertask', 'msg', '"use strict"; return (' + condition + ')');
|
|
1063
|
+
const result = func(this.formData, usertaskWithContext, this.msg);
|
|
1051
1064
|
return Boolean(result);
|
|
1052
1065
|
} catch (err) {
|
|
1053
1066
|
console.error('Error while evaluating condition: ' + err);
|
|
@@ -168,8 +168,7 @@ code {
|
|
|
168
168
|
min-height: 36px;
|
|
169
169
|
padding: 8px 12px;
|
|
170
170
|
box-sizing: border-box;
|
|
171
|
-
|
|
172
|
-
word-wrap: break-word;
|
|
171
|
+
flex-shrink: 0;
|
|
173
172
|
}
|
|
174
173
|
|
|
175
174
|
@media screen and (min-width: 600px) {
|
|
@@ -178,8 +177,10 @@ code {
|
|
|
178
177
|
}
|
|
179
178
|
|
|
180
179
|
.ui-dynamic-form-footer-action-button {
|
|
181
|
-
|
|
182
|
-
|
|
180
|
+
max-width: 200px;
|
|
181
|
+
white-space: nowrap;
|
|
182
|
+
overflow: hidden;
|
|
183
|
+
text-overflow: ellipsis;
|
|
183
184
|
}
|
|
184
185
|
}
|
|
185
186
|
|
|
@@ -286,13 +287,15 @@ code {
|
|
|
286
287
|
font-size: 16px;
|
|
287
288
|
width: 100%;
|
|
288
289
|
box-sizing: border-box;
|
|
289
|
-
white-space:
|
|
290
|
-
|
|
290
|
+
white-space: nowrap;
|
|
291
|
+
overflow: hidden;
|
|
292
|
+
text-overflow: ellipsis;
|
|
291
293
|
}
|
|
292
294
|
|
|
293
295
|
.ui-dynamic-form-footer-action-button .v-btn__content {
|
|
294
|
-
white-space:
|
|
295
|
-
|
|
296
|
+
white-space: nowrap !important;
|
|
297
|
+
overflow: hidden !important;
|
|
298
|
+
text-overflow: ellipsis !important;
|
|
296
299
|
max-width: 100% !important;
|
|
297
300
|
display: block !important;
|
|
298
301
|
}
|
|
@@ -307,8 +310,9 @@ code {
|
|
|
307
310
|
|
|
308
311
|
.ui-dynamic-form-footer-action-primary .v-btn__content,
|
|
309
312
|
.ui-dynamic-form-footer-action-secondary .v-btn__content {
|
|
310
|
-
white-space:
|
|
311
|
-
|
|
313
|
+
white-space: nowrap !important;
|
|
314
|
+
overflow: hidden !important;
|
|
315
|
+
text-overflow: ellipsis !important;
|
|
312
316
|
max-width: 100% !important;
|
|
313
317
|
display: block !important;
|
|
314
318
|
}
|