diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6ef59fb60..2346a2017 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,5 +1,5 @@ class UsersController < ApplicationController - has_filters %w{proposals debates budget_investments comments}, only: :show + has_filters %w{proposals debates budget_investments comments follows}, only: :show load_and_authorize_resource helper_method :author? @@ -17,7 +17,8 @@ class UsersController < ApplicationController proposals: Proposal.where(author_id: @user.id).count, debates: (Setting['feature.debates'] ? Debate.where(author_id: @user.id).count : 0), budget_investments: (Setting['feature.budgets'] ? Budget::Investment.where(author_id: @user.id).count : 0), - comments: only_active_commentables.count) + comments: only_active_commentables.count, + follows: @user.follows.count) end def load_filtered_activity @@ -26,7 +27,8 @@ class UsersController < ApplicationController when "proposals" then load_proposals when "debates" then load_debates when "budget_investments" then load_budget_investments - when "comments" then load_comments + when "comments" then load_comments + when "follows" then load_follows else load_available_activity end end @@ -44,6 +46,9 @@ class UsersController < ApplicationController elsif @activity_counts[:comments] > 0 load_comments @current_filter = "comments" + elsif @activity_counts[:follows] > 0 + load_follows + @current_filter = "follows" end end @@ -63,8 +68,9 @@ class UsersController < ApplicationController @budget_investments = Budget::Investment.where(author_id: @user.id).order(created_at: :desc).page(params[:page]) end - def load_interests - @user.interests + def load_follows + @followable_types = @user.follows.pluck(:followable_type).uniq + @follows = @user.follows end def valid_access? diff --git a/app/helpers/follows_helper.rb b/app/helpers/follows_helper.rb index 63f50f7be..60ee0141f 100644 --- a/app/helpers/follows_helper.rb +++ b/app/helpers/follows_helper.rb @@ -52,6 +52,18 @@ module FollowsHelper "unfollow-drop-#{entity_full_name(followable)}-#{followable.id}" end + def entity_title(title) + entity = title.gsub('::', '/').downcase + t("activerecord.models.#{entity}.other") + end + + def entity_icon(entity) + case entity + when "Proposal" then "proposals" + when "Budget::Investment" then "budget" + end + end + private def followed?(followable) diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 9c13e8ef8..968fa6e66 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -41,4 +41,4 @@ module UsersHelper current_user && current_user.administrator? end -end \ No newline at end of file +end diff --git a/app/views/users/_activity_page.html.erb b/app/views/users/_activity_page.html.erb index 455d30f50..bbea17ae6 100644 --- a/app/views/users/_activity_page.html.erb +++ b/app/views/users/_activity_page.html.erb @@ -1,4 +1,4 @@ -<%= render "following" %> +<%= render "following" if @follows.present? %> <%= render "proposals" if @proposals.present? %> <%= render "debates" if @debates.present? && feature?(:debates) %> <%= render "budget_investments" if @budget_investments.present? && feature?(:budgets) %> diff --git a/app/views/users/_budget_investment.html.erb b/app/views/users/_budget_investment.html.erb new file mode 100644 index 000000000..774fae777 --- /dev/null +++ b/app/views/users/_budget_investment.html.erb @@ -0,0 +1,11 @@ +
| - <%= link_to budget_investment.title, budget_investment_path(budget_investment.budget, budget_investment) %> - | -- <% 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 %> - | -
|
- <%= link_to "add translation", nil %>
- - This is longer content Donec id elit non mi porta gravida at eget metus. - |
-
|
- <%= link_to proposal.title, proposal, proposal.retired? ? {class: 'retired'} : {} %>
- - <%= proposal.summary %> - |
-
- <% if author? %>
- - <%= link_to t("users.proposals.send_notification"), new_proposal_notification_path(proposal_id: proposal.id), - class: 'button hollow' %> - | - -- <% if proposal.retired? %> - <%= t('users.proposals.retired') %> - <% else %> - <%= link_to t('users.proposals.retire'), - retire_form_proposal_path(proposal), - class: 'button hollow alert' %> - <% end %> - | - <% end %> - -