More keyboard shortcuts: c for archive card

Thanks to xet7 !

Related #1878
This commit is contained in:
Lauri Ojansivu 2020-01-09 23:22:27 +02:00
parent 5724674e73
commit d16a601c04

View file

@ -70,6 +70,30 @@ Mousetrap.bind('space', evt => {
}
});
// XXX This shortcut should also work when hovering over a card in board view
Mousetrap.bind('c', evt => {
if (!Session.get('currentCard')) {
return;
}
const currentUserId = Meteor.userId();
if (currentUserId === null) {
return;
}
if (
Meteor.user().isBoardMember() &&
!Meteor.user().isCommentOnly() &&
!Meteor.user().isWorker()
) {
const card = Cards.findOne(Session.get('currentCard'));
card.archive();
// We should prevent scrolling in card when spacebar is clicked
// This should do it according to Mousetrap docs, but it doesn't
evt.preventDefault();
}
});
Template.keyboardShortcuts.helpers({
mapping: [
{
@ -104,5 +128,9 @@ Template.keyboardShortcuts.helpers({
keys: ['SPACE'],
action: 'shortcut-assign-self',
},
{
keys: ['C'],
action: 'archive-card',
},
],
});