Browse Source

insert linked card at search dialog set's now the next card number too

Martin Filser 2 years ago
parent
commit
2f2aa7b08a
1 changed files with 12 additions and 20 deletions
  1. 12 20
      client/components/lists/listBody.js

+ 12 - 20
client/components/lists/listBody.js

@@ -617,36 +617,27 @@ BlazeComponent.extendComponent({
       this.isListTemplateSearch ||
       this.isSwimlaneTemplateSearch ||
       this.isBoardTemplateSearch;
-    let board = {};
+
+    this.board = {};
     if (this.isTemplateSearch) {
-      board._id = (Meteor.user().profile || {}).templatesBoardId;
+      const boardId = (Meteor.user().profile || {}).templatesBoardId;
+      if (boardId) {
+        this.board = ReactiveCache.getBoard(boardId);
+      }
     } else {
-      // Prefetch first non-current board id
-      board = Boards.find({
-        archived: false,
-        'members.userId': Meteor.userId(),
-        _id: {
-          $nin: [
-            Session.get('currentBoard'),
-            (Meteor.user().profile || {}).templatesBoardId,
-          ],
-        },
-      });
+      this.board = Utils.getCurrentBoard();
     }
-    if (!board) {
+    if (!this.board) {
       Popup.back();
       return;
     }
-    const boardId = board._id;
+    this.boardId = this.board._id;
     // Subscribe to this board
-    subManager.subscribe('board', boardId, false);
-    this.selectedBoardId = new ReactiveVar(boardId);
+    subManager.subscribe('board', this.boardId, false);
+    this.selectedBoardId = new ReactiveVar(this.boardId);
     this.list = $(Popup._getTopStack().openerElement).closest('.js-list');
 
     if (!this.isBoardTemplateSearch) {
-      this.boardId = Session.get('currentBoard');
-      // In order to get current board info
-      subManager.subscribe('board', this.boardId, false);
       this.swimlaneId = '';
       // Swimlane where to insert card
       const swimlane = $(Popup._getTopStack().openerElement).parents(
@@ -734,6 +725,7 @@ BlazeComponent.extendComponent({
           if (!this.isTemplateSearch || this.isCardTemplateSearch) {
             // Card insertion
             // 1. Common
+            element.cardNumber = this.board.getNextCardNumber();
             element.sort = this.getSortIndex();
             // 1.A From template
             if (this.isTemplateSearch) {