Skip to content
Snippets Groups Projects
index.js 2.44 KiB
import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '../views/Index.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'index',
    component: Index
  },
  {
    path: '/connexion/',
    name: 'login',
    // route level code-splitting
    // this generates a separate chunk (login.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "login" */'../views/registration/Login.vue')
  },
  {
    path: '/my_account/',
    name: 'my_account',
    component: () => import('../views/My_account.vue')
  },
  {
    path: '/mentions/',
    name: 'mentions',
    component: () => import('../views/flatpages/with_right_menu.vue')
  },
  {
    path: '/aide/',
    name: 'aide',
    component: () => import('../views/flatpages/Default.vue')
  },
  // * PROJECTS
  {
    path: '/projet/:slug',
    name: 'project_detail',
    props: true,
    hasProject: true, //* used to know if project should be unset
    component: () => import('../views/project/Project_detail.vue')
  },
  {
    path: '/project_edit/',
    name: 'project_edit',
    //props: true,
    hasProject: true,
    component: () => import('../views/project/Project_edit.vue')
  },
  {
    path: '/project_type_list/',
    name: 'project_type_list',
    //props: true,
    component: () => import('../views/project/Project_type_list.vue')
  },
  {
    path: '/project_mapping/',
    name: 'project_mapping',
    props: true,
    hasProject: true,
    component: () => import('../views/project/Project_mapping.vue')
  },
  // * FEATURE
  {
    path: '/project_members/',
    name: 'project_members',
    props: true,
    hasProject: true,
    component: () => import('../views/project/Project_members.vue')
  },
  {
    path: '/feature_list/',
    name: 'feature_list',
    props: true,
    hasProject: true,
    component: () => import('../views/feature/Feature_list.vue')
  },


]
//let routerHistory = [];

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
  routerHistory: [],
  scrollBehavior(to, from, savedPosition) { //* record each route change to turn back to origin after redirect
    const fromHistory = Boolean(savedPosition);

    if (fromHistory && this.options.routerHistory.length > 0) {
      this.options.routerHistory.splice(-1, 1);
    } else {
      this.options.routerHistory.push(from);
    }
    return savedPosition || { x: 0, y: 0 };
  },
})

export default router