adds unselected investment link

This commit is contained in:
Alberto Garcia Cabeza
2017-05-05 19:07:37 +02:00
parent 98a76a1ae5
commit 6ab6986d9e
5 changed files with 51 additions and 9 deletions

View File

@@ -47,6 +47,7 @@ class Budget
scope :undecided, -> { where(feasibility: "undecided") }
scope :with_supports, -> { where('cached_votes_up > 0') }
scope :selected, -> { where(selected: true) }
scope :unselected, -> { where(selected: false) }
scope :last_week, -> { where("created_at >= ?", 7.days.ago)}
scope :by_group, -> (group_id) { where(group_id: group_id) }
@@ -235,11 +236,15 @@ class Budget
def self.apply_filters_and_search(budget, params)
investments = all
if budget.balloting?
if budget.balloting? && params[:unfeasible].blank? && params[:unselected].blank?
investments = investments.selected
elsif budget.balloting? && params[:unfeasible].blank?
investments = investments.feasible.unselected
else
investments = params[:unfeasible].present? ? investments.unfeasible : investments.not_unfeasible
end
investments = investments.by_heading(params[:heading_id]) if params[:heading_id].present?
investments = investments.search(params[:search]) if params[:search].present?
investments

View File

@@ -13,9 +13,15 @@
<h3><%= t("budgets.groups.show.unfeasible_title") %></h3>
</div>
</div>
<% elsif params[:unselected] %>
<div class="row margin-top">
<div class="small-12 column">
<h3><%= t("budgets.groups.show.unselected_title") %></h3>
</div>
</div>
<% end %>
<div class="row margin-top">
<div class="row margin">
<div id="select-district" class="small-12 medium-7 column select-district">
<div class="row">
<% @group.headings.each_slice(7) do |slice| %>
@@ -25,7 +31,8 @@
class="<%= css_for_ballot_heading(heading) %>">
<%= link_to heading.name,
budget_investments_path(heading_id: heading.id,
unfeasible: params[:unfeasible]),
unfeasible: params[:unfeasible],
unselected: params[:unselected]),
data: { no_turbolink: true } %><br>
</span>
<% end %>
@@ -40,10 +47,19 @@
</div>
<% if params[:unfeasible].blank? %>
<div class="row margin-top">
<div class="row">
<div class="small-12 column">
<small><%= link_to t("budgets.groups.show.unfeasible"),
budget_path(@budget, unfeasible: 1) %></small>
</div>
</div>
<% end %>
<% if params[:unselected].blank? %>
<div class="row">
<div class="small-12 column">
<small><%= link_to t("budgets.groups.show.unselected"),
budget_path(@budget, unselected: 1) %></small>
</div>
</div>
<% end %>

View File

@@ -35,10 +35,12 @@
</div>
</div>
<div class="row margin-top">
<div class="row margin">
<div class="small-12 medium-9 column">
<% if params[:unfeasible] %>
<h3 class="margin-bottom"><%= t("budgets.show.unfeasible_title") %></h3>
<% elsif params[:unselected] %>
<h3 class="margin-bottom"><%= t("budgets.show.unselected_title") %></h3>
<% end %>
<table class="table-fixed">
<thead>
@@ -52,12 +54,14 @@
<%= link_to group.name,
budget_investments_path(@budget,
heading_id: group.headings.first.id,
unfeasible: params[:unfeasible]),
unfeasible: params[:unfeasible],
unselected: params[:unselected]),
data: { no_turbolink: true } %>
<% else %>
<%= link_to group.name,
budget_group_path(@budget, group,
unfeasible: params[:unfeasible]) %>
unfeasible: params[:unfeasible],
unselected: params[:unselected]) %>
<% end %>
<br>
</td>
@@ -69,10 +73,19 @@
</div>
<% unless params[:unfeasible] %>
<div class="row margin-top">
<div class="row">
<div class="small-12 column">
<small><%= link_to t("budgets.show.unfeasible"),
budget_path(@budget, unfeasible: 1) %></small>
</div>
</div>
<% end %>
<% unless params[:unselected] %>
<div class="row">
<div class="small-12 column">
<small><%= link_to t("budgets.show.unselected"),
budget_path(@budget, unselected: 1) %></small>
</div>
</div>
<% end %>