Browse Source

Merge remote-tracking branch 'upstream/devel' into devel

Lauri Ojansivu 7 years ago
parent
commit
c1ddaaa475
3 changed files with 27 additions and 8 deletions
  1. 5 5
      client/components/cards/cardDetails.js
  2. 2 3
      models/cards.js
  3. 20 0
      models/trelloCreator.js

+ 5 - 5
client/components/cards/cardDetails.js

@@ -172,13 +172,13 @@ Template.cardDetailsActionsPopup.events({
   'click .js-copy-card': Popup.open('copyCard'),
   'click .js-move-card-to-top' (evt) {
     evt.preventDefault();
-    const minOrder = _.min(this.list().cards().map((c) => c.sort));
-    this.move(this.listId, minOrder - 1);
+    const minOrder = _.min(this.list().cards(this.swimlaneId).map((c) => c.sort));
+    this.move(this.swimlaneId, this.listId, minOrder - 1);
   },
   'click .js-move-card-to-bottom' (evt) {
     evt.preventDefault();
-    const maxOrder = _.max(this.list().cards().map((c) => c.sort));
-    this.move(this.listId, maxOrder + 1);
+    const maxOrder = _.max(this.list().cards(this.swimlaneId).map((c) => c.sort));
+    this.move(this.swimlaneId, this.listId, maxOrder + 1);
   },
   'click .js-archive' (evt) {
     evt.preventDefault();
@@ -215,7 +215,7 @@ Template.moveCardPopup.events({
     // instead from a “component” state.
     const card = Cards.findOne(Session.get('currentCard'));
     const newListId = this._id;
-    card.move(newListId);
+    card.move(card.swimlaneId, newListId, 0);
     Popup.close();
   },
 });

+ 2 - 3
models/cards.js

@@ -225,10 +225,9 @@ Cards.mutations({
       swimlaneId,
       listId,
       boardId: list.boardId,
+      sort: sortIndex,
     };
-    if (sortIndex) {
-      mutatedFields.sort = sortIndex;
-    }
+
     return {$set: mutatedFields};
   },
 

+ 20 - 0
models/trelloCreator.js

@@ -23,6 +23,8 @@ export class TrelloCreator {
 
     // Map of labels Trello ID => Wekan ID
     this.labels = {};
+    // Default swimlane
+    this.swimlane = null;
     // Map of lists Trello ID => Wekan ID
     this.lists = {};
     // Map of cards Trello ID => Wekan ID
@@ -230,6 +232,7 @@ export class TrelloCreator {
         dateLastActivity: this._now(),
         description: card.desc,
         listId: this.lists[card.idList],
+        swimlaneId: this.swimlane,
         sort: card.pos,
         title: card.name,
         // we attribute the card to its creator if available
@@ -397,6 +400,22 @@ export class TrelloCreator {
     });
   }
 
+  createSwimlanes(boardId) {
+      const swimlaneToCreate = {
+        archived: false,
+        boardId,
+        // We are being defensing here by providing a default date (now) if the
+        // creation date wasn't found on the action log. This happen on old
+        // Wekan boards (eg from 2013) that didn't log the 'createList' action
+        // we require.
+        createdAt: this._now(),
+        title: 'Default',
+      };
+      const swimlaneId = Swimlanes.direct.insert(swimlaneToCreate);
+      Swimlanes.direct.update(swimlaneId, {$set: {'updatedAt': this._now()}});
+      this.swimlane = swimlaneId;
+  }
+
   createChecklists(trelloChecklists) {
     trelloChecklists.forEach((checklist) => {
       if (this.cards[checklist.idCard]) {
@@ -607,6 +626,7 @@ export class TrelloCreator {
     this.parseActions(board.actions);
     const boardId = this.createBoardAndLabels(board);
     this.createLists(board.lists, boardId);
+    this.createSwimlanes(boardId);
     this.createCards(board.cards, boardId);
     this.createChecklists(board.checklists);
     this.importActions(board.actions, boardId);