No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    How to detect completion of q-stepper?

    Help
    3
    4
    1326
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • krsyoung
      krsyoung last edited by krsyoung

      I see in previous versions of Quasar there used the be a @finish event (see http://v0-13.quasar-framework.org/components/stepper.html).

      This is no longer available. Curious if others have an approach to dealing with routing (or anything) once the user clicks “Done” on the last step?

      My current approach is as follows:

            <q-stepper-navigation>
              <q-btn
                flat
                @click="$refs.stepper.previous()"
                label="Back"
              />
              <q-btn
                v-if="currentStep !== 'done'"
                @click="$refs.stepper.next()"
                label="Next"
              />
              <q-btn
                v-if="currentStep === 'done'"
                @click="finish()"
                label="Done"
              />
            </q-stepper-navigation>
      
      1 Reply Last reply Reply Quote 0
      • Shone
        Shone last edited by

        @krsyoung You could track step name name="first" name="second" name="finish" or you could use v-model.
        Make sure to read the docs.
        https://quasar-framework.org/components/stepper.html

        Shone

        1 Reply Last reply Reply Quote 1
        • rstoenescu
          rstoenescu Admin last edited by

          So user should click on “Done” button, right? It calls “finish()” method… so there you go. When “finish()” gets called the Stepper has finished its job.
          Won’t get into details, because there’s quite a lot to explain here and time is limited, but since you now have buttons to control the flow of QStepper you’re able to determine that yourself. Just trying to make QStepper cover as much use cases as possible.

          1 Reply Last reply Reply Quote 1
          • krsyoung
            krsyoung last edited by krsyoung

            Ok thanks guys, sounds like my current approach is the “best” approach.

            Here is the full reference for others who might be in the same boat:

            <template>
              <q-page padding>
                <!-- content -->
                <q-stepper ref="stepper" v-model="currentStep">
                  <q-step default title="Welcome" name="welcome">
                    <h5 class="q-mt-xs q-mb-md">Welcome</h5>
                  </q-step>
            
                  <q-step title="Pizza" name="pizza">
                    <pizza ref="pizza"></pizza>
                  </q-step>
            
                  <q-step title="Wings" name="wings">
                    <wings ref="wings"></wings>
                  </q-step>
            
                  <q-step title="Done" name="done">
                    <p>Enjoy!</p>
                  </q-step>
            
                  <!-- custom nav to deal with done -->
                  <q-stepper-navigation>
                    <q-btn
                      flat
                      @click="$refs.stepper.previous()"
                      label="Back"
                    />
                    <q-btn
                      v-if="currentStep !== 'done'"
                      @click="$refs.stepper.next()"
                      label="Next"
                    />
                    <q-btn
                      v-if="currentStep === 'done'"
                      @click="finish()"
                      label="Done"
                    />
                  </q-stepper-navigation>
                  <q-inner-loading :visible="inProgress" />
                </q-stepper>
              </q-page>
            </template>
            
            <script>
            import Pizza from '../components/Pizza'
            import Wings from '../components/Wings'
            
            export default {
              name: 'Order',
              data () {
                return {
                  currentStep: 'welcome',
                  inProgress: false
                }
              },
              components: {
                Pizza,
                Wings
              },
              watch: {
                currentStep (to, from) {
                  this.transition(from, to)
                }
              },
              methods: {
                transition (from, to) {
                  if (from === 'pizza') {
                    console.log('ajax to save the pizza toppings')
                    this.inProgress = true
                    this.$store.dispatch('pizza/update', pizza)
                      .then(response => {
                        this.inProgress = false
                        this.currentStep = to
                      })
                  } else {
                    this.currentStep = to
                  }
                },
                finish () {
                  console.log('ajax to submit the order')
                  this.$store.dispatch('order/create', pizza)
                    .then(response => {
                      this.$router.push('/')
                    })    
                }
              }
            }
            </script>
            
            1 Reply Last reply Reply Quote 1
            • First post
              Last post