Procházet zdrojové kódy

Merge pull request #4377 from Viehlieb/feature/shortcuts_for_label_assignment

Feature/shortcuts for label assignment
Lauri Ojansivu před 3 roky
rodič
revize
f71728ae16
4 změnil soubory, kde provedl 78 přidání a 2 odebrání
  1. 70 1
      client/lib/keyboard.js
  2. 3 0
      client/lib/multiSelection.js
  3. 3 1
      i18n/de.i18n.json
  4. 2 0
      i18n/en.i18n.json

+ 70 - 1
client/lib/keyboard.js

@@ -8,7 +8,7 @@ function getHoveredCardId() {
 }
 
 function getSelectedCardId() {
-  return Session.get('selectedCard') || getHoveredCardId();
+  return Session.get('currentCard') || Session.get('selectedCard') || getHoveredCardId();
 }
 
 Mousetrap.bind('?', () => {
@@ -68,6 +68,67 @@ Mousetrap.bind(['down', 'up'], (evt, key) => {
   }
 });
 
+numbArray = _.range(1,10).map(x => 'shift+'+String(x))
+Mousetrap.bind(numbArray, (evt, key) => {
+  num = parseInt(key.substr(6, key.length));
+  const currentUserId = Meteor.userId();
+  if (currentUserId === null) {
+    return;
+  }
+  const currentBoardId = Session.get('currentBoard');
+  board = Boards.findOne(currentBoardId);
+  labels = board.labels;
+  if(MultiSelection.isActive())
+  {
+    const cardIds = MultiSelection.getSelectedCardIds();
+    for (const cardId of cardIds)
+    {
+      card = Cards.findOne(cardId);
+      if(num <= board.labels.length)
+      {
+        card.removeLabel(labels[num-1]["_id"]);
+      }
+    }
+  }
+});
+
+numArray = _.range(1,10).map(x => String(x))
+Mousetrap.bind(numArray, (evt, key) => {
+  num = parseInt(key);
+  const currentUserId = Meteor.userId();
+  const currentBoardId = Session.get('currentBoard');
+  if (currentUserId === null) {
+    return;
+  }
+  board = Boards.findOne(currentBoardId);
+  labels = board.labels;
+  if(MultiSelection.isActive() && Meteor.user().isBoardMember())
+  {
+    const cardIds = MultiSelection.getSelectedCardIds();
+    for (const cardId of cardIds)
+    {
+      card = Cards.findOne(cardId);
+      if(num <= board.labels.length)
+      {
+        card.addLabel(labels[num-1]["_id"]);
+      }
+    }
+    return;
+  }
+
+  const cardId = getSelectedCardId();
+  if (!cardId) {
+    return;
+  }
+  if (Meteor.user().isBoardMember()) {
+    const card = Cards.findOne(cardId);
+    if(num <= board.labels.length)
+    {
+      card.toggleLabel(labels[num-1]["_id"]);
+    }
+  }
+});
+
 Mousetrap.bind('space', evt => {
   const cardId = getSelectedCardId();
   if (!cardId) {
@@ -154,5 +215,13 @@ Template.keyboardShortcuts.helpers({
       keys: ['c'],
       action: 'archive-card',
     },
+    {
+      keys: ['number keys 1-9'],
+      action: 'toggle-labels'
+    },
+    {
+      keys: ['shift + number keys 1-9'],
+      action: 'remove-labels-multiselect'
+    },
   ],
 });

+ 3 - 0
client/lib/multiSelection.js

@@ -83,6 +83,9 @@ MultiSelection = {
   isEmpty() {
     return this.count() === 0;
   },
+  getSelectedCardIds(){
+    return this._selectedCards.curValue;
+  },
 
   activate() {
     if (!this.isActive()) {

+ 3 - 1
i18n/de.i18n.json

@@ -571,6 +571,8 @@
     "has-spenttime-cards": "Hat Karten mit aufgewendeten Zeiten",
     "time": "Zeit",
     "title": "Titel",
+    "toggle-labels": "Label 1-9 für Karte Toggeln. \"Multiselect\": Label 1-9 hinzufügen",
+    "remove-labels-multiselect": "\"Multiselect\" Label 1-9 entfernen",
     "tracking": "Folgen",
     "tracking-info": "Sie werden über alle Änderungen an Karten benachrichtigt, an denen Sie als Ersteller oder Mitglied beteiligt sind.",
     "type": "Typ",
@@ -1145,4 +1147,4 @@
     "copyChecklist": "Checkliste kopieren",
     "copyChecklistPopup-title": "Checkliste kopieren",
     "card-show-lists": "Listen anzeigen"
-}
+}

+ 2 - 0
i18n/en.i18n.json

@@ -571,6 +571,8 @@
   "has-spenttime-cards": "Has spent time cards",
   "time": "Time",
   "title": "Title",
+  "toggle-labels": "Toggle labels 1-9 for card. \"Multiselect\": adds labels 1-9",
+  "remove-labels-multiselect": "\"Multiselect\" removes labels 1-9",
   "tracking": "Tracking",
   "tracking-info": "You will be notified of any changes to those cards you are involved as creator or member.",
   "type": "Type",