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