Move every Boards.findOne(Session.get('currentBoard')) to the ReactiveCache

This commit is contained in:
Martin Filser 2022-12-15 22:26:08 +01:00
parent cecf69af02
commit 9022e9949f
18 changed files with 69 additions and 69 deletions

View file

@ -25,8 +25,8 @@ BlazeComponent.extendComponent({
Meteor.settings && Meteor.settings &&
Meteor.settings.public && Meteor.settings.public &&
Meteor.settings.public.sandstorm; Meteor.settings.public.sandstorm;
if (isSandstorm && Session.get('currentBoard')) { if (isSandstorm && Utils.getCurrentBoardId()) {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
currentBoard.archive(); currentBoard.archive();
} }
const board = this.currentData(); const board = this.currentData();
@ -39,8 +39,8 @@ BlazeComponent.extendComponent({
Meteor.settings && Meteor.settings &&
Meteor.settings.public && Meteor.settings.public &&
Meteor.settings.public.sandstorm; Meteor.settings.public.sandstorm;
if (isSandstorm && Session.get('currentBoard')) { if (isSandstorm && Utils.getCurrentBoardId()) {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
Boards.remove(currentBoard._id); Boards.remove(currentBoard._id);
} }
Boards.remove(this._id); Boards.remove(this._id);

View file

@ -43,7 +43,7 @@ BlazeComponent.extendComponent({
this.mouseHasEnterCardDetails = false; this.mouseHasEnterCardDetails = false;
// fix swimlanes sort field if there are null values // fix swimlanes sort field if there are null values
const currentBoardData = Boards.findOne(Session.get('currentBoard')); const currentBoardData = Utils.getCurrentBoard();
const nullSortSwimlanes = currentBoardData.nullSortSwimlanes(); const nullSortSwimlanes = currentBoardData.nullSortSwimlanes();
if (nullSortSwimlanes.count() > 0) { if (nullSortSwimlanes.count() > 0) {
const swimlanes = currentBoardData.swimlanes(); const swimlanes = currentBoardData.swimlanes();
@ -214,7 +214,7 @@ BlazeComponent.extendComponent({
// If there is no data in the board (ie, no lists) we autofocus the list // If there is no data in the board (ie, no lists) we autofocus the list
// creation form by clicking on the corresponding element. // creation form by clicking on the corresponding element.
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
if (Utils.canModifyBoard() && currentBoard.lists().count() === 0) { if (Utils.canModifyBoard() && currentBoard.lists().count() === 0) {
boardComponent.openNewListForm(); boardComponent.openNewListForm();
} }
@ -222,7 +222,7 @@ BlazeComponent.extendComponent({
notDisplayThisBoard() { notDisplayThisBoard() {
let allowPrivateVisibilityOnly = TableVisibilityModeSettings.findOne('tableVisibilityMode-allowPrivateOnly'); let allowPrivateVisibilityOnly = TableVisibilityModeSettings.findOne('tableVisibilityMode-allowPrivateOnly');
let currentBoard = Boards.findOne(Session.get('currentBoard')); let currentBoard = Utils.getCurrentBoard();
if (allowPrivateVisibilityOnly !== undefined && allowPrivateVisibilityOnly.booleanValue && currentBoard.permission == 'public') { if (allowPrivateVisibilityOnly !== undefined && allowPrivateVisibilityOnly.booleanValue && currentBoard.permission == 'public') {
return true; return true;
} }
@ -342,7 +342,7 @@ BlazeComponent.extendComponent({
}, },
locale: TAPi18n.getLanguage(), locale: TAPi18n.getLanguage(),
events(start, end, timezone, callback) { events(start, end, timezone, callback) {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
const events = []; const events = [];
const pushEvent = function (card, title, start, end, extraCls) { const pushEvent = function (card, title, start, end, extraCls) {
start = start || card.startAt; start = start || card.startAt;
@ -416,7 +416,7 @@ BlazeComponent.extendComponent({
} }
}, },
select: function(startDate) { select: function(startDate) {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
const currentUser = Meteor.user(); const currentUser = Meteor.user();
const $modal = $(` const $modal = $(`
<div class="modal fade" tabindex="-1" role="dialog"> <div class="modal fade" tabindex="-1" role="dialog">

View file

@ -18,14 +18,14 @@ Template.boardMenuPopup.events({
'click .js-change-board-color': Popup.open('boardChangeColor'), 'click .js-change-board-color': Popup.open('boardChangeColor'),
'click .js-change-language': Popup.open('changeLanguage'), 'click .js-change-language': Popup.open('changeLanguage'),
'click .js-archive-board ': Popup.afterConfirm('archiveBoard', function() { 'click .js-archive-board ': Popup.afterConfirm('archiveBoard', function() {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
currentBoard.archive(); currentBoard.archive();
// XXX We should have some kind of notification on top of the page to // XXX We should have some kind of notification on top of the page to
// confirm that the board was successfully archived. // confirm that the board was successfully archived.
FlowRouter.go('home'); FlowRouter.go('home');
}), }),
'click .js-delete-board': Popup.afterConfirm('deleteBoard', function() { 'click .js-delete-board': Popup.afterConfirm('deleteBoard', function() {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
Popup.back(); Popup.back();
Boards.remove(currentBoard._id); Boards.remove(currentBoard._id);
FlowRouter.go('home'); FlowRouter.go('home');
@ -58,7 +58,7 @@ Template.boardChangeTitlePopup.events({
BlazeComponent.extendComponent({ BlazeComponent.extendComponent({
watchLevel() { watchLevel() {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
return currentBoard && currentBoard.getWatchLevel(Meteor.userId()); return currentBoard && currentBoard.getWatchLevel(Meteor.userId());
}, },
@ -70,7 +70,7 @@ BlazeComponent.extendComponent({
// Only show the star counter if the number of star is greater than 2 // Only show the star counter if the number of star is greater than 2
showStarCounter() { showStarCounter() {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
return currentBoard && currentBoard.stars >= 2; return currentBoard && currentBoard.stars >= 2;
}, },
/* /*
@ -315,12 +315,12 @@ BlazeComponent.extendComponent({
return !TableVisibilityModeSettings.findOne('tableVisibilityMode-allowPrivateOnly').booleanValue; return !TableVisibilityModeSettings.findOne('tableVisibilityMode-allowPrivateOnly').booleanValue;
}, },
visibilityCheck() { visibilityCheck() {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
return this.currentData() === currentBoard.permission; return this.currentData() === currentBoard.permission;
}, },
selectBoardVisibility() { selectBoardVisibility() {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
const visibility = this.currentData(); const visibility = this.currentData();
currentBoard.setVisibility(visibility); currentBoard.setVisibility(visibility);
Popup.back(); Popup.back();
@ -337,7 +337,7 @@ BlazeComponent.extendComponent({
BlazeComponent.extendComponent({ BlazeComponent.extendComponent({
watchLevel() { watchLevel() {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
return currentBoard.getWatchLevel(Meteor.userId()); return currentBoard.getWatchLevel(Meteor.userId());
}, },

View file

@ -326,7 +326,7 @@ BlazeComponent.extendComponent({
return ret; return ret;
}, },
isBackgroundImage() { isBackgroundImage() {
//const currentBoard = Boards.findOne(Session.get('currentBoard')); //const currentBoard = Utils.getCurrentBoard();
//return currentBoard.backgroundImageURL === $(".attachment-thumbnail-img").attr("src"); //return currentBoard.backgroundImageURL === $(".attachment-thumbnail-img").attr("src");
return false; return false;
}, },
@ -342,14 +342,14 @@ BlazeComponent.extendComponent({
Popup.back(); Popup.back();
}, },
'click .js-add-background-image'() { 'click .js-add-background-image'() {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
currentBoard.setBackgroundImageURL(attachmentActionsLink); currentBoard.setBackgroundImageURL(attachmentActionsLink);
Utils.setBackgroundImage(attachmentActionsLink); Utils.setBackgroundImage(attachmentActionsLink);
Popup.back(); Popup.back();
event.preventDefault(); event.preventDefault();
}, },
'click .js-remove-background-image'() { 'click .js-remove-background-image'() {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
currentBoard.setBackgroundImageURL(""); currentBoard.setBackgroundImageURL("");
Utils.setBackgroundImage(""); Utils.setBackgroundImage("");
Popup.back(); Popup.back();

View file

@ -727,7 +727,7 @@ BlazeComponent.extendComponent({
}).register('editCardTitleForm'); }).register('editCardTitleForm');
Template.cardMembersPopup.onCreated(function () { Template.cardMembersPopup.onCreated(function () {
let currBoard = Boards.findOne(Session.get('currentBoard')); let currBoard = Utils.getCurrentBoard();
let members = currBoard.activeMembers(); let members = currBoard.activeMembers();
// let query = { // let query = {
@ -757,7 +757,7 @@ Template.cardMembersPopup.helpers({
}); });
const filterMembers = (filterTerm) => { const filterMembers = (filterTerm) => {
let currBoard = Boards.findOne(Session.get('currentBoard')); let currBoard = Utils.getCurrentBoard();
let members = currBoard.activeMembers(); let members = currBoard.activeMembers();
// let query = { // let query = {
@ -1597,7 +1597,7 @@ EscapeActions.register(
); );
Template.cardAssigneesPopup.onCreated(function () { Template.cardAssigneesPopup.onCreated(function () {
let currBoard = Boards.findOne(Session.get('currentBoard')); let currBoard = Utils.getCurrentBoard();
let members = currBoard.activeMembers(); let members = currBoard.activeMembers();
// let query = { // let query = {

View file

@ -32,7 +32,7 @@ Template.createLabelPopup.helpers({
// is not already used in the board (although it's not a problem if two // is not already used in the board (although it's not a problem if two
// labels have the same color). // labels have the same color).
defaultColor() { defaultColor() {
const labels = Boards.findOne(Session.get('currentBoard')).labels; const labels = Utils.getCurrentBoard().labels;
const usedColors = _.pluck(labels, 'color'); const usedColors = _.pluck(labels, 'color');
const availableColors = _.difference(labelColors, usedColors); const availableColors = _.difference(labelColors, usedColors);
return availableColors.length > 1 ? availableColors[0] : labelColors[0]; return availableColors.length > 1 ? availableColors[0] : labelColors[0];
@ -117,7 +117,7 @@ Template.createLabelPopup.events({
// Create the new label // Create the new label
'submit .create-label'(event, templateInstance) { 'submit .create-label'(event, templateInstance) {
event.preventDefault(); event.preventDefault();
const board = Boards.findOne(Session.get('currentBoard')); const board = Utils.getCurrentBoard();
const name = templateInstance const name = templateInstance
.$('#labelName') .$('#labelName')
.val() .val()
@ -130,13 +130,13 @@ Template.createLabelPopup.events({
Template.editLabelPopup.events({ Template.editLabelPopup.events({
'click .js-delete-label': Popup.afterConfirm('deleteLabel', function () { 'click .js-delete-label': Popup.afterConfirm('deleteLabel', function () {
const board = Boards.findOne(Session.get('currentBoard')); const board = Utils.getCurrentBoard();
board.removeLabel(this._id); board.removeLabel(this._id);
Popup.back(2); Popup.back(2);
}), }),
'submit .edit-label'(event, templateInstance) { 'submit .edit-label'(event, templateInstance) {
event.preventDefault(); event.preventDefault();
const board = Boards.findOne(Session.get('currentBoard')); const board = Utils.getCurrentBoard();
const name = templateInstance const name = templateInstance
.$('#labelName') .$('#labelName')
.val() .val()

View file

@ -75,7 +75,7 @@ BlazeComponent.extendComponent({
const nCards = MultiSelection.isActive() ? MultiSelection.count() : 1; const nCards = MultiSelection.isActive() ? MultiSelection.count() : 1;
const sortIndex = calculateIndex(prevCardDom, nextCardDom, nCards); const sortIndex = calculateIndex(prevCardDom, nextCardDom, nCards);
const listId = Blaze.getData(ui.item.parents('.list').get(0))._id; const listId = Blaze.getData(ui.item.parents('.list').get(0))._id;
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
const defaultSwimlaneId = currentBoard.getDefaultSwimline()._id; const defaultSwimlaneId = currentBoard.getDefaultSwimline()._id;
let targetSwimlaneId = null; let targetSwimlaneId = null;

View file

@ -349,7 +349,7 @@ BlazeComponent.extendComponent({
{ {
match: /\B@([\w.-]*)$/, match: /\B@([\w.-]*)$/,
search(term, callback) { search(term, callback) {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
callback( callback(
$.map(currentBoard.activeMembers(), member => { $.map(currentBoard.activeMembers(), member => {
const user = Users.findOne(member.userId); const user = Users.findOne(member.userId);
@ -374,7 +374,7 @@ BlazeComponent.extendComponent({
{ {
match: /\B#(\w*)$/, match: /\B#(\w*)$/,
search(term, callback) { search(term, callback) {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
callback( callback(
$.map(currentBoard.labels, label => { $.map(currentBoard.labels, label => {
if (label.name == undefined) { if (label.name == undefined) {

View file

@ -13,7 +13,7 @@ BlazeComponent.extendComponent({
{ {
match: /\B@([\w.-]*)$/, match: /\B@([\w.-]*)$/,
search(term, callback) { search(term, callback) {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
callback( callback(
_.union( _.union(
currentBoard currentBoard
@ -328,7 +328,7 @@ Blaze.Template.registerHelper(
new Template('mentions', function() { new Template('mentions', function() {
const view = this; const view = this;
let content = Blaze.toHTML(view.templateContentBlock); let content = Blaze.toHTML(view.templateContentBlock);
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
if (!currentBoard) if (!currentBoard)
return HTML.Raw( return HTML.Raw(
DOMPurify.sanitize(content, { ALLOW_UNKNOWN_PROTOCOLS: true }), DOMPurify.sanitize(content, { ALLOW_UNKNOWN_PROTOCOLS: true }),

View file

@ -18,7 +18,7 @@ BlazeComponent.extendComponent({
}, },
labels() { labels() {
const labels = Boards.findOne(Session.get('currentBoard')).labels; const labels = Utils.getCurrentBoard().labels;
for (let i = 0; i < labels.length; i++) { for (let i = 0; i < labels.length; i++) {
if (labels[i].name === '' || labels[i].name === undefined) { if (labels[i].name === '' || labels[i].name === undefined) {
labels[i].name = labels[i].color.toUpperCase(); labels[i].name = labels[i].color.toUpperCase();

View file

@ -5,7 +5,7 @@ BlazeComponent.extendComponent({
this.subscribe('allRules'); this.subscribe('allRules');
}, },
labels() { labels() {
const labels = Boards.findOne(Session.get('currentBoard')).labels; const labels = Utils.getCurrentBoard().labels;
for (let i = 0; i < labels.length; i++) { for (let i = 0; i < labels.length; i++) {
if (labels[i].name === '' || labels[i].name === undefined) { if (labels[i].name === '' || labels[i].name === undefined) {
labels[i].name = labels[i].color; labels[i].name = labels[i].color;

View file

@ -177,7 +177,7 @@ Template.memberPopup.helpers({
memberType() { memberType() {
const type = Users.findOne(this.userId).isBoardAdmin() ? 'admin' : 'normal'; const type = Users.findOne(this.userId).isBoardAdmin() ? 'admin' : 'normal';
if (type === 'normal') { if (type === 'normal') {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
const commentOnly = currentBoard.hasCommentOnly(this.userId); const commentOnly = currentBoard.hasCommentOnly(this.userId);
const noComments = currentBoard.hasNoComments(this.userId); const noComments = currentBoard.hasNoComments(this.userId);
const worker = currentBoard.hasWorker(this.userId); const worker = currentBoard.hasWorker(this.userId);
@ -219,14 +219,14 @@ Template.boardMenuPopup.events({
'click .js-board-info-on-my-boards': Popup.open('boardInfoOnMyBoards'), 'click .js-board-info-on-my-boards': Popup.open('boardInfoOnMyBoards'),
'click .js-change-language': Popup.open('changeLanguage'), 'click .js-change-language': Popup.open('changeLanguage'),
'click .js-archive-board ': Popup.afterConfirm('archiveBoard', function() { 'click .js-archive-board ': Popup.afterConfirm('archiveBoard', function() {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
currentBoard.archive(); currentBoard.archive();
// XXX We should have some kind of notification on top of the page to // XXX We should have some kind of notification on top of the page to
// confirm that the board was successfully archived. // confirm that the board was successfully archived.
FlowRouter.go('home'); FlowRouter.go('home');
}), }),
'click .js-delete-board': Popup.afterConfirm('deleteBoard', function() { 'click .js-delete-board': Popup.afterConfirm('deleteBoard', function() {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
Popup.back(); Popup.back();
Boards.remove(currentBoard._id); Boards.remove(currentBoard._id);
FlowRouter.go('home'); FlowRouter.go('home');
@ -301,13 +301,13 @@ Template.removeMemberPopup.helpers({
return Users.findOne(this.userId); return Users.findOne(this.userId);
}, },
board() { board() {
return Boards.findOne(Session.get('currentBoard')); return Utils.getCurrentBoard();
}, },
}); });
Template.leaveBoardPopup.helpers({ Template.leaveBoardPopup.helpers({
board() { board() {
return Boards.findOne(Session.get('currentBoard')); return Utils.getCurrentBoard();
}, },
}); });
BlazeComponent.extendComponent({ BlazeComponent.extendComponent({
@ -658,7 +658,7 @@ BlazeComponent.extendComponent({
}, },
isSelected() { isSelected() {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
return currentBoard.color === this.currentData().toString(); return currentBoard.color === this.currentData().toString();
}, },
@ -666,7 +666,7 @@ BlazeComponent.extendComponent({
return [ return [
{ {
'click .js-select-background'(evt) { 'click .js-select-background'(evt) {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
const newColor = this.currentData().toString(); const newColor = this.currentData().toString();
currentBoard.setColor(newColor); currentBoard.setColor(newColor);
evt.preventDefault(); evt.preventDefault();
@ -681,7 +681,7 @@ BlazeComponent.extendComponent({
return [ return [
{ {
submit(event) { submit(event) {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
const backgroundImageURL = this.find('.js-board-background-image-url').value.trim(); const backgroundImageURL = this.find('.js-board-background-image-url').value.trim();
currentBoard.setBackgroundImageURL(backgroundImageURL); currentBoard.setBackgroundImageURL(backgroundImageURL);
Utils.setBackgroundImage(); Utils.setBackgroundImage();
@ -689,7 +689,7 @@ BlazeComponent.extendComponent({
event.preventDefault(); event.preventDefault();
}, },
'click .js-remove-background-image'() { 'click .js-remove-background-image'() {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
currentBoard.setBackgroundImageURL(""); currentBoard.setBackgroundImageURL("");
Popup.back(); Popup.back();
Utils.reload(); Utils.reload();
@ -702,14 +702,14 @@ BlazeComponent.extendComponent({
Template.boardChangeBackgroundImagePopup.helpers({ Template.boardChangeBackgroundImagePopup.helpers({
backgroundImageURL() { backgroundImageURL() {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
return currentBoard.backgroundImageURL; return currentBoard.backgroundImageURL;
}, },
}); });
BlazeComponent.extendComponent({ BlazeComponent.extendComponent({
onCreated() { onCreated() {
this.currentBoard = Boards.findOne(Session.get('currentBoard')); this.currentBoard = Utils.getCurrentBoard();
}, },
allowsCardCounterList() { allowsCardCounterList() {
@ -762,7 +762,7 @@ BlazeComponent.extendComponent({
BlazeComponent.extendComponent({ BlazeComponent.extendComponent({
onCreated() { onCreated() {
this.currentBoard = Boards.findOne(Session.get('currentBoard')); this.currentBoard = Utils.getCurrentBoard();
}, },
allowsSubtasks() { allowsSubtasks() {
@ -888,7 +888,7 @@ BlazeComponent.extendComponent({
BlazeComponent.extendComponent({ BlazeComponent.extendComponent({
onCreated() { onCreated() {
this.currentBoard = Boards.findOne(Session.get('currentBoard')); this.currentBoard = Utils.getCurrentBoard();
}, },
allowsReceivedDate() { allowsReceivedDate() {
@ -1323,7 +1323,7 @@ BlazeComponent.extendComponent({
BlazeComponent.extendComponent({ BlazeComponent.extendComponent({
onCreated() { onCreated() {
this.currentBoard = Boards.findOne(Session.get('currentBoard')); this.currentBoard = Utils.getCurrentBoard();
}, },
allowsDescriptionTextOnMinicard() { allowsDescriptionTextOnMinicard() {
@ -1489,7 +1489,7 @@ BlazeComponent.extendComponent({
}, },
'click .js-select-member'() { 'click .js-select-member'() {
const userId = this.currentData().__originalId; const userId = this.currentData().__originalId;
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
if (!currentBoard.hasMember(userId)) { if (!currentBoard.hasMember(userId)) {
this.inviteUser(userId); this.inviteUser(userId);
} }
@ -1545,7 +1545,7 @@ BlazeComponent.extendComponent({
this.setError(''); this.setError('');
}, },
'change #jsBoardOrgs'() { 'change #jsBoardOrgs'() {
let currentBoard = Boards.findOne(Session.get('currentBoard')); let currentBoard = Utils.getCurrentBoard();
let selectElt = document.getElementById("jsBoardOrgs"); let selectElt = document.getElementById("jsBoardOrgs");
let selectedOrgId = selectElt.options[selectElt.selectedIndex].value; let selectedOrgId = selectElt.options[selectElt.selectedIndex].value;
let selectedOrgDisplayName = selectElt.options[selectElt.selectedIndex].text; let selectedOrgDisplayName = selectElt.options[selectElt.selectedIndex].text;
@ -1619,7 +1619,7 @@ BlazeComponent.extendComponent({
}, },
'click #leaveBoardBtn'(){ 'click #leaveBoardBtn'(){
let stringOrgId = document.getElementById('hideOrgId').value; let stringOrgId = document.getElementById('hideOrgId').value;
let currentBoard = Boards.findOne(Session.get('currentBoard')); let currentBoard = Utils.getCurrentBoard();
let boardOrganizations = []; let boardOrganizations = [];
if(currentBoard.orgs !== undefined){ if(currentBoard.orgs !== undefined){
for(let i = 0; i < currentBoard.orgs.length; i++){ for(let i = 0; i < currentBoard.orgs.length; i++){
@ -1690,7 +1690,7 @@ BlazeComponent.extendComponent({
this.setError(''); this.setError('');
}, },
'change #jsBoardTeams'() { 'change #jsBoardTeams'() {
let currentBoard = Boards.findOne(Session.get('currentBoard')); let currentBoard = Utils.getCurrentBoard();
let selectElt = document.getElementById("jsBoardTeams"); let selectElt = document.getElementById("jsBoardTeams");
let selectedTeamId = selectElt.options[selectElt.selectedIndex].value; let selectedTeamId = selectElt.options[selectElt.selectedIndex].value;
let selectedTeamDisplayName = selectElt.options[selectElt.selectedIndex].text; let selectedTeamDisplayName = selectElt.options[selectElt.selectedIndex].text;
@ -1799,7 +1799,7 @@ BlazeComponent.extendComponent({
}, },
'click #leaveBoardTeamBtn'(){ 'click #leaveBoardTeamBtn'(){
let stringTeamId = document.getElementById('hideTeamId').value; let stringTeamId = document.getElementById('hideTeamId').value;
let currentBoard = Boards.findOne(Session.get('currentBoard')); let currentBoard = Utils.getCurrentBoard();
let boardTeams = []; let boardTeams = [];
if(currentBoard.teams !== undefined){ if(currentBoard.teams !== undefined){
for(let i = 0; i < currentBoard.teams.length; i++){ for(let i = 0; i < currentBoard.teams.length; i++){
@ -1852,7 +1852,7 @@ Template.changePermissionsPopup.events({
'click .js-set-admin, click .js-set-normal, click .js-set-no-comments, click .js-set-comment-only, click .js-set-worker'( 'click .js-set-admin, click .js-set-normal, click .js-set-no-comments, click .js-set-comment-only, click .js-set-worker'(
event, event,
) { ) {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
const memberId = this.userId; const memberId = this.userId;
const isAdmin = $(event.currentTarget).hasClass('js-set-admin'); const isAdmin = $(event.currentTarget).hasClass('js-set-admin');
const isCommentOnly = $(event.currentTarget).hasClass( const isCommentOnly = $(event.currentTarget).hasClass(
@ -1873,12 +1873,12 @@ Template.changePermissionsPopup.events({
Template.changePermissionsPopup.helpers({ Template.changePermissionsPopup.helpers({
isAdmin() { isAdmin() {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
return currentBoard.hasAdmin(this.userId); return currentBoard.hasAdmin(this.userId);
}, },
isNormal() { isNormal() {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
return ( return (
!currentBoard.hasAdmin(this.userId) && !currentBoard.hasAdmin(this.userId) &&
!currentBoard.hasNoComments(this.userId) && !currentBoard.hasNoComments(this.userId) &&
@ -1888,7 +1888,7 @@ Template.changePermissionsPopup.helpers({
}, },
isNoComments() { isNoComments() {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
return ( return (
!currentBoard.hasAdmin(this.userId) && !currentBoard.hasAdmin(this.userId) &&
currentBoard.hasNoComments(this.userId) currentBoard.hasNoComments(this.userId)
@ -1896,7 +1896,7 @@ Template.changePermissionsPopup.helpers({
}, },
isCommentOnly() { isCommentOnly() {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
return ( return (
!currentBoard.hasAdmin(this.userId) && !currentBoard.hasAdmin(this.userId) &&
currentBoard.hasCommentOnly(this.userId) currentBoard.hasCommentOnly(this.userId)
@ -1904,14 +1904,14 @@ Template.changePermissionsPopup.helpers({
}, },
isWorker() { isWorker() {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
return ( return (
!currentBoard.hasAdmin(this.userId) && currentBoard.hasWorker(this.userId) !currentBoard.hasAdmin(this.userId) && currentBoard.hasWorker(this.userId)
); );
}, },
isLastAdmin() { isLastAdmin() {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
return ( return (
currentBoard.hasAdmin(this.userId) && currentBoard.activeAdmins() === 1 currentBoard.hasAdmin(this.userId) && currentBoard.activeAdmins() === 1
); );

View file

@ -162,7 +162,7 @@ Template.archivesSidebar.helpers({
return Meteor.user().isBoardAdmin(); return Meteor.user().isBoardAdmin();
}, },
isWorker() { isWorker() {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
return ( return (
!currentBoard.hasAdmin(this.userId) && currentBoard.hasWorker(this.userId) !currentBoard.hasAdmin(this.userId) && currentBoard.hasWorker(this.userId)
); );

View file

@ -4,12 +4,12 @@ BlazeComponent.extendComponent({
}, },
cards() { cards() {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
return currentBoard.searchCards(this.term.get()); return currentBoard.searchCards(this.term.get());
}, },
lists() { lists() {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
return currentBoard.searchLists(this.term.get()); return currentBoard.searchLists(this.term.get());
}, },

View file

@ -61,7 +61,7 @@ BlazeComponent.extendComponent({
{ {
submit(event) { submit(event) {
event.preventDefault(); event.preventDefault();
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
const nextSwimlane = currentBoard.nextSwimlane(this.currentSwimlane); const nextSwimlane = currentBoard.nextSwimlane(this.currentSwimlane);
const titleInput = this.find('.swimlane-name-input'); const titleInput = this.find('.swimlane-name-input');
const title = titleInput.value.trim(); const title = titleInput.value.trim();

View file

@ -239,7 +239,7 @@ BlazeComponent.extendComponent({
BlazeComponent.extendComponent({ BlazeComponent.extendComponent({
onCreated() { onCreated() {
this.currentBoard = Boards.findOne(Session.get('currentBoard')); this.currentBoard = Utils.getCurrentBoard();
this.isListTemplatesSwimlane = this.isListTemplatesSwimlane =
this.currentBoard.isTemplatesBoard() && this.currentBoard.isTemplatesBoard() &&
this.currentData().isListTemplatesSwimlane(); this.currentData().isListTemplatesSwimlane();
@ -263,7 +263,7 @@ BlazeComponent.extendComponent({
if (lastList) { if (lastList) {
const positionInput = this.find('.list-position-input'); const positionInput = this.find('.list-position-input');
const position = positionInput.value.trim(); const position = positionInput.value.trim();
const ret = Lists.findOne({ boardId: Session.get('currentBoard'), _id: position, archived: false }) const ret = Lists.findOne({ boardId: Utils.getCurrentBoardId(), _id: position, archived: false })
sortIndex = parseInt(JSON.stringify(ret['sort'])) sortIndex = parseInt(JSON.stringify(ret['sort']))
sortIndex = sortIndex+1 sortIndex = sortIndex+1
} else { } else {
@ -350,7 +350,7 @@ class MoveSwimlaneComponent extends BlazeComponent {
} }
board() { board() {
return Boards.findOne(Session.get('currentBoard')); return Utils.getCurrentBoard();
} }
toBoardsSelector() { toBoardsSelector() {

View file

@ -2,7 +2,7 @@ import { ReactiveCache } from '/imports/reactiveCache';
Utils = { Utils = {
setBackgroundImage(url) { setBackgroundImage(url) {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
if (currentBoard.backgroundImageURL !== undefined) { if (currentBoard.backgroundImageURL !== undefined) {
$(".board-wrapper,.board-wrapper .board-canvas").css({"background":"url(" + currentBoard.backgroundImageURL + ")","background-size":"cover"}); $(".board-wrapper,.board-wrapper .board-canvas").css({"background":"url(" + currentBoard.backgroundImageURL + ")","background-size":"cover"});
$(".swimlane,.swimlane .list,.swimlane .list .list-body,.swimlane .list:first-child .list-body").css({"background-color":"transparent"}); $(".swimlane,.swimlane .list,.swimlane .list .list-body,.swimlane .list:first-child .list-body").css({"background-color":"transparent"});
@ -439,7 +439,7 @@ Utils = {
}, },
setCustomUI(data) { setCustomUI(data) {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Utils.getCurrentBoard();
if (currentBoard) { if (currentBoard) {
DocHead.setTitle(`${currentBoard.title} - ${data.productName}`); DocHead.setTitle(`${currentBoard.title} - ${data.productName}`);
} else { } else {

View file

@ -421,7 +421,7 @@ _.each(redirections, (newPath, oldPath) => {
//Meteor.isClient && Meteor.startup(() => { //Meteor.isClient && Meteor.startup(() => {
// Tracker.autorun(() => { // Tracker.autorun(() => {
// const currentBoard = Boards.findOne(Session.get('currentBoard')); // const currentBoard = Utils.getCurrentBoard();
// const titleStack = [appTitle]; // const titleStack = [appTitle];
// if (currentBoard) { // if (currentBoard) {
// titleStack.push(currentBoard.title); // titleStack.push(currentBoard.title);