client: refactor linking and routing

Print all links through new uri.js component
Refactor the router to use more predictable parsing
Fix linking to entities with weird names (that contain slashes, + etc.)
This commit is contained in:
rr-
2017-01-20 21:51:04 +01:00
parent 6714f05b49
commit 1acceb941d
65 changed files with 380 additions and 295 deletions

View File

@ -2,6 +2,7 @@
const router = require('../router.js');
const api = require('../api.js');
const uri = require('../util/uri.js');
const topNavigation = require('../models/top_navigation.js');
const LoginView = require('../views/login_view.js');
@ -21,7 +22,7 @@ class LoginController {
api.forget();
api.login(e.detail.name, e.detail.password, e.detail.remember)
.then(() => {
const ctx = router.show('/');
const ctx = router.show(uri.formatClientLink());
ctx.controller.showSuccess('Logged in');
}, error => {
this._loginView.showError(error.message);
@ -34,16 +35,16 @@ class LogoutController {
constructor() {
api.forget();
api.logout();
const ctx = router.show('/');
const ctx = router.show(uri.formatClientLink());
ctx.controller.showSuccess('Logged out');
}
}
module.exports = router => {
router.enter('/login', (ctx, next) => {
router.enter(['login'], (ctx, next) => {
ctx.controller = new LoginController();
});
router.enter('/logout', (ctx, next) => {
router.enter(['logout'], (ctx, next) => {
ctx.controller = new LogoutController();
});
};