From d16a601c04aeb1d3550c5c541be02a67276a34cf Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Thu, 9 Jan 2020 23:22:27 +0200 Subject: More keyboard shortcuts: c for archive card Thanks to xet7 ! Related #1878 --- client/lib/keyboard.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'client/lib/keyboard.js') diff --git a/client/lib/keyboard.js b/client/lib/keyboard.js index d3f974be..da33f806 100755 --- a/client/lib/keyboard.js +++ b/client/lib/keyboard.js @@ -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', + }, ], }); -- cgit v1.2.3-1-g7c22 From 1c488cb8a7f8a226f1f38575fa32822fedab1067 Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Wed, 29 Apr 2020 15:06:27 +0200 Subject: Fix shortcuts mapping in the shortcuts list Shorcuts are case-sensitive therefore let's fix the keys in the shortcuts list. --- client/lib/keyboard.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'client/lib/keyboard.js') diff --git a/client/lib/keyboard.js b/client/lib/keyboard.js index da33f806..055eec18 100755 --- a/client/lib/keyboard.js +++ b/client/lib/keyboard.js @@ -97,19 +97,19 @@ Mousetrap.bind('c', evt => { Template.keyboardShortcuts.helpers({ mapping: [ { - keys: ['W'], + keys: ['w'], action: 'shortcut-toggle-sidebar', }, { - keys: ['Q'], + keys: ['q'], action: 'shortcut-filter-my-cards', }, { - keys: ['F'], + keys: ['f'], action: 'shortcut-toggle-filterbar', }, { - keys: ['X'], + keys: ['x'], action: 'shortcut-clear-filters', }, { @@ -129,7 +129,7 @@ Template.keyboardShortcuts.helpers({ action: 'shortcut-assign-self', }, { - keys: ['C'], + keys: ['c'], action: 'archive-card', }, ], -- cgit v1.2.3-1-g7c22 From 301d96f3924d1b59912cfc85cb8e84a8c3f28d1e Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Wed, 29 Apr 2020 15:07:08 +0200 Subject: Support card shortcuts when hovering a card --- client/lib/keyboard.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'client/lib/keyboard.js') diff --git a/client/lib/keyboard.js b/client/lib/keyboard.js index 055eec18..e861e416 100755 --- a/client/lib/keyboard.js +++ b/client/lib/keyboard.js @@ -1,6 +1,16 @@ // 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). +function getHoveredCardId() { + const card = $('.js-minicard:hover').get(0); + if (!card) return null; + return Blaze.getData(card)._id; +} + +function getSelectedCardId() { + return Session.get('selectedCard') || getHoveredCardId(); +} + Mousetrap.bind('?', () => { FlowRouter.go('shortcuts'); }); @@ -50,9 +60,9 @@ Mousetrap.bind(['down', 'up'], (evt, key) => { } }); -// XXX This shortcut should also work when hovering over a card in board view Mousetrap.bind('space', evt => { - if (!Session.get('currentCard')) { + const cardId = getSelectedCardId(); + if (!cardId) { return; } @@ -62,7 +72,7 @@ Mousetrap.bind('space', evt => { } if (Meteor.user().isBoardMember()) { - const card = Cards.findOne(Session.get('currentCard')); + const card = Cards.findOne(cardId); card.toggleMember(currentUserId); // We should prevent scrolling in card when spacebar is clicked // This should do it according to Mousetrap docs, but it doesn't @@ -70,9 +80,9 @@ 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')) { + const cardId = getSelectedCardId(); + if (!cardId) { return; } @@ -86,7 +96,7 @@ Mousetrap.bind('c', evt => { !Meteor.user().isCommentOnly() && !Meteor.user().isWorker() ) { - const card = Cards.findOne(Session.get('currentCard')); + const card = Cards.findOne(cardId); card.archive(); // We should prevent scrolling in card when spacebar is clicked // This should do it according to Mousetrap docs, but it doesn't -- cgit v1.2.3-1-g7c22