diff options
author | Maxime Quandalle <maxime@quandalle.com> | 2015-06-16 23:50:47 +0200 |
---|---|---|
committer | Maxime Quandalle <maxime@quandalle.com> | 2015-06-16 23:50:47 +0200 |
commit | 879fc47b530e89ce11ae60579962d9bcaf103b17 (patch) | |
tree | fc51c887161bcab9cdc7ffde976bb060d48ba80b /client/components/sidebar | |
parent | f039923ac134e4a3cc70a1a7d47c21460676b1c0 (diff) | |
download | wekan-879fc47b530e89ce11ae60579962d9bcaf103b17.tar.gz wekan-879fc47b530e89ce11ae60579962d9bcaf103b17.tar.bz2 wekan-879fc47b530e89ce11ae60579962d9bcaf103b17.zip |
Fix some sidebar bugs
Diffstat (limited to 'client/components/sidebar')
-rw-r--r-- | client/components/sidebar/sidebar.js | 80 |
1 files changed, 44 insertions, 36 deletions
diff --git a/client/components/sidebar/sidebar.js b/client/components/sidebar/sidebar.js index 01612835..e4937bec 100644 --- a/client/components/sidebar/sidebar.js +++ b/client/components/sidebar/sidebar.js @@ -62,6 +62,10 @@ BlazeComponent.extendComponent({ return this.isOpen() && this.getView() !== defaultView; }, + scrollTop: function() { + this.$('.js-board-sidebar-content').scrollTop(0); + }, + getView: function() { return this._view.get(); }, @@ -70,6 +74,7 @@ BlazeComponent.extendComponent({ view = _.isString(view) ? view : defaultView; if (this._view.get() !== view) { this._view.set(view); + this.scrollTop(); EscapeActions.executeUpTo('detailsPane'); } this.open(); @@ -87,42 +92,6 @@ BlazeComponent.extendComponent({ return TAPi18n.__(viewTitles[this.getView()]); }, - // Board members can assign people or labels by drag-dropping elements from - // the sidebar to the cards on the board. In order to re-initialize the - // jquery-ui 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. - onRendered: function() { - var self = this; - if (! Meteor.userId() || ! Meteor.user().isBoardMember()) - return; - - self.autorun(function() { - var currentBoardId = Tracker.nonreactive(function() { - return Session.get('currentBoard'); - }); - Boards.findOne(currentBoardId, { - fields: { - members: 1, - labels: 1 - } - }); - Tracker.afterFlush(function() { - self.$('.js-member,.js-label').draggable({ - appendTo: 'body', - helper: 'clone', - revert: 'invalid', - revertDuration: 150, - snap: false, - snapMode: 'both', - start: function() { - EscapeActions.executeUpTo('popup'); - } - }); - }); - }); - }, - events: function() { // XXX Hacky, we need some kind of `super` var mixinEvents = this.getMixin(Mixins.InfiniteScrolling).events(); @@ -186,6 +155,45 @@ Template.labelsWidget.events({ 'click .js-add-label': Popup.open('createLabel') }); +// Board members can assign people or labels by drag-dropping elements from the +// sidebar to the cards on the board. In order to re-initialize the jquery-ui +// 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.userId() || ! Meteor.user().isBoardMember()) + return; + + self.autorun(function() { + var currentBoardId = Tracker.nonreactive(function() { + return Session.get('currentBoard'); + }); + Boards.findOne(currentBoardId, { + fields: { + members: 1, + labels: 1 + } + }); + Tracker.afterFlush(function() { + self.$('.js-member,.js-label').draggable({ + appendTo: 'body', + helper: 'clone', + revert: 'invalid', + revertDuration: 150, + snap: false, + snapMode: 'both', + start: function() { + EscapeActions.executeUpTo('popup'); + } + }); + }); + }); +}; + +Template.membersWidget.onRendered(draggableMembersLabelsWidgets); +Template.labelsWidget.onRendered(draggableMembersLabelsWidgets); + Template.addMemberPopup.helpers({ isBoardMember: function() { var user = Users.findOne(this._id); |