Quellcode durchsuchen

Add view boards field to change between views

Andrés Manelli vor 7 Jahren
Ursprung
Commit
a14f4ffee2

+ 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'}}")
             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
         a.board-header-btn.js-multiselection-activate(
             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'() {
         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'() {
         Sidebar.setView('filter');
       },

+ 3 - 0
i18n/en.i18n.json

@@ -95,6 +95,9 @@
     "boardChangeWatchPopup-title": "Change Watch",
     "boardMenuPopup-title": "Board Menu",
     "boards": "Boards",
+    "board-view": "Board View",
+    "board-view-swimlanes": "Swimlanes",
+    "board-view-lists": "Lists",
     "bucket-example": "Like “Bucket List” for example",
     "cancel": "Cancel",
     "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: {
     type: Date,
     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
+      );
+    }
+  });
+});