diff options
Diffstat (limited to 'client/components/cards/details.js')
-rw-r--r-- | client/components/cards/details.js | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/client/components/cards/details.js b/client/components/cards/details.js new file mode 100644 index 00000000..a4fe89a3 --- /dev/null +++ b/client/components/cards/details.js @@ -0,0 +1,103 @@ +BlazeComponent.extendComponent({ + template: function() { + return 'cardSidebar'; + }, + + mixins: function() { + return [Mixins.InfiniteScrolling]; + }, + + calculateNextPeak: function() { + var altitude = this.find('.js-card-sidebar-content').scrollHeight; + this.callFirstWith(this, 'setNextPeak', altitude); + }, + + reachNextPeak: function() { + var activitiesComponent = this.componentChildren('activities')[0]; + activitiesComponent.loadNextPage(); + }, + + events: function() { + return [{ + 'click .js-move-card': Popup.open('moveCard'), + 'submit .js-card-description': function(evt) { + evt.preventDefault(); + var cardId = Session.get('currentCard'); + var form = this.componentChildren('inlinedForm')[0]; + var newDescription = form.getValue(); + Cards.update(cardId, { + $set: { + description: newDescription + } + }); + form.close(); + }, + 'click .js-close-card-detail': function() { + Utils.goBoardId(Session.get('currentBoard')); + }, + 'click .editable .js-card-title': function(event, t) { + var editable = t.$('.card-detail-title'); + + // add class editing and focus + $('.editing').removeClass('editing'); + editable.addClass('editing'); + editable.find('#title').focus(); + }, + 'click .js-edit-desc': function(event, t) { + var editable = t.$('.card-detail-item'); + + // editing remove based and add current editing. + $('.editing').removeClass('editing'); + editable.addClass('editing'); + editable.find('#desc').focus(); + + event.preventDefault(); + }, + 'click .js-cancel-edit': function(event, t) { + // remove editing hide. + $('.editing').removeClass('editing'); + }, + 'submit #WindowTitleEdit': function(event, t) { + var title = t.find('#title').value; + if ($.trim(title)) { + Cards.update(this.card._id, { + $set: { + title: title + } + }, function (err, res) { + if (!err) $('.editing').removeClass('editing'); + }); + } + + event.preventDefault(); + }, + 'submit #WindowDescEdit': function(event, t) { + Cards.update(this.card._id, { + $set: { + description: t.find('#desc').value + } + }, function(err) { + if (!err) $('.editing').removeClass('editing'); + }); + event.preventDefault(); + }, + 'click .member': Popup.open('cardMember'), + 'click .js-details-edit-members': Popup.open('cardMembers'), + 'click .js-details-edit-labels': Popup.open('cardLabels') + }]; + } +}).register('cardSidebar'); + +Template.moveCardPopup.events({ + 'click .js-select-list': function() { + // XXX We should *not* get the currentCard from the global state, but + // instead from a “component” state. + var cardId = Session.get('currentCard'); + var newListId = this._id; + Cards.update(cardId, { + $set: { + listId: newListId + } + }); + } +}); |