Add search to SDG managed content
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
<%= header %>
|
||||
|
||||
<%= render Admin::SearchComponent.new(label: search_label) %>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
@@ -25,4 +25,8 @@ class SDGManagement::Relations::IndexComponent < ApplicationComponent
|
||||
id: record
|
||||
}
|
||||
end
|
||||
|
||||
def search_label
|
||||
t("admin.shared.search.label.#{model_class.table_name}")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,6 +4,8 @@ class SDGManagement::RelationsController < SDGManagement::BaseController
|
||||
|
||||
def index
|
||||
@records = relatable_class.accessible_by(current_ability).order(:id).page(params[:page])
|
||||
|
||||
@records = @records.search(params[:search]) if params[:search].present?
|
||||
end
|
||||
|
||||
def edit
|
||||
|
||||
@@ -1255,11 +1255,14 @@ en:
|
||||
search:
|
||||
label:
|
||||
booths: "Search booth by name or location"
|
||||
budget_investments: "Search investments by title, description or heading"
|
||||
debates: "Search debates by title or description"
|
||||
legislation_processes: "Search processes by title or description"
|
||||
local_census_records: "Search by document number"
|
||||
organizations: "Name, email or phone number"
|
||||
poll_officers: "Search poll officers"
|
||||
poll_questions: "Search poll questions"
|
||||
polls: "Search polls by name or description"
|
||||
proposals: "Search proposals by title, code, description or question"
|
||||
users: "Search user by name or email"
|
||||
search: "Search"
|
||||
|
||||
@@ -1254,11 +1254,14 @@ es:
|
||||
search:
|
||||
label:
|
||||
booths: "Buscar urna por nombre"
|
||||
budget_investments: "Buscar proyectos por título, descripción o partida"
|
||||
debates: "Buscar debates por título o descripción"
|
||||
legislation_processes: "Buscar procesos por título o descripción"
|
||||
local_census_records: "Búsqueda por número de documento"
|
||||
organizations: "Nombre, email o teléfono"
|
||||
poll_officers: "Buscar presidentes de mesa"
|
||||
poll_questions: "Buscar preguntas"
|
||||
polls: "Buscar votaciones por nombre o descripción"
|
||||
proposals: "Buscar propuestas por título, código, descripción o pregunta"
|
||||
users: "Buscar usuario por nombre o email"
|
||||
search: "Buscar"
|
||||
|
||||
@@ -87,6 +87,19 @@ describe "SDG Relations", :js do
|
||||
|
||||
expect(page).to have_css "h2", exact_text: "Build a hospital"
|
||||
end
|
||||
|
||||
scenario "search" do
|
||||
create(:poll, name: "Internet speech freedom")
|
||||
create(:poll, name: "SDG interest")
|
||||
|
||||
visit sdg_management_polls_path
|
||||
|
||||
fill_in "search", with: "speech"
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content "Internet speech freedom"
|
||||
expect(page).not_to have_content "SDG interest"
|
||||
end
|
||||
end
|
||||
|
||||
describe "Edit" do
|
||||
|
||||
Reference in New Issue
Block a user