Commit 22fcb2f4 authored by Valery Sizov's avatar Valery Sizov

improve UI

parent 1b437ec3
class @Subscription class @Subscription
constructor: (url) -> constructor: (url) ->
$(".subscribe-button").click (event)=> $(".subscribe-button").unbind("click").click (event)=>
btn = $(event.currentTarget) btn = $(event.currentTarget)
action = btn.prop("value") action = btn.find("span").text()
current_status = $(".sub_status").text().trim() current_status = $(".subscription-status").attr("data-status")
$(".fa-spinner.subscription").removeClass("hidden") btn.prop("disabled", true)
$(".sub_status").empty()
$.post url, => $.post url, =>
$(".fa-spinner.subscription").addClass("hidden") btn.prop("disabled", false)
status = if current_status == "subscribed" then "unsubscribed" else "subscribed" status = if current_status == "subscribed" then "unsubscribed" else "subscribed"
$(".sub_status").text(status) $(".subscription-status").attr("data-status", status)
action = if status == "subscribed" then "Unsubscribe" else "Subscribe" action = if status == "subscribed" then "Unsubscribe" else "Subscribe"
btn.prop("value", action) btn.find("span").text(action)
$(".subscription-status>div").toggleClass("hidden")
...@@ -31,11 +31,15 @@ ...@@ -31,11 +31,15 @@
.issuable-context-title .issuable-context-title
%label %label
Subscription: Subscription:
%i.fa.fa-spinner.fa-spin.hidden.subscription %button.btn.btn-block.subscribe-button
%span.sub_status %i.fa.fa-eye
= @issue.subscribed?(current_user) ? "subscribed" : "unsubscribed" %span= @issue.subscribed?(current_user) ? "Unsubscribe" : "Subscribe"
- subscribe_action = @issue.subscribed?(current_user) ? "Unsubscribe" : "Subscribe" - subscribtion_status = @issue.subscribed?(current_user) ? "subscribed" : "unsubscribed"
%input.btn.subscribe-button{:type => "button", :value => subscribe_action} .subscription-status{"data-status" => subscribtion_status}
.description-block.unsubscribed{class: ( "hidden" if @issue.subscribed?(current_user) )}
You're not receiving notifications from this thread.
.description-block.subscribed{class: ( "hidden" unless @issue.subscribed?(current_user) )}
You're receiving notifications because you're subscribed to this thread.
:coffeescript :coffeescript
$ -> $ ->
......
...@@ -33,11 +33,15 @@ ...@@ -33,11 +33,15 @@
.issuable-context-title .issuable-context-title
%label %label
Subscription: Subscription:
%i.fa.fa-spinner.fa-spin.hidden.subscription %button.btn.btn-block.subscribe-button
%span.sub_status %i.fa.fa-eye
= @merge_request.subscribed?(current_user) ? "subscribed" : "unsubscribed" %span= @merge_request.subscribed?(current_user) ? "Unsubscribe" : "Subscribe"
- subscribe_action = @merge_request.subscribed?(current_user) ? "Unsubscribe" : "Subscribe" - subscribtion_status = @merge_request.subscribed?(current_user) ? "subscribed" : "unsubscribed"
%input.btn.subscribe-button{:type => "button", :value => subscribe_action} .subscription-status{"data-status" => subscribtion_status}
.description-block.unsubscribed{class: ( "hidden" if @merge_request.subscribed?(current_user) )}
You're not receiving notifications from this thread.
.description-block.subscribed{class: ( "hidden" unless @merge_request.subscribed?(current_user) )}
You're receiving notifications because you're subscribed to this thread.
:coffeescript :coffeescript
$ -> $ ->
......
...@@ -19,12 +19,12 @@ class Spinach::Features::ProjectIssues < Spinach::FeatureSteps ...@@ -19,12 +19,12 @@ class Spinach::Features::ProjectIssues < Spinach::FeatureSteps
end end
step 'I should see that I am subscribed' do step 'I should see that I am subscribed' do
find(".sub_status").text.should == "subscribed" find(".subscribe-button span").text.should == "Unsubscribe"
end end
step 'I should see that I am unsubscribed' do step 'I should see that I am unsubscribed' do
sleep 0.2 sleep 0.2
find(".sub_status").text.should == "unsubscribed" find(".subscribe-button span").text.should == "Subscribe"
end end
step 'I click link "Closed"' do step 'I click link "Closed"' do
......
...@@ -57,12 +57,12 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps ...@@ -57,12 +57,12 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
end end
step 'I should see that I am subscribed' do step 'I should see that I am subscribed' do
find(".sub_status").text.should == "subscribed" find(".subscribe-button span").text.should == "Unsubscribe"
end end
step 'I should see that I am unsubscribed' do step 'I should see that I am unsubscribed' do
sleep 0.2 sleep 0.2
find(".sub_status").text.should == "unsubscribed" find(".subscribe-button span").text.should == "Subscribe"
end end
step 'I click button "Unsubscribe"' do step 'I click button "Unsubscribe"' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment