diff options
author | Maxime Quandalle <maxime@quandalle.com> | 2015-05-12 19:20:58 +0200 |
---|---|---|
committer | Maxime Quandalle <maxime@quandalle.com> | 2015-05-12 19:33:50 +0200 |
commit | 2dbea30842ec63a68055245fe26633bb7913daf3 (patch) | |
tree | e9143893a3d3bf4ad34dd3a97d6f3466561c8756 /client/components/cards/events.js | |
download | wekan-2dbea30842ec63a68055245fe26633bb7913daf3.tar.gz wekan-2dbea30842ec63a68055245fe26633bb7913daf3.tar.bz2 wekan-2dbea30842ec63a68055245fe26633bb7913daf3.zip |
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
Diffstat (limited to 'client/components/cards/events.js')
-rw-r--r-- | client/components/cards/events.js | 285 |
1 files changed, 285 insertions, 0 deletions
diff --git a/client/components/cards/events.js b/client/components/cards/events.js new file mode 100644 index 00000000..9c270e8d --- /dev/null +++ b/client/components/cards/events.js @@ -0,0 +1,285 @@ +// Template.cards.events({ +// // 'click .js-cancel': function(event, t) { +// // var composer = t.$('.card-composer'); + +// // // Keep the old value in memory to display it again next time +// // var inputCacheKey = "addCard-" + this.listId; +// // var oldValue = composer.find('.js-card-title').val(); +// // InputsCache.set(inputCacheKey, oldValue); + +// // // add composer hide class +// // composer.addClass('hide'); +// // composer.find('.js-card-title').val(''); + +// // // remove hide open link class +// // $('.js-open-card-composer').removeClass('hide'); +// // }, +// 'submit': function(evt, tpl) { +// evt.preventDefault(); +// var textarea = $(evt.currentTarget).find('textarea'); +// var title = textarea.val(); +// var lastCard = tpl.find('.js-minicard:last-child'); +// var sort; +// if (lastCard === null) { +// sort = 0; +// } else { +// sort = Blaze.getData(lastCard).sort + 1; +// } +// // debugger + +// // Clear the form in-memory cache +// // var inputCacheKey = "addCard-" + this.listId; +// // InputsCache.set(inputCacheKey, ''); + +// // title trim if not empty then +// if ($.trim(title)) { +// Cards.insert({ +// title: title, +// listId: Template.currentData().listId, +// boardId: Template.currentData().board._id, +// sort: sort +// }, function(err, _id) { +// // In case the filter is active we need to add the newly +// // inserted card in the list of exceptions -- cards that are +// // not filtered. Otherwise the card will disappear instantly. +// // See https://github.com/libreboard/libreboard/issues/80 +// Filter.addException(_id); +// }); + +// // empty and focus. +// textarea.val('').focus(); + +// // focus complete then scroll top +// Utils.Scroll(tpl.find('.js-minicards')).top(1000, true); +// } +// } +// }); + +// Template.cards.events({ +// 'click .member': Popup.open('cardMember') +// }); + +Template.cardMemberPopup.events({ + 'click .js-remove-member': function() { + Cards.update(this.cardId, {$pull: {members: this.userId}}); + Popup.close(); + } +}); + +Template.WindowActivityModule.events({ + 'click .js-new-comment:not(.focus)': function(evt) { + var $this = $(evt.currentTarget); + $this.addClass('focus'); + }, + 'submit #CommentForm': function(evt, t) { + var text = t.$('.js-new-comment-input'); + if ($.trim(text.val())) { + CardComments.insert({ + boardId: this.card.boardId, + cardId: this.card._id, + text: text.val() + }); + text.val(''); + $('.focus').removeClass('focus'); + } + evt.preventDefault(); + } +}); + +Template.WindowSidebarModule.events({ + 'click .js-change-card-members': Popup.open('cardMembers'), + 'click .js-edit-labels': Popup.open('cardLabels'), + 'click .js-archive-card': function(evt) { + // Update + Cards.update(this.card._id, { + $set: { + archived: true + } + }); + evt.preventDefault(); + }, + 'click .js-unarchive-card': function(evt) { + Cards.update(this.card._id, { + $set: { + archived: false + } + }); + evt.preventDefault(); + }, + 'click .js-delete-card': Popup.afterConfirm('cardDelete', function() { + Cards.remove(this.card._id); + + // redirect board + Utils.goBoardId(this.card.board()._id); + Popup.close(); + }), + 'click .js-more-menu': Popup.open('cardMore'), + 'click .js-attach': Popup.open('cardAttachments') +}); + +Template.WindowAttachmentsModule.events({ + 'click .js-attach': Popup.open('cardAttachments'), + 'click .js-confirm-delete': Popup.afterConfirm('attachmentDelete', + function() { + Attachments.remove(this._id); + Popup.close(); + } + ), + // If we let this event bubble, Iron-Router will handle it and empty the + // page content, see #101. + 'click .js-open-viewer, click .js-download': function(event) { + event.stopPropagation(); + }, + 'click .js-add-cover': function() { + Cards.update(this.cardId, { $set: { coverId: this._id } }); + }, + 'click .js-remove-cover': function() { + Cards.update(this.cardId, { $unset: { coverId: '' } }); + } +}); + +Template.cardMembersPopup.events({ + 'click .js-select-member': function(evt) { + var cardId = Template.parentData(2).data._id; + var memberId = this.userId; + var operation; + if (Cards.find({ _id: cardId, members: memberId}).count() === 0) + operation = '$addToSet'; + else + operation = '$pull'; + + var query = {}; + query[operation] = { + members: memberId + }; + Cards.update(cardId, query); + evt.preventDefault(); + } +}); + +Template.cardLabelsPopup.events({ + 'click .js-select-label': function(evt) { + var cardId = Template.parentData(2).data._id; + var labelId = this._id; + var operation; + if (Cards.find({ _id: cardId, labelIds: labelId}).count() === 0) + operation = '$addToSet'; + else + operation = '$pull'; + + var query = {}; + query[operation] = { + labelIds: labelId + }; + Cards.update(cardId, query); + evt.preventDefault(); + }, + 'click .js-edit-label': Popup.open('editLabel'), + 'click .js-add-label': Popup.open('createLabel') +}); + +Template.formLabel.events({ + 'click .js-palette-color': function(evt) { + var $this = $(evt.currentTarget); + + // hide selected ll colors + $('.js-palette-select').addClass('hide'); + + // show select color + $this.find('.js-palette-select').removeClass('hide'); + } +}); + +Template.createLabelPopup.events({ + // Create the new label + 'submit .create-label': function(evt, tpl) { + var name = tpl.$('#labelName').val().trim(); + var boardId = Session.get('currentBoard'); + var selectLabelDom = tpl.$('.js-palette-select:not(.hide)').get(0); + var selectLabel = Blaze.getData(selectLabelDom); + Boards.update(boardId, { + $push: { + labels: { + _id: Random.id(6), + name: name, + color: selectLabel.color + } + } + }); + Popup.back(); + evt.preventDefault(); + } +}); + +Template.editLabelPopup.events({ + 'click .js-delete-label': Popup.afterConfirm('deleteLabel', function() { + var boardId = Session.get('currentBoard'); + Boards.update(boardId, { + $pull: { + labels: { + _id: this._id + } + } + }); + Popup.back(2); + }), + 'submit .edit-label': function(evt, tpl) { + var name = tpl.$('#labelName').val().trim(); + var boardId = Session.get('currentBoard'); + var getLabel = Utils.getLabelIndex(boardId, this._id); + var selectLabelDom = tpl.$('.js-palette-select:not(.hide)').get(0); + var selectLabel = Blaze.getData(selectLabelDom); + var $set = {}; + + // set label index + $set[getLabel.key('name')] = name; + + // set color + $set[getLabel.key('color')] = selectLabel.color; + + // update + Boards.update(boardId, { $set: $set }); + + // return to the previous popup view trigger + Popup.back(); + + evt.preventDefault(); + }, + 'click .js-select-label': function() { + Cards.remove(this.cardId); + + // redirect board + Utils.goBoardId(this.boardId); + } +}); + +Template.cardMorePopup.events({ + 'click .js-delete': Popup.afterConfirm('cardDelete', function() { + Cards.remove(this.card._id); + + // redirect board + Utils.goBoardId(this.card.board()._id); + }) +}); + +Template.cardAttachmentsPopup.events({ + 'change .js-attach-file': function(evt) { + var card = this.card; + FS.Utility.eachFile(evt, function(f) { + var file = new FS.File(f); + + // set Ids + file.boardId = card.boardId; + file.cardId = card._id; + + // upload file + Attachments.insert(file); + + Popup.close(); + }); + }, + 'click .js-computer-upload': function(evt, t) { + t.find('.js-attach-file').click(); + evt.preventDefault(); + } +}); |