improve UI

This commit is contained in:
Valery Sizov
2015-03-17 17:11:57 +02:00
parent 1b437ec349
commit 22fcb2f418
5 changed files with 30 additions and 22 deletions
@@ -1,17 +1,17 @@
class @Subscription
constructor: (url) ->
$(".subscribe-button").click (event)=>
$(".subscribe-button").unbind("click").click (event)=>
btn = $(event.currentTarget)
action = btn.prop("value")
current_status = $(".sub_status").text().trim()
$(".fa-spinner.subscription").removeClass("hidden")
$(".sub_status").empty()
action = btn.find("span").text()
current_status = $(".subscription-status").attr("data-status")
btn.prop("disabled", true)
$.post url, =>
$(".fa-spinner.subscription").addClass("hidden")
btn.prop("disabled", false)
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"
btn.prop("value", action)
btn.find("span").text(action)
$(".subscription-status>div").toggleClass("hidden")
@@ -31,11 +31,15 @@
.issuable-context-title
%label
Subscription:
%i.fa.fa-spinner.fa-spin.hidden.subscription
%span.sub_status
= @issue.subscribed?(current_user) ? "subscribed" : "unsubscribed"
- subscribe_action = @issue.subscribed?(current_user) ? "Unsubscribe" : "Subscribe"
%input.btn.subscribe-button{:type => "button", :value => subscribe_action}
%button.btn.btn-block.subscribe-button
%i.fa.fa-eye
%span= @issue.subscribed?(current_user) ? "Unsubscribe" : "Subscribe"
- subscribtion_status = @issue.subscribed?(current_user) ? "subscribed" : "unsubscribed"
.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
$ ->
@@ -33,11 +33,15 @@
.issuable-context-title
%label
Subscription:
%i.fa.fa-spinner.fa-spin.hidden.subscription
%span.sub_status
= @merge_request.subscribed?(current_user) ? "subscribed" : "unsubscribed"
- subscribe_action = @merge_request.subscribed?(current_user) ? "Unsubscribe" : "Subscribe"
%input.btn.subscribe-button{:type => "button", :value => subscribe_action}
%button.btn.btn-block.subscribe-button
%i.fa.fa-eye
%span= @merge_request.subscribed?(current_user) ? "Unsubscribe" : "Subscribe"
- subscribtion_status = @merge_request.subscribed?(current_user) ? "subscribed" : "unsubscribed"
.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
$ ->
+2 -2
View File
@@ -19,12 +19,12 @@ class Spinach::Features::ProjectIssues < Spinach::FeatureSteps
end
step 'I should see that I am subscribed' do
find(".sub_status").text.should == "subscribed"
find(".subscribe-button span").text.should == "Unsubscribe"
end
step 'I should see that I am unsubscribed' do
sleep 0.2
find(".sub_status").text.should == "unsubscribed"
find(".subscribe-button span").text.should == "Subscribe"
end
step 'I click link "Closed"' do
+2 -2
View File
@@ -57,12 +57,12 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
end
step 'I should see that I am subscribed' do
find(".sub_status").text.should == "subscribed"
find(".subscribe-button span").text.should == "Unsubscribe"
end
step 'I should see that I am unsubscribed' do
sleep 0.2
find(".sub_status").text.should == "unsubscribed"
find(".subscribe-button span").text.should == "Subscribe"
end
step 'I click button "Unsubscribe"' do