diff --git a/client/lib/keyboard.js b/client/lib/keyboard.js index ca4461930..5fcea4566 100644 --- a/client/lib/keyboard.js +++ b/client/lib/keyboard.js @@ -8,7 +8,7 @@ function getHoveredCardId() { } function getSelectedCardId() { - return Session.get('currentCard') || getHoveredCardId(); + return Session.get('currentCard') || Session.get('selectedCard') || getHoveredCardId(); } Mousetrap.bind('?', () => { @@ -68,21 +68,58 @@ Mousetrap.bind(['down', 'up'], (evt, key) => { } }); -numArray = _.range(1,10).map(x => String(x)) -Mousetrap.bind(numArray, (evt, key) => { - num = parseInt(key); - const cardId = getSelectedCardId(); - if (!cardId) { +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) @@ -182,5 +219,9 @@ Template.keyboardShortcuts.helpers({ keys: ['number keys 1-9'], action: 'toggle-labels' }, + { + keys: ['shift + number keys 1-9'], + action: 'remove-labels-multiselect' + }, ], }); diff --git a/client/lib/multiSelection.js b/client/lib/multiSelection.js index 8ba3173f1..79f5aff67 100644 --- a/client/lib/multiSelection.js +++ b/client/lib/multiSelection.js @@ -83,6 +83,9 @@ MultiSelection = { isEmpty() { return this.count() === 0; }, + getSelectedCardIds(){ + return this._selectedCards.curValue; + }, activate() { if (!this.isActive()) { diff --git a/i18n/de.i18n.json b/i18n/de.i18n.json index 05b0af9c8..0cd924553 100644 --- a/i18n/de.i18n.json +++ b/i18n/de.i18n.json @@ -571,7 +571,8 @@ "has-spenttime-cards": "Hat Karten mit aufgewendeten Zeiten", "time": "Zeit", "title": "Titel", - "toggle-labels": "Label 1-9 für Karte Toggeln", + "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", diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json index 2c897d0c3..eb0b42708 100644 --- a/i18n/en.i18n.json +++ b/i18n/en.i18n.json @@ -571,7 +571,8 @@ "has-spenttime-cards": "Has spent time cards", "time": "Time", "title": "Title", - "toggle-labels": "Toggle Labels 1-9 for card", + "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",