parsley/app/javascript/router.js

164 lines
3.5 KiB
JavaScript
Raw Normal View History

2018-03-29 01:57:00 -05:00
import Vue from 'vue';
import Router from 'vue-router';
import The404Page from './components/The404Page';
2018-03-30 14:31:09 -05:00
import TheAboutPage from './components/TheAboutPage';
import TheCalculator from './components/TheCalculator';
2018-04-13 10:25:18 -05:00
import TheLog from './components/TheLog';
import TheLogList from './components/TheLogList';
import TheLogCreator from './components/TheLogCreator';
import TheLogEditor from './components/TheLogEditor';
2018-09-11 22:56:26 -05:00
import TheFoodList from './components/TheFoodList';
import TheFood from "./components/TheFood";
import TheFoodEditor from "./components/TheFoodEditor";
import TheFoodCreator from "./components/TheFoodCreator";
2018-03-30 14:31:09 -05:00
import TheNotesList from './components/TheNotesList';
2018-04-01 21:43:23 -05:00
import TheRecipe from './components/TheRecipe';
import TheRecipeEditor from './components/TheRecipeEditor';
import TheRecipeCreator from './components/TheRecipeCreator';
2018-03-29 01:57:00 -05:00
import TheRecipeList from './components/TheRecipeList';
2018-08-28 10:39:11 -05:00
import TheTaskListList from './components/TheTaskListList';
2018-06-09 12:36:46 -05:00
import TheUserCreator from './components/TheUserCreator';
import TheUserEditor from './components/TheUserEditor';
import TheAdminUserList from './components/TheAdminUserList';
import TheAdminUserEditor from './components/TheAdminUserEditor';
2018-03-29 01:57:00 -05:00
Vue.use(Router);
2018-04-01 12:17:54 -05:00
const router = new Router({
routes: []
});
router.addRoutes(
[
2018-03-29 01:57:00 -05:00
{
path: '/',
2018-04-01 21:43:23 -05:00
redirect: '/recipes'
},
{
path: '/recipes',
2018-03-29 01:57:00 -05:00
name: 'recipeList',
component: TheRecipeList
},
2018-04-01 21:43:23 -05:00
{
path: '/recipes/new',
name: 'new_recipe',
component: TheRecipeCreator
},
2018-03-30 14:31:09 -05:00
{
path: '/recipes/:id/edit',
name: 'edit_recipe',
2018-04-01 21:43:23 -05:00
component: TheRecipeEditor
2018-03-30 14:31:09 -05:00
},
{
path: '/recipe/:id',
name: 'recipe',
2018-04-01 21:43:23 -05:00
component: TheRecipe
2018-03-30 14:31:09 -05:00
},
{
path: "/about",
name: "about",
component: TheAboutPage
},
{
path: "/calculator",
name: "calculator",
component: TheCalculator
},
{
2018-09-11 22:56:26 -05:00
path: "/foods",
name: "foods",
component: TheFoodList
2018-03-30 14:31:09 -05:00
},
2018-04-02 00:10:06 -05:00
{
2018-09-11 22:56:26 -05:00
path: "/foods/new",
name: "new_food",
component: TheFoodCreator
2018-04-02 00:10:06 -05:00
},
{
2018-09-11 22:56:26 -05:00
path: "/foods/:id/edit",
name: "edit_food",
component: TheFoodEditor
2018-04-02 00:10:06 -05:00
},
{
2018-09-11 22:56:26 -05:00
path: "/foods/:id",
name: "food",
component: TheFood
2018-04-02 00:10:06 -05:00
},
2018-04-13 10:25:18 -05:00
{
path: "/logs",
name: "logs",
component: TheLogList
},
{
path: "/recipes/:recipeId/logs/new",
name: "new_log",
component: TheLogCreator
},
{
path: "/logs/:id/edit",
name: "edit_log",
component: TheLogEditor
},
{
path: "/logs/:id",
name: "log",
component: TheLog
},
2018-03-30 14:31:09 -05:00
{
path: "/notes",
name: "notes",
component: TheNotesList
},
2018-08-28 10:39:11 -05:00
{
path: "/tasks",
name: "task_lists",
component: TheTaskListList
},
2018-04-01 12:17:54 -05:00
{
path: "/logout",
name: "logout",
beforeEnter: (to, from, next) => {
const $store = router.app.$store;
$store.dispatch("logout")
.then(() => next("/"));
}
},
2018-06-09 12:36:46 -05:00
{
path: "/user/new",
name: "new_user",
component: TheUserCreator
},
{
path: "/user/edit",
name: "edit_user",
component: TheUserEditor
},
{
path: "/admin/users",
name: "admin_users",
component: TheAdminUserList
},
{
path: "/admin/users/:id/edit",
name: "admin_edit_user",
component: TheAdminUserEditor
},
2018-03-29 01:57:00 -05:00
{
path: '*',
component: The404Page
}
]
2018-04-01 12:17:54 -05:00
);
export default router;