diff options
author | Rémy Coutable <remy@rymai.me> | 2016-03-01 17:33:13 +0100 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-03-15 18:22:02 +0100 |
commit | 54ec7e959900493b6e9174bf4dfe09ed0afd1e46 (patch) | |
tree | 22b79458e9d5ad2aa8ccf7ae00935c9a14aae33c /app/assets/javascripts/subscription.js.coffee | |
parent | 0444fa560acd07255960284f19b1de6499cd5910 (diff) | |
download | gitlab-ce-54ec7e959900493b6e9174bf4dfe09ed0afd1e46.tar.gz |
Improving the original label-subscribing implementation
1. Make the "subscribed" text in Issuable sidebar reflect the labels
subscription status
2. Current user mut be logged-in to toggle issue/MR/label subscription
Diffstat (limited to 'app/assets/javascripts/subscription.js.coffee')
-rw-r--r-- | app/assets/javascripts/subscription.js.coffee | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/app/assets/javascripts/subscription.js.coffee b/app/assets/javascripts/subscription.js.coffee index afc17338b26..084f0e0dc65 100644 --- a/app/assets/javascripts/subscription.js.coffee +++ b/app/assets/javascripts/subscription.js.coffee @@ -1,19 +1,21 @@ class @Subscription - constructor: (@url, container) -> - @subscribe_button = $(container).find(".subscribe-button") - @subscription_status = $(container).find(".subscription-status") - @subscribe_button.unbind("click").click(@toggleSubscription) + constructor: (container) -> + $container = $(container) + @url = $container.attr('data-url') + @subscribe_button = $container.find('.subscribe-button') + @subscription_status = $container.find('.subscription-status') + @subscribe_button.unbind('click').click(@toggleSubscription) toggleSubscription: (event) => btn = $(event.currentTarget) - action = btn.find("span").text() - current_status = @subscription_status.attr("data-status") - btn.prop("disabled", true) + action = btn.find('span').text() + current_status = @subscription_status.attr('data-status') + btn.prop('disabled', true) $.post @url, => - btn.prop("disabled", false) - status = if current_status == "subscribed" then "unsubscribed" else "subscribed" - @subscription_status.attr("data-status", status) - action = if status == "subscribed" then "Unsubscribe" else "Subscribe" - btn.find("span").text(action) - @subscription_status.find(">div").toggleClass("hidden") + btn.prop('disabled', false) + status = if current_status == 'subscribed' then 'unsubscribed' else 'subscribed' + @subscription_status.attr('data-status', status) + action = if status == 'subscribed' then 'Unsubscribe' else 'Subscribe' + btn.find('span').text(action) + @subscription_status.find('>div').toggleClass('hidden') |