From 31c4aa01bda63e510e120ae9da8149c732111d2a Mon Sep 17 00:00:00 2001 From: Maxime Quandalle Date: Thu, 27 Aug 2015 00:27:23 +0200 Subject: Open a modal (or a new page) based on context This feature is also sometime named the Pinterest-style route, which is further explained in this react-router example: https://github.com/rackt/react-router/tree/cf0419f70e14a0ae39cba2ff99b01d3cbbd085be/examples/pinterest --- client/config/router.js | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'client/config') diff --git a/client/config/router.js b/client/config/router.js index ef874c5b..eb072934 100644 --- a/client/config/router.js +++ b/client/config/router.js @@ -1,3 +1,8 @@ +let previousPath; +FlowRouter.triggers.exit([({path}) => { + previousPath = path; +}]); + FlowRouter.route('/', { name: 'home', triggersEnter: [AccountsTemplates.ensureSignedIn], @@ -5,7 +10,8 @@ FlowRouter.route('/', { EscapeActions.executeAll(); Filter.reset(); - Session.set('currentBoard', ''); + Session.set('currentBoard', null); + Session.set('currentCard', null); BlazeLayout.render('defaultLayout', { content: 'boardList' }); } @@ -31,14 +37,32 @@ FlowRouter.route('/b/:id/:slug', { FlowRouter.route('/b/:boardId/:slug/:cardId', { name: 'card', action: function(params) { + EscapeActions.executeUpTo('popup-close'); Session.set('currentBoard', params.boardId); Session.set('currentCard', params.cardId); - EscapeActions.executeUpTo('popup-close'); BlazeLayout.render('defaultLayout', { content: 'board' }); } }); +FlowRouter.route('/shortcuts', { + name: 'shortcuts', + action: function(params) { + const shortcutsTemplate = 'keyboardShortcuts'; + + EscapeActions.executeUpTo('popup-close'); + + if (previousPath) { + Modal.open(shortcutsTemplate, { + onCloseGoTo: previousPath + }); + } else { + // XXX There is currently no way to escape this page on Sandstorm + BlazeLayout.render('defaultLayout', { content: shortcutsTemplate }); + } + } +}); + FlowRouter.notFound = { action: function() { BlazeLayout.render('defaultLayout', { content: 'notFound' }); -- cgit v1.2.3-1-g7c22