|
@@ -319,6 +319,9 @@ BlazeComponent.extendComponent({
|
|
},
|
|
},
|
|
|
|
|
|
swimlanes() {
|
|
swimlanes() {
|
|
|
|
+ if (!this.selectedBoardId) {
|
|
|
|
+ return [];
|
|
|
|
+ }
|
|
const swimlanes = Swimlanes.find({boardId: this.selectedBoardId.get()});
|
|
const swimlanes = Swimlanes.find({boardId: this.selectedBoardId.get()});
|
|
if (swimlanes.count())
|
|
if (swimlanes.count())
|
|
this.selectedSwimlaneId.set(swimlanes.fetch()[0]._id);
|
|
this.selectedSwimlaneId.set(swimlanes.fetch()[0]._id);
|
|
@@ -326,6 +329,9 @@ BlazeComponent.extendComponent({
|
|
},
|
|
},
|
|
|
|
|
|
lists() {
|
|
lists() {
|
|
|
|
+ if (!this.selectedBoardId) {
|
|
|
|
+ return [];
|
|
|
|
+ }
|
|
const lists = Lists.find({boardId: this.selectedBoardId.get()});
|
|
const lists = Lists.find({boardId: this.selectedBoardId.get()});
|
|
if (lists.count())
|
|
if (lists.count())
|
|
this.selectedListId.set(lists.fetch()[0]._id);
|
|
this.selectedListId.set(lists.fetch()[0]._id);
|
|
@@ -333,6 +339,9 @@ BlazeComponent.extendComponent({
|
|
},
|
|
},
|
|
|
|
|
|
cards() {
|
|
cards() {
|
|
|
|
+ if (!this.board) {
|
|
|
|
+ return [];
|
|
|
|
+ }
|
|
const ownCardsIds = this.board.cards().map((card) => { return card.linkedId || card._id; });
|
|
const ownCardsIds = this.board.cards().map((card) => { return card.linkedId || card._id; });
|
|
return Cards.find({
|
|
return Cards.find({
|
|
boardId: this.selectedBoardId.get(),
|
|
boardId: this.selectedBoardId.get(),
|
|
@@ -360,6 +369,11 @@ BlazeComponent.extendComponent({
|
|
// LINK CARD
|
|
// LINK CARD
|
|
evt.stopPropagation();
|
|
evt.stopPropagation();
|
|
evt.preventDefault();
|
|
evt.preventDefault();
|
|
|
|
+ const linkedId = $('.js-select-cards option:selected').val();
|
|
|
|
+ if (!linkedId) {
|
|
|
|
+ Popup.close();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
const _id = Cards.insert({
|
|
const _id = Cards.insert({
|
|
title: $('.js-select-cards option:selected').text(), //dummy
|
|
title: $('.js-select-cards option:selected').text(), //dummy
|
|
listId: this.listId,
|
|
listId: this.listId,
|
|
@@ -367,7 +381,7 @@ BlazeComponent.extendComponent({
|
|
boardId: this.boardId,
|
|
boardId: this.boardId,
|
|
sort: Lists.findOne(this.listId).cards().count(),
|
|
sort: Lists.findOne(this.listId).cards().count(),
|
|
type: 'cardType-linkedCard',
|
|
type: 'cardType-linkedCard',
|
|
- linkedId: $('.js-select-cards option:selected').val(),
|
|
|
|
|
|
+ linkedId,
|
|
});
|
|
});
|
|
Filter.addException(_id);
|
|
Filter.addException(_id);
|
|
Popup.close();
|
|
Popup.close();
|
|
@@ -377,6 +391,10 @@ BlazeComponent.extendComponent({
|
|
evt.stopPropagation();
|
|
evt.stopPropagation();
|
|
evt.preventDefault();
|
|
evt.preventDefault();
|
|
const impBoardId = $('.js-select-boards option:selected').val();
|
|
const impBoardId = $('.js-select-boards option:selected').val();
|
|
|
|
+ if (!impBoardId || Cards.findOne({linkedId: impBoardId, archived: false})) {
|
|
|
|
+ Popup.close();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
const _id = Cards.insert({
|
|
const _id = Cards.insert({
|
|
title: $('.js-select-boards option:selected').text(), //dummy
|
|
title: $('.js-select-boards option:selected').text(), //dummy
|
|
listId: this.listId,
|
|
listId: this.listId,
|
|
@@ -400,11 +418,16 @@ BlazeComponent.extendComponent({
|
|
|
|
|
|
onCreated() {
|
|
onCreated() {
|
|
// Prefetch first non-current board id
|
|
// Prefetch first non-current board id
|
|
- const boardId = Boards.findOne({
|
|
|
|
|
|
+ let board = Boards.findOne({
|
|
archived: false,
|
|
archived: false,
|
|
'members.userId': Meteor.userId(),
|
|
'members.userId': Meteor.userId(),
|
|
_id: {$ne: Session.get('currentBoard')},
|
|
_id: {$ne: Session.get('currentBoard')},
|
|
- })._id;
|
|
|
|
|
|
+ });
|
|
|
|
+ if (!board) {
|
|
|
|
+ Popup.close();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ const boardId = board._id;
|
|
// Subscribe to this board
|
|
// Subscribe to this board
|
|
subManager.subscribe('board', boardId);
|
|
subManager.subscribe('board', boardId);
|
|
this.selectedBoardId = new ReactiveVar(boardId);
|
|
this.selectedBoardId = new ReactiveVar(boardId);
|
|
@@ -412,7 +435,7 @@ BlazeComponent.extendComponent({
|
|
this.boardId = Session.get('currentBoard');
|
|
this.boardId = Session.get('currentBoard');
|
|
// In order to get current board info
|
|
// In order to get current board info
|
|
subManager.subscribe('board', this.boardId);
|
|
subManager.subscribe('board', this.boardId);
|
|
- const board = Boards.findOne(this.boardId);
|
|
|
|
|
|
+ board = Boards.findOne(this.boardId);
|
|
// List where to insert card
|
|
// List where to insert card
|
|
const list = $(Popup._getTopStack().openerElement).closest('.js-list');
|
|
const list = $(Popup._getTopStack().openerElement).closest('.js-list');
|
|
this.listId = Blaze.getData(list[0])._id;
|
|
this.listId = Blaze.getData(list[0])._id;
|
|
@@ -438,6 +461,9 @@ BlazeComponent.extendComponent({
|
|
},
|
|
},
|
|
|
|
|
|
results() {
|
|
results() {
|
|
|
|
+ if (!this.selectedBoardId) {
|
|
|
|
+ return [];
|
|
|
|
+ }
|
|
const board = Boards.findOne(this.selectedBoardId.get());
|
|
const board = Boards.findOne(this.selectedBoardId.get());
|
|
return board.searchCards(this.term.get(), false);
|
|
return board.searchCards(this.term.get(), false);
|
|
},
|
|
},
|