-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
User page: new following section #1750
Merged
bertocq
merged 17 commits into
consuldemocracy:master
from
rockandror:followable-user-activity
Jul 24, 2017
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
52e195d
Add tab. Add accordion. Add style. Pass test scss-lint.
agileontheweb 7e2e94d
Add following tab to user public page.
taitus 556e259
Remove margin bottom in the table inside accordion. Divided into grou…
agileontheweb b0c571e
Do not display send notification button when proposal is from another…
taitus cef67c5
Increased test coverage to Following user public page.
taitus 36f9836
Use inflector methods instead of manual replacements.
Senen 249641f
Simpler code to get followable object icon.
Senen 16987e7
Easier conditional usage.
Senen 57c8887
Add method to follows helper to get followable partial name and argum…
Senen b7ef755
minor refactoring for follows
voodoorai2000 3be893b
Merge pull request #12 from consul/follows-refactoring
Senen cba497b
Create new followables helper to have some methods previously on foll…
Senen c9a6630
Remove popup on follow buttons and remove uneeded code.
Senen 119a6b3
Remove where clause from followable button partial and rename followa…
Senen 3b13350
Remove uneeded initialization after ajax refresh.
Senen dec7d2d
Add followable specific notices to follows controller actions and ren…
Senen b7bce2e
Remove complex methods from follow model. Create instance method foll…
Senen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
App.Followable = | ||
|
||
initialize: -> | ||
$('.followable-content a[data-toggle]').on 'click', (event) -> | ||
event.preventDefault() | ||
|
||
update: (followable_id, button) -> | ||
update: (followable_id, button, notice) -> | ||
$("#" + followable_id + " .js-follow").html(button) | ||
# Temporary line. Waiting for issue resolution: https://github.com/consul/consul/issues/1736 | ||
initialize_modules() | ||
if ($('[data-alert]').length > 0) | ||
$('[data-alert]').replaceWith(notice) | ||
else | ||
$("body").append(notice) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module FollowablesHelper | ||
|
||
def followable_type_title(followable_type) | ||
t("activerecord.models.#{followable_type.underscore}.other") | ||
end | ||
|
||
def followable_icon(followable) | ||
{ | ||
proposals: 'Proposal', | ||
budget: 'Budget::Investment' | ||
}.invert[followable] | ||
end | ||
|
||
def render_follow(follow) | ||
followable = follow.followable | ||
partial = followable_class_name(followable) | ||
locals = {followable_class_name(followable).to_sym => followable} | ||
|
||
render partial, locals | ||
end | ||
|
||
def followable_class_name(followable) | ||
followable.class.to_s.parameterize.gsub('-', '_') | ||
end | ||
|
||
def find_or_build_follow(user, followable) | ||
Follow.find_or_initialize_by(user: user, followable: followable) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,13 @@ | ||
module FollowsHelper | ||
|
||
def show_follow_action?(followable) | ||
current_user && !followed?(followable) | ||
end | ||
|
||
def show_unfollow_action?(followable) | ||
current_user && followed?(followable) | ||
end | ||
|
||
def follow_entity_text(followable) | ||
entity = followable.class.name.gsub('::', '/').downcase | ||
def follow_text(followable) | ||
entity = followable.class.name.underscore | ||
t('shared.follow_entity', entity: t("activerecord.models.#{entity}.one").downcase) | ||
end | ||
|
||
def follow_entity_title(followable) | ||
entity = followable.class.name.gsub('::', '/').downcase | ||
t('shared.follow_entity_title', entity: t("activerecord.models.#{entity}.one").downcase) | ||
end | ||
|
||
def unfollow_entity_text(followable) | ||
entity = followable.class.name.gsub('::', '/').downcase | ||
def unfollow_text(followable) | ||
entity = followable.class.name.underscore | ||
t('shared.unfollow_entity', entity: t("activerecord.models.#{entity}.one").downcase) | ||
end | ||
|
||
def entity_full_name(followable) | ||
name = followable.class.name | ||
name.downcase.gsub("::", "-") | ||
end | ||
|
||
def follow_link_wrapper_id(followable) | ||
"follow-expand-#{entity_full_name(followable)}-#{followable.id}" | ||
end | ||
|
||
def unfollow_link_wrapper_id(followable) | ||
"unfollow-expand-#{entity_full_name(followable)}-#{followable.id}" | ||
end | ||
|
||
def follow_link_id(followable) | ||
"follow-#{entity_full_name(followable)}-#{followable.id}" | ||
end | ||
|
||
def unfollow_link_id(followable) | ||
"unfollow-#{entity_full_name(followable)}-#{followable.id}" | ||
end | ||
|
||
def follow_drop_id(followable) | ||
"follow-drop-#{entity_full_name(followable)}-#{followable.id}" | ||
end | ||
|
||
def unfollow_drop_id(followable) | ||
"unfollow-drop-#{entity_full_name(followable)}-#{followable.id}" | ||
end | ||
|
||
private | ||
|
||
def followed?(followable) | ||
Follow.followed?(current_user, followable) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,4 +41,4 @@ def current_administrator? | |
current_user && current_user.administrator? | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,7 @@ def initialize(user) | |
can :create, Budget::Investment, budget: { phase: "accepting" } | ||
can :suggest, Budget::Investment, budget: { phase: "accepting" } | ||
can :destroy, Budget::Investment, budget: { phase: ["accepting", "reviewing"] }, author_id: user.id | ||
can :vote, Budget::Investment, budget: { phase: "selecting" } | ||
can :vote, Budget::Investment, budget: { phase: "selecting" } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ^_^ /bertocq likes this |
||
can [:show, :create], Budget::Ballot, budget: { phase: "balloting" } | ||
can [:create, :destroy], Budget::Ballot::Line, budget: { phase: "balloting" } | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<span class="js-follow"> | ||
<span class="followable-content"> | ||
|
||
<% if follow.followable.followed_by?(current_user) %> | ||
|
||
<%= link_to t('shared.unfollow'), | ||
follow_path(follow), | ||
method: :delete, remote: true, | ||
title: unfollow_text(follow.followable), | ||
class: 'button hollow' %> | ||
|
||
<% else %> | ||
|
||
<%= link_to t('shared.follow'), | ||
follows_path(followable_id: follow.followable.id, | ||
followable_type: follow.followable.class.name), | ||
method: :post, remote: true, | ||
title: follow_text(follow.followable), | ||
class: 'button hollow' %> | ||
|
||
<% end %> | ||
|
||
</span> | ||
</span> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
App.Followable.update("<%= dom_id(@followable) %>", | ||
"<%= j render('followable_button', followable: @followable) %>") | ||
App.Followable.update("<%= dom_id(@follow.followable) %>", | ||
"<%= j render('follow_button', follow: @follow) %>", | ||
"<%= j render('layouts/flash') %>") |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't really understand the reason to remove
author_or_admin?
method and its usage, can you explain a bit further? :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bertocq The main reason is that apparently it was not being used anywhere in the application.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 you're right, I did a project search and no use, although sometimes looking for the method string is not enough if you do compose de method name with a string interpolation like
send("#{this}_or_#{that}")
but that's not the case I guess based on the specs passing ^_^Nice catch & cleanup 👏 😄