-
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
Changes from 11 commits
52e195d
7e2e94d
556e259
b0c571e
cef67c5
36f9836
249641f
16987e7
57c8887
b7ef755
3be893b
cba497b
c9a6630
119a6b3
3b13350
dec7d2d
b7bce2e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,23 +9,22 @@ def show_unfollow_action?(followable) | |
end | ||
|
||
def follow_entity_text(followable) | ||
entity = followable.class.name.gsub('::', '/').downcase | ||
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. 👏 nice cleaning up on the side! 💪 |
||
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 | ||
entity = followable.class.name.underscore | ||
t('shared.follow_entity_title', entity: t("activerecord.models.#{entity}.one").downcase) | ||
end | ||
|
||
def unfollow_entity_text(followable) | ||
entity = followable.class.name.gsub('::', '/').downcase | ||
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("::", "-") | ||
followable.class.name.parameterize | ||
end | ||
|
||
def follow_link_wrapper_id(followable) | ||
|
@@ -52,6 +51,29 @@ def unfollow_drop_id(followable) | |
"unfollow-drop-#{entity_full_name(followable)}-#{followable.id}" | ||
end | ||
|
||
def entity_title(title) | ||
t("activerecord.models.#{title.underscore}.other") | ||
end | ||
|
||
def entity_icon(entity) | ||
{ | ||
proposals: 'Proposal', | ||
budget: 'Budget::Investment' | ||
}.invert[entity] | ||
end | ||
|
||
def entity_class_name(followable) | ||
followable.class.to_s.parameterize.gsub('-','_') | ||
end | ||
|
||
def render_follow(follow) | ||
followable = follow.followable | ||
partial = entity_class_name(followable) | ||
locals = {entity_class_name(followable).to_sym => followable} | ||
|
||
render partial, locals | ||
end | ||
|
||
private | ||
|
||
def followed?(followable) | ||
|
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 |
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" } | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<tr id="budget_investment_<%= budget_investment.id %>"> | ||
<td> | ||
<%= link_to budget_investment.title, budget_investment_path(budget_investment.budget, budget_investment) %> | ||
</td> | ||
<td class="text-right"> | ||
<% if can? :destroy, budget_investment %> | ||
<%= link_to t('shared.delete'), budget_investment_path(budget_investment.budget, budget_investment), | ||
method: :delete, class: "button hollow alert" %> | ||
<% end %> | ||
</td> | ||
</tr> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<ul class="accordion" data-accordion data-allow-all-closed="true"> | ||
|
||
<% @follows.each do |followable_type, follows| %> | ||
|
||
<li class="accordion-item" data-accordion-item> | ||
|
||
<a href="#" class="accordion-title"> | ||
<span class="icon"> | ||
<i class="icon icon-<%= entity_icon(followable_type) %>"></i> | ||
</span> | ||
<span class="title"> | ||
<strong><%= entity_title(followable_type) %></strong> | ||
</span> | ||
</a> | ||
|
||
<div class="accordion-content" data-tab-content> | ||
<table> | ||
<tbody> | ||
<% follows.each do |follow| %> | ||
<%= render_follow(follow) %> | ||
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. @voodoorai2000 nice refactor! 😍 |
||
<% end %> | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
</li> | ||
|
||
<% end %> | ||
|
||
</ul> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<tr id="proposal_<%= proposal.id %>"> | ||
<td> | ||
<%= link_to proposal.title, proposal, proposal.retired? ? { class: 'retired' } : {} %> | ||
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. I like that |
||
<br> | ||
<%= proposal.summary %> | ||
</td> | ||
|
||
<% if proposal.retired? %> | ||
|
||
<td class="text-center"> | ||
<span class="label alert"><%= t('users.proposals.retired') %></span> | ||
</td> | ||
|
||
<% elsif author?(proposal) %> | ||
|
||
<td class="text-center"> | ||
<%= link_to t("users.proposals.send_notification"), | ||
new_proposal_notification_path(proposal_id: proposal.id), | ||
class: 'button hollow' %> | ||
</td> | ||
|
||
<td class="text-center"> | ||
<% if proposal.retired? %> | ||
<span class="label alert"><%= t('users.proposals.retired') %></span> | ||
<% else %> | ||
<%= link_to t('users.proposals.retire'), | ||
retire_form_proposal_path(proposal), | ||
class: 'button hollow alert' %> | ||
<% end %> | ||
</td> | ||
|
||
<% end %> | ||
|
||
</tr> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,7 @@ | |
<p><%= t('users.show.private_activity') %></p> | ||
<% end %> | ||
|
||
<% if @user.public_interests || @authorized_current_user %> | ||
<% if valid_interests_access? %> | ||
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. Nice catch! |
||
<div id="public_interests" class="public-interests"> | ||
<h4><%= t('account.show.public_interests_title_list') %></h4> | ||
<% @user.interests.in_groups_of(10, false) do |interests_group| %> | ||
|
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 👏 😄