summaryrefslogtreecommitdiffstats
path: root/client/components/cards/cardDetails.js
diff options
context:
space:
mode:
authorMaxime Quandalle <maxime@quandalle.com>2015-08-28 02:21:42 +0200
committerMaxime Quandalle <maxime@quandalle.com>2015-08-28 02:25:26 +0200
commitb5dabfe88695a8f8211b29fea0dc16131c9a1829 (patch)
treeb257eddd507f0980a32e7c2c5932b866401a9b15 /client/components/cards/cardDetails.js
parent29e93162c2eb5b86b1afb3328748eb3b32b47b94 (diff)
downloadwekan-b5dabfe88695a8f8211b29fea0dc16131c9a1829.tar.gz
wekan-b5dabfe88695a8f8211b29fea0dc16131c9a1829.tar.bz2
wekan-b5dabfe88695a8f8211b29fea0dc16131c9a1829.zip
More explicit file names
Diffstat (limited to 'client/components/cards/cardDetails.js')
-rw-r--r--client/components/cards/cardDetails.js123
1 files changed, 123 insertions, 0 deletions
diff --git a/client/components/cards/cardDetails.js b/client/components/cards/cardDetails.js
new file mode 100644
index 00000000..4fa90bf7
--- /dev/null
+++ b/client/components/cards/cardDetails.js
@@ -0,0 +1,123 @@
+BlazeComponent.extendComponent({
+ template: function() {
+ return 'cardDetails';
+ },
+
+ mixins: function() {
+ return [Mixins.InfiniteScrolling, Mixins.PerfectScrollbar];
+ },
+
+ calculateNextPeak: function() {
+ var altitude = this.find('.js-card-details').scrollHeight;
+ this.callFirstWith(this, 'setNextPeak', altitude);
+ },
+
+ reachNextPeak: function() {
+ var activitiesComponent = this.componentChildren('activities')[0];
+ activitiesComponent.loadNextPage();
+ },
+
+ onRendered: function() {
+ var bodyBoardComponent = this.componentParent();
+ var additionalMargin = 550;
+ var $cardDetails = this.$(this.firstNode());
+ var scollLeft = $cardDetails.offset().left + additionalMargin;
+ bodyBoardComponent.scrollLeft(scollLeft);
+ },
+
+ onDestroyed: function() {
+ this.componentParent().showOverlay.set(false);
+ },
+
+ updateCard: function(modifier) {
+ Cards.update(this.data()._id, {
+ $set: modifier
+ });
+ },
+
+ onCreated: function() {
+ this.isLoaded = new ReactiveVar(false);
+ },
+
+ events: function() {
+ var events = {
+ [CSSEvents.animationend + ' .js-card-details']: function() {
+ this.isLoaded.set(true);
+ }
+ };
+
+ return [_.extend(events, {
+ 'click .js-close-card-details': function() {
+ Utils.goBoardId(this.data().boardId);
+ },
+ 'click .js-move-card': Popup.open('moveCard'),
+ 'click .js-open-card-details-menu': Popup.open('cardDetailsActions'),
+ 'submit .js-card-description': function(evt) {
+ evt.preventDefault();
+ var description = this.currentComponent().getValue();
+ this.updateCard({ description: description });
+ },
+ 'submit .js-card-details-title': function(evt) {
+ evt.preventDefault();
+ var title = this.currentComponent().getValue();
+ if ($.trim(title)) {
+ this.updateCard({ title: title });
+ }
+ },
+ 'click .js-member': Popup.open('cardMember'),
+ 'click .js-add-members': Popup.open('cardMembers'),
+ 'click .js-add-labels': Popup.open('cardLabels'),
+ 'mouseenter .js-card-details': function() {
+ this.componentParent().showOverlay.set(true);
+ }
+ })];
+ }
+}).register('cardDetails');
+
+Template.cardDetailsActionsPopup.events({
+ 'click .js-members': Popup.open('cardMembers'),
+ 'click .js-labels': Popup.open('cardLabels'),
+ 'click .js-attachments': Popup.open('cardAttachments'),
+ // 'click .js-copy': Popup.open(),
+ 'click .js-archive': function(evt) {
+ evt.preventDefault();
+ Cards.update(this._id, {
+ $set: {
+ archived: true
+ }
+ });
+ Popup.close();
+ },
+ 'click .js-more': Popup.open('cardMore')
+});
+
+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
+ }
+ });
+ Popup.close();
+ }
+});
+
+Template.cardMorePopup.events({
+ 'click .js-delete': Popup.afterConfirm('cardDelete', function() {
+ Popup.close();
+ Cards.remove(this._id);
+ Utils.goBoardId(this.board()._id);
+ })
+});
+
+// Close the card details pane by pressing escape
+EscapeActions.register('detailsPane',
+ function() { Utils.goBoardId(Session.get('currentBoard')); },
+ function() { return ! Session.equals('currentCard', null); }, {
+ noClickEscapeOn: '.js-card-details,.board-sidebar,#header'
+ }
+);