2015-05-27 17:17:00 +02:00
|
|
|
Template.boardChangeTitlePopup.events({
|
2015-09-03 23:12:46 +02:00
|
|
|
submit(evt, tpl) {
|
2015-09-08 20:19:42 +02:00
|
|
|
const newTitle = tpl.$('.js-board-name').val().trim();
|
2015-12-07 11:22:30 +08:00
|
|
|
const newDesc = tpl.$('.js-board-desc').val().trim();
|
2015-09-08 20:19:42 +02:00
|
|
|
if (newTitle) {
|
|
|
|
this.rename(newTitle);
|
2017-02-01 20:01:38 +02:00
|
|
|
this.setDescription(newDesc);
|
2015-05-27 17:17:00 +02:00
|
|
|
Popup.close();
|
|
|
|
}
|
|
|
|
evt.preventDefault();
|
2015-09-03 23:12:46 +02:00
|
|
|
},
|
2015-05-27 17:17:00 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
BlazeComponent.extendComponent({
|
2016-01-05 23:26:02 +08:00
|
|
|
watchLevel() {
|
|
|
|
const currentBoard = Boards.findOne(Session.get('currentBoard'));
|
2016-01-08 11:44:20 +08:00
|
|
|
return currentBoard && currentBoard.getWatchLevel(Meteor.userId());
|
2016-01-05 23:26:02 +08:00
|
|
|
},
|
|
|
|
|
2015-09-03 23:12:46 +02:00
|
|
|
isStarred() {
|
|
|
|
const boardId = Session.get('currentBoard');
|
|
|
|
const user = Meteor.user();
|
2015-08-23 22:00:02 +02:00
|
|
|
return user && user.hasStarred(boardId);
|
2015-05-27 17:17:00 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
// Only show the star counter if the number of star is greater than 2
|
2015-09-03 23:12:46 +02:00
|
|
|
showStarCounter() {
|
2015-09-05 23:14:24 +02:00
|
|
|
const currentBoard = Boards.findOne(Session.get('currentBoard'));
|
2015-06-06 14:48:36 +02:00
|
|
|
return currentBoard && currentBoard.stars >= 2;
|
2015-05-27 17:17:00 +02:00
|
|
|
},
|
|
|
|
|
2015-09-03 23:12:46 +02:00
|
|
|
events() {
|
2015-05-27 17:17:00 +02:00
|
|
|
return [{
|
|
|
|
'click .js-edit-board-title': Popup.open('boardChangeTitle'),
|
2015-09-03 23:12:46 +02:00
|
|
|
'click .js-star-board'() {
|
2015-05-27 17:17:00 +02:00
|
|
|
Meteor.user().toggleBoardStar(Session.get('currentBoard'));
|
|
|
|
},
|
|
|
|
'click .js-change-visibility': Popup.open('boardChangeVisibility'),
|
2016-01-05 23:26:02 +08:00
|
|
|
'click .js-watch-board': Popup.open('boardChangeWatch'),
|
2018-01-22 16:54:19 -03:00
|
|
|
'click .js-toggle-board-view'() {
|
2018-04-16 14:33:53 -03:00
|
|
|
const currentUser = Meteor.user();
|
|
|
|
if (currentUser.profile.boardView === 'board-view-swimlanes') {
|
2018-06-26 19:55:23 +03:00
|
|
|
currentUser.setBoardView('board-view-cal');
|
2018-04-16 14:33:53 -03:00
|
|
|
} else if (currentUser.profile.boardView === 'board-view-lists') {
|
|
|
|
currentUser.setBoardView('board-view-swimlanes');
|
2018-06-26 19:55:23 +03:00
|
|
|
} else if (currentUser.profile.boardView === 'board-view-cal') {
|
|
|
|
currentUser.setBoardView('board-view-lists');
|
2018-01-22 16:54:19 -03:00
|
|
|
}
|
|
|
|
},
|
2019-03-03 22:27:05 +02:00
|
|
|
'click .js-toggle-sidebar'() {
|
|
|
|
Sidebar.toggle();
|
|
|
|
},
|
2015-09-03 23:12:46 +02:00
|
|
|
'click .js-open-filter-view'() {
|
2015-05-27 17:17:00 +02:00
|
|
|
Sidebar.setView('filter');
|
|
|
|
},
|
2015-09-03 23:12:46 +02:00
|
|
|
'click .js-filter-reset'(evt) {
|
2015-05-27 17:17:00 +02:00
|
|
|
evt.stopPropagation();
|
|
|
|
Sidebar.setView();
|
|
|
|
Filter.reset();
|
2015-05-29 23:35:30 +02:00
|
|
|
},
|
2018-02-23 01:10:21 +01:00
|
|
|
'click .js-open-search-view'() {
|
|
|
|
Sidebar.setView('search');
|
|
|
|
},
|
2018-08-03 19:47:20 +02:00
|
|
|
'click .js-open-rules-view'() {
|
2018-08-16 16:54:29 +02:00
|
|
|
Modal.openWide('rulesMain');
|
2018-08-03 19:47:20 +02:00
|
|
|
},
|
2015-09-03 23:12:46 +02:00
|
|
|
'click .js-multiselection-activate'() {
|
|
|
|
const currentCard = Session.get('currentCard');
|
2015-05-29 23:35:30 +02:00
|
|
|
MultiSelection.activate();
|
|
|
|
if (currentCard) {
|
|
|
|
MultiSelection.add(currentCard);
|
|
|
|
}
|
|
|
|
},
|
2015-09-03 23:12:46 +02:00
|
|
|
'click .js-multiselection-reset'(evt) {
|
2015-05-29 23:35:30 +02:00
|
|
|
evt.stopPropagation();
|
|
|
|
MultiSelection.disable();
|
2015-09-03 23:12:46 +02:00
|
|
|
},
|
2016-04-18 20:26:10 +02:00
|
|
|
'click .js-log-in'() {
|
|
|
|
FlowRouter.go('atSignIn');
|
|
|
|
},
|
2015-05-27 17:17:00 +02:00
|
|
|
}];
|
2015-09-03 23:12:46 +02:00
|
|
|
},
|
2015-12-09 23:19:10 -05:00
|
|
|
}).register('boardHeaderBar');
|
2015-05-27 17:17:00 +02:00
|
|
|
|
2017-03-18 18:49:39 -04:00
|
|
|
Template.boardHeaderBar.helpers({
|
|
|
|
canModifyBoard() {
|
|
|
|
return Meteor.user() && Meteor.user().isBoardMember() && !Meteor.user().isCommentOnly();
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2017-02-22 17:33:17 +05:30
|
|
|
const CreateBoard = BlazeComponent.extendComponent({
|
|
|
|
template() {
|
|
|
|
return 'createBoard';
|
|
|
|
},
|
|
|
|
|
2015-09-03 23:12:46 +02:00
|
|
|
onCreated() {
|
2015-05-27 17:17:00 +02:00
|
|
|
this.visibilityMenuIsOpen = new ReactiveVar(false);
|
|
|
|
this.visibility = new ReactiveVar('private');
|
2017-02-22 18:59:51 +05:30
|
|
|
this.boardId = new ReactiveVar('');
|
2015-05-27 17:17:00 +02:00
|
|
|
},
|
|
|
|
|
2015-09-03 23:12:46 +02:00
|
|
|
visibilityCheck() {
|
2015-05-27 17:17:00 +02:00
|
|
|
return this.currentData() === this.visibility.get();
|
|
|
|
},
|
|
|
|
|
2015-09-03 23:12:46 +02:00
|
|
|
setVisibility(visibility) {
|
2015-05-27 17:17:00 +02:00
|
|
|
this.visibility.set(visibility);
|
|
|
|
this.visibilityMenuIsOpen.set(false);
|
|
|
|
},
|
|
|
|
|
2015-09-06 22:47:29 +02:00
|
|
|
toggleVisibilityMenu() {
|
2015-09-03 23:12:46 +02:00
|
|
|
this.visibilityMenuIsOpen.set(!this.visibilityMenuIsOpen.get());
|
2015-05-27 17:17:00 +02:00
|
|
|
},
|
|
|
|
|
2015-09-03 23:12:46 +02:00
|
|
|
onSubmit(evt) {
|
2015-05-27 17:17:00 +02:00
|
|
|
evt.preventDefault();
|
2015-09-03 23:12:46 +02:00
|
|
|
const title = this.find('.js-new-board-title').value;
|
|
|
|
const visibility = this.visibility.get();
|
2015-05-27 17:17:00 +02:00
|
|
|
|
2017-02-22 18:59:51 +05:30
|
|
|
this.boardId.set(Boards.insert({
|
2015-09-03 23:12:46 +02:00
|
|
|
title,
|
|
|
|
permission: visibility,
|
2017-02-22 18:59:51 +05:30
|
|
|
}));
|
2015-05-27 17:17:00 +02:00
|
|
|
|
2018-01-19 12:22:03 -03:00
|
|
|
Swimlanes.insert({
|
|
|
|
title: 'Default',
|
|
|
|
boardId: this.boardId.get(),
|
|
|
|
});
|
|
|
|
|
2017-02-22 18:59:51 +05:30
|
|
|
Utils.goBoardId(this.boardId.get());
|
2015-05-27 17:17:00 +02:00
|
|
|
},
|
|
|
|
|
2015-09-03 23:12:46 +02:00
|
|
|
events() {
|
2015-05-27 17:17:00 +02:00
|
|
|
return [{
|
2015-09-03 23:12:46 +02:00
|
|
|
'click .js-select-visibility'() {
|
2015-05-27 17:17:00 +02:00
|
|
|
this.setVisibility(this.currentData());
|
|
|
|
},
|
2015-09-06 22:47:29 +02:00
|
|
|
'click .js-change-visibility': this.toggleVisibilityMenu,
|
2019-02-25 22:48:25 +01:00
|
|
|
'click .js-board-template': Popup.open('searchElement'),
|
2015-05-27 17:17:00 +02:00
|
|
|
}];
|
2015-09-03 23:12:46 +02:00
|
|
|
},
|
2015-05-27 17:17:00 +02:00
|
|
|
}).register('createBoardPopup');
|
|
|
|
|
2017-02-22 17:33:17 +05:30
|
|
|
(class HeaderBarCreateBoard extends CreateBoard {
|
|
|
|
onSubmit(evt) {
|
|
|
|
super.onSubmit(evt);
|
|
|
|
// Immediately star boards crated with the headerbar popup.
|
2017-02-22 18:59:51 +05:30
|
|
|
Meteor.user().toggleBoardStar(this.boardId.get());
|
2017-02-22 17:33:17 +05:30
|
|
|
}
|
2017-02-22 18:59:51 +05:30
|
|
|
}).register('headerBarCreateBoardPopup');
|
2017-02-22 17:33:17 +05:30
|
|
|
|
2015-05-27 17:17:00 +02:00
|
|
|
BlazeComponent.extendComponent({
|
2015-09-03 23:12:46 +02:00
|
|
|
visibilityCheck() {
|
|
|
|
const currentBoard = Boards.findOne(Session.get('currentBoard'));
|
2015-05-27 17:17:00 +02:00
|
|
|
return this.currentData() === currentBoard.permission;
|
|
|
|
},
|
|
|
|
|
2015-09-03 23:12:46 +02:00
|
|
|
selectBoardVisibility() {
|
2015-09-08 20:19:42 +02:00
|
|
|
const currentBoard = Boards.findOne(Session.get('currentBoard'));
|
|
|
|
const visibility = this.currentData();
|
|
|
|
currentBoard.setVisibility(visibility);
|
2015-05-27 17:17:00 +02:00
|
|
|
Popup.close();
|
|
|
|
},
|
|
|
|
|
2015-09-03 23:12:46 +02:00
|
|
|
events() {
|
2015-05-27 17:17:00 +02:00
|
|
|
return [{
|
2015-09-03 23:12:46 +02:00
|
|
|
'click .js-select-visibility': this.selectBoardVisibility,
|
2015-05-27 17:17:00 +02:00
|
|
|
}];
|
2015-09-03 23:12:46 +02:00
|
|
|
},
|
2015-05-27 17:17:00 +02:00
|
|
|
}).register('boardChangeVisibilityPopup');
|
2016-01-05 23:26:02 +08:00
|
|
|
|
|
|
|
BlazeComponent.extendComponent({
|
|
|
|
watchLevel() {
|
|
|
|
const currentBoard = Boards.findOne(Session.get('currentBoard'));
|
|
|
|
return currentBoard.getWatchLevel(Meteor.userId());
|
|
|
|
},
|
|
|
|
|
|
|
|
watchCheck() {
|
|
|
|
return this.currentData() === this.watchLevel();
|
|
|
|
},
|
|
|
|
|
|
|
|
events() {
|
|
|
|
return [{
|
|
|
|
'click .js-select-watch'() {
|
|
|
|
const level = this.currentData();
|
|
|
|
Meteor.call('watch', 'board', Session.get('currentBoard'), level, (err, ret) => {
|
|
|
|
if (!err && ret) Popup.close();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
}];
|
|
|
|
},
|
|
|
|
}).register('boardChangeWatchPopup');
|