summaryrefslogtreecommitdiffstats
path: root/client/components/sidebar/sidebar.js
diff options
context:
space:
mode:
Diffstat (limited to 'client/components/sidebar/sidebar.js')
-rw-r--r--client/components/sidebar/sidebar.js194
1 files changed, 99 insertions, 95 deletions
diff --git a/client/components/sidebar/sidebar.js b/client/components/sidebar/sidebar.js
index 97b6f2de..51f3e0e4 100644
--- a/client/components/sidebar/sidebar.js
+++ b/client/components/sidebar/sidebar.js
@@ -1,76 +1,76 @@
Sidebar = null;
-var defaultView = 'home';
+const defaultView = 'home';
-var viewTitles = {
+const viewTitles = {
filter: 'filter-cards',
multiselection: 'multi-selection',
- archives: 'archives'
+ archives: 'archives',
};
BlazeComponent.extendComponent({
- template: function() {
+ template() {
return 'sidebar';
},
- mixins: function() {
+ mixins() {
return [Mixins.InfiniteScrolling, Mixins.PerfectScrollbar];
},
- onCreated: function() {
- this._isOpen = new ReactiveVar(! Session.get('currentCard'));
+ onCreated() {
+ this._isOpen = new ReactiveVar(!Session.get('currentCard'));
this._view = new ReactiveVar(defaultView);
Sidebar = this;
},
- onDestroyed: function() {
+ onDestroyed() {
Sidebar = null;
},
- isOpen: function() {
+ isOpen() {
return this._isOpen.get();
},
- open: function() {
- if (! this._isOpen.get()) {
+ open() {
+ if (!this._isOpen.get()) {
this._isOpen.set(true);
EscapeActions.executeUpTo('detailsPane');
}
},
- hide: function() {
+ hide() {
if (this._isOpen.get()) {
this._isOpen.set(false);
}
},
- toogle: function() {
- this._isOpen.set(! this._isOpen.get());
+ toogle() {
+ this._isOpen.set(!this._isOpen.get());
},
- calculateNextPeak: function() {
- var altitude = this.find('.js-board-sidebar-content').scrollHeight;
+ calculateNextPeak() {
+ const altitude = this.find('.js-board-sidebar-content').scrollHeight;
this.callFirstWith(this, 'setNextPeak', altitude);
},
- reachNextPeak: function() {
- var activitiesComponent = this.componentChildren('activities')[0];
+ reachNextPeak() {
+ const activitiesComponent = this.componentChildren('activities')[0];
activitiesComponent.loadNextPage();
},
- isTongueHidden: function() {
+ isTongueHidden() {
return this.isOpen() && this.getView() !== defaultView;
},
- scrollTop: function() {
+ scrollTop() {
this.$('.js-board-sidebar-content').scrollTop(0);
},
- getView: function() {
+ getView() {
return this._view.get();
},
- setView: function(view) {
+ setView(view) {
view = _.isString(view) ? view : defaultView;
if (this._view.get() !== view) {
this._view.set(view);
@@ -80,83 +80,84 @@ BlazeComponent.extendComponent({
this.open();
},
- isDefaultView: function() {
+ isDefaultView() {
return this.getView() === defaultView;
},
- getViewTemplate: function() {
- return this.getView() + 'Sidebar';
+ getViewTemplate() {
+ return `${this.getView()}Sidebar`;
},
- getViewTitle: function() {
+ getViewTitle() {
return TAPi18n.__(viewTitles[this.getView()]);
},
- events: function() {
+ events() {
// XXX Hacky, we need some kind of `super`
- var mixinEvents = this.getMixin(Mixins.InfiniteScrolling).events();
+ const mixinEvents = this.getMixin(Mixins.InfiniteScrolling).events();
return mixinEvents.concat([{
'click .js-toogle-sidebar': this.toogle,
- 'click .js-back-home': this.setView
+ 'click .js-back-home': this.setView,
}]);
- }
+ },
}).register('sidebar');
-Blaze.registerHelper('Sidebar', function() {
- return Sidebar;
-});
+Blaze.registerHelper('Sidebar', () => Sidebar);
EscapeActions.register('sidebarView',
- function() { Sidebar.setView(defaultView); },
- function() { return Sidebar && Sidebar.getView() !== defaultView; }
+ () => { Sidebar.setView(defaultView); },
+ () => { return Sidebar && Sidebar.getView() !== defaultView; }
);
-var getMemberIndex = function(board, searchId) {
- for (var i = 0; i < board.members.length; i++) {
+function getMemberIndex(board, searchId) {
+ for (let i = 0; i < board.members.length; i++) {
if (board.members[i].userId === searchId)
return i;
}
throw new Meteor.Error('Member not found');
-};
+}
Template.memberPopup.helpers({
- user: function() {
+ user() {
return Users.findOne(this.userId);
},
- memberType: function() {
- var type = Users.findOne(this.userId).isBoardAdmin() ? 'admin' : 'normal';
+ memberType() {
+ const type = Users.findOne(this.userId).isBoardAdmin() ? 'admin' : 'normal';
return TAPi18n.__(type).toLowerCase();
- }
+ },
});
Template.memberPopup.events({
- 'click .js-filter-member': function() {
+ 'click .js-filter-member'() {
Filter.members.toogle(this.userId);
Popup.close();
},
'click .js-change-role': Popup.open('changePermissions'),
'click .js-remove-member': Popup.afterConfirm('removeMember', function() {
- var currentBoard = Boards.findOne(Session.get('currentBoard'));
- var memberIndex = getMemberIndex(currentBoard, this.userId);
- var setQuery = {};
- setQuery[['members', memberIndex, 'isActive'].join('.')] = false;
- Boards.update(currentBoard._id, { $set: setQuery });
+ const currentBoard = Boards.findOne(Session.get('currentBoard'));
+ const memberIndex = getMemberIndex(currentBoard, this.userId);
+
+ Boards.update(currentBoard._id, {
+ $set: {
+ [`members.${memberIndex}.isActive`]: false,
+ },
+ });
Popup.close();
}),
- 'click .js-leave-member': function() {
+ 'click .js-leave-member'() {
// XXX Not implemented
Popup.close();
- }
+ },
});
Template.membersWidget.events({
'click .js-member': Popup.open('member'),
- 'click .js-manage-board-members': Popup.open('addMember')
+ 'click .js-manage-board-members': Popup.open('addMember'),
});
Template.labelsWidget.events({
'click .js-label': Popup.open('editLabel'),
- 'click .js-add-label': Popup.open('createLabel')
+ 'click .js-add-label': Popup.open('createLabel'),
});
// Board members can assign people or labels by drag-dropping elements from the
@@ -164,99 +165,102 @@ Template.labelsWidget.events({
// plugin any time a draggable member or label is modified or removed we use a
// autorun function and register a dependency on the both members and labels
// fields of the current board document.
-var draggableMembersLabelsWidgets = function() {
- var self = this;
- if (! Meteor.user() || ! Meteor.user().isBoardMember())
+function draggableMembersLabelsWidgets() {
+ if (!Meteor.user() || !Meteor.user().isBoardMember())
return;
- self.autorun(function() {
- var currentBoardId = Tracker.nonreactive(function() {
+ this.autorun(() => {
+ const currentBoardId = Tracker.nonreactive(() => {
return Session.get('currentBoard');
});
Boards.findOne(currentBoardId, {
fields: {
members: 1,
- labels: 1
- }
+ labels: 1,
+ },
});
- Tracker.afterFlush(function() {
- self.$('.js-member,.js-label').draggable({
+ Tracker.afterFlush(() => {
+ this.$('.js-member,.js-label').draggable({
appendTo: 'body',
helper: 'clone',
revert: 'invalid',
revertDuration: 150,
snap: false,
snapMode: 'both',
- start: function() {
+ start() {
EscapeActions.executeUpTo('popup-back');
- }
+ },
});
});
});
-};
+}
Template.membersWidget.onRendered(draggableMembersLabelsWidgets);
Template.labelsWidget.onRendered(draggableMembersLabelsWidgets);
Template.addMemberPopup.helpers({
- isBoardMember: function() {
- var user = Users.findOne(this._id);
+ isBoardMember() {
+ const user = Users.findOne(this._id);
return user && user.isBoardMember();
- }
+ },
});
Template.addMemberPopup.events({
- 'click .pop-over-member-list li:not(.disabled)': function() {
- var userId = this._id;
- var currentBoard = Boards.findOne(Session.get('currentBoard'));
- var currentMembersIds = _.pluck(currentBoard.members, 'userId');
+ 'click .pop-over-member-list li:not(.disabled)'() {
+ const userId = this._id;
+ const currentBoard = Boards.findOne(Session.get('currentBoard'));
+ const currentMembersIds = _.pluck(currentBoard.members, 'userId');
if (currentMembersIds.indexOf(userId) === -1) {
Boards.update(currentBoard._id, {
$push: {
members: {
- userId: userId,
+ userId,
isAdmin: false,
- isActive: true
- }
- }
+ isActive: true,
+ },
+ },
});
} else {
- var memberIndex = getMemberIndex(currentBoard, userId);
- var setQuery = {};
- setQuery[['members', memberIndex, 'isActive'].join('.')] = true;
- Boards.update(currentBoard._id, { $set: setQuery });
+ const memberIndex = getMemberIndex(currentBoard, userId);
+
+ Boards.update(currentBoard._id, {
+ $set: {
+ [`members.${memberIndex}.isActive`]: true,
+ },
+ });
}
Popup.close();
- }
+ },
});
-Template.addMemberPopup.onRendered(function() {
+Template.addMemberPopup.onRendered(() => {
this.find('.js-search-member input').focus();
});
Template.changePermissionsPopup.events({
- 'click .js-set-admin, click .js-set-normal': function(event) {
- var currentBoard = Boards.findOne(Session.get('currentBoard'));
- var memberIndex = getMemberIndex(currentBoard, this.user._id);
- var isAdmin = $(event.currentTarget).hasClass('js-set-admin');
- var setQuery = {};
- setQuery[['members', memberIndex, 'isAdmin'].join('.')] = isAdmin;
+ 'click .js-set-admin, click .js-set-normal'(event) {
+ const currentBoard = Boards.findOne(Session.get('currentBoard'));
+ const memberIndex = getMemberIndex(currentBoard, this.user._id);
+ const isAdmin = $(event.currentTarget).hasClass('js-set-admin');
+
Boards.update(currentBoard._id, {
- $set: setQuery
+ $set: {
+ [`members.${memberIndex}.isAdmin`]: isAdmin,
+ },
});
Popup.back(1);
- }
+ },
});
Template.changePermissionsPopup.helpers({
- isAdmin: function() {
+ isAdmin() {
return this.user.isBoardAdmin();
},
- isLastAdmin: function() {
- if (! this.user.isBoardAdmin())
+ isLastAdmin() {
+ if (!this.user.isBoardAdmin())
return false;
- var currentBoard = Boards.findOne(Session.get('currentBoard'));
- var nbAdmins = _.where(currentBoard.members, { isAdmin: true }).length;
+ const currentBoard = Boards.findOne(Session.get('currentBoard'));
+ const nbAdmins = _.where(currentBoard.members, { isAdmin: true }).length;
return nbAdmins === 1;
- }
+ },
});