adds filtering of tags for spending proposals
This commit is contained in:
@@ -16,7 +16,7 @@ class Admin::SpendingProposalsController < Admin::BaseController
|
||||
def edit
|
||||
@admins = Administrator.includes(:user).all
|
||||
@valuators = Valuator.includes(:user).all.order("users.username ASC")
|
||||
@tags = ActsAsTaggableOn::Tag.where('taggings.taggable_type' => 'SpendingProposal').includes(:taggings)
|
||||
@tags = ActsAsTaggableOn::Tag.spending_proposal_tags
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
6
app/helpers/spending_proposals_helper.rb
Normal file
6
app/helpers/spending_proposals_helper.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
module SpendingProposalsHelper
|
||||
|
||||
def spending_proposal_tags_select_options
|
||||
ActsAsTaggableOn::Tag.spending_proposal_tags.pluck(:name)
|
||||
end
|
||||
end
|
||||
@@ -35,6 +35,7 @@ class SpendingProposal < ActiveRecord::Base
|
||||
results = self
|
||||
results = results.by_geozone(params[:geozone_id]) if params[:geozone_id].present?
|
||||
results = results.by_administrator(params[:administrator_id]) if params[:administrator_id].present?
|
||||
results = results.by_tag(params[:tag_name]) if params[:tag_name].present?
|
||||
results = results.send(current_filter) if current_filter.present?
|
||||
results.for_render
|
||||
end
|
||||
@@ -51,6 +52,10 @@ class SpendingProposal < ActiveRecord::Base
|
||||
where(administrator_id: administrator.presence)
|
||||
end
|
||||
|
||||
def self.by_tag(tag_name)
|
||||
tagged_with(tag_name)
|
||||
end
|
||||
|
||||
def feasibility
|
||||
case feasible
|
||||
when true
|
||||
|
||||
@@ -2,6 +2,13 @@
|
||||
|
||||
<div>
|
||||
<%= form_tag admin_spending_proposals_path, method: :get, enforce_utf8: false do %>
|
||||
<div class="small-12 medium-4 column float-right">
|
||||
<%= select_tag :tag_name,
|
||||
options_for_select(spending_proposal_tags_select_options, params[:tag_name]),
|
||||
{ prompt: t("admin.spending_proposals.index.tags_filter_all"),
|
||||
label: false,
|
||||
class: "js-submit-on-change" } %>
|
||||
</div>
|
||||
<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]),
|
||||
@@ -25,7 +32,7 @@
|
||||
|
||||
<table>
|
||||
<% @spending_proposals.each do |spending_proposal| %>
|
||||
<tr id="<%= dom_id(spending_proposal) %>">
|
||||
<tr id="<%= dom_id(spending_proposal) %>" class="spending_proposal">
|
||||
<td>
|
||||
<strong><%= spending_proposal.id %></strong>
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user