Adapt public views for flagging/unflagging investments
This commit is contained in:
@@ -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 }
|
||||
|
||||
10
app/views/budgets/investments/_actions.html.erb
Normal file
10
app/views/budgets/investments/_actions.html.erb
Normal 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 %>
|
||||
|
|
||||
<%= link_to t("admin.actions.hide_author").capitalize, hide_moderation_user_path(investment.author_id),
|
||||
method: :put, data: { confirm: t("admin.actions.confirm") } %>
|
||||
<% end %>
|
||||
25
app/views/budgets/investments/_flag_actions.html.erb
Normal file
25
app/views/budgets/investments/_flag_actions.html.erb
Normal 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>
|
||||
@@ -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"> • </span>
|
||||
<%= investment.heading.name %>
|
||||
<span class="bullet"> • </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 %>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
App.Flaggable.update("<%= dom_id(@investment) %>", "<%= j render("budgets/investments/flag_actions", investment: @investment) %>")
|
||||
Reference in New Issue
Block a user