summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFatih Acet <acetfatih@gmail.com>2016-05-24 03:10:38 +0300
committerFatih Acet <acetfatih@gmail.com>2016-05-24 03:10:38 +0300
commit1d7c3c79b1060e62ee1aa8a0e173334bb9180706 (patch)
treeb8530ec7cd78c4602cd35572dfeb2ec1e0bbb82c
parent5b046f8571ba360ec7b87d01db7b0933ab4388bf (diff)
downloadgitlab-ce-1d7c3c79b1060e62ee1aa8a0e173334bb9180706.tar.gz
Handle thumbsup and thumbsdown mutuality.
-rw-r--r--app/assets/javascripts/awards_handler.coffee8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/assets/javascripts/awards_handler.coffee b/app/assets/javascripts/awards_handler.coffee
index 0ab3796118e..7235ec57851 100644
--- a/app/assets/javascripts/awards_handler.coffee
+++ b/app/assets/javascripts/awards_handler.coffee
@@ -24,6 +24,7 @@ class @AwardsHandler
handleClick: (e) =>
e.preventDefault()
+
$emojiBtn = $(e.currentTarget)
$addAwardBtn = $('.js-add-award.is-active')
$votesBlock = $($addAwardBtn.closest('.js-award-holder').data('target'))
@@ -36,6 +37,13 @@ class @AwardsHandler
$votesBlock.addClass 'js-awards-block'
awardUrl = $votesBlock.data 'award-url'
emoji = $emojiBtn.find('.icon').data('emoji')
+
+ if emoji in [ 'thumbsup', 'thumbsdown' ]
+ mutualVote = if emoji is 'thumbsup' then 'thumbsdown' else 'thumbsup'
+
+ isAlreadyVoted = $("[data-emoji=#{mutualVote}]").parent().hasClass 'active'
+ @addAward awardUrl, mutualVote if isAlreadyVoted
+
@addAward awardUrl, emoji