wekan/client/components/boards/boardsList.js

100 lines
2.5 KiB
JavaScript
Raw Normal View History

const subManager = new SubsManager();
Template.boardListHeaderBar.events({
'click .js-open-archived-board'() {
Modal.open('archivedBoards');
},
});
Template.boardListHeaderBar.helpers({
templatesBoardId() {
2019-02-24 00:13:35 +01:00
return Meteor.user().getTemplatesBoardId();
},
templatesBoardSlug() {
2019-02-24 00:13:35 +01:00
return Meteor.user().getTemplatesBoardSlug();
},
});
BlazeComponent.extendComponent({
onCreated() {
Meteor.subscribe('setting');
},
boards() {
2019-06-28 12:52:09 -05:00
return Boards.find(
{
archived: false,
'members.userId': Meteor.userId(),
type: 'board',
},
{ sort: ['title'] },
);
},
isStarred() {
const user = Meteor.user();
2015-08-23 22:00:02 +02:00
return user && user.hasStarred(this.currentData()._id);
},
hasOvertimeCards() {
subManager.subscribe('board', this.currentData()._id, false);
return this.currentData().hasOvertimeCards();
},
hasSpentTimeCards() {
subManager.subscribe('board', this.currentData()._id, false);
return this.currentData().hasSpentTimeCards();
},
isInvited() {
const user = Meteor.user();
return user && user.isInvitedTo(this.currentData()._id);
},
events() {
2019-06-28 12:52:09 -05:00
return [
{
'click .js-add-board': Popup.open('createBoard'),
'click .js-star-board'(evt) {
const boardId = this.currentData()._id;
Meteor.user().toggleBoardStar(boardId);
evt.preventDefault();
},
'click .js-clone-board'(evt) {
Meteor.call(
'cloneBoard',
this.currentData()._id,
Session.get('fromBoard'),
(err, res) => {
if (err) {
this.setError(err.error);
} else {
Session.set('fromBoard', null);
Utils.goBoardId(res);
}
},
);
evt.preventDefault();
},
'click .js-archive-board'(evt) {
const boardId = this.currentData()._id;
Meteor.call('archiveBoard', boardId);
evt.preventDefault();
},
'click .js-accept-invite'() {
const boardId = this.currentData()._id;
2019-07-18 13:06:25 -05:00
Meteor.call('acceptInvite', boardId);
2019-06-28 12:52:09 -05:00
},
'click .js-decline-invite'() {
const boardId = this.currentData()._id;
Meteor.call('quitBoard', boardId, (err, ret) => {
if (!err && ret) {
2019-07-18 13:06:25 -05:00
Meteor.call('acceptInvite', boardId);
2019-06-28 12:52:09 -05:00
FlowRouter.go('home');
2019-02-12 23:40:12 +01:00
}
2019-06-28 12:52:09 -05:00
});
},
},
2019-06-28 12:52:09 -05:00
];
},
}).register('boardList');