Преглед на файлове

More keyboard shortcuts: c for archive card

Thanks to xet7 !

Related #1878
Lauri Ojansivu преди 5 години
родител
ревизия
d16a601c04
променени са 1 файла, в които са добавени 28 реда и са изтрити 0 реда
  1. 28 0
      client/lib/keyboard.js

+ 28 - 0
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',
+    },
   ],
 });