Admins can search investments by title or ID (#2401)

This commit is contained in:
Angel Perez
2018-01-31 09:47:11 -04:00
parent 45d07fa16f
commit 47c9b343ee
4 changed files with 30 additions and 9 deletions

View File

@@ -35,7 +35,9 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
def update
set_valuation_tags
if @investment.update(budget_investment_params)
redirect_to admin_budget_budget_investment_path(@budget, @investment, Budget::Investment.filter_params(params)),
redirect_to admin_budget_budget_investment_path(@budget,
@investment,
Budget::Investment.filter_params(params)),
notice: t("flash.actions.update.budget_investment")
else
load_admins
@@ -62,9 +64,8 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
end
def load_investments
@investments = if params[:project_title].present?
Budget::Investment.where("title ILIKE ?",
"%#{params[:project_title].strip}%")
@investments = if params[:title_or_id].present?
Budget::Investment.search_by_title_or_id(params)
else
Budget::Investment.scoped_filter(params, @current_filter)
.order(sort_by(params[:sort_by]))
@@ -74,8 +75,8 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
def budget_investment_params
params.require(:budget_investment)
.permit(:title, :description, :external_url, :heading_id, :administrator_id, :tag_list, :valuation_tag_list,
:incompatible, :selected, valuator_ids: [])
.permit(:title, :description, :external_url, :heading_id, :administrator_id, :tag_list,
:valuation_tag_list, :incompatible, :selected, valuator_ids: [])
end
def load_budget