summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Hartmayer <hello@hartmayer.com>2020-04-29 15:07:08 +0200
committerMarc Hartmayer <hello@hartmayer.com>2020-04-29 15:17:43 +0200
commit301d96f3924d1b59912cfc85cb8e84a8c3f28d1e (patch)
treeaf25fc1fed2422a39745fb270849e573d31199dc
parent1c488cb8a7f8a226f1f38575fa32822fedab1067 (diff)
downloadwekan-301d96f3924d1b59912cfc85cb8e84a8c3f28d1e.tar.gz
wekan-301d96f3924d1b59912cfc85cb8e84a8c3f28d1e.tar.bz2
wekan-301d96f3924d1b59912cfc85cb8e84a8c3f28d1e.zip
Support card shortcuts when hovering a card
-rwxr-xr-xclient/lib/keyboard.js22
1 files changed, 16 insertions, 6 deletions
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