Adapt public views for flagging/unflagging investments

This commit is contained in:
Angel Perez
2018-06-13 13:54:18 -04:00
parent bcb0b9fbfa
commit 8ef3e81e03
5 changed files with 215 additions and 163 deletions

View File

@@ -14,6 +14,7 @@ class StatsController < ApplicationController
@debate_votes = daily_cache('debate_votes') { Vote.where(votable_type: 'Debate').count }
@proposal_votes = daily_cache('proposal_votes') { Vote.where(votable_type: 'Proposal').count }
@comment_votes = daily_cache('comment_votes') { Vote.where(votable_type: 'Comment').count }
@investment_votes = daily_cache('budget_investment_votes') { Vote.where(votable_type: 'Budget::Investment').count }
@votes = daily_cache('votes') { Vote.count }
@verified_users = daily_cache('verified_users') { User.with_hidden.level_two_or_three_verified.count }

View File

@@ -0,0 +1,10 @@
<% if can? :hide, investment %>
<%= link_to t("admin.actions.hide").capitalize, hide_moderation_budget_investment_path(investment),
method: :put, remote: true, data: { confirm: t("admin.actions.confirm") } %>
<% end %>
<% if can? :hide, investment.author %>
&nbsp;|&nbsp;
<%= link_to t("admin.actions.hide_author").capitalize, hide_moderation_user_path(investment.author_id),
method: :put, data: { confirm: t("admin.actions.confirm") } %>
<% end %>

View File

@@ -0,0 +1,25 @@
<span class="flag-content">
<% if show_flag_action? investment %>
<a id="flag-expand-investment-<%= investment.id %>" data-toggle="flag-drop-investment-<%= investment.id %>" title="<%= t('shared.flag') %>">
<span class="icon-flag flag-disable"></span>
</a>
<span class="dropdown-pane" id="flag-drop-investment-<%= investment.id %>" data-dropdown data-auto-focus="true">
<%= link_to t('shared.flag'), flag_budget_investment_path(investment.budget, investment.id),
method: :put,
remote: true,
id: "flag-investment-#{ investment.id }" %>
</span>
<% end %>
<% if show_unflag_action? investment %>
<a id="unflag-expand-investment-<%= investment.id %>" data-toggle="unflag-drop-investment-<%= investment.id %>" title="<%= t('shared.unflag') %>">
<span class="icon-flag flag-active"></span>
</a>
<span class="dropdown-pane" id="unflag-drop-investment-<%= investment.id %>" data-dropdown data-auto-focus="true">
<%= link_to t('shared.unflag'), unflag_budget_investment_path(investment.budget, investment.id),
method: :put,
remote: true,
id: "unflag-investment-#{ investment.id }" %>
</span>
<% end %>
</span>

View File

@@ -7,7 +7,12 @@
og_image_url: (investment.image.present? ? investment.image_url(:thumb) : nil) %>
<% end %>
<section class="budget-investment-show" id="<%= dom_id(investment) %>">
<% cache [locale_and_user_status(investment),
investment,
investment.author,
Flag.flagged?(current_user, investment),
@investment_votes] do %>
<section class="budget-investment-show" id="<%= dom_id(investment) %>">
<div class="row">
<div class="small-12 medium-9 column">
@@ -21,6 +26,10 @@
<%= l investment.created_at.to_date %>
<span class="bullet">&nbsp;&bull;&nbsp;</span>
<%= investment.heading.name %>
<span class="bullet">&nbsp;&bull;&nbsp;</span>
<span class="js-flag-actions">
<%= render 'budgets/investments/flag_actions', investment: @investment %>
</span>
</div>
<br>
@@ -76,6 +85,10 @@
<% end %>
<%= render 'relationable/related_content', relationable: @investment %>
<div class="js-moderator-investment-actions margin">
<%= render "budgets/investments/actions", investment: @investment %>
</div>
</div>
<aside class="small-12 medium-3 column">
@@ -130,13 +143,6 @@
</div>
<% end %>
<% else %>
<div class="float-right">
<span class="label-budget-investment float-left">
<%= t("budgets.investments.show.title") %>
</span>
<span class="icon-budget"></span>
</div>
<br>
<% if investment.unfeasible? %>
<div class="callout warning">
<%= t("budgets.investments.show.project_unfeasible_html") %>
@@ -153,6 +159,14 @@
<div class="callout warning">
<%= t("budgets.investments.show.project_not_selected_html") %>
</div>
<% else %>
<br>
<div class="float-right">
<span class="label-budget-investment float-left">
<%= t("budgets.investments.show.title") %>
</span>
<span class="icon-budget"></span>
</div>
<% end %>
<% if investment.should_show_price? %>
<div class="sidebar-divider"></div>
@@ -183,4 +197,5 @@
</aside>
</div>
</section>
</section>
<% end %>

View File

@@ -0,0 +1 @@
App.Flaggable.update("<%= dom_id(@investment) %>", "<%= j render("budgets/investments/flag_actions", investment: @investment) %>")