mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 23:40:13 +01:00
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:
cf0419f70e/examples/pinterest
This commit is contained in:
parent
95dcd8a146
commit
31c4aa01bd
6 changed files with 57 additions and 24 deletions
|
|
@ -5,9 +5,7 @@ Template.header.helpers({
|
||||||
},
|
},
|
||||||
|
|
||||||
wrappedHeader: function() {
|
wrappedHeader: function() {
|
||||||
var unwrapedRoutes = ['board', 'card'];
|
return ! Session.get('currentBoard');
|
||||||
var currentRouteName = FlowRouter.getRouteName();
|
|
||||||
return unwrapedRoutes.indexOf(currentRouteName) === -1;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
4
client/components/main/keyboardShortcuts.tpl.jade
Normal file
4
client/components/main/keyboardShortcuts.tpl.jade
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
.wrapper
|
||||||
|
h2
|
||||||
|
i.fa.fa-keyboard-o
|
||||||
|
| Keyboard shortcuts
|
||||||
|
|
@ -1,3 +1,8 @@
|
||||||
|
let previousPath;
|
||||||
|
FlowRouter.triggers.exit([({path}) => {
|
||||||
|
previousPath = path;
|
||||||
|
}]);
|
||||||
|
|
||||||
FlowRouter.route('/', {
|
FlowRouter.route('/', {
|
||||||
name: 'home',
|
name: 'home',
|
||||||
triggersEnter: [AccountsTemplates.ensureSignedIn],
|
triggersEnter: [AccountsTemplates.ensureSignedIn],
|
||||||
|
|
@ -5,7 +10,8 @@ FlowRouter.route('/', {
|
||||||
EscapeActions.executeAll();
|
EscapeActions.executeAll();
|
||||||
Filter.reset();
|
Filter.reset();
|
||||||
|
|
||||||
Session.set('currentBoard', '');
|
Session.set('currentBoard', null);
|
||||||
|
Session.set('currentCard', null);
|
||||||
|
|
||||||
BlazeLayout.render('defaultLayout', { content: 'boardList' });
|
BlazeLayout.render('defaultLayout', { content: 'boardList' });
|
||||||
}
|
}
|
||||||
|
|
@ -31,14 +37,32 @@ FlowRouter.route('/b/:id/:slug', {
|
||||||
FlowRouter.route('/b/:boardId/:slug/:cardId', {
|
FlowRouter.route('/b/:boardId/:slug/:cardId', {
|
||||||
name: 'card',
|
name: 'card',
|
||||||
action: function(params) {
|
action: function(params) {
|
||||||
|
EscapeActions.executeUpTo('popup-close');
|
||||||
Session.set('currentBoard', params.boardId);
|
Session.set('currentBoard', params.boardId);
|
||||||
Session.set('currentCard', params.cardId);
|
Session.set('currentCard', params.cardId);
|
||||||
EscapeActions.executeUpTo('popup-close');
|
|
||||||
|
|
||||||
BlazeLayout.render('defaultLayout', { content: 'board' });
|
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 = {
|
FlowRouter.notFound = {
|
||||||
action: function() {
|
action: function() {
|
||||||
BlazeLayout.render('defaultLayout', { content: 'notFound' });
|
BlazeLayout.render('defaultLayout', { content: 'notFound' });
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,9 @@ EscapeActions = {
|
||||||
'textcomplete',
|
'textcomplete',
|
||||||
'popup-back',
|
'popup-back',
|
||||||
'popup-close',
|
'popup-close',
|
||||||
|
'modalWindow',
|
||||||
'inlinedForm',
|
'inlinedForm',
|
||||||
'detailsPane',
|
'detailsPane',
|
||||||
'modalWindow',
|
|
||||||
'multiselection',
|
'multiselection',
|
||||||
'sidebarView'
|
'sidebarView'
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -1,35 +1,37 @@
|
||||||
// XXX Pressing `?` should display a list of all shortcuts available.
|
|
||||||
//
|
|
||||||
// XXX There is no reason to define these shortcuts globally, they should be
|
// XXX There is no reason to define these shortcuts globally, they should be
|
||||||
// attached to a template (most of them will go in the `board` template).
|
// attached to a template (most of them will go in the `board` template).
|
||||||
|
|
||||||
Mousetrap.bind('w', function() {
|
Mousetrap.bind('?', () => {
|
||||||
|
FlowRouter.go('shortcuts');
|
||||||
|
});
|
||||||
|
|
||||||
|
Mousetrap.bind('w', () => {
|
||||||
Sidebar.toogle();
|
Sidebar.toogle();
|
||||||
});
|
});
|
||||||
|
|
||||||
Mousetrap.bind('q', function() {
|
Mousetrap.bind('q', () => {
|
||||||
var currentBoardId = Session.get('currentBoard');
|
const currentBoardId = Session.get('currentBoard');
|
||||||
var currentUserId = Meteor.userId();
|
const currentUserId = Meteor.userId();
|
||||||
if (currentBoardId && currentUserId) {
|
if (currentBoardId && currentUserId) {
|
||||||
Filter.members.toogle(currentUserId);
|
Filter.members.toogle(currentUserId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Mousetrap.bind('x', function() {
|
Mousetrap.bind('x', () => {
|
||||||
if (Filter.isActive()) {
|
if (Filter.isActive()) {
|
||||||
Filter.reset();
|
Filter.reset();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Mousetrap.bind(['down', 'up'], function(evt, key) {
|
Mousetrap.bind(['down', 'up'], (evt, key) => {
|
||||||
if (! Session.get('currentCard')) {
|
if (! Session.get('currentCard')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var nextFunc = (key === 'down' ? 'next' : 'prev');
|
const nextFunc = (key === 'down' ? 'next' : 'prev');
|
||||||
var nextCard = $('.js-minicard.is-selected')[nextFunc]('.js-minicard').get(0);
|
const nextCard = $('.js-minicard.is-selected')[nextFunc]('.js-minicard').get(0);
|
||||||
if (nextCard) {
|
if (nextCard) {
|
||||||
var nextCardId = Blaze.getData(nextCard)._id;
|
const nextCardId = Blaze.getData(nextCard)._id;
|
||||||
Utils.goCardId(nextCardId);
|
Utils.goCardId(nextCardId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -2,27 +2,32 @@ const closedValue = null
|
||||||
|
|
||||||
window.Modal = new class {
|
window.Modal = new class {
|
||||||
constructor() {
|
constructor() {
|
||||||
this._currentModal = new ReactiveVar(closedValue)
|
this._currentModal = new ReactiveVar(closedValue);
|
||||||
|
this._onCloseGoTo = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
getTemplateName() {
|
getTemplateName() {
|
||||||
return this._currentModal.get()
|
return this._currentModal.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
isOpen() {
|
isOpen() {
|
||||||
return this.getTemplateName() !== closedValue
|
return this.getTemplateName() !== closedValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
this._currentModal.set(closedValue)
|
this._currentModal.set(closedValue);
|
||||||
|
if (this._onCloseGoTo) {
|
||||||
|
FlowRouter.go(this._onCloseGoTo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open(modalName) {
|
open(modalName, options) {
|
||||||
this._currentModal.set(modalName)
|
this._currentModal.set(modalName);
|
||||||
|
this._onCloseGoTo = options && options.onCloseGoTo || '';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Blaze.registerHelper('Modal', Modal)
|
Blaze.registerHelper('Modal', Modal);
|
||||||
|
|
||||||
EscapeActions.register('modalWindow',
|
EscapeActions.register('modalWindow',
|
||||||
() => Modal.close(),
|
() => Modal.close(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue