summaryrefslogtreecommitdiffstats
path: root/client/components/sidebar
diff options
context:
space:
mode:
Diffstat (limited to 'client/components/sidebar')
-rw-r--r--client/components/sidebar/sidebar.js194
-rw-r--r--client/components/sidebar/sidebarArchives.js34
-rw-r--r--client/components/sidebar/sidebarFilters.js100
3 files changed, 166 insertions, 162 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;
- }
+ },
});
diff --git a/client/components/sidebar/sidebarArchives.js b/client/components/sidebar/sidebarArchives.js
index 4e44f3f4..f2597c3c 100644
--- a/client/components/sidebar/sidebarArchives.js
+++ b/client/components/sidebar/sidebarArchives.js
@@ -1,46 +1,46 @@
BlazeComponent.extendComponent({
- template: function() {
+ template() {
return 'archivesSidebar';
},
- tabs: function() {
+ tabs() {
return [
{ name: TAPi18n.__('cards'), slug: 'cards' },
- { name: TAPi18n.__('lists'), slug: 'lists' }
- ]
+ { name: TAPi18n.__('lists'), slug: 'lists' },
+ ];
},
- archivedCards: function() {
+ archivedCards() {
return Cards.find({ archived: true });
},
- archivedLists: function() {
+ archivedLists() {
return Lists.find({ archived: true });
},
- cardIsInArchivedList: function() {
+ cardIsInArchivedList() {
return this.currentData().list().archived;
},
- onRendered: function() {
- //XXX We should support dragging a card from the sidebar to the board
+ onRendered() {
+ // XXX We should support dragging a card from the sidebar to the board
},
- events: function() {
+ events() {
return [{
- 'click .js-restore-card': function() {
- var cardId = this.currentData()._id;
+ 'click .js-restore-card'() {
+ const cardId = this.currentData()._id;
Cards.update(cardId, {$set: {archived: false}});
},
'click .js-delete-card': Popup.afterConfirm('cardDelete', function() {
- var cardId = this._id;
+ const cardId = this._id;
Cards.remove(cardId);
Popup.close();
}),
- 'click .js-restore-list': function() {
- var listId = this.currentData()._id;
+ 'click .js-restore-list'() {
+ const listId = this.currentData()._id;
Lists.update(listId, {$set: {archived: false}});
- }
+ },
}];
- }
+ },
}).register('archivesSidebar');
diff --git a/client/components/sidebar/sidebarFilters.js b/client/components/sidebar/sidebarFilters.js
index c7b28443..7fce7286 100644
--- a/client/components/sidebar/sidebarFilters.js
+++ b/client/components/sidebar/sidebarFilters.js
@@ -1,136 +1,136 @@
BlazeComponent.extendComponent({
- template: function() {
+ template() {
return 'filterSidebar';
},
- events: function() {
+ events() {
return [{
- 'click .js-toggle-label-filter': function(evt) {
+ 'click .js-toggle-label-filter'(evt) {
evt.preventDefault();
Filter.labelIds.toogle(this.currentData()._id);
Filter.resetExceptions();
},
- 'click .js-toogle-member-filter': function(evt) {
+ 'click .js-toogle-member-filter'(evt) {
evt.preventDefault();
Filter.members.toogle(this.currentData()._id);
Filter.resetExceptions();
},
- 'click .js-clear-all': function(evt) {
+ 'click .js-clear-all'(evt) {
evt.preventDefault();
Filter.reset();
},
- 'click .js-filter-to-selection': function(evt) {
+ 'click .js-filter-to-selection'(evt) {
evt.preventDefault();
- var selectedCards = Cards.find(Filter.mongoSelector()).map(function(c) {
+ const selectedCards = Cards.find(Filter.mongoSelector()).map((c) => {
return c._id;
});
MultiSelection.add(selectedCards);
- }
+ },
}];
- }
+ },
}).register('filterSidebar');
-var updateSelectedCards = function(query) {
- Cards.find(MultiSelection.getMongoSelector()).forEach(function(card) {
+function updateSelectedCards(query) {
+ Cards.find(MultiSelection.getMongoSelector()).forEach((card) => {
Cards.update(card._id, query);
});
-};
+}
BlazeComponent.extendComponent({
- template: function() {
+ template() {
return 'multiselectionSidebar';
},
- mapSelection: function(kind, _id) {
- return Cards.find(MultiSelection.getMongoSelector()).map(function(card) {
- var methodName = kind === 'label' ? 'hasLabel' : 'isAssigned';
+ mapSelection(kind, _id) {
+ return Cards.find(MultiSelection.getMongoSelector()).map((card) => {
+ const methodName = kind === 'label' ? 'hasLabel' : 'isAssigned';
return card[methodName](_id);
});
},
- allSelectedElementHave: function(kind, _id) {
+ allSelectedElementHave(kind, _id) {
if (MultiSelection.isEmpty())
return false;
else
return _.every(this.mapSelection(kind, _id));
},
- someSelectedElementHave: function(kind, _id) {
+ someSelectedElementHave(kind, _id) {
if (MultiSelection.isEmpty())
return false;
else
return _.some(this.mapSelection(kind, _id));
},
- events: function() {
+ events() {
return [{
- 'click .js-toggle-label-multiselection': function(evt) {
- var labelId = this.currentData()._id;
- var mappedSelection = this.mapSelection('label', labelId);
- var operation;
+ 'click .js-toggle-label-multiselection'(evt) {
+ const labelId = this.currentData()._id;
+ const mappedSelection = this.mapSelection('label', labelId);
+ let operation;
if (_.every(mappedSelection))
operation = '$pull';
- else if (_.every(mappedSelection, function(bool) { return ! bool; }))
+ else if (_.every(mappedSelection, (bool) => !bool))
operation = '$addToSet';
else {
- var popup = Popup.open('disambiguateMultiLabel');
+ const popup = Popup.open('disambiguateMultiLabel');
// XXX We need to have a better integration between the popup and the
// UI components systems.
return popup.call(this.currentData(), evt);
}
- var query = {};
- query[operation] = {
- labelIds: labelId
- };
- updateSelectedCards(query);
+ updateSelectedCards({
+ [operation]: {
+ labelIds: labelId,
+ },
+ });
},
- 'click .js-toogle-member-multiselection': function(evt) {
- var memberId = this.currentData()._id;
- var mappedSelection = this.mapSelection('member', memberId);
- var operation;
+ 'click .js-toogle-member-multiselection'(evt) {
+ const memberId = this.currentData()._id;
+ const mappedSelection = this.mapSelection('member', memberId);
+ let operation;
if (_.every(mappedSelection))
operation = '$pull';
- else if (_.every(mappedSelection, function(bool) { return ! bool; }))
+ else if (_.every(mappedSelection, (bool) => !bool))
operation = '$addToSet';
else {
- var popup = Popup.open('disambiguateMultiMember');
+ const popup = Popup.open('disambiguateMultiMember');
// XXX We need to have a better integration between the popup and the
// UI components systems.
return popup.call(this.currentData(), evt);
}
- var query = {};
- query[operation] = {
- members: memberId
- };
- updateSelectedCards(query);
+ updateSelectedCards({
+ [operation]: {
+ members: memberId,
+ },
+ });
},
- 'click .js-archive-selection': function() {
+ 'click .js-archive-selection'() {
updateSelectedCards({$set: {archived: true}});
- }
+ },
}];
- }
+ },
}).register('multiselectionSidebar');
Template.disambiguateMultiLabelPopup.events({
- 'click .js-remove-label': function() {
+ 'click .js-remove-label'() {
updateSelectedCards({$pull: {labelIds: this._id}});
Popup.close();
},
- 'click .js-add-label': function() {
+ 'click .js-add-label'() {
updateSelectedCards({$addToSet: {labelIds: this._id}});
Popup.close();
- }
+ },
});
Template.disambiguateMultiMemberPopup.events({
- 'click .js-unassign-member': function() {
+ 'click .js-unassign-member'() {
updateSelectedCards({$pull: {members: this._id}});
Popup.close();
},
- 'click .js-assign-member': function() {
+ 'click .js-assign-member'() {
updateSelectedCards({$addToSet: {members: this._id}});
Popup.close();
- }
+ },
});