2019-03-04 12:04:12 +02:00
|
|
|
Template.boardMenuPopup.events({
|
|
|
|
'click .js-rename-board': Popup.open('boardChangeTitle'),
|
|
|
|
'click .js-custom-fields'() {
|
|
|
|
Sidebar.setView('customFields');
|
|
|
|
Popup.close();
|
|
|
|
},
|
|
|
|
'click .js-open-archives'() {
|
|
|
|
Sidebar.setView('archives');
|
|
|
|
Popup.close();
|
|
|
|
},
|
|
|
|
'click .js-change-board-color': Popup.open('boardChangeColor'),
|
|
|
|
'click .js-change-language': Popup.open('changeLanguage'),
|
|
|
|
'click .js-archive-board ': Popup.afterConfirm('archiveBoard', function() {
|
|
|
|
const currentBoard = Boards.findOne(Session.get('currentBoard'));
|
|
|
|
currentBoard.archive();
|
|
|
|
// XXX We should have some kind of notification on top of the page to
|
|
|
|
// confirm that the board was successfully archived.
|
|
|
|
FlowRouter.go('home');
|
|
|
|
}),
|
|
|
|
'click .js-delete-board': Popup.afterConfirm('deleteBoard', function() {
|
|
|
|
const currentBoard = Boards.findOne(Session.get('currentBoard'));
|
|
|
|
Popup.close();
|
|
|
|
Boards.remove(currentBoard._id);
|
|
|
|
FlowRouter.go('home');
|
|
|
|
}),
|
|
|
|
'click .js-outgoing-webhooks': Popup.open('outgoingWebhooks'),
|
|
|
|
'click .js-import-board': Popup.open('chooseBoardSource'),
|
|
|
|
'click .js-subtask-settings': Popup.open('boardSubtaskSettings'),
|
|
|
|
});
|
|
|
|
|
|
|
|
Template.boardMenuPopup.helpers({
|
|
|
|
exportUrl() {
|
|
|
|
const params = {
|
|
|
|
boardId: Session.get('currentBoard'),
|
|
|
|
};
|
|
|
|
const queryParams = {
|
|
|
|
authToken: Accounts._storedLoginToken(),
|
|
|
|
};
|
|
|
|
return FlowRouter.path('/api/boards/:boardId/export', params, queryParams);
|
|
|
|
},
|
|
|
|
exportFilename() {
|
|
|
|
const boardId = Session.get('currentBoard');
|
|
|
|
return `wekan-export-board-${boardId}.json`;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2015-05-27 17:17:00 +02:00
|
|
|
Template.boardChangeTitlePopup.events({
|
2019-06-28 12:52:09 -05:00
|
|
|
submit(event, templateInstance) {
|
|
|
|
const newTitle = templateInstance
|
|
|
|
.$('.js-board-name')
|
|
|
|
.val()
|
|
|
|
.trim();
|
|
|
|
const newDesc = templateInstance
|
|
|
|
.$('.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();
|
|
|
|
}
|
2019-06-28 12:52:09 -05:00
|
|
|
event.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() {
|
2019-06-28 12:52:09 -05:00
|
|
|
return [
|
|
|
|
{
|
|
|
|
'click .js-edit-board-title': Popup.open('boardChangeTitle'),
|
|
|
|
'click .js-star-board'() {
|
|
|
|
Meteor.user().toggleBoardStar(Session.get('currentBoard'));
|
|
|
|
},
|
|
|
|
'click .js-open-board-menu': Popup.open('boardMenu'),
|
|
|
|
'click .js-change-visibility': Popup.open('boardChangeVisibility'),
|
|
|
|
'click .js-watch-board': Popup.open('boardChangeWatch'),
|
|
|
|
'click .js-open-archived-board'() {
|
|
|
|
Modal.open('archivedBoards');
|
|
|
|
},
|
|
|
|
'click .js-toggle-board-view'() {
|
|
|
|
const currentUser = Meteor.user();
|
|
|
|
if (
|
|
|
|
(currentUser.profile || {}).boardView === 'board-view-swimlanes'
|
|
|
|
) {
|
|
|
|
currentUser.setBoardView('board-view-cal');
|
|
|
|
} else if (
|
|
|
|
(currentUser.profile || {}).boardView === 'board-view-lists'
|
|
|
|
) {
|
|
|
|
currentUser.setBoardView('board-view-swimlanes');
|
|
|
|
} else if (
|
|
|
|
(currentUser.profile || {}).boardView === 'board-view-cal'
|
|
|
|
) {
|
|
|
|
currentUser.setBoardView('board-view-lists');
|
|
|
|
} else {
|
|
|
|
currentUser.setBoardView('board-view-swimlanes');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'click .js-toggle-sidebar'() {
|
|
|
|
Sidebar.toggle();
|
|
|
|
},
|
|
|
|
'click .js-open-filter-view'() {
|
|
|
|
Sidebar.setView('filter');
|
|
|
|
},
|
|
|
|
'click .js-filter-reset'(event) {
|
|
|
|
event.stopPropagation();
|
|
|
|
Sidebar.setView();
|
|
|
|
Filter.reset();
|
|
|
|
},
|
|
|
|
'click .js-open-search-view'() {
|
|
|
|
Sidebar.setView('search');
|
|
|
|
},
|
|
|
|
'click .js-open-rules-view'() {
|
|
|
|
Modal.openWide('rulesMain');
|
|
|
|
},
|
|
|
|
'click .js-multiselection-activate'() {
|
|
|
|
const currentCard = Session.get('currentCard');
|
|
|
|
MultiSelection.activate();
|
|
|
|
if (currentCard) {
|
|
|
|
MultiSelection.add(currentCard);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'click .js-multiselection-reset'(event) {
|
|
|
|
event.stopPropagation();
|
|
|
|
MultiSelection.disable();
|
|
|
|
},
|
|
|
|
'click .js-log-in'() {
|
|
|
|
FlowRouter.go('atSignIn');
|
|
|
|
},
|
2015-05-27 17:17:00 +02:00
|
|
|
},
|
2019-06-28 12:52:09 -05: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() {
|
2019-06-28 12:52:09 -05:00
|
|
|
return (
|
|
|
|
Meteor.user() &&
|
|
|
|
Meteor.user().isBoardMember() &&
|
|
|
|
!Meteor.user().isCommentOnly()
|
|
|
|
);
|
2017-03-18 18:49:39 -04:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
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
|
|
|
},
|
|
|
|
|
2019-06-28 12:52:09 -05:00
|
|
|
onSubmit(event) {
|
|
|
|
event.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
|
|
|
|
2019-06-28 12:52:09 -05:00
|
|
|
this.boardId.set(
|
|
|
|
Boards.insert({
|
|
|
|
title,
|
|
|
|
permission: visibility,
|
|
|
|
}),
|
|
|
|
);
|
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() {
|
2019-06-28 12:52:09 -05:00
|
|
|
return [
|
|
|
|
{
|
|
|
|
'click .js-select-visibility'() {
|
|
|
|
this.setVisibility(this.currentData());
|
|
|
|
},
|
|
|
|
'click .js-change-visibility': this.toggleVisibilityMenu,
|
|
|
|
'click .js-import': Popup.open('boardImportBoard'),
|
|
|
|
submit: this.onSubmit,
|
|
|
|
'click .js-import-board': Popup.open('chooseBoardSource'),
|
|
|
|
'click .js-board-template': Popup.open('searchElement'),
|
2015-05-27 17:17:00 +02:00
|
|
|
},
|
2019-06-28 12:52:09 -05: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 {
|
2019-06-28 12:52:09 -05:00
|
|
|
onSubmit(event) {
|
|
|
|
super.onSubmit(event);
|
2017-02-22 17:33:17 +05:30
|
|
|
// 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
|
|
|
}
|
2019-06-28 12:52:09 -05:00
|
|
|
}.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() {
|
2019-06-28 12:52:09 -05:00
|
|
|
return [
|
|
|
|
{
|
|
|
|
'click .js-select-visibility': this.selectBoardVisibility,
|
|
|
|
},
|
|
|
|
];
|
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() {
|
2019-06-28 12:52:09 -05:00
|
|
|
return [
|
|
|
|
{
|
|
|
|
'click .js-select-watch'() {
|
|
|
|
const level = this.currentData();
|
|
|
|
Meteor.call(
|
|
|
|
'watch',
|
|
|
|
'board',
|
|
|
|
Session.get('currentBoard'),
|
|
|
|
level,
|
|
|
|
(err, ret) => {
|
|
|
|
if (!err && ret) Popup.close();
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
2016-01-05 23:26:02 +08:00
|
|
|
},
|
2019-06-28 12:52:09 -05:00
|
|
|
];
|
2016-01-05 23:26:02 +08:00
|
|
|
},
|
|
|
|
}).register('boardChangeWatchPopup');
|