Remove popup on follow buttons and remove uneeded code.
This commit is contained in:
@@ -94,7 +94,6 @@ var initialize_modules = function() {
|
||||
App.LegislationAnnotatable.initialize();
|
||||
App.WatchFormChanges.initialize();
|
||||
App.TreeNavigator.initialize();
|
||||
App.Followable.initialize();
|
||||
};
|
||||
|
||||
$(function(){
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
App.Followable =
|
||||
|
||||
initialize: ->
|
||||
$('.followable-content a[data-toggle]').on 'click', (event) ->
|
||||
event.preventDefault()
|
||||
|
||||
update: (followable_id, button) ->
|
||||
$("#" + followable_id + " .js-follow").html(button)
|
||||
# Temporary line. Waiting for issue resolution: https://github.com/consul/consul/issues/1736
|
||||
|
||||
@@ -8,17 +8,8 @@ module FollowablesHelper
|
||||
current_user && followed?(followable)
|
||||
end
|
||||
|
||||
def entity_title(title)
|
||||
t("activerecord.models.#{title.underscore}.other")
|
||||
end
|
||||
|
||||
def followable_full_name(followable)
|
||||
followable.class.name.parameterize
|
||||
end
|
||||
|
||||
def followable_title(followable)
|
||||
entity = followable.class.name.underscore
|
||||
t('shared.followable_title', entity: t("activerecord.models.#{entity}.one").downcase)
|
||||
def followable_type_title(followable_type)
|
||||
t("activerecord.models.#{followable_type.underscore}.other")
|
||||
end
|
||||
|
||||
def followable_icon(followable)
|
||||
|
||||
@@ -10,32 +10,4 @@ module FollowsHelper
|
||||
t('shared.unfollow_entity', entity: t("activerecord.models.#{entity}.one").downcase)
|
||||
end
|
||||
|
||||
def follow_link_wrapper_id(followable)
|
||||
"follow-expand-#{followable_full_name(followable)}-#{followable.id}"
|
||||
end
|
||||
|
||||
def unfollow_link_wrapper_id(followable)
|
||||
"unfollow-expand-#{followable_full_name(followable)}-#{followable.id}"
|
||||
end
|
||||
|
||||
def follow_link_id(followable)
|
||||
"follow-#{followable_full_name(followable)}-#{followable.id}"
|
||||
end
|
||||
|
||||
def unfollow_link_id(followable)
|
||||
"unfollow-#{followable_full_name(followable)}-#{followable.id}"
|
||||
end
|
||||
|
||||
def follow_drop_id(followable)
|
||||
"follow-drop-#{followable_full_name(followable)}-#{followable.id}"
|
||||
end
|
||||
|
||||
def unfollow_drop_id(followable)
|
||||
"unfollow-drop-#{followable_full_name(followable)}-#{followable.id}"
|
||||
end
|
||||
|
||||
def entity_title(title)
|
||||
t("activerecord.models.#{title.underscore}.other")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -3,41 +3,23 @@
|
||||
|
||||
<% if show_follow_action? followable %>
|
||||
|
||||
<%= link_to "##{follow_link_wrapper_id(followable)}",
|
||||
id: follow_link_wrapper_id(followable),
|
||||
title: follow_text(followable),
|
||||
data: { toggle: follow_drop_id(followable) },
|
||||
class: 'button hollow' do %>
|
||||
<%= t('shared.follow') %>
|
||||
<% end %>
|
||||
<div class="dropdown-pane" id="<%= follow_drop_id(followable) %>"
|
||||
data-dropdown data-auto-focus="true">
|
||||
<%= link_to follow_text(followable),
|
||||
<%= link_to t('shared.follow'),
|
||||
follows_path(followable_id: followable.id,
|
||||
followable_type: followable.class.name),
|
||||
method: :post, remote: true,
|
||||
id: follow_link_id(followable) %>
|
||||
</div>
|
||||
title: follow_text(followable),
|
||||
class: 'button hollow' %>
|
||||
|
||||
<% end %>
|
||||
|
||||
<% if show_unfollow_action? followable %>
|
||||
|
||||
<% follow = followable.follows.where(user: current_user).first %>
|
||||
<%= link_to "##{unfollow_link_wrapper_id(followable)}",
|
||||
id: unfollow_link_wrapper_id(followable),
|
||||
title: unfollow_text(followable),
|
||||
data: { toggle: unfollow_drop_id(followable) },
|
||||
class: 'button hollow' do %>
|
||||
<%= t('shared.unfollow') %>
|
||||
<% end %>
|
||||
<div class="dropdown-pane" id="<%= unfollow_drop_id(followable) %>"
|
||||
data-dropdown data-auto-focus="true">
|
||||
<%= link_to unfollow_text(followable),
|
||||
<%= link_to t('shared.unfollow'),
|
||||
follow_path(follow),
|
||||
method: :delete, remote: true,
|
||||
id: unfollow_link_id(followable) %>
|
||||
</div>
|
||||
title: unfollow_text(followable),
|
||||
class: 'button hollow' %>
|
||||
|
||||
<% end %>
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<i class="icon icon-<%= followable_icon(followable_type) %>"></i>
|
||||
</span>
|
||||
<span class="title">
|
||||
<strong><%= entity_title(followable_type) %></strong>
|
||||
<strong><%= followable_type_title(followable_type) %></strong>
|
||||
</span>
|
||||
</a>
|
||||
|
||||
|
||||
@@ -41,16 +41,15 @@ shared_examples "followable" do |followable_class_name, followable_path, followa
|
||||
expect(page).to have_link("Follow")
|
||||
end
|
||||
|
||||
scenario "Should display unfollow button when click on follow button", :js do
|
||||
scenario "Should display unfollow after user clicks on follow button", :js do
|
||||
user = create(:user)
|
||||
login_as(user)
|
||||
|
||||
visit send(followable_path, arguments)
|
||||
within "##{dom_id(followable)}" do
|
||||
click_link "Follow"
|
||||
page.find("#follow-#{followable_dom_name}-#{followable.id}").click
|
||||
|
||||
expect(page).to have_css("#unfollow-expand-#{followable_dom_name}-#{followable.id}")
|
||||
expect(page).to have_link "Unfollow"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -64,7 +63,7 @@ shared_examples "followable" do |followable_class_name, followable_path, followa
|
||||
expect(page).to have_link("Unfollow")
|
||||
end
|
||||
|
||||
scenario "Should display follow button when click on unfollow button", :js do
|
||||
scenario "Should display follow button after user clicks on unfollow button", :js do
|
||||
user = create(:user)
|
||||
follow = create(:follow, user: user, followable: followable)
|
||||
login_as(user)
|
||||
@@ -72,9 +71,8 @@ shared_examples "followable" do |followable_class_name, followable_path, followa
|
||||
visit send(followable_path, arguments)
|
||||
within "##{dom_id(followable)}" do
|
||||
click_link "Unfollow"
|
||||
page.find("#unfollow-#{followable_dom_name}-#{followable.id}").click
|
||||
|
||||
expect(page).to have_css("#follow-expand-#{followable_dom_name}-#{followable.id}")
|
||||
expect(page).to have_link "Follow"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user