浏览代码

Merge pull request #5570 from NadavTasher/feature/new-card-keyboard-shortcut

Added 'n' shortcut for adding new minicards to current list
Lauri Ojansivu 6 月之前
父节点
当前提交
3338fc366d
共有 1 个文件被更改,包括 28 次插入0 次删除
  1. 28 0
      client/lib/keyboard.js

+ 28 - 0
client/lib/keyboard.js

@@ -179,6 +179,30 @@ Mousetrap.bind('c', evt => {
   }
   }
 });
 });
 
 
+Mousetrap.bind('n', evt => {
+  const cardId = getSelectedCardId();
+  if (!cardId) {
+    return;
+  }
+
+  const currentUserId = Meteor.userId();
+  if (currentUserId === null) {
+    return;
+  }
+
+  if (Utils.canModifyBoard()) {
+    // Find the current hovered card
+    const card = ReactiveCache.getCard(cardId);
+
+    // Find the button and click it
+    $(`#js-list-${card.listId} .list-body .minicards .open-minicard-composer`).click()
+
+    // 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({
 Template.keyboardShortcuts.helpers({
   mapping: [
   mapping: [
     {
     {
@@ -193,6 +217,10 @@ Template.keyboardShortcuts.helpers({
       keys: ['a'],
       keys: ['a'],
       action: 'shortcut-filter-my-assigned-cards',
       action: 'shortcut-filter-my-assigned-cards',
     },
     },
+    {
+      keys: ['n'],
+      action: 'add-card-to-bottom-of-list',
+    },
     {
     {
       keys: ['f'],
       keys: ['f'],
       action: 'shortcut-toggle-filterbar',
       action: 'shortcut-toggle-filterbar',