Changed public board changing Swimlanes/Lists/Calendar view

and changing Hide minicard label text
from using cookies to using browser localStorage.

Thanks to xet7 !
This commit is contained in:
Lauri Ojansivu 2020-10-28 15:45:37 +02:00
parent a463f2a855
commit 460b1d3a66
9 changed files with 51 additions and 63 deletions

View file

@ -1,5 +1,3 @@
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
const subManager = new SubsManager(); const subManager = new SubsManager();
const { calculateIndex } = Utils; const { calculateIndex } = Utils;
const swimlaneWhileSortingHeight = 150; const swimlaneWhileSortingHeight = 150;
@ -197,7 +195,7 @@ BlazeComponent.extendComponent({
if (currentUser) { if (currentUser) {
showDesktopDragHandles = (currentUser.profile || {}) showDesktopDragHandles = (currentUser.profile || {})
.showDesktopDragHandles; .showDesktopDragHandles;
} else if (cookies.has('showDesktopDragHandles')) { } else if (window.localStorage.getItem('showDesktopDragHandles')) {
showDesktopDragHandles = true; showDesktopDragHandles = true;
} else { } else {
showDesktopDragHandles = false; showDesktopDragHandles = false;
@ -237,7 +235,9 @@ BlazeComponent.extendComponent({
if (currentUser) { if (currentUser) {
return (currentUser.profile || {}).boardView === 'board-view-swimlanes'; return (currentUser.profile || {}).boardView === 'board-view-swimlanes';
} else { } else {
return cookies.get('boardView') === 'board-view-swimlanes'; return (
window.localStorage.getItem('boardView') === 'board-view-swimlanes'
);
} }
}, },
@ -246,7 +246,7 @@ BlazeComponent.extendComponent({
if (currentUser) { if (currentUser) {
return (currentUser.profile || {}).boardView === 'board-view-lists'; return (currentUser.profile || {}).boardView === 'board-view-lists';
} else { } else {
return cookies.get('boardView') === 'board-view-lists'; return window.localStorage.getItem('boardView') === 'board-view-lists';
} }
}, },
@ -255,7 +255,7 @@ BlazeComponent.extendComponent({
if (currentUser) { if (currentUser) {
return (currentUser.profile || {}).boardView === 'board-view-cal'; return (currentUser.profile || {}).boardView === 'board-view-cal';
} else { } else {
return cookies.get('boardView') === 'board-view-cal'; return window.localStorage.getItem('boardView') === 'board-view-cal';
} }
}, },
@ -417,7 +417,7 @@ BlazeComponent.extendComponent({
if (currentUser) { if (currentUser) {
return (currentUser.profile || {}).boardView === 'board-view-cal'; return (currentUser.profile || {}).boardView === 'board-view-cal';
} else { } else {
return cookies.get('boardView') === 'board-view-cal'; return window.localStorage.getItem('boardView') === 'board-view-cal';
} }
}, },
}).register('calendarView'); }).register('calendarView');

View file

@ -1,5 +1,3 @@
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
// Template.cards.events({ // Template.cards.events({
// 'click .member': Popup.open('cardMember') // 'click .member': Popup.open('cardMember')
// }); // });
@ -34,10 +32,10 @@ BlazeComponent.extendComponent({
}, },
{ {
'click .js-toggle-minicard-label-text'() { 'click .js-toggle-minicard-label-text'() {
if (cookies.has('hiddenMinicardLabelText')) { if (window.localStorage.getItem('hiddenMinicardLabelText')) {
cookies.remove('hiddenMinicardLabelText'); //true window.localStorage.removeItem('hiddenMinicardLabelText'); //true
} else { } else {
cookies.set('hiddenMinicardLabelText', 'true'); //true window.localStorage.setItem('hiddenMinicardLabelText', 'true'); //true
} }
}, },
}, },
@ -50,7 +48,7 @@ Template.minicard.helpers({
currentUser = Meteor.user(); currentUser = Meteor.user();
if (currentUser) { if (currentUser) {
return (currentUser.profile || {}).showDesktopDragHandles; return (currentUser.profile || {}).showDesktopDragHandles;
} else if (cookies.has('showDesktopDragHandles')) { } else if (window.localStorage.getItem('showDesktopDragHandles')) {
return true; return true;
} else { } else {
return false; return false;
@ -60,7 +58,7 @@ Template.minicard.helpers({
currentUser = Meteor.user(); currentUser = Meteor.user();
if (currentUser) { if (currentUser) {
return (currentUser.profile || {}).hiddenMinicardLabelText; return (currentUser.profile || {}).hiddenMinicardLabelText;
} else if (cookies.has('hiddenMinicardLabelText')) { } else if (window.localStorage.getItem('hiddenMinicardLabelText')) {
return true; return true;
} else { } else {
return false; return false;

View file

@ -1,5 +1,3 @@
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
const { calculateIndex } = Utils; const { calculateIndex } = Utils;
BlazeComponent.extendComponent({ BlazeComponent.extendComponent({
@ -124,7 +122,7 @@ BlazeComponent.extendComponent({
if (currentUser) { if (currentUser) {
showDesktopDragHandles = (currentUser.profile || {}) showDesktopDragHandles = (currentUser.profile || {})
.showDesktopDragHandles; .showDesktopDragHandles;
} else if (cookies.has('showDesktopDragHandles')) { } else if (window.localStorage.getItem('showDesktopDragHandles')) {
showDesktopDragHandles = true; showDesktopDragHandles = true;
} else { } else {
showDesktopDragHandles = false; showDesktopDragHandles = false;
@ -185,7 +183,7 @@ Template.list.helpers({
currentUser = Meteor.user(); currentUser = Meteor.user();
if (currentUser) { if (currentUser) {
return (currentUser.profile || {}).showDesktopDragHandles; return (currentUser.profile || {}).showDesktopDragHandles;
} else if (cookies.has('showDesktopDragHandles')) { } else if (window.localStorage.getItem('showDesktopDragHandles')) {
return true; return true;
} else { } else {
return false; return false;

View file

@ -1,5 +1,3 @@
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
let listsColors; let listsColors;
Meteor.startup(() => { Meteor.startup(() => {
listsColors = Lists.simpleSchema()._schema.color.allowedValues; listsColors = Lists.simpleSchema()._schema.color.allowedValues;
@ -110,7 +108,7 @@ Template.listHeader.helpers({
currentUser = Meteor.user(); currentUser = Meteor.user();
if (currentUser) { if (currentUser) {
return (currentUser.profile || {}).showDesktopDragHandles; return (currentUser.profile || {}).showDesktopDragHandles;
} else if (cookies.has('showDesktopDragHandles')) { } else if (window.localStorage.getItem('showDesktopDragHandles')) {
return true; return true;
} else { } else {
return false; return false;

View file

@ -1,5 +1,3 @@
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
Sidebar = null; Sidebar = null;
const defaultView = 'home'; const defaultView = 'home';
@ -112,10 +110,12 @@ BlazeComponent.extendComponent({
currentUser = Meteor.user(); currentUser = Meteor.user();
if (currentUser) { if (currentUser) {
Meteor.call('toggleMinicardLabelText'); Meteor.call('toggleMinicardLabelText');
} else if (cookies.has('hiddenMinicardLabelText')) { } else if (window.localStorage.getItem('hiddenMinicardLabelText')) {
cookies.remove('hiddenMinicardLabelText'); window.localStorage.removeItem('hiddenMinicardLabelText');
location.reload();
} else { } else {
cookies.set('hiddenMinicardLabelText', 'true'); window.localStorage.setItem('hiddenMinicardLabelText', 'true');
location.reload();
} }
}, },
'click .js-shortcuts'() { 'click .js-shortcuts'() {
@ -133,7 +133,7 @@ Template.homeSidebar.helpers({
currentUser = Meteor.user(); currentUser = Meteor.user();
if (currentUser) { if (currentUser) {
return (currentUser.profile || {}).hiddenMinicardLabelText; return (currentUser.profile || {}).hiddenMinicardLabelText;
} else if (cookies.has('hiddenMinicardLabelText')) { } else if (window.localStorage.getItem('hiddenMinicardLabelText')) {
return true; return true;
} else { } else {
return false; return false;

View file

@ -1,5 +1,3 @@
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
const { calculateIndexData } = Utils; const { calculateIndexData } = Utils;
let swimlaneColors; let swimlaneColors;
@ -35,7 +33,7 @@ Template.swimlaneHeader.helpers({
currentUser = Meteor.user(); currentUser = Meteor.user();
if (currentUser) { if (currentUser) {
return (currentUser.profile || {}).showDesktopDragHandles; return (currentUser.profile || {}).showDesktopDragHandles;
} else if (cookies.has('showDesktopDragHandles')) { } else if (window.localStorage.getItem('showDesktopDragHandles')) {
return true; return true;
} else { } else {
return false; return false;

View file

@ -1,5 +1,3 @@
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
const { calculateIndex } = Utils; const { calculateIndex } = Utils;
function currentListIsInThisSwimlane(swimlaneId) { function currentListIsInThisSwimlane(swimlaneId) {
@ -102,7 +100,7 @@ function initSortable(boardComponent, $listsDom) {
if (currentUser) { if (currentUser) {
showDesktopDragHandles = (currentUser.profile || {}) showDesktopDragHandles = (currentUser.profile || {})
.showDesktopDragHandles; .showDesktopDragHandles;
} else if (cookies.has('showDesktopDragHandles')) { } else if (window.localStorage.getItem('showDesktopDragHandles')) {
showDesktopDragHandles = true; showDesktopDragHandles = true;
} else { } else {
showDesktopDragHandles = false; showDesktopDragHandles = false;
@ -178,7 +176,7 @@ BlazeComponent.extendComponent({
if (currentUser) { if (currentUser) {
showDesktopDragHandles = (currentUser.profile || {}) showDesktopDragHandles = (currentUser.profile || {})
.showDesktopDragHandles; .showDesktopDragHandles;
} else if (cookies.has('showDesktopDragHandles')) { } else if (window.localStorage.getItem('showDesktopDragHandles')) {
showDesktopDragHandles = true; showDesktopDragHandles = true;
} else { } else {
showDesktopDragHandles = false; showDesktopDragHandles = false;
@ -269,7 +267,7 @@ Template.swimlane.helpers({
currentUser = Meteor.user(); currentUser = Meteor.user();
if (currentUser) { if (currentUser) {
return (currentUser.profile || {}).showDesktopDragHandles; return (currentUser.profile || {}).showDesktopDragHandles;
} else if (cookies.has('showDesktopDragHandles')) { } else if (window.localStorage.getItem('showDesktopDragHandles')) {
return true; return true;
} else { } else {
return false; return false;

View file

@ -1,6 +1,3 @@
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
Template.headerUserBar.events({ Template.headerUserBar.events({
'click .js-open-header-member-menu': Popup.open('memberMenu'), 'click .js-open-header-member-menu': Popup.open('memberMenu'),
'click .js-change-avatar': Popup.open('changeAvatar'), 'click .js-change-avatar': Popup.open('changeAvatar'),
@ -200,7 +197,7 @@ Template.changeSettingsPopup.helpers({
currentUser = Meteor.user(); currentUser = Meteor.user();
if (currentUser) { if (currentUser) {
return (currentUser.profile || {}).showDesktopDragHandles; return (currentUser.profile || {}).showDesktopDragHandles;
} else if (cookies.has('showDesktopDragHandles')) { } else if (window.localStorage.getItem('showDesktopDragHandles')) {
return true; return true;
} else { } else {
return false; return false;
@ -210,7 +207,7 @@ Template.changeSettingsPopup.helpers({
currentUser = Meteor.user(); currentUser = Meteor.user();
if (currentUser) { if (currentUser) {
return (currentUser.profile || {}).hasHiddenSystemMessages; return (currentUser.profile || {}).hasHiddenSystemMessages;
} else if (cookies.has('hasHiddenSystemMessages')) { } else if (window.localStorage.getItem('hasHiddenSystemMessages')) {
return true; return true;
} else { } else {
return false; return false;
@ -221,7 +218,7 @@ Template.changeSettingsPopup.helpers({
if (currentUser) { if (currentUser) {
return Meteor.user().getLimitToShowCardsCount(); return Meteor.user().getLimitToShowCardsCount();
} else { } else {
return cookies.get('limitToShowCardsCount'); return window.localStorage.getItem('limitToShowCardsCount');
} }
}, },
weekDays(startDay) { weekDays(startDay) {
@ -242,7 +239,7 @@ Template.changeSettingsPopup.helpers({
if (currentUser) { if (currentUser) {
return currentUser.getStartDayOfWeek(); return currentUser.getStartDayOfWeek();
} else { } else {
return cookies.get('startDayOfWeek'); return window.localStorage.getItem('startDayOfWeek');
} }
}, },
}); });
@ -252,20 +249,20 @@ Template.changeSettingsPopup.events({
currentUser = Meteor.user(); currentUser = Meteor.user();
if (currentUser) { if (currentUser) {
Meteor.call('toggleDesktopDragHandles'); Meteor.call('toggleDesktopDragHandles');
} else if (cookies.has('showDesktopDragHandles')) { } else if (window.localStorage.getItem('showDesktopDragHandles')) {
cookies.remove('showDesktopDragHandles'); window.localStorage.removeItem('showDesktopDragHandles');
} else { } else {
cookies.set('showDesktopDragHandles', 'true'); window.localStorage.setItem('showDesktopDragHandles', 'true');
} }
}, },
'click .js-toggle-system-messages'() { 'click .js-toggle-system-messages'() {
currentUser = Meteor.user(); currentUser = Meteor.user();
if (currentUser) { if (currentUser) {
Meteor.call('toggleSystemMessages'); Meteor.call('toggleSystemMessages');
} else if (cookies.has('hasHiddenSystemMessages')) { } else if (window.localStorage.getItem('hasHiddenSystemMessages')) {
cookies.remove('hasHiddenSystemMessages'); window.localStorage.removeItem('hasHiddenSystemMessages');
} else { } else {
cookies.set('hasHiddenSystemMessages', 'true'); window.localStorage.setItem('hasHiddenSystemMessages', 'true');
} }
}, },
'click .js-apply-user-settings'(event, templateInstance) { 'click .js-apply-user-settings'(event, templateInstance) {
@ -283,14 +280,14 @@ Template.changeSettingsPopup.events({
if (currentUser) { if (currentUser) {
Meteor.call('changeLimitToShowCardsCount', minLimit); Meteor.call('changeLimitToShowCardsCount', minLimit);
} else { } else {
cookies.set('limitToShowCardsCount', minLimit); window.localStorage.setItem('limitToShowCardsCount', minLimit);
} }
} }
if (!isNaN(startDay)) { if (!isNaN(startDay)) {
if (currentUser) { if (currentUser) {
Meteor.call('changeStartDayOfWeek', startDay); Meteor.call('changeStartDayOfWeek', startDay);
} else { } else {
cookies.set('startDayOfWeek', startDay); window.localStorage.setItem('startDayOfWeek', startDay);
} }
} }
Popup.back(); Popup.back();

View file

@ -1,43 +1,44 @@
import { Cookies } from 'meteor/ostrio:cookies';
const cookies = new Cookies();
Utils = { Utils = {
setBoardView(view) { setBoardView(view) {
currentUser = Meteor.user(); currentUser = Meteor.user();
if (currentUser) { if (currentUser) {
Meteor.user().setBoardView(view); Meteor.user().setBoardView(view);
} else if (view === 'board-view-swimlanes') { } else if (view === 'board-view-swimlanes') {
cookies.set('boardView', 'board-view-swimlanes'); //true window.localStorage.setItem('boardView', 'board-view-swimlanes'); //true
location.reload(); location.reload();
} else if (view === 'board-view-lists') { } else if (view === 'board-view-lists') {
cookies.set('boardView', 'board-view-lists'); //true window.localStorage.setItem('boardView', 'board-view-lists'); //true
location.reload(); location.reload();
} else if (view === 'board-view-cal') { } else if (view === 'board-view-cal') {
cookies.set('boardView', 'board-view-cal'); //true window.localStorage.setItem('boardView', 'board-view-cal'); //true
location.reload(); location.reload();
} else { } else {
cookies.set('boardView', 'board-view-swimlanes'); //true window.localStorage.setItem('boardView', 'board-view-swimlanes'); //true
location.reload(); location.reload();
} }
}, },
unsetBoardView() { unsetBoardView() {
cookies.remove('boardView'); window.localStorage.removeItem('boardView');
cookies.remove('collapseSwimlane'); window.localStorage.removeItem('collapseSwimlane');
}, },
boardView() { boardView() {
currentUser = Meteor.user(); currentUser = Meteor.user();
if (currentUser) { if (currentUser) {
return (currentUser.profile || {}).boardView; return (currentUser.profile || {}).boardView;
} else if (cookies.get('boardView') === 'board-view-swimlanes') { } else if (
window.localStorage.getItem('boardView') === 'board-view-swimlanes'
) {
return 'board-view-swimlanes'; return 'board-view-swimlanes';
} else if (cookies.get('boardView') === 'board-view-lists') { } else if (
window.localStorage.getItem('boardView') === 'board-view-lists'
) {
return 'board-view-lists'; return 'board-view-lists';
} else if (cookies.get('boardView') === 'board-view-cal') { } else if (window.localStorage.getItem('boardView') === 'board-view-cal') {
return 'board-view-cal'; return 'board-view-cal';
} else { } else {
cookies.set('boardView', 'board-view-swimlanes'); //true window.localStorage.setItem('boardView', 'board-view-swimlanes'); //true
location.reload(); location.reload();
return 'board-view-swimlanes'; return 'board-view-swimlanes';
} }