Guide on navigating to a specific step within a wizard using Vue and TypeScript

In this wizard, there are 6 steps. The last step includes a button that redirects the user back to step 4 when clicked. The user must then complete steps 5 and 6 in order to finish the wizard.

step6.ts

<router-link
        to="/stepFour"
        custom
        v-slot="{ navigate }"
>
        <q-btn
          :ripple="false"
          flat
          :label="$t('pages.projects.project.deviceConnection.validation.symbolDidntBlink')"
          @click="navigate"
          role="link"
        />
</router-link>

router.ts

  const routes = [
  //connect: redirect
  {
    path: 'stepFour',
    name: 'step4',
    component: () => import('components/connection/4_stepFour/stepFour.vue'),
    props: {
      slaveLevel: 1,
    },
  },
];

wizard.vue

<template>
  <q-stepper
    v-bind:value="value"
    v-on:input="handleInput"
    ref="stepper"
    color="primary"
    flat
    class="c-stepper"
    @transition="transitionPanel"
  >
    <slot />

    <template v-slot:navigation>
      <q-card-actions class="c-wizarDialog__footer c-btn__action" align="center">
        <q-btn
          v-if="value > 1 && !disablePreviousButton"
          :ripple="false"
          :disable="disablePreviousButton"
          icon="chevron_left"
          flat
          dense
          size="lg"
          text-color="primary"
          @click="goPrevious($refs)"
          data-cy="wizard-back"
          class="c-btn--previous"
        />

        <q-btn
          :ripple="false"
          v-if="value === numberOfSteps"
          :disable="disableFinishButtonState"
          @click="finish(actionButtonFunction)"
          color="primary"
          :label="$t('general.finish')"
          class="c-btn--finish full-width"
          data-cy="wizard-finish"
        />

        <q-btn
          v-else-if="pShowNextButton"
          :ripple="false"
          :disabled="disableNextButton"
          @click="goToNextStep($refs)"
          color="primary"
          class="c-btn--continue full-width"
          data-cy="wizard-continue"
        >
          {{ $t('general.continue') }}
        </q-btn>
      </q-card-actions>
    </template>
  </q-stepper>
</template>

connection.ts

<template>
  <WizardDialog
    :title="$t('components.appBar.connection')"
    :actionButtonTitle="$t('general.createButtonText')"
    v-on:dialogVisibility="handleDialogVisibility"
    :cancelButtonLabel="''"
  >
    <Wizard
      :number-of-steps="numberOfSteps"
      v-model="step"
      :action-button-function="finishFunction"
      :disable-next-button="disableNextButton"
      :has-step-errors="hasStepErrors"
    >
      <WizardStep
        class="c-identifyDialog"
        :number-of-steps="numberOfSteps"
        :name="0"
        :done="step > 0"
      >
//wizard steps from 1 to 5

      <WizardStep :number-of-steps="numberOfSteps" :name="6" :done="step > 6" v-if="!isHelp">
        <StepSix />
      </WizardStep>
    </Wizard>
  </WizardDialog>
</template>

This section of code implements a redirection to step 4 outside of the wizard interface. Assistance is needed to correct this behavior.

Answer №1

Router-links are designed to update the current page of your app, leading to the stepFour component completely replacing everything. Take a look at Quasar's QStepper API documentation. Utilizing router-links for controlling component navigation is unnecessary as the functionality is built into the component using v-model. Simply changing the v-model value will dictate which step the component displays. Here's a basic example:

<q-stepper
  v-model="step"
>
  <q-step :name="1" />
  <q-step :name="2" />
  <q-step :name="3" />
</q-stepper>

By setting step to a value of 1, 2, or 3 in a function, q-stepper will automatically switch to the corresponding named q-step child component.

Answer №2

Instead of including the code snippet in step6.ts, make changes to the wizard.ts file in the following way.

  <WizardStep :number-of-steps="numberOfSteps" :name="6" :done="step > 6" v-if="!isHelp">
    <StepSix ref="step6" />
    <div >
    <q-btn
        :ripple="false"
        flat
        color="primary"
        class="q-mb-sm full-width"
        @click="redirect()"
      >
        {{ $t('pages.projects.project.deviceConnection.validation.symbolDidntBlink') }}
      </q-btn>
    </div>
  </WizardStep>

This action will direct the user to step4 within the wizard.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is subtyping causing issues in TypeScript's inheritance model?

I am currently utilizing TypeScript for my coding projects, and I have observed that it can allow the production of non-type-safe code. Despite implementing all the "strict" options available to me, the behavior I am experiencing goes against the principle ...

When object signatures match exactly, TypeScript issues a warning

I am facing an issue with typescript while trying to use my own custom type from express' types. When I attempt to pass 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>' as a parameter of type 'Context&a ...

Is it possible to display two menus on opposite sides of the screen while using Google Maps?

Currently, I am working on developing a Progressive Web App using Vue.js and Vuetify.js. My goal is to have two buttons overlaid on Google Maps - one on the left side of the screen to open a navigation drawer, and another on the right side to display user ...

Comparing TypeScript and C++ in terms of defining class reference member variables

class B; class A { A(B b_) : b{b_} {} B &b; }; In C++, it is possible to have a reference member variable like 'b' in class A. Can the same be achieved in TypeScript? Alternatively, is there a specific method to accomplish this in ...

Setting up pagination in Angular Material can sometimes present challenges

After implementing pagination and following the guidelines provided here. This is my code from the app.component.ts file - import { Component, OnInit, ViewChild } from '@angular/core'; import {MatPaginator} from '@angular/material/paginat ...

Typescript: object containing at least one property with the type T assigned

Is there a method to write the HasNumber interface in Typescript without receiving an error due to the fact that the HasNumberAndString interface includes a property that is not of type number? I am looking for a way to require the HasNumberAndString int ...

"Vue's prevention of default behavior in router-link element is effective in Chrome, but it seems to

My component uses a router-link as the root tag, and I'm trying to prevent its default link behavior in case there are issues with JavaScript or if it's disabled. In Chrome, I was able to achieve this using event modifiers like: @click.native.ca ...

What is the best way to troubleshoot the TypeScript error I am encountering in my JavaScript file?

Currently experiencing a TypeScript error within a JavaScript file The issue is within a folder containing only one JavaScript file, and there are no Node.js or package.json files present. I have disabled the TypeScript extensions (not using tslint). Re ...

A step-by-step guide on utilizing moment.js to format the data provided by a vuetify v-text-field (with the type: time)

Currently, I have set up this element in the code: <v-text-field label="Choose a time" type="time" mask="time" step="1800" prepend-inner-icon="access_time" v-model="expiryTime" :rules="[v => !!v || 'Time is required']" requ ...

The Bootstrap Vue Pagination feature seems to be experiencing an issue where data is not being displayed on

My VueJS application utilizes Bootstrap Vue Table and Pagination components to display a list of users with pagination. Although the data is successfully loaded, page 2 of the pagination does not render any information. The Users component passes the nece ...

To effectively manage this file type with Vue and vue-chartjs, it is essential to utilize a suitable loader

I have been working on an application that has multiple pages functioning properly. I am now trying to incorporate a new page with a chart feature. In order to test it out, I made modifications to include the necessary packages. "dependencies": { ...

How to simulate a long press mouse click in Vue testing

After developing a custom helper for simulating long click actions with the mouse, such as pressing the left click for one second, I now want to test it using vue-test-utils. However, my search for relevant information on this topic has come up empty-hande ...

Organizing the AuthGuard(canActivate) and AuthService code in Angular 2

After working on my current code, I have encountered an issue when routing to a page with the canActivate method. I was able to retrieve authentication data from the server using the following setup auth.guard.ts (version 1) import { CanActivate, Activat ...

Leveraging typegoose in a multitenant environment within the nestjs framework

I am looking to implement multitenancy functionality where each tenant will have its own database. Can Typegoose dynamically create connections for this purpose? ...

NextJS API routes consistently provide a status code of 200 upon execution

I am new to the concepts of Next.js, and I recently encountered an issue while attempting to fetch data from an API. The API is designed to check if a user session exists (i.e., if the user is logged in) and then returns a JSON response through a GET reque ...

Struggling with a malfunctioning Bootstrap dropdown that refuses to drop down

I've been working on a VueJS single-page application, but I can't seem to get the dropdown feature to work. I've followed the instructions from the Bootstrap guide and tried everything they recommended, but it just won't cooperate. Can ...

Outputting main value using Vue.js loop

Below is an array example: data() { return { shoppingItems: [ {name: 'apple', price: '10'}, {name: 'orange', price: '12'} ] } } I am attempting to loop through it as shown below: <ul> ...

What is the best way to add a border around an image along with a button using VueJS?

I am struggling to link a button and an image in VueJS to display a border around the picture. While I can successfully display the border on the button, I am unsure how to extend it to the image as well. Vue.component('my-button', 'my-img& ...

Sharing Laravel routes with vue components

In my `index.blade.php`, I have incorporated Vue code into the view. Generally, we pass Laravel routes like this: <a href="{{route('some-route')}}"> Link </a> Now, picture a scenario where I have a main Vue component within this `in ...

The Electron/React/Typescript module is missing: Error: Unable to locate 'fs' in the /node_modules/electron directory

Within my Electron application, I have a file named App.ts. It contains the following code snippet: import { ipcRenderer } from 'electron'; // remaining code However, during the app development process, I encountered this error message: Error: ...