소스 검색

Add view boards field to change between views

Andrés Manelli 7 년 전
부모
커밋
a14f4ffee2
5개의 변경된 파일44개의 추가작업 그리고 0개의 파일을 삭제
  1. 5 0
      client/components/boards/boardHeader.jade
  2. 16 0
      client/components/boards/boardHeader.js
  3. 3 0
      i18n/en.i18n.json
  4. 8 0
      models/boards.js
  5. 12 0
      server/migrations.js

+ 5 - 0
client/components/boards/boardHeader.jade

@@ -87,6 +87,11 @@ template(name="boardHeaderBar")
           a.board-header-btn-close.js-filter-reset(title="{{_ 'filter-clear'}}")
           a.board-header-btn-close.js-filter-reset(title="{{_ 'filter-clear'}}")
             i.fa.fa-times-thin
             i.fa.fa-times-thin
 
 
+      a.board-header-btn.js-toggle-board-view(
+        title="{{_ 'board-view'}}")
+        i.fa.fa-th-large
+        span {{_ currentBoard.view}}
+
       if canModifyBoard
       if canModifyBoard
         a.board-header-btn.js-multiselection-activate(
         a.board-header-btn.js-multiselection-activate(
             title="{{#if MultiSelection.isActive}}{{_ 'multi-selection-on'}}{{else}}{{_ 'multi-selection'}}{{/if}}"
             title="{{#if MultiSelection.isActive}}{{_ 'multi-selection-on'}}{{else}}{{_ 'multi-selection'}}{{/if}}"

+ 16 - 0
client/components/boards/boardHeader.js

@@ -76,6 +76,22 @@ BlazeComponent.extendComponent({
       'click .js-open-archived-board'() {
       'click .js-open-archived-board'() {
         Modal.open('archivedBoards');
         Modal.open('archivedBoards');
       },
       },
+      'click .js-toggle-board-view'() {
+        const currentBoard = Boards.findOne(Session.get('currentBoard'));
+        if (currentBoard.view === 'board-view-swimlanes') {
+          Boards.update(currentBoard._id, {
+            $set: {
+              view: 'board-view-lists',
+            }
+          });
+        } else if (currentBoard.view === 'board-view-lists') {
+          Boards.update(currentBoard._id, {
+            $set: {
+              view: 'board-view-swimlanes',
+            }
+          });
+        }
+      },
       'click .js-open-filter-view'() {
       'click .js-open-filter-view'() {
         Sidebar.setView('filter');
         Sidebar.setView('filter');
       },
       },

+ 3 - 0
i18n/en.i18n.json

@@ -95,6 +95,9 @@
     "boardChangeWatchPopup-title": "Change Watch",
     "boardChangeWatchPopup-title": "Change Watch",
     "boardMenuPopup-title": "Board Menu",
     "boardMenuPopup-title": "Board Menu",
     "boards": "Boards",
     "boards": "Boards",
+    "board-view": "Board View",
+    "board-view-swimlanes": "Swimlanes",
+    "board-view-lists": "Lists",
     "bucket-example": "Like “Bucket List” for example",
     "bucket-example": "Like “Bucket List” for example",
     "cancel": "Cancel",
     "cancel": "Cancel",
     "card-archived": "This card is archived.",
     "card-archived": "This card is archived.",

+ 8 - 0
models/boards.js

@@ -31,6 +31,14 @@ Boards.attachSchema(new SimpleSchema({
       }
       }
     },
     },
   },
   },
+  view: {
+    type: String,
+    autoValue() { // eslint-disable-line consistent-return
+      if (this.isInsert) {
+        return 'board-view-swimlanes';
+      }
+    },
+  },
   createdAt: {
   createdAt: {
     type: Date,
     type: Date,
     autoValue() { // eslint-disable-line consistent-return
     autoValue() { // eslint-disable-line consistent-return

+ 12 - 0
server/migrations.js

@@ -175,3 +175,15 @@ Migrations.add('add-swimlanes', () => {
     });
     });
   });
   });
 });
 });
+
+Migrations.add('add-views', () => {
+  Boards.find().forEach((board) => {
+    if (!board.hasOwnProperty('view')) {
+      Boards.direct.update(
+          { _id: board._id },
+          { $set: { view: 'board-view-swimlanes' } },
+          noValidate
+      );
+    }
+  });
+});