@5minds/node-red-dashboard-2-processcube-dynamic-form 2.1.0 → 2.1.1-develop-1e7b10-me1d8ayv

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.
@@ -1,44 +1,126 @@
1
1
  <template>
2
- <div class="ui-dynamic-form-footer-actions-container">
3
- <div class="ui-dynamic-form-footer-actions-left">
4
- <div v-for="(action, index) in actions" :key="index">
5
- <v-btn v-if="action.alignment === 'left' || !action.alignment" :key="index"
6
- class="ui-dynamic-form-footer-action-button" :class="getActionButtonClass(action)"
7
- :disabled="formIsFinished" @click="actionCallback(action)">
8
- {{ action.label }}
9
- </v-btn>
10
- </div>
11
- </div>
12
- <div class="ui-dynamic-form-footer-actions-right">
13
- <div v-for="(action, index) in actions" :key="index">
14
- <v-btn v-if="action.alignment === 'right'" :key="index" class="ui-dynamic-form-footer-action-button"
15
- :class="getActionButtonClass(action)" :disabled="formIsFinished" @click="actionCallback(action)">
16
- {{ action.label }}
17
- </v-btn>
18
- </div>
19
- </div>
2
+ <div class="ui-dynamic-form-footer-actions-container">
3
+ <div class="ui-dynamic-form-footer-actions-left">
4
+ <div v-for="(action, index) in leftSideActions" :key="`left-${index}`">
5
+ <v-btn
6
+ class="ui-dynamic-form-footer-action-button"
7
+ :class="getActionButtonClass(action)"
8
+ :disabled="formIsFinished"
9
+ @click="actionCallback(action)"
10
+ >
11
+ {{ action.label }}
12
+ </v-btn>
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>
20
34
  </div>
35
+ <div class="ui-dynamic-form-footer-actions-right">
36
+ <div v-for="(action, index) in rightSideActions" :key="`right-${index}`">
37
+ <v-btn
38
+ class="ui-dynamic-form-footer-action-button"
39
+ :class="getActionButtonClass(action)"
40
+ :disabled="formIsFinished"
41
+ @click="actionCallback(action)"
42
+ >
43
+ {{ action.label }}
44
+ </v-btn>
45
+ </div>
46
+ </div>
47
+ </div>
21
48
  </template>
22
49
 
23
50
  <script>
24
-
25
51
  export default {
26
- name: 'UIDynamicFormFooterAction',
27
- props: {
28
- actions: { type: Array, default() { return [] } },
29
- actionCallback: { type: Function, default(action) { } },
30
- formIsFinished: { type: Boolean, default() { return false } }
52
+ name: 'UIDynamicFormFooterAction',
53
+ props: {
54
+ actions: {
55
+ type: Array,
56
+ default() {
57
+ return [];
58
+ },
59
+ },
60
+ actionCallback: { type: Function, default(action) {} },
61
+ formIsFinished: {
62
+ type: Boolean,
63
+ default() {
64
+ return false;
65
+ },
31
66
  },
32
- methods: {
33
- getActionButtonClass(action) {
34
- return action.primary === 'true' ? 'ui-dynamic-form-footer-action-primary' : 'ui-dynamic-form-footer-action-secondary'
35
- }
36
- }
37
- }
67
+ },
68
+ computed: {
69
+ leftSideActions() {
70
+ const leftActions = this.actions.filter((action) => action.alignment === 'left' || !action.alignment);
71
+ const sortPrimaryToLeft = (a, b) => {
72
+ const aPrimary = a.primary === 'true';
73
+ const bPrimary = b.primary === 'true';
74
+ if (aPrimary && !bPrimary) return -1;
75
+ if (!aPrimary && bPrimary) return 1;
76
+ return 0;
77
+ };
38
78
 
79
+ return leftActions.sort(sortPrimaryToLeft);
80
+ },
81
+ rightSideActions() {
82
+ const rightActions = this.actions.filter((action) => action.alignment === 'right');
83
+ const sortPrimaryToRight = (a, b) => {
84
+ const aPrimary = a.primary === 'true';
85
+ const bPrimary = b.primary === 'true';
86
+ if (!aPrimary && bPrimary) return -1;
87
+ if (aPrimary && !bPrimary) return 1;
88
+ return 0;
89
+ };
90
+
91
+ return rightActions.sort(sortPrimaryToRight);
92
+ },
93
+ },
94
+ methods: {
95
+ getActionButtonClass(action) {
96
+ return action.primary === 'true'
97
+ ? 'ui-dynamic-form-footer-action-primary'
98
+ : 'ui-dynamic-form-footer-action-secondary';
99
+ },
100
+ handleTerminate() {
101
+ const terminateAction = {
102
+ label: 'Terminate',
103
+ alignment: 'left',
104
+ primary: 'false',
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);
119
+ },
120
+ },
121
+ };
39
122
  </script>
40
123
 
41
124
  <style>
42
- /* CSS is auto scoped, but using named classes is still recommended */
43
125
  @import '../stylesheets/ui-dynamic-form.css';
44
126
  </style>