When logged in, use database for setting, so that changes are

immediate. Only on public board use cookies.
Comment out Collapse CSS that is not in use.

Thanks to xet7 !
This commit is contained in:
Lauri Ojansivu 2019-11-19 14:09:36 +02:00
parent f595120e72
commit 351d4767d7
12 changed files with 318 additions and 131 deletions

View file

@ -196,9 +196,20 @@ BlazeComponent.extendComponent({
const cookies = new Cookies();
this.autorun(() => {
let showDesktopDragHandles = false;
currentUser = Meteor.user();
if (currentUser) {
showDesktopDragHandles = (currentUser.profile || {}).showDesktopDragHandles;
} else {
if (cookies.has('showDesktopDragHandles')) {
showDesktopDragHandles = true;
} else {
showDesktopDragHandles = false;
}
}
if (
Utils.isMiniScreen() ||
(!Utils.isMiniScreen() && cookies.has('showDesktopDragHandles'))
(!Utils.isMiniScreen() && showDesktopDragHandles)
) {
$swimlanesDom.sortable({
handle: '.js-swimlane-header-handle',
@ -230,33 +241,36 @@ BlazeComponent.extendComponent({
},
isViewSwimlanes() {
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
const currentUser = Meteor.user();
if (!currentUser) {
currentUser = Meteor.user();
if (currentUser) {
return (currentUser.profile || {}).boardView === 'board-view-swimlanes';
} else {
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
return cookies.get('boardView') === 'board-view-swimlanes';
}
return (currentUser.profile || {}).boardView === 'board-view-swimlanes';
},
isViewLists() {
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
const currentUser = Meteor.user();
if (!currentUser) {
currentUser = Meteor.user();
if (currentUser) {
return (currentUser.profile || {}).boardView === 'board-view-lists';
} else {
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
return cookies.get('boardView') === 'board-view-lists';
}
return (currentUser.profile || {}).boardView === 'board-view-lists';
},
isViewCalendar() {
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
const currentUser = Meteor.user();
if (!currentUser) {
currentUser = Meteor.user();
if (currentUser) {
return (currentUser.profile || {}).boardView === 'board-view-cal';
} else {
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
return cookies.get('boardView') === 'board-view-cal';
}
return (currentUser.profile || {}).boardView === 'board-view-cal';
},
openNewListForm() {
@ -413,12 +427,13 @@ BlazeComponent.extendComponent({
};
},
isViewCalendar() {
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
const currentUser = Meteor.user();
if (!currentUser) {
currentUser = Meteor.user();
if (currentUser) {
return (currentUser.profile || {}).boardView === 'board-view-cal';
} else {
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
return cookies.get('boardView') === 'board-view-cal';
}
return (currentUser.profile || {}).boardView === 'board-view-cal';
},
}).register('calendarView');

View file

@ -33,21 +33,31 @@ BlazeComponent.extendComponent({
Template.minicard.helpers({
showDesktopDragHandles() {
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
if (cookies.has('showDesktopDragHandles')) {
return true;
currentUser = Meteor.user();
if (currentUser) {
return (currentUser.profile || {}).showDesktopDragHandles;
} else {
return false;
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
if (cookies.has('showDesktopDragHandles')) {
return true;
} else {
return false;
}
}
},
hiddenMinicardLabelText() {
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
if (cookies.has('hiddenMinicardLabelText')) {
return true;
currentUser = Meteor.user();
if (currentUser) {
return (currentUser.profile || {}).hiddenMinicardLabelText;
} else {
return false;
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
if (cookies.has('hiddenMinicardLabelText')) {
return true;
} else {
return false;
}
}
},
});

View file

@ -119,7 +119,19 @@ BlazeComponent.extendComponent({
const cookies = new Cookies();
this.autorun(() => {
if (!Utils.isMiniScreen() && cookies.has('showDesktopDragHandles')) {
let showDesktopDragHandles = false;
currentUser = Meteor.user();
if (currentUser) {
showDesktopDragHandles = (currentUser.profile || {}).showDesktopDragHandles;
} else {
if (cookies.has('showDesktopDragHandles')) {
showDesktopDragHandles = true;
} else {
showDesktopDragHandles = false;
}
}
if (!Utils.isMiniScreen() && showDesktopDragHandles) {
$cards.sortable({
handle: '.handle',
});
@ -163,12 +175,17 @@ BlazeComponent.extendComponent({
Template.list.helpers({
showDesktopDragHandles() {
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
if (cookies.has('showDesktopDragHandles')) {
return true;
currentUser = Meteor.user();
if (currentUser) {
return (currentUser.profile || {}).showDesktopDragHandles;
} else {
return false;
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
if (cookies.has('showDesktopDragHandles')) {
return true;
} else {
return false;
}
}
},
});

View file

@ -102,12 +102,17 @@ BlazeComponent.extendComponent({
Template.listHeader.helpers({
showDesktopDragHandles() {
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
if (cookies.has('showDesktopDragHandles')) {
return true;
currentUser = Meteor.user();
if (currentUser) {
return (currentUser.profile || {}).showDesktopDragHandles;
} else {
return false;
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
if (cookies.has('showDesktopDragHandles')) {
return true;
} else {
return false;
}
}
},
});

View file

@ -107,12 +107,17 @@ BlazeComponent.extendComponent({
'click .js-toggle-sidebar': this.toggle,
'click .js-back-home': this.setView,
'click .js-toggle-minicard-label-text'() {
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
if (cookies.has('hiddenMinicardLabelText')) {
cookies.remove('hiddenMinicardLabelText'); //true
currentUser = Meteor.user();
if (currentUser) {
Meteor.call('toggleMinicardLabelText');
} else {
cookies.set('hiddenMinicardLabelText', 'true'); //true
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
if (cookies.has('hiddenMinicardLabelText')) {
cookies.remove('hiddenMinicardLabelText');
} else {
cookies.set('hiddenMinicardLabelText', 'true');
}
}
},
'click .js-shortcuts'() {
@ -127,12 +132,17 @@ Blaze.registerHelper('Sidebar', () => Sidebar);
Template.homeSidebar.helpers({
hiddenMinicardLabelText() {
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
if (cookies.has('hiddenMinicardLabelText')) {
return true;
currentUser = Meteor.user();
if (currentUser) {
return (currentUser.profile || {}).hiddenMinicardLabelText;
} else {
return false;
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
if (cookies.has('hiddenMinicardLabelText')) {
return true;
} else {
return false;
}
}
},
});

View file

@ -30,12 +30,17 @@ BlazeComponent.extendComponent({
Template.swimlaneHeader.helpers({
showDesktopDragHandles() {
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
if (cookies.has('showDesktopDragHandles')) {
return true;
currentUser = Meteor.user();
if (currentUser) {
return (currentUser.profile || {}).showDesktopDragHandles;
} else {
return false;
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
if (cookies.has('showDesktopDragHandles')) {
return true;
} else {
return false;
}
}
},
});

View file

@ -20,28 +20,28 @@ template(name="swimlane")
if currentUser.isBoardMember
unless currentUser.isCommentOnly
+addListForm
if collapseSwimlane
// Minimize swimlanes next 2 lines below https://www.w3schools.com/howto/howto_js_accordion.asp
button(class="accordion")
div(class="panel")
.swimlane.js-lists.js-swimlane
if isMiniScreen
if currentListIsInThisSwimlane _id
+list(currentList)
unless currentList
each lists
+miniList(this)
if currentUser.isBoardMember
unless currentUser.isCommentOnly
+addListForm
else
each lists
+list(this)
if currentCardIsInThisList _id ../_id
+cardDetails(currentCard)
if currentUser.isBoardMember
unless currentUser.isCommentOnly
+addListForm
//if collapseSwimlane
// // Minimize swimlanes next 2 lines below https://www.w3schools.com/howto/howto_js_accordion.asp
// button(class="accordion")
// div(class="panel")
// .swimlane.js-lists.js-swimlane
// if isMiniScreen
// if currentListIsInThisSwimlane _id
// +list(currentList)
// unless currentList
// each lists
// +miniList(this)
// if currentUser.isBoardMember
// unless currentUser.isCommentOnly
// +addListForm
// else
// each lists
// +list(this)
// if currentCardIsInThisList _id ../_id
// +cardDetails(currentCard)
// if currentUser.isBoardMember
// unless currentUser.isCommentOnly
// +addListForm
template(name="listsGroup")
.swimlane.list-group.js-lists

View file

@ -99,7 +99,21 @@ function initSortable(boardComponent, $listsDom) {
boardComponent.autorun(() => {
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
if (!Utils.isMiniScreen() && cookies.has('showDesktopDragHandles')) {
let showDesktopDragHandles = false;
currentUser = Meteor.user();
if (currentUser) {
showDesktopDragHandles = (currentUser.profile || {}).showDesktopDragHandles;
} else {
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
if (cookies.has('showDesktopDragHandles')) {
showDesktopDragHandles = true;
} else {
showDesktopDragHandles = false;
}
}
if (!Utils.isMiniScreen() && showDesktopDragHandles) {
$listsDom.sortable({
handle: '.js-list-handle',
});
@ -186,10 +200,23 @@ BlazeComponent.extendComponent({
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
let showDesktopDragHandles = false;
currentUser = Meteor.user();
if (currentUser) {
showDesktopDragHandles = (currentUser.profile || {}).showDesktopDragHandles;
} else {
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
if (cookies.has('showDesktopDragHandles')) {
showDesktopDragHandles = true;
} else {
showDesktopDragHandles = false;
}
}
const noDragInside = ['a', 'input', 'textarea', 'p'].concat(
Utils.isMiniScreen() ||
(!Utils.isMiniScreen() && cookies.has('showDesktopDragHandles'))
(!Utils.isMiniScreen() && showDesktopDragHandles)
? ['.js-list-handle', '.js-swimlane-header-handle']
: ['.js-list-header'],
);
@ -270,12 +297,17 @@ BlazeComponent.extendComponent({
Template.swimlane.helpers({
showDesktopDragHandles() {
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
if (cookies.has('showDesktopDragHandles')) {
return true;
currentUser = Meteor.user();
if (currentUser) {
return (currentUser.profile || {}).showDesktopDragHandles;
} else {
return false;
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
if (cookies.has('showDesktopDragHandles')) {
return true;
} else {
return false;
}
}
},
canSeeAddList() {

View file

@ -1,5 +1,6 @@
@import 'nib'
/*
// Minimize swimlanes start https://www.w3schools.com/howto/howto_js_accordion.asp
.accordion
@ -33,6 +34,7 @@
padding: 0px
// Minimize swimlanes end https://www.w3schools.com/howto/howto_js_accordion.asp
*/
.swimlane
// Even if this background color is the same as the body we can't leave it

View file

@ -5,10 +5,22 @@ Template.headerUserBar.events({
Template.memberMenuPopup.helpers({
templatesBoardId() {
return Meteor.user().getTemplatesBoardId();
currentUser = Meteor.user();
if (currentUser) {
return Meteor.user().getTemplatesBoardId();
} else {
// No need to getTemplatesBoardId on public board
return false;
}
},
templatesBoardSlug() {
return Meteor.user().getTemplatesBoardSlug();
currentUser = Meteor.user();
if (currentUser) {
return Meteor.user().getTemplatesBoardSlug();
} else {
// No need to getTemplatesBoardSlug() on public board
return false;
}
},
});
@ -162,44 +174,73 @@ Template.changeLanguagePopup.events({
Template.changeSettingsPopup.helpers({
showDesktopDragHandles() {
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
if (cookies.has('showDesktopDragHandles')) {
return true;
currentUser = Meteor.user();
if (currentUser) {
return (currentUser.profile || {}).showDesktopDragHandles;
} else {
return false;
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
if (cookies.has('showDesktopDragHandles')) {
return true;
} else {
return false;
}
}
},
hiddenSystemMessages() {
const currentUser = Meteor.user();
currentUser = Meteor.user();
if (currentUser) {
return Meteor.user().hasHiddenSystemMessages();
return (currentUser.profile || {}).hasHiddenSystemMessages;
} else {
return false;
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
if (cookies.has('hasHiddenSystemMessages')) {
return true;
} else {
return false;
}
}
},
showCardsCountAt() {
const currentUser = Meteor.user();
currentUser = Meteor.user();
if (currentUser) {
return Meteor.user().getLimitToShowCardsCount();
} else {
return false;
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
return cookies.get('limitToShowCardsCount');
}
},
});
Template.changeSettingsPopup.events({
'click .js-toggle-desktop-drag-handles'() {
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
if (cookies.has('showDesktopDragHandles')) {
cookies.remove('showDesktopDragHandles'); //true
currentUser = Meteor.user();
if (currentUser) {
Meteor.call('toggleDesktopDragHandles');
} else {
cookies.set('showDesktopDragHandles', 'true'); //true
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
if (cookies.has('showDesktopDragHandles')) {
cookies.remove('showDesktopDragHandles');
} else {
cookies.set('showDesktopDragHandles', 'true');
}
}
},
'click .js-toggle-system-messages'() {
Meteor.call('toggleSystemMessages');
currentUser = Meteor.user();
if (currentUser) {
Meteor.call('toggleSystemMessages');
} else {
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
if (cookies.has('hasHiddenSystemMessages')) {
cookies.remove('hasHiddenSystemMessages');
} else {
cookies.set('hasHiddenSystemMessages', 'true');
}
}
},
'click .js-apply-show-cards-at'(event, templateInstance) {
event.preventDefault();
@ -208,7 +249,14 @@ Template.changeSettingsPopup.events({
10,
);
if (!isNaN(minLimit)) {
Meteor.call('changeLimitToShowCardsCount', minLimit);
currentUser = Meteor.user();
if (currentUser) {
Meteor.call('changeLimitToShowCardsCount', minLimit);
} else {
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
cookies.set('limitToShowCardsCount', minLimit);
}
Popup.back();
}
},

View file

@ -119,6 +119,13 @@ Users.attachSchema(
type: String,
optional: true,
},
'profile.showDesktopDragHandles': {
/**
* does the user want to hide system messages?
*/
type: Boolean,
optional: true,
},
'profile.hiddenSystemMessages': {
/**
* does the user want to hide system messages?
@ -126,6 +133,13 @@ Users.attachSchema(
type: Boolean,
optional: true,
},
'profile.hiddenMinicardLabelText': {
/**
* does the user want to hide minicard label texts?
*/
type: Boolean,
optional: true,
},
'profile.initials': {
/**
* initials of the user
@ -184,7 +198,6 @@ Users.attachSchema(
allowedValues: [
'board-view-lists',
'board-view-swimlanes',
'board-view-collapse',
'board-view-cal',
],
},
@ -382,18 +395,10 @@ Users.helpers({
}
return ret;
},
//hasSortBy() {
// if use doesn't have dragHandle, then we can let user to choose sort list by different order
//return this.hasShowDesktopDragHandles();
// return false;
/*
if (typeof currentUser === 'undefined' || typeof currentUser === 'null') {
return false;
} else {
return this.hasShowDesktopDragHandles();
}
*/
//},
hasSortBy() {
// if use doesn't have dragHandle, then we can let user to choose sort list by different order
return !this.hasShowDesktopDragHandles();
},
getListSortBy() {
return this._getListSortBy()[0];
},
@ -414,11 +419,21 @@ Users.helpers({
return _.contains(notifications, activityId);
},
hasShowDesktopDragHandles() {
const profile = this.profile || {};
return profile.showDesktopDragHandles || false;
},
hasHiddenSystemMessages() {
const profile = this.profile || {};
return profile.hiddenSystemMessages || false;
},
hasHiddenMinicardLabelText() {
const profile = this.profile || {};
return profile.hiddenMinicardLabelText || false;
},
getEmailBuffer() {
const { emailBuffer = [] } = this.profile || {};
return emailBuffer;
@ -440,11 +455,8 @@ Users.helpers({
},
getLimitToShowCardsCount() {
currentUser = Meteor.user();
if (currentUser) {
const profile = this.profile || {};
return profile.showCardsCountAt;
}
const profile = this.profile || {};
return profile.showCardsCountAt;
},
getName() {
@ -524,6 +536,13 @@ Users.mutations({
},
};
},
toggleDesktopHandles(value = false) {
return {
$set: {
'profile.showDesktopDragHandles': !value,
},
};
},
toggleSystem(value = false) {
return {
@ -533,6 +552,14 @@ Users.mutations({
};
},
toggleLabelText(value = false) {
return {
$set: {
'profile.hiddenMinicardLabelText': !value,
},
};
},
addNotification(activityId) {
return {
$addToSet: {
@ -597,10 +624,18 @@ Meteor.methods({
check(value, String);
Meteor.user().setListSortBy(value);
},
toggleDesktopDragHandles() {
const user = Meteor.user();
user.toggleDesktopHandles(user.hasShowDesktopDragHandles());
},
toggleSystemMessages() {
const user = Meteor.user();
user.toggleSystem(user.hasHiddenSystemMessages());
},
toggleMinicardLabelText() {
const user = Meteor.user();
user.toggleLabelText(user.hasHiddenMinicardLabelText());
},
changeLimitToShowCardsCount(limit) {
check(limit, Number);
Meteor.user().setShowCardsCountAt(limit);

View file

@ -794,24 +794,32 @@ Migrations.add('add-assignee', () => {
);
});
Migrations.add('remove-profile-showDesktopDragHandles', () => {
Migrations.add('add-profile-showDesktopDragHandles', () => {
Users.update(
{},
{
$unset: {
'profile.showDesktopDragHandles': 1,
'profile.showDesktopDragHandles': {
$exists: false,
},
},
{
$set: {
'profile.showDesktopDragHandles': false,
},
},
noValidateMulti,
);
});
Migrations.add('remove-profile-hiddenMinicardLabelText', () => {
Migrations.add('add-profile-hiddenMinicardLabelText', () => {
Users.update(
{},
{
$unset: {
'profile.hiddenMinicardLabelText': 1,
'profile.hiddenMinicardLabelText': {
$exists: false,
},
},
{
$set: {
'profile.hiddenMinicardLabelText': false,
},
},
noValidateMulti,