Merge branch 'andresmanelli-viewProfile' into devel

This commit is contained in:
Lauri Ojansivu 2018-04-16 21:51:10 +03:00
commit 2cd1fbf9d9
9 changed files with 52 additions and 38 deletions

View file

@ -1,3 +1,11 @@
# Upcoming Wekan release
This release fixes the following bugs:
- [Fix Switch List/swimlane view only working with admin privileges](https://github.com/wekan/wekan/issues/1567).
Thanks to GitHub user andresmanelli for contributions.
# v0.84 2018-04-16 Wekan release
This release adds the following new features:

View file

@ -87,15 +87,13 @@ BlazeComponent.extendComponent({
},
isViewSwimlanes() {
const currentBoardId = Session.get('currentBoard');
const board = Boards.findOne(currentBoardId);
return (board.view === 'board-view-swimlanes');
const currentUser = Meteor.user();
return (currentUser.profile.boardView === 'board-view-swimlanes');
},
isViewLists() {
const currentBoardId = Session.get('currentBoard');
const board = Boards.findOne(currentBoardId);
return (board.view === 'board-view-lists');
const currentUser = Meteor.user();
return (currentUser.profile.boardView === 'board-view-lists');
},
openNewListForm() {

View file

@ -95,7 +95,7 @@ template(name="boardHeaderBar")
a.board-header-btn.js-toggle-board-view(
title="{{_ 'board-view'}}")
i.fa.fa-th-large
span {{_ currentBoard.view}}
span {{_ currentUser.profile.boardView}}
if canModifyBoard
a.board-header-btn.js-multiselection-activate(

View file

@ -77,19 +77,11 @@ BlazeComponent.extendComponent({
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',
},
});
const currentUser = Meteor.user();
if (currentUser.profile.boardView === 'board-view-swimlanes') {
currentUser.setBoardView('board-view-lists');
} else if (currentUser.profile.boardView === 'board-view-lists') {
currentUser.setBoardView('board-view-swimlanes');
}
},
'click .js-open-filter-view'() {

View file

@ -37,11 +37,11 @@ BlazeComponent.extendComponent({
const labelIds = formComponent.labels.get();
const boardId = this.data().board()._id;
const board = Boards.findOne(boardId);
let swimlaneId = '';
if (board.view === 'board-view-swimlanes')
const boardView = Meteor.user().profile.boardView;
if (boardView === 'board-view-swimlanes')
swimlaneId = this.parentComponent().parentComponent().data()._id;
else
else if (boardView === 'board-view-lists')
swimlaneId = Swimlanes.findOne({boardId})._id;
if (title) {
@ -106,8 +106,8 @@ BlazeComponent.extendComponent({
},
idOrNull(swimlaneId) {
const board = Boards.findOne(Session.get('currentBoard'));
if (board.view === 'board-view-swimlanes')
const currentUser = Meteor.user();
if (currentUser.profile.boardView === 'board-view-swimlanes')
return swimlaneId;
return undefined;
},

View file

@ -2,11 +2,10 @@ const { calculateIndex } = Utils;
function currentCardIsInThisList(listId, swimlaneId) {
const currentCard = Cards.findOne(Session.get('currentCard'));
const currentBoardId = Session.get('currentBoard');
const board = Boards.findOne(currentBoardId);
if (board.view === 'board-view-lists')
const currentUser = Meteor.user();
if (currentUser.profile.boardView === 'board-view-lists')
return currentCard && currentCard.listId === listId;
else if (board.view === 'board-view-swimlanes')
else if (currentUser.profile.boardView === 'board-view-swimlanes')
return currentCard && currentCard.listId === listId && currentCard.swimlaneId === swimlaneId;
else
return false;

View file

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

View file

@ -43,7 +43,9 @@ Users.attachSchema(new SimpleSchema({
optional: true,
autoValue() { // eslint-disable-line consistent-return
if (this.isInsert && !this.isSet) {
return {};
return {
boardView: 'board-view-lists',
};
}
},
},
@ -95,6 +97,10 @@ Users.attachSchema(new SimpleSchema({
type: String,
optional: true,
},
'profile.boardView': {
type: String,
optional: true,
},
services: {
type: Object,
optional: true,
@ -329,6 +335,14 @@ Users.mutations({
setShowCardsCountAt(limit) {
return {$set: {'profile.showCardsCountAt': limit}};
},
setBoardView(view) {
return {
$set : {
'profile.boardView': view,
},
};
},
});
Meteor.methods({

View file

@ -208,3 +208,14 @@ Migrations.add('add-checklist-items', () => {
);
});
});
Migrations.add('add-profile-view', () => {
Users.find().forEach((user) => {
// Set default view
Users.direct.update(
{ _id: user._id },
{ $set: { 'profile.boardView': 'board-view-lists' } },
noValidate
);
});
});