bfg-common 1.3.409 → 1.3.411
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/components/atoms/wizard/Wizard.vue +26 -176
- package/components/atoms/wizard/lib/utils/utils.ts +189 -1
- package/components/atoms/wizard/step/Step.vue +3 -29
- package/components/common/diagramMain/modals/migrateVmkernelAdapter/MigrateVmkernelAdapter.vue +190 -194
- package/components/common/vm/actions/add/Add.vue +598 -602
- package/components/common/vm/actions/clone/Clone.vue +514 -518
- package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/model/Model.vue +1 -0
- package/components/common/wizards/network/add/Add.vue +4 -11
- package/package.json +1 -1
|
@@ -11,8 +11,7 @@
|
|
|
11
11
|
</h1>
|
|
12
12
|
<atoms-wizard-step
|
|
13
13
|
:test-id="props.testId"
|
|
14
|
-
:steps="
|
|
15
|
-
:was-completed="props.wasCompleted"
|
|
14
|
+
:steps="props.wizard.stepsInSelectedSchemeWithStatus.value"
|
|
16
15
|
@change="onSelectStep"
|
|
17
16
|
/>
|
|
18
17
|
</nav>
|
|
@@ -22,7 +21,7 @@
|
|
|
22
21
|
<div class="modal-title-wrapper">
|
|
23
22
|
<h2 class="modal-title">
|
|
24
23
|
<span class="modal-title-text">
|
|
25
|
-
{{
|
|
24
|
+
{{ props.wizard.selectedStepCom.value.title }}
|
|
26
25
|
</span>
|
|
27
26
|
</h2>
|
|
28
27
|
</div>
|
|
@@ -37,12 +36,20 @@
|
|
|
37
36
|
</button>
|
|
38
37
|
</div>
|
|
39
38
|
<div class="modal-body" style="padding: 16px 15px 10px 10px">
|
|
40
|
-
<div
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
<div
|
|
40
|
+
v-if="props.wizard.selectedStepCom.value.subTitle"
|
|
41
|
+
class="content-heading"
|
|
42
|
+
>
|
|
43
|
+
<div
|
|
44
|
+
v-if="props.wizard.selectedStepCom.value.subTitle !== 'border'"
|
|
45
|
+
>
|
|
46
|
+
<h2>{{ props.wizard.selectedStepCom.value.subTitle }}</h2>
|
|
43
47
|
</div>
|
|
44
48
|
</div>
|
|
45
|
-
<slot
|
|
49
|
+
<slot
|
|
50
|
+
name="modalBody"
|
|
51
|
+
:selected-step="props.wizard.selectedStepCom.value"
|
|
52
|
+
/>
|
|
46
53
|
</div>
|
|
47
54
|
<div class="modal-footer">
|
|
48
55
|
<slot name="modalFooterContent"></slot>
|
|
@@ -56,7 +63,7 @@
|
|
|
56
63
|
{{ props.localization.cancel }}
|
|
57
64
|
</button>
|
|
58
65
|
<button
|
|
59
|
-
v-if="!
|
|
66
|
+
v-if="!props.wizard.isFirstStepCom.value"
|
|
60
67
|
:id="`${props.testId}-back-button`"
|
|
61
68
|
:data-id="`${props.testId}-back-button`"
|
|
62
69
|
class="btn btn-outline"
|
|
@@ -65,7 +72,7 @@
|
|
|
65
72
|
{{ props.localization.back }}
|
|
66
73
|
</button>
|
|
67
74
|
<button
|
|
68
|
-
v-if="
|
|
75
|
+
v-if="props.wizard.isLastStepCom.value"
|
|
69
76
|
:id="`${props.testId}-finish-button`"
|
|
70
77
|
:data-id="`${props.testId}-finish-button`"
|
|
71
78
|
class="btn btn-success"
|
|
@@ -88,10 +95,13 @@
|
|
|
88
95
|
</div>
|
|
89
96
|
</div>
|
|
90
97
|
|
|
91
|
-
<div v-show="props.
|
|
98
|
+
<div v-show="props.wizard.wizardLoader.status" class="loader">
|
|
92
99
|
<i class="fa clr-tree-node-caret-icon spinner" />
|
|
93
|
-
<div v-if="props.
|
|
94
|
-
<p
|
|
100
|
+
<div v-if="props.wizard.wizardLoader.messages.length" class="text">
|
|
101
|
+
<p
|
|
102
|
+
v-for="message in props.wizard.wizardLoader.messages"
|
|
103
|
+
:key="message"
|
|
104
|
+
>
|
|
95
105
|
{{ message }}
|
|
96
106
|
</p>
|
|
97
107
|
</div>
|
|
@@ -107,26 +117,20 @@ import type {
|
|
|
107
117
|
UI_I_WizardStep,
|
|
108
118
|
UI_I_WizardStepNavigation,
|
|
109
119
|
} from '~/components/atoms/wizard/lib/models/interfaces'
|
|
110
|
-
import { UI_E_WIZARD_STATUS } from '~/components/atoms/wizard/lib/models/enums'
|
|
111
120
|
|
|
112
121
|
const props = withDefaults(
|
|
113
122
|
defineProps<{
|
|
114
123
|
title: string
|
|
115
124
|
show: boolean
|
|
116
|
-
steps: UI_I_WizardStep[]
|
|
117
125
|
selectedScheme: number[]
|
|
118
|
-
isLoading?: boolean
|
|
119
|
-
loaderMessages?: string[]
|
|
120
126
|
isDisabledNext?: boolean
|
|
121
127
|
isDisabledFinish?: boolean
|
|
122
128
|
localization?: UI_I_Localization
|
|
123
129
|
testId?: string
|
|
124
|
-
wasCompleted: boolean
|
|
125
130
|
maxHeight?: string
|
|
131
|
+
wizard: any
|
|
126
132
|
}>(),
|
|
127
133
|
{
|
|
128
|
-
isLoading: false,
|
|
129
|
-
loaderMessages: () => [],
|
|
130
134
|
isDisabledNext: false,
|
|
131
135
|
isDisabledFinish: false,
|
|
132
136
|
localization: () => ({}),
|
|
@@ -141,175 +145,21 @@ const emits = defineEmits<{
|
|
|
141
145
|
(event: 'change-steps', value: UI_I_WizardStep[]): void
|
|
142
146
|
}>()
|
|
143
147
|
|
|
144
|
-
const steps = ref<UI_I_WizardStep[]>(
|
|
145
|
-
useDeepCopy(
|
|
146
|
-
props.steps.filter((step: UI_I_WizardStep) =>
|
|
147
|
-
props.selectedScheme.includes(step.id)
|
|
148
|
-
)
|
|
149
|
-
)
|
|
150
|
-
)
|
|
151
|
-
|
|
152
148
|
const onHide = (): void => {
|
|
153
149
|
emits('hide')
|
|
154
150
|
}
|
|
155
151
|
|
|
156
|
-
const isSelected = (status: UI_E_WIZARD_STATUS): boolean =>
|
|
157
|
-
status === UI_E_WIZARD_STATUS.SELECTED ||
|
|
158
|
-
status === UI_E_WIZARD_STATUS.INVALID_SELECTED
|
|
159
|
-
|
|
160
|
-
const isLastStep = computed<boolean>(() => {
|
|
161
|
-
const lastStepStatus = steps.value[steps.value.length - 1].status
|
|
162
|
-
return isSelected(lastStepStatus)
|
|
163
|
-
})
|
|
164
|
-
|
|
165
|
-
const isFirstStep = computed<boolean>(() => {
|
|
166
|
-
const firstStepStatus = steps.value[0].status
|
|
167
|
-
return isSelected(firstStepStatus)
|
|
168
|
-
})
|
|
169
|
-
|
|
170
|
-
const selectedStep = computed<UI_I_WizardStep>(
|
|
171
|
-
() =>
|
|
172
|
-
steps.value.find((step: UI_I_WizardStep) => isSelected(step.status)) ||
|
|
173
|
-
steps.value[0]
|
|
174
|
-
)
|
|
175
|
-
|
|
176
152
|
const onSelectStep = (step: UI_I_WizardStepNavigation): void => {
|
|
177
|
-
|
|
178
|
-
(st: UI_I_WizardStep) => st.id === step.id
|
|
179
|
-
)
|
|
180
|
-
const indexInactive = steps.value.findIndex(
|
|
181
|
-
(st: UI_I_WizardStep) => st.status === UI_E_WIZARD_STATUS.INACTIVE
|
|
182
|
-
)
|
|
183
|
-
|
|
184
|
-
const newSteps = steps.value.map((st: UI_I_WizardStep, i: number) => {
|
|
185
|
-
if (!st.isValid && index === i)
|
|
186
|
-
return { ...st, status: UI_E_WIZARD_STATUS.INVALID_SELECTED }
|
|
187
|
-
|
|
188
|
-
if (index === i) return { ...st, status: UI_E_WIZARD_STATUS.SELECTED }
|
|
189
|
-
|
|
190
|
-
if (!st.isValid && index !== i)
|
|
191
|
-
return { ...st, status: UI_E_WIZARD_STATUS.INVALID }
|
|
192
|
-
|
|
193
|
-
// If current step is before first inactive, and it is not to be selected or hasn't inactive index, and it is last step, but it is not to be selected, set it as active
|
|
194
|
-
if (
|
|
195
|
-
(indexInactive - 1 === i && index !== indexInactive - 1) ||
|
|
196
|
-
(indexInactive < 0 && steps.value.length - 1 === i && index !== i)
|
|
197
|
-
)
|
|
198
|
-
return { ...st, status: UI_E_WIZARD_STATUS.ACTIVE }
|
|
199
|
-
|
|
200
|
-
if (index !== i && st.status !== UI_E_WIZARD_STATUS.INACTIVE)
|
|
201
|
-
return { ...st, status: UI_E_WIZARD_STATUS.COMPLETED }
|
|
202
|
-
|
|
203
|
-
return st
|
|
204
|
-
})
|
|
205
|
-
|
|
206
|
-
emits('change-steps', newSteps)
|
|
153
|
+
emits('change-steps', props.wizard.selectedStepData(step))
|
|
207
154
|
}
|
|
208
155
|
|
|
209
156
|
const onNextStep = (): void => {
|
|
210
|
-
|
|
211
|
-
(st: UI_I_WizardStep) => isSelected(st.status)
|
|
212
|
-
)
|
|
213
|
-
const stepIndex: number = currentStepIndex + 1
|
|
214
|
-
const step: UI_I_WizardStep = steps.value[stepIndex]
|
|
215
|
-
|
|
216
|
-
if (!step) return
|
|
217
|
-
|
|
218
|
-
const index = steps.value.findIndex(
|
|
219
|
-
(st: UI_I_WizardStep) => st.id === step.id
|
|
220
|
-
)
|
|
221
|
-
|
|
222
|
-
const newSteps = steps.value.map((st: UI_I_WizardStep, i: number) => {
|
|
223
|
-
if (!st.isValid && index === i)
|
|
224
|
-
return { ...st, status: UI_E_WIZARD_STATUS.INVALID_SELECTED }
|
|
225
|
-
|
|
226
|
-
if (!st.isValid && index !== i)
|
|
227
|
-
return { ...st, status: UI_E_WIZARD_STATUS.INVALID }
|
|
228
|
-
|
|
229
|
-
const indexInactive = steps.value.findIndex(
|
|
230
|
-
(st: UI_I_WizardStep) => st.status === UI_E_WIZARD_STATUS.INACTIVE
|
|
231
|
-
)
|
|
232
|
-
|
|
233
|
-
// If current step is not equal selected step, and it is not inactive or active, set it as completed
|
|
234
|
-
if (
|
|
235
|
-
index !== i &&
|
|
236
|
-
st.status !== UI_E_WIZARD_STATUS.INACTIVE &&
|
|
237
|
-
st.status !== UI_E_WIZARD_STATUS.ACTIVE
|
|
238
|
-
)
|
|
239
|
-
return { ...st, status: UI_E_WIZARD_STATUS.COMPLETED }
|
|
240
|
-
|
|
241
|
-
if (index === i) {
|
|
242
|
-
return { ...st, status: UI_E_WIZARD_STATUS.SELECTED }
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
if (stepIndex !== indexInactive && indexInactive - 1 === i)
|
|
246
|
-
return { ...st, status: UI_E_WIZARD_STATUS.ACTIVE }
|
|
247
|
-
|
|
248
|
-
return st
|
|
249
|
-
})
|
|
250
|
-
|
|
251
|
-
emits('change-steps', newSteps)
|
|
157
|
+
emits('change-steps', props.wizard.nextStepData)
|
|
252
158
|
}
|
|
253
159
|
|
|
254
160
|
const onPreviousStep = (): void => {
|
|
255
|
-
|
|
256
|
-
(st: UI_I_WizardStep) => isSelected(st.status)
|
|
257
|
-
)
|
|
258
|
-
const stepIndex: number = currentStepIndex - 1
|
|
259
|
-
const step: UI_I_WizardStep = steps.value[stepIndex]
|
|
260
|
-
|
|
261
|
-
const indexInactive = steps.value.findIndex(
|
|
262
|
-
(st: UI_I_WizardStep) => st.status === UI_E_WIZARD_STATUS.INACTIVE
|
|
263
|
-
)
|
|
264
|
-
|
|
265
|
-
if (!step) return
|
|
266
|
-
const index = steps.value.findIndex(
|
|
267
|
-
(st: UI_I_WizardStep) => st.title === step.title
|
|
268
|
-
)
|
|
269
|
-
|
|
270
|
-
const newSteps = steps.value.map((st: UI_I_WizardStep, i: number) => {
|
|
271
|
-
if (!st.isValid && index === i)
|
|
272
|
-
return { ...st, status: UI_E_WIZARD_STATUS.INVALID_SELECTED }
|
|
273
|
-
|
|
274
|
-
if (index === i) return { ...st, status: UI_E_WIZARD_STATUS.SELECTED }
|
|
275
|
-
|
|
276
|
-
if (!st.isValid && index !== i)
|
|
277
|
-
return { ...st, status: UI_E_WIZARD_STATUS.INVALID }
|
|
278
|
-
|
|
279
|
-
// If current step is before first inactive, and it is not to be selected or hasn't inactive index, and it is last step
|
|
280
|
-
if (
|
|
281
|
-
(indexInactive - 1 === i && index !== indexInactive - 1) ||
|
|
282
|
-
(indexInactive < 0 && steps.value.length - 1 === i)
|
|
283
|
-
)
|
|
284
|
-
return { ...st, status: UI_E_WIZARD_STATUS.ACTIVE }
|
|
285
|
-
|
|
286
|
-
if (index !== i && st.status !== UI_E_WIZARD_STATUS.INACTIVE)
|
|
287
|
-
return { ...st, status: UI_E_WIZARD_STATUS.COMPLETED }
|
|
288
|
-
|
|
289
|
-
return st
|
|
290
|
-
})
|
|
291
|
-
|
|
292
|
-
emits('change-steps', newSteps)
|
|
161
|
+
emits('change-steps', props.wizard.previousStepData)
|
|
293
162
|
}
|
|
294
|
-
|
|
295
|
-
watch(
|
|
296
|
-
() => props.selectedScheme,
|
|
297
|
-
(newValue: number[]) => {
|
|
298
|
-
steps.value = props.steps.filter((step: UI_I_WizardStep) =>
|
|
299
|
-
newValue.includes(step.id)
|
|
300
|
-
)
|
|
301
|
-
},
|
|
302
|
-
{ deep: true, immediate: true }
|
|
303
|
-
)
|
|
304
|
-
watch(
|
|
305
|
-
() => props.steps,
|
|
306
|
-
(newValue: UI_I_WizardStep[]) => {
|
|
307
|
-
steps.value = newValue.filter((step: UI_I_WizardStep) =>
|
|
308
|
-
props.selectedScheme.includes(step.id)
|
|
309
|
-
)
|
|
310
|
-
},
|
|
311
|
-
{ deep: true, immediate: true }
|
|
312
|
-
)
|
|
313
163
|
</script>
|
|
314
164
|
|
|
315
165
|
<style scoped lang="scss">
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
UI_I_Loader,
|
|
6
6
|
UI_I_ValidationReturn,
|
|
7
7
|
UI_I_WizardStep,
|
|
8
|
+
UI_I_WizardStepNavigation,
|
|
8
9
|
} from '~/components/atoms/wizard/lib/models/interfaces'
|
|
9
10
|
import { UI_E_WIZARD_STATUS } from '~/components/atoms/wizard/lib/models/enums'
|
|
10
11
|
|
|
@@ -18,6 +19,11 @@ export default class Wizard {
|
|
|
18
19
|
private _waitingStepId: Ref<number>
|
|
19
20
|
selectedScheme: ComputedRef<number[]>
|
|
20
21
|
alertMessages: ComputedRef<string[][]>
|
|
22
|
+
stepsInSelectedScheme: ComputedRef<UI_I_WizardStep[]>
|
|
23
|
+
stepsInSelectedSchemeWithStatus: ComputedRef<UI_I_WizardStepNavigation[]>
|
|
24
|
+
isLastStepCom: ComputedRef<boolean>
|
|
25
|
+
isFirstStepCom: ComputedRef<boolean>
|
|
26
|
+
selectedStepCom: ComputedRef<UI_I_WizardStep>
|
|
21
27
|
|
|
22
28
|
constructor(steps: UI_I_WizardStep[], stepsSchemeInitial: number[][]) {
|
|
23
29
|
this._steps = ref<UI_I_WizardStep[]>(useDeepCopy(steps))
|
|
@@ -33,6 +39,7 @@ export default class Wizard {
|
|
|
33
39
|
this.selectedScheme = computed<number[]>(
|
|
34
40
|
() => this._stepsScheme.value[this._selectedSchemeId.value]
|
|
35
41
|
)
|
|
42
|
+
|
|
36
43
|
this.alertMessages = computed<string[][]>(() =>
|
|
37
44
|
this._steps.value.map((step: UI_I_WizardStep) =>
|
|
38
45
|
Object.values(step.fields).reduce(
|
|
@@ -42,6 +49,56 @@ export default class Wizard {
|
|
|
42
49
|
)
|
|
43
50
|
)
|
|
44
51
|
)
|
|
52
|
+
this.stepsInSelectedScheme = computed<UI_I_WizardStep[]>(() =>
|
|
53
|
+
this._steps.value.filter((step: UI_I_WizardStep) =>
|
|
54
|
+
this.selectedScheme.value.includes(step.id)
|
|
55
|
+
)
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
this.stepsInSelectedSchemeWithStatus = computed<
|
|
59
|
+
UI_I_WizardStepNavigation[]
|
|
60
|
+
>(() =>
|
|
61
|
+
this.stepsInSelectedScheme.value.map((step: UI_I_WizardStep) => {
|
|
62
|
+
return {
|
|
63
|
+
...step,
|
|
64
|
+
status: {
|
|
65
|
+
disabled: step.status === UI_E_WIZARD_STATUS.INACTIVE,
|
|
66
|
+
active:
|
|
67
|
+
step.status === UI_E_WIZARD_STATUS.SELECTED ||
|
|
68
|
+
step.status === UI_E_WIZARD_STATUS.INVALID_SELECTED,
|
|
69
|
+
error:
|
|
70
|
+
step.status === UI_E_WIZARD_STATUS.INVALID_SELECTED ||
|
|
71
|
+
step.status === UI_E_WIZARD_STATUS.INVALID,
|
|
72
|
+
complete:
|
|
73
|
+
step.status === UI_E_WIZARD_STATUS.COMPLETED ||
|
|
74
|
+
((step.status === UI_E_WIZARD_STATUS.SELECTED ||
|
|
75
|
+
step.status === UI_E_WIZARD_STATUS.INVALID_SELECTED ||
|
|
76
|
+
step.status === UI_E_WIZARD_STATUS.INVALID) &&
|
|
77
|
+
this.wasCompleted()),
|
|
78
|
+
},
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
this.isLastStepCom = computed<boolean>(() => {
|
|
84
|
+
const lastStepStatus =
|
|
85
|
+
this.stepsInSelectedScheme.value[
|
|
86
|
+
this.stepsInSelectedScheme.value.length - 1
|
|
87
|
+
].status
|
|
88
|
+
return this.isSelected(lastStepStatus)
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
this.isFirstStepCom = computed<boolean>(() => {
|
|
92
|
+
const firstStepStatus = this.stepsInSelectedScheme.value[0].status
|
|
93
|
+
return this.isSelected(firstStepStatus)
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
this.selectedStepCom = computed<UI_I_WizardStep>(
|
|
97
|
+
() =>
|
|
98
|
+
this.stepsInSelectedScheme.value.find((step: UI_I_WizardStep) =>
|
|
99
|
+
this.isSelected(step.status)
|
|
100
|
+
) || this.stepsInSelectedScheme.value[0]
|
|
101
|
+
)
|
|
45
102
|
}
|
|
46
103
|
|
|
47
104
|
get steps(): UI_I_WizardStep[] {
|
|
@@ -87,6 +144,128 @@ export default class Wizard {
|
|
|
87
144
|
return this.selectedScheme.value[currentStepIndex + 1]
|
|
88
145
|
}
|
|
89
146
|
|
|
147
|
+
get nextStepData(): UI_I_WizardStep[] {
|
|
148
|
+
const currentStepIndex: number = this.stepsInSelectedScheme.value.findIndex(
|
|
149
|
+
(st: UI_I_WizardStep) => this.isSelected(st.status)
|
|
150
|
+
)
|
|
151
|
+
const stepIndex: number = currentStepIndex + 1
|
|
152
|
+
const step: UI_I_WizardStep = this.stepsInSelectedScheme.value[stepIndex]
|
|
153
|
+
|
|
154
|
+
if (!step) return []
|
|
155
|
+
|
|
156
|
+
const index = this.stepsInSelectedScheme.value.findIndex(
|
|
157
|
+
(st: UI_I_WizardStep) => st.id === step.id
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
return this.stepsInSelectedScheme.value.map(
|
|
161
|
+
(st: UI_I_WizardStep, i: number) => {
|
|
162
|
+
if (!st.isValid && index === i)
|
|
163
|
+
return { ...st, status: UI_E_WIZARD_STATUS.INVALID_SELECTED }
|
|
164
|
+
|
|
165
|
+
if (!st.isValid && index !== i)
|
|
166
|
+
return { ...st, status: UI_E_WIZARD_STATUS.INVALID }
|
|
167
|
+
|
|
168
|
+
const indexInactive = this.stepsInSelectedScheme.value.findIndex(
|
|
169
|
+
(st: UI_I_WizardStep) => st.status === UI_E_WIZARD_STATUS.INACTIVE
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
// If current step is not equal selected step, and it is not inactive or active, set it as completed
|
|
173
|
+
if (
|
|
174
|
+
index !== i &&
|
|
175
|
+
st.status !== UI_E_WIZARD_STATUS.INACTIVE &&
|
|
176
|
+
st.status !== UI_E_WIZARD_STATUS.ACTIVE
|
|
177
|
+
)
|
|
178
|
+
return { ...st, status: UI_E_WIZARD_STATUS.COMPLETED }
|
|
179
|
+
|
|
180
|
+
if (index === i) {
|
|
181
|
+
return { ...st, status: UI_E_WIZARD_STATUS.SELECTED }
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (stepIndex !== indexInactive && indexInactive - 1 === i)
|
|
185
|
+
return { ...st, status: UI_E_WIZARD_STATUS.ACTIVE }
|
|
186
|
+
|
|
187
|
+
return st
|
|
188
|
+
}
|
|
189
|
+
)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
get previousStepData(): UI_I_WizardStep[] {
|
|
193
|
+
const currentStepIndex: number = this.stepsInSelectedScheme.value.findIndex(
|
|
194
|
+
(st: UI_I_WizardStep) => this.isSelected(st.status)
|
|
195
|
+
)
|
|
196
|
+
const stepIndex: number = currentStepIndex - 1
|
|
197
|
+
const step: UI_I_WizardStep = this.stepsInSelectedScheme.value[stepIndex]
|
|
198
|
+
|
|
199
|
+
const indexInactive = this.stepsInSelectedScheme.value.findIndex(
|
|
200
|
+
(st: UI_I_WizardStep) => st.status === UI_E_WIZARD_STATUS.INACTIVE
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
if (!step) return []
|
|
204
|
+
const index = this.stepsInSelectedScheme.value.findIndex(
|
|
205
|
+
(st: UI_I_WizardStep) => st.title === step.title
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
return this.stepsInSelectedScheme.value.map(
|
|
209
|
+
(st: UI_I_WizardStep, i: number) => {
|
|
210
|
+
if (!st.isValid && index === i)
|
|
211
|
+
return { ...st, status: UI_E_WIZARD_STATUS.INVALID_SELECTED }
|
|
212
|
+
|
|
213
|
+
if (index === i) return { ...st, status: UI_E_WIZARD_STATUS.SELECTED }
|
|
214
|
+
|
|
215
|
+
if (!st.isValid && index !== i)
|
|
216
|
+
return { ...st, status: UI_E_WIZARD_STATUS.INVALID }
|
|
217
|
+
|
|
218
|
+
// If current step is before first inactive, and it is not to be selected or hasn't inactive index, and it is last step
|
|
219
|
+
if (
|
|
220
|
+
(indexInactive - 1 === i && index !== indexInactive - 1) ||
|
|
221
|
+
(indexInactive < 0 &&
|
|
222
|
+
this.stepsInSelectedScheme.value.length - 1 === i)
|
|
223
|
+
)
|
|
224
|
+
return { ...st, status: UI_E_WIZARD_STATUS.ACTIVE }
|
|
225
|
+
|
|
226
|
+
if (index !== i && st.status !== UI_E_WIZARD_STATUS.INACTIVE)
|
|
227
|
+
return { ...st, status: UI_E_WIZARD_STATUS.COMPLETED }
|
|
228
|
+
|
|
229
|
+
return st
|
|
230
|
+
}
|
|
231
|
+
)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
selectedStepData(step: UI_I_WizardStepNavigation): UI_I_WizardStep[] {
|
|
235
|
+
const index = this.stepsInSelectedScheme.value.findIndex(
|
|
236
|
+
(st: UI_I_WizardStep) => st.id === step.id
|
|
237
|
+
)
|
|
238
|
+
const indexInactive = this.stepsInSelectedScheme.value.findIndex(
|
|
239
|
+
(st: UI_I_WizardStep) => st.status === UI_E_WIZARD_STATUS.INACTIVE
|
|
240
|
+
)
|
|
241
|
+
|
|
242
|
+
return this.stepsInSelectedScheme.value.map(
|
|
243
|
+
(st: UI_I_WizardStep, i: number) => {
|
|
244
|
+
if (!st.isValid && index === i)
|
|
245
|
+
return { ...st, status: UI_E_WIZARD_STATUS.INVALID_SELECTED }
|
|
246
|
+
|
|
247
|
+
if (index === i) return { ...st, status: UI_E_WIZARD_STATUS.SELECTED }
|
|
248
|
+
|
|
249
|
+
if (!st.isValid && index !== i)
|
|
250
|
+
return { ...st, status: UI_E_WIZARD_STATUS.INVALID }
|
|
251
|
+
|
|
252
|
+
// If current step is before first inactive, and it is not to be selected or hasn't inactive index, and it is last step, but it is not to be selected, set it as active
|
|
253
|
+
if (
|
|
254
|
+
(indexInactive - 1 === i && index !== indexInactive - 1) ||
|
|
255
|
+
(indexInactive < 0 &&
|
|
256
|
+
this.stepsInSelectedScheme.value.length - 1 === i &&
|
|
257
|
+
index !== i)
|
|
258
|
+
)
|
|
259
|
+
return { ...st, status: UI_E_WIZARD_STATUS.ACTIVE }
|
|
260
|
+
|
|
261
|
+
if (index !== i && st.status !== UI_E_WIZARD_STATUS.INACTIVE)
|
|
262
|
+
return { ...st, status: UI_E_WIZARD_STATUS.COMPLETED }
|
|
263
|
+
|
|
264
|
+
return st
|
|
265
|
+
}
|
|
266
|
+
)
|
|
267
|
+
}
|
|
268
|
+
|
|
90
269
|
setLoader(status: boolean, messages?: string[]): void {
|
|
91
270
|
this._wizardLoader.value.status = status
|
|
92
271
|
|
|
@@ -317,7 +496,12 @@ export default class Wizard {
|
|
|
317
496
|
validation.stepHasError && this.goToFirstInvalidStep()
|
|
318
497
|
|
|
319
498
|
return
|
|
320
|
-
} else if (
|
|
499
|
+
} else if (
|
|
500
|
+
(this.isLastStep() ||
|
|
501
|
+
nextStep.id ===
|
|
502
|
+
this.selectedScheme.value[this.selectedScheme.value.length - 1]) &&
|
|
503
|
+
finalValidationFunc
|
|
504
|
+
) {
|
|
321
505
|
const finalValidation: UI_I_ValidationReturn =
|
|
322
506
|
await finalValidationFunc(value, currentStep, nextStep)
|
|
323
507
|
|
|
@@ -474,6 +658,10 @@ export default class Wizard {
|
|
|
474
658
|
}
|
|
475
659
|
|
|
476
660
|
isLastStep(): boolean {
|
|
661
|
+
console.log(
|
|
662
|
+
this.selectedScheme.value[this.selectedScheme.value.length - 2],
|
|
663
|
+
this.selectedStepId
|
|
664
|
+
)
|
|
477
665
|
return (
|
|
478
666
|
this.selectedScheme.value[this.selectedScheme.value.length - 2] ===
|
|
479
667
|
this.selectedStepId
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<div class="clr-wizard-stepnav">
|
|
3
3
|
<div class="clr-wizard-stepnav-list">
|
|
4
4
|
<div
|
|
5
|
-
v-for="(step, key) in steps"
|
|
5
|
+
v-for="(step, key) in props.steps"
|
|
6
6
|
:key="key"
|
|
7
7
|
:class="[
|
|
8
8
|
'clr-wizard clr-wizard-stepnav-item clr-nav-link nav-item',
|
|
@@ -27,42 +27,16 @@
|
|
|
27
27
|
</template>
|
|
28
28
|
|
|
29
29
|
<script setup lang="ts">
|
|
30
|
-
import type {
|
|
31
|
-
UI_I_WizardStep,
|
|
32
|
-
UI_I_WizardStepNavigation,
|
|
33
|
-
} from '~/components/atoms/wizard/lib/models/interfaces'
|
|
34
|
-
import { UI_E_WIZARD_STATUS } from '~/components/atoms/wizard/lib/models/enums'
|
|
30
|
+
import type { UI_I_WizardStepNavigation } from '~/components/atoms/wizard/lib/models/interfaces'
|
|
35
31
|
|
|
36
32
|
const props = withDefaults(
|
|
37
33
|
defineProps<{
|
|
38
|
-
steps:
|
|
39
|
-
wasCompleted: boolean
|
|
34
|
+
steps: UI_I_WizardStepNavigation[]
|
|
40
35
|
testId?: string
|
|
41
36
|
}>(),
|
|
42
37
|
{ testId: 'ui-vertical-step' }
|
|
43
38
|
)
|
|
44
39
|
|
|
45
|
-
const steps = computed<UI_I_WizardStepNavigation[]>(() =>
|
|
46
|
-
props.steps.map((step: UI_I_WizardStep) => ({
|
|
47
|
-
...step,
|
|
48
|
-
status: {
|
|
49
|
-
disabled: step.status === UI_E_WIZARD_STATUS.INACTIVE,
|
|
50
|
-
active:
|
|
51
|
-
step.status === UI_E_WIZARD_STATUS.SELECTED ||
|
|
52
|
-
step.status === UI_E_WIZARD_STATUS.INVALID_SELECTED,
|
|
53
|
-
error:
|
|
54
|
-
step.status === UI_E_WIZARD_STATUS.INVALID_SELECTED ||
|
|
55
|
-
step.status === UI_E_WIZARD_STATUS.INVALID,
|
|
56
|
-
complete:
|
|
57
|
-
step.status === UI_E_WIZARD_STATUS.COMPLETED ||
|
|
58
|
-
((step.status === UI_E_WIZARD_STATUS.SELECTED ||
|
|
59
|
-
step.status === UI_E_WIZARD_STATUS.INVALID_SELECTED ||
|
|
60
|
-
step.status === UI_E_WIZARD_STATUS.INVALID) &&
|
|
61
|
-
props.wasCompleted),
|
|
62
|
-
},
|
|
63
|
-
}))
|
|
64
|
-
)
|
|
65
|
-
|
|
66
40
|
const emits = defineEmits<{
|
|
67
41
|
(event: 'change', step: UI_I_WizardStepNavigation): void
|
|
68
42
|
}>()
|