Skip to content

Commit f6a55be

Browse files
save wip
1 parent f8198f0 commit f6a55be

File tree

2 files changed

+37
-22
lines changed

2 files changed

+37
-22
lines changed

components/Step.vue

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
<template>
2-
<v-stepper-content :step="step_index + 1">
2+
<v-stepper-content :step="props.step_index + 1">
33
<v-row
44
align="center"
55
class="mb-4 py-2"
6-
@click="set_current_step(step_index)"
6+
@click="set_current_step(props.step_index)"
77
>
88
<v-col cols="auto" class="d-flex justify-center align-center">
99
<v-icon
10-
v-if="current_step_index > step_index"
10+
v-if="props.active_step_index > props.step_index"
1111
icon="mdi-check-circle"
1212
color="grey"
1313
/>
1414
<v-icon
15-
v-else-if="current_step_index == step_index"
16-
:icon="`mdi-numeric-${step_index + 1}-circle`"
15+
v-else-if="props.active_step_index == props.step_index"
16+
:icon="`mdi-numeric-${props.step_index + 1}-circle`"
1717
color="primary"
1818
/>
1919
<v-icon
2020
v-else
21-
:icon="`mdi-numeric-${step_index + 1}-circle`"
21+
:icon="`mdi-numeric-${props.step_index + 1}-circle`"
2222
color="grey"
2323
/>
2424
</v-col>
2525
<v-col>
2626
<p class="m-0 font-weight-bold">
27-
{{ steps[step_index].step_title }}
27+
{{ props.step.title }}
2828
</p>
2929
</v-col>
3030
<v-chip-group
3131
v-if="
32-
steps[step_index].chips.length && current_step_index >= step_index
32+
props.step.chips.length && props.active_step_index >= props.step_index
3333
"
3434
column
3535
class="d-flex flex-wrap ma-2 overflow-y-auto"
3636
multiple
3737
style="max-height: 150px"
3838
>
3939
<v-chip
40-
v-for="(chip, chip_index) in steps[step_index].chips"
40+
v-for="(chip, chip_index) in props.step.chips"
4141
:key="chip_index"
4242
class="ma-1"
4343
:title="chip"
@@ -47,18 +47,21 @@
4747
</v-chip-group>
4848
</v-row>
4949
<component
50-
v-if="step_index == current_step_index"
51-
:key="step_index"
52-
:is="steps[step_index].component.component_name"
53-
v-bind="steps[step_index].component.component_options"
50+
v-if="props.step_index == props.active_step_index"
51+
:key="props.step_index"
52+
:is="props.step.component.component_name"
53+
v-bind="props.step.component.component_options"
5454
@update_values="update_values_event"
55-
@increment_step="increment_step"
56-
@decrement_step="decrement_step"
55+
@reset_values="emit('reset_values')"
56+
@increment_step="increment_step()"
57+
@decrement_step="decrement_step()"
5758
/>
5859
</v-stepper-content>
5960
</template>
6061

6162
<script setup>
63+
const emit = defineEmits(["reset_values"])
64+
6265
function truncate(text, maxLength) {
6366
if (text.length > maxLength) {
6467
return text.slice(0, maxLength) + "..."
@@ -68,18 +71,20 @@
6871
6972
const props = defineProps({
7073
step_index: { type: Number, required: true },
74+
active_step_index: { type: Number, required: true },
75+
step: { type: Object, required: true },
7176
})
7277
73-
const stepper_tree = inject("stepper_tree")
74-
const { current_step_index, steps } = toRefs(stepper_tree)
75-
7678
function set_current_step(step_index) {
7779
stepper_tree.current_step_index = step_index
7880
}
7981
8082
function update_values_event(keys_values_object) {
8183
for (const [key, value] of Object.entries(keys_values_object)) {
8284
stepper_tree[key] = value
85+
console.log("key", key)
86+
console.log("value", value)
87+
console.log("stepper_tree[key]", stepper_tree[key])
8388
}
8489
}
8590

components/Stepper.vue

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
<template>
22
<v-stepper-vertical
3-
v-model="current_step_index"
3+
v-model="props.stepper_tree.current_step_index"
44
class="pa-4 ma-0"
55
elevation="1"
66
rounded
77
>
88
<v-stepper-items>
99
<v-col cols="12">
10-
<Step v-for="(step, index) in steps" :key="step" :step_index="index" />
10+
<Step
11+
v-for="(step, index) in props.stepper_tree.steps"
12+
:key="step"
13+
:step_index="index"
14+
:step="step"
15+
:active_step_index="props.stepper_tree.current_step_index"
16+
@reset_values="emit('reset_values')"
17+
/>
1118
</v-col>
1219
</v-stepper-items>
1320
</v-stepper-vertical>
1421
</template>
1522

1623
<script setup>
17-
const stepper_tree = inject("stepper_tree")
18-
const { steps, current_step_index } = toRefs(stepper_tree)
24+
const emit = defineEmits(["reset_values"])
25+
26+
const props = defineProps({
27+
stepper_tree: { type: Object, required: true },
28+
})
1929
</script>

0 commit comments

Comments
 (0)