From 7eed0628d0bd9846950ff025dc647bd7e6dc6523 Mon Sep 17 00:00:00 2001 From: Dominik Pschenitschni Date: Sun, 14 Nov 2021 21:33:53 +0100 Subject: [PATCH] feat: mount list views as route-views --- src/router/index.ts | 66 +++++++++++-------- .../list/{views/Gantt.vue => ListGantt.vue} | 15 ++++- .../list/{views/Kanban.vue => ListKanban.vue} | 31 +++++---- .../list/{views/List.vue => ListList.vue} | 28 +++++--- .../list/{views/Table.vue => ListTable.vue} | 20 ++++-- .../list/{ShowList.vue => ListWrapper.vue} | 16 +---- 6 files changed, 104 insertions(+), 72 deletions(-) rename src/views/list/{views/Gantt.vue => ListGantt.vue} (94%) rename src/views/list/{views/Kanban.vue => ListKanban.vue} (97%) rename src/views/list/{views/List.vue => ListList.vue} (93%) rename src/views/list/{views/Table.vue => ListTable.vue} (96%) rename src/views/list/{ShowList.vue => ListWrapper.vue} (91%) diff --git a/src/router/index.ts b/src/router/index.ts index 7995ee174..fd31d79ba 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -2,6 +2,8 @@ import { createRouter, createWebHistory, RouteLocation } from 'vue-router' import {saveLastVisited} from '@/helpers/saveLastVisited' import {store} from '@/store' +import {getListView} from '@/helpers/saveListView' + import HomeComponent from '../views/Home' import NotFoundComponent from '../views/404' import About from '../views/About' @@ -23,12 +25,12 @@ import NewLabelComponent from '../views/labels/NewLabel' // Migration import MigrationComponent from '../views/migrator/Migrate' import MigrateServiceComponent from '../views/migrator/MigrateService' + // List Views -import ShowListComponent from '../views/list/ShowList' -import Kanban from '../views/list/views/Kanban' -import List from '../views/list/views/List' -import Gantt from '../views/list/views/Gantt' -import Table from '../views/list/views/Table' +import ListList from '../views/list/ListList' +import ListGantt from '../views/list/ListGantt' +import ListTable from '../views/list/ListTable' +import ListKanban from '../views/list/ListKanban' // List Settings import ListSettingEdit from '../views/list/settings/edit' @@ -323,29 +325,37 @@ const router = createRouter({ { path: '/lists/:listId', name: 'list.index', - component: ShowListComponent, - children: [ - { - path: '/lists/:listId/list', - name: 'list.list', - component: List, - }, - { - path: '/lists/:listId/gantt', - name: 'list.gantt', - component: Gantt, - }, - { - path: '/lists/:listId/table', - name: 'list.table', - component: Table, - }, - { - path: '/lists/:listId/kanban', - name: 'list.kanban', - component: Kanban, - }, - ], + beforeEnter(to) { + // Redirect the user to list view by default + + const savedListView = getListView(to.params.listId) + console.debug('Replaced list view with', savedListView) + + return { + name: savedListView, + params: {listId: to.params.listId}, + } + }, + }, + { + path: '/lists/:listId/list', + name: 'list.list', + component: ListList, + }, + { + path: '/lists/:listId/gantt', + name: 'list.gantt', + component: ListGantt, + }, + { + path: '/lists/:listId/table', + name: 'list.table', + component: ListTable, + }, + { + path: '/lists/:listId/kanban', + name: 'list.kanban', + component: ListKanban, }, { path: '/teams', diff --git a/src/views/list/views/Gantt.vue b/src/views/list/ListGantt.vue similarity index 94% rename from src/views/list/views/Gantt.vue rename to src/views/list/ListGantt.vue index 3c3ee344a..224f0539b 100644 --- a/src/views/list/views/Gantt.vue +++ b/src/views/list/ListGantt.vue @@ -1,6 +1,6 @@