Add view boards field to change between views

This commit is contained in:
Andrés Manelli 2018-01-22 16:54:19 -03:00
parent 2d7d9b5d9f
commit a14f4ffee2
5 changed files with 44 additions and 0 deletions

View file

@ -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}}"

View file

@ -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');
},

View file

@ -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.",

View file

@ -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

View file

@ -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
);
}
});
});