Skip to content
Snippets Groups Projects
index.js 4.35 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')
  },
  // * PROJECT
  {
    path: '/creer-projet/',
    name: 'project_create',
    component: () => import('../views/project/Project_edit.vue')
  },
  {
    path: '/projet/:slug',
    name: 'project_detail',
    props: true,
    component: () => import('../views/project/Project_detail.vue'),
  },
  {
    path: '/projet/:slug/editer',
    name: 'project_edit',
    component: () => import('../views/project/Project_edit.vue')
  },
  {
    path: '/projet-type/',
    name: 'project_type_list',
    component: () => import('../views/project/Project_type_list.vue')
  },
  {
    path: '/creer-projet/create_from/:slug/',
    name: 'project_create_from',
    component: () => import('../views/project/Project_edit.vue')
  },
  {
    path: '/projet/:slug/administration-carte/',
    name: 'project_mapping',
    component: () => import('../views/project/Project_mapping.vue')
  },
  {
    path: '/projet/:slug/membres/',
    name: 'project_members',
    component: () => import('../views/project/Project_members.vue')
  },
  // * FEATURE TYPE 
  {
    path: '/projet/:slug/type-signalement/ajouter/',
    name: 'ajouter-type-signalement',
    props: true,
    component: () => import('../views/feature_type/Feature_type_edit.vue')
  },
  {
    path: '/projet/:slug/type-signalement/ajouter/create_from/:slug_type_signal',
    name: 'dupliquer-type-signalement',
    component: () => import('../views/feature_type/Feature_type_edit.vue')
  },
  {
    path: '/projet/:slug/type-signalement/:feature_type_slug/',
    name: 'details-type-signalement',
    component: () => import('../views/feature_type/Feature_type_detail.vue')
  },
  {
    path: '/projet/:slug/type-signalement/:slug_type_signal/editer/',
    name: 'editer-type-signalement',
    component: () => import('../views/feature_type/Feature_type_edit.vue')
  },
  {
    path: '/projet/:slug/type-signalement/:slug_type_signal/symbologie/',
    name: 'editer-symbologie-signalement',
    component: () => import('../views/feature_type/Feature_type_symbology.vue')
  },
  // * FEATURE 
  {
    path: '/projet/:slug/signalement/lister/',
    name: 'liste-signalements',
    component: () => import('../views/feature/Feature_list.vue')
  },
  {
    path: '/projet/:slug/type-signalement/:slug_type_signal/signalement/ajouter/',
    name: 'ajouter-signalement',
    component: () => import('../views/feature/Feature_edit.vue')
  },
  {
    path: '/projet/:slug/type-signalement/:slug_type_signal/signalement/:slug_signal',
    name: 'details-signalement',
    component: () => import('../views/feature/Feature_detail.vue')
  },
  {
    path: '/projet/:slug/type-signalement/:slug_type_signal/offline',
    name: 'offline-signalement',
    component: () => import('../views/feature/Feature_offline.vue')
  },
  {
    path: '/projet/:slug/type-signalement/:slug_type_signal/signalement/:slug_signal/editer/',
    name: 'editer-signalement',
    component: () => import('../views/feature/Feature_edit.vue')
  },

  { path: '/:pathMatch(.*)*', name: 'NotFound', component: () => import('../views/NotFound.vue') },
]
//let routerHistory = [];

const router = new VueRouter({
  mode: 'history',
  base: '/geocontrib/',
  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