Merge pull request #1046 from consul/valuator-extra-links
Valuator extra links
This commit is contained in:
@@ -355,3 +355,16 @@ body.admin {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.admin-content .select-geozone {
|
||||
|
||||
a {
|
||||
display: block;
|
||||
|
||||
&.active {
|
||||
color: $brand;
|
||||
font-weight: bold;
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ class Valuation::SpendingProposalsController < Valuation::BaseController
|
||||
load_and_authorize_resource
|
||||
|
||||
def index
|
||||
@geozone_filters = geozone_filters
|
||||
if current_user.valuator?
|
||||
@spending_proposals = SpendingProposal.scoped_filter(params_for_current_valuator, @current_filter).order(created_at: :desc).page(params[:page])
|
||||
else
|
||||
@@ -31,6 +32,26 @@ class Valuation::SpendingProposalsController < Valuation::BaseController
|
||||
|
||||
private
|
||||
|
||||
def geozone_filters
|
||||
|
||||
spending_proposals = SpendingProposal.by_valuator(current_user.valuator.try(:id)).valuation_open.all.to_a
|
||||
|
||||
[ { name: t('valuation.spending_proposals.index.geozone_filter_all'),
|
||||
id: nil,
|
||||
pending_count: spending_proposals.size
|
||||
},
|
||||
{ name: t('geozones.none'),
|
||||
id: 'all',
|
||||
pending_count: spending_proposals.count{|x| x.geozone_id.nil?}
|
||||
}
|
||||
] + Geozone.all.order(name: :asc).collect do |g|
|
||||
{ name: g.name,
|
||||
id: g.id,
|
||||
pending_count: spending_proposals.count{|x| x.geozone_id == g.id}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def valuation_params
|
||||
params[:spending_proposal][:feasible] = nil if params[:spending_proposal][:feasible] == 'nil'
|
||||
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
<h2><%= t("valuation.spending_proposals.index.title") %></h2>
|
||||
|
||||
<div>
|
||||
<%= form_tag valuation_spending_proposals_path, method: :get, enforce_utf8: false do %>
|
||||
<div class="small-12 medium-4 column float-right">
|
||||
<%= select_tag :geozone_id,
|
||||
options_for_select(geozone_select_options.unshift([t("geozones.none"), "all"]), params[:geozone_id]),
|
||||
{ prompt: t("valuation.spending_proposals.index.geozone_filter_all"),
|
||||
label: false,
|
||||
class: "js-submit-on-change" } %>
|
||||
<div class="row collapse">
|
||||
<% @geozone_filters.each_slice(8) do |slice| %>
|
||||
<div class="small-12 medium-4 column select-geozone">
|
||||
<% slice.each do |filter| %>
|
||||
<%= link_to valuation_spending_proposals_path(geozone_id: filter[:id]),
|
||||
class: "#{'active' if params[:geozone_id].to_s == filter[:id].to_s}" do %>
|
||||
<%= filter[:name] %> (<%= filter[:pending_count] %>)
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -38,4 +39,4 @@
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<%= paginate @spending_proposals %>
|
||||
<%= paginate @spending_proposals %>
|
||||
|
||||
@@ -76,17 +76,17 @@ feature 'Valuation spending proposals' do
|
||||
expect(page).to have_link("Realocate visitors")
|
||||
expect(page).to have_link("Destroy the city")
|
||||
|
||||
select "District 9", from: "geozone_id"
|
||||
click_link "District 9", exact: false
|
||||
|
||||
expect(page).to have_link("Realocate visitors")
|
||||
expect(page).to_not have_link("Destroy the city")
|
||||
|
||||
select "All city", from: "geozone_id"
|
||||
click_link "All city", exact: false
|
||||
|
||||
expect(page).to have_link("Destroy the city")
|
||||
expect(page).to_not have_link("Realocate visitors")
|
||||
|
||||
select "All zones", from: "geozone_id"
|
||||
click_link "All zones", exact: false
|
||||
expect(page).to have_link("Realocate visitors")
|
||||
expect(page).to have_link("Destroy the city")
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user