Kaynağa Gözat

Add UI code and make some fixes to list move code
Still need to add new lists to all swimlanes

John R. Supplee 4 yıl önce
ebeveyn
işleme
aad300613d

+ 2 - 0
client/components/swimlanes/swimlaneHeader.jade

@@ -39,6 +39,8 @@ template(name="swimlaneActionPopup")
       hr
       ul.pop-over-list
         li: a.js-close-swimlane {{_ 'archive-swimlane'}}
+      ul.pop-over-list
+        li: a.js-move-swimlane {{_ 'move-swimlane'}}
 
 template(name="swimlaneAddPopup")
   unless currentUser.isCommentOnly

+ 16 - 11
client/components/swimlanes/swimlaneHeader.js

@@ -47,20 +47,25 @@ Template.swimlaneFixedHeader.helpers({
   },
 });
 
-Template.swimlaneActionPopup.events({
-  'click .js-set-swimlane-color': Popup.open('setSwimlaneColor'),
-  'click .js-close-swimlane'(event) {
-    event.preventDefault();
-    this.archive();
-    Popup.close();
-  },
-});
-
-Template.swimlaneActionPopup.helpers({
+BlazeComponent.extendComponent({
   isCommentOnly() {
     return Meteor.user().isCommentOnly();
   },
-});
+
+  events() {
+    return [
+      {
+        'click .js-set-swimlane-color': Popup.open('setSwimlaneColor'),
+        'click .js-close-swimlane'(event) {
+          event.preventDefault();
+          this.archive();
+          Popup.close();
+        },
+        'click .js-move-swimlane': Popup.open('moveSwimlane'),
+      },
+    ];
+  },
+}).register('swimlaneActionPopup');
 
 BlazeComponent.extendComponent({
   onCreated() {

+ 10 - 0
client/components/swimlanes/swimlanes.jade

@@ -61,3 +61,13 @@ template(name="addListForm")
             a.open-list-composer.js-open-inlined-form
               i.fa.fa-plus
               | {{_ 'add-list'}}
+
+template(name="moveSwimlanePopup")
+  unless currentUser.isWorker
+    label {{_ 'boards'}}:
+    select.js-select-boards(autofocus)
+      each toBoard in toBoards
+        option(value="{{toBoard._id}}") {{toBoard.title}}
+
+  .edit-controls.clearfix
+    button.primary.confirm.js-done {{_ 'done'}}

+ 47 - 0
client/components/swimlanes/swimlanes.js

@@ -323,3 +323,50 @@ BlazeComponent.extendComponent({
     initSortable(boardComponent, $listsDom);
   },
 }).register('listsGroup');
+
+BlazeComponent.extendComponent({
+  onCreated() {
+    this.currentSwimlane = this.currentData();
+  },
+
+  board() {
+    return Boards.findOne(Session.get('currentBoard'));
+  },
+
+  toBoards() {
+    const boards = Boards.find(
+      {
+        archived: false,
+        'members.userId': Meteor.userId(),
+        type: 'board',
+        _id: { $ne: this.board()._id },
+      },
+      {
+        sort: { title: 1 },
+      },
+    );
+
+    console.log('boards.count():', boards.count());
+    console.log('boards:', boards);
+
+    return boards;
+  },
+
+  events() {
+    return [
+      {
+        'click .js-done'() {
+          const swimlane = Swimlanes.findOne(this.currentSwimlane._id);
+          const bSelect = $('.js-select-boards')[0];
+          let boardId;
+          if (bSelect) {
+            boardId = bSelect.options[bSelect.selectedIndex].value;
+            swimlane.move(boardId);
+            this.board().getDefaultSwimline();
+          }
+          Popup.close();
+        },
+      },
+    ];
+  },
+}).register('moveSwimlanePopup');

+ 2 - 1
i18n/en.i18n.json

@@ -984,5 +984,6 @@
   "created-at-oldest-first": "Created At (Oldest First)",
   "links-heading": "Links",
   "hide-system-messages-of-all-users": "Hide system messages of all users",
-  "now-system-messages-of-all-users-are-hidden": "Now system messages of all users are hidden"
+  "now-system-messages-of-all-users-are-hidden": "Now system messages of all users are hidden",
+  "move-swimlane": "Move Swimlane"
 }

+ 10 - 3
models/swimlanes.js

@@ -269,7 +269,7 @@ Swimlanes.mutations({
     return { $set: { archived: true, archivedAt: new Date() } };
   },
 
-  move(boardId, sort=null) {
+  move(boardId, sort = null) {
     const mutatedFields = {};
 
     if (this.boardId !== boardId) {
@@ -282,14 +282,21 @@ Swimlanes.mutations({
 
     if (Object.keys(mutatedFields).length) {
       this.lists().forEach(list => {
-        list.move(boardId, this._id);
+        const boardList = Lists.findOne({ boardId, title: list.title });
+
+        if (boardList) {
+          list.cards().forEach(card => {
+            card.move(boardId, this._id, boardList._id);
+          });
+        } else {
+          list.move(boardId, this._id);
+        }
       });
 
       Swimlanes.update(this._id, {
         $set: mutatedFields,
       });
     }
-
   },
 
   restore() {