diff --git a/app/views/moderation/users/index.html.erb b/app/views/moderation/users/index.html.erb
index c7fcf502b..9008f8fec 100644
--- a/app/views/moderation/users/index.html.erb
+++ b/app/views/moderation/users/index.html.erb
@@ -1,15 +1,6 @@
<%= t("moderation.users.index.title") %>
-<%= form_for(User.new, url: moderation_users_path, as: :user, method: :get) do |f| %>
-
-
- <%= text_field_tag :name_or_email, "", placeholder: t("moderation.users.index.search_placeholder") %>
-
-
- <%= f.submit t("moderation.users.index.search"), class: "button success" %>
-
-
-<% end %>
+<%= render Admin::SearchComponent.new(label: t("moderation.users.index.search_placeholder")) %>
<% if @users.present? %>
<%= page_entries_info @users %>
diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml
index cf330ae41..6c05bf15c 100644
--- a/config/locales/en/admin.yml
+++ b/config/locales/en/admin.yml
@@ -907,7 +907,6 @@ en:
entry_name: officer
search:
email_placeholder: Search user by email
- search: Search
user_not_found: User not found
help: "To add or remove Poll officers use the search form below."
poll_officer_assignments:
@@ -1170,7 +1169,6 @@ en:
no_organizations: There are no organizations.
reject: Reject
rejected: Rejected
- search: Search
search_placeholder: Name, email or phone number
title: Organisations
verified: Verified
@@ -1255,23 +1253,19 @@ en:
shared:
true_value: "Yes"
false_value: "No"
+ search:
+ search: "Search"
booths_search:
- button: Search
placeholder: Search booth by name or location
poll_officers_search:
- button: Search
placeholder: Search poll officers
poll_questions_search:
- button: Search
placeholder: Search poll questions
proposal_search:
- button: Search
placeholder: Search proposals by title, code, description or question
debate_search:
- button: Search
placeholder: Search debates by title or description
user_search:
- button: Search
placeholder: Search user by name or email
search_results: "Search results"
no_search_results: "No results found."
@@ -1440,7 +1434,6 @@ en:
erased: Erased
search:
placeholder: Search user by email, name or document number
- search: Search
verifications:
index:
phone_not_given: Phone not given
@@ -1581,7 +1574,6 @@ en:
postal_code: Postal code
search:
placeholder: Search by document number
- search: Search
import: Import CSV
new:
creating: Creating new local census record
diff --git a/config/locales/en/moderation.yml b/config/locales/en/moderation.yml
index 01be3e57d..53b2ea64d 100644
--- a/config/locales/en/moderation.yml
+++ b/config/locales/en/moderation.yml
@@ -111,7 +111,6 @@ en:
index:
hidden: Blocked
hide: Block
- search: Search
search_placeholder: email or name of user
title: Block users
notice_hide: User blocked. All of this user's debates and comments have been hidden.
diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml
index 18c87db4b..f970c74f4 100644
--- a/config/locales/es/admin.yml
+++ b/config/locales/es/admin.yml
@@ -906,7 +906,6 @@ es:
entry_name: presidente de mesa
search:
email_placeholder: Buscar usuario por email
- search: Buscar
user_not_found: Usuario no encontrado
help: "Para añadir o eliminar Presidentes de mesa utiliza el buscador a continuación."
poll_officer_assignments:
@@ -1169,7 +1168,6 @@ es:
no_organizations: No hay organizaciones.
reject: Rechazar
rejected: Rechazada
- search: Buscar
search_placeholder: Nombre, email o teléfono
title: Organizaciones
verified: Verificada
@@ -1254,23 +1252,19 @@ es:
shared:
true_value: "Sí"
false_value: "No"
+ search:
+ search: "Buscar"
booths_search:
- button: Buscar
placeholder: Buscar urna por nombre
poll_officers_search:
- button: Buscar
placeholder: Buscar presidentes de mesa
poll_questions_search:
- button: Buscar
placeholder: Buscar preguntas
proposal_search:
- button: Buscar
placeholder: Buscar propuestas por título, código, descripción o pregunta
debate_search:
- button: Buscar
placeholder: Buscar debates por título o descripción
user_search:
- button: Buscar
placeholder: Buscar usuario por nombre o email
search_results: "Resultados de la búsqueda"
no_search_results: "No se han encontrado resultados."
@@ -1439,7 +1433,6 @@ es:
erased: Borrados
search:
placeholder: Buscar usuario por email, nombre o DNI
- search: Buscar
verifications:
index:
phone_not_given: No ha dado su teléfono
@@ -1580,7 +1573,6 @@ es:
postal_code: Código postal
search:
placeholder: Búsqueda por número de documento
- search: Buscar
import: Importar CSV
new:
creating: Creando nuevo registro de censo local
@@ -1605,4 +1597,4 @@ es:
errored: Filas erróneas
created: Registros creados
local_census_records:
- no_records_found: No se han encontrado registros.
\ No newline at end of file
+ no_records_found: No se han encontrado registros.
diff --git a/config/locales/es/moderation.yml b/config/locales/es/moderation.yml
index a31d7b6c5..968c7bfd0 100644
--- a/config/locales/es/moderation.yml
+++ b/config/locales/es/moderation.yml
@@ -111,7 +111,6 @@ es:
index:
hidden: Bloqueado
hide: Bloquear
- search: Buscar
search_placeholder: email o nombre de usuario
title: Bloquear usuarios
notice_hide: Usuario bloqueado. Se han ocultado todos sus debates y comentarios.
diff --git a/spec/controllers/moderation/users_controller_spec.rb b/spec/controllers/moderation/users_controller_spec.rb
index 424e41c8b..1699c9c4e 100644
--- a/spec/controllers/moderation/users_controller_spec.rb
+++ b/spec/controllers/moderation/users_controller_spec.rb
@@ -7,9 +7,9 @@ describe Moderation::UsersController do
it "keeps query parameters while using protected redirects" do
user = create(:user, email: "user@consul.dev")
- get :hide_in_moderation_screen, params: { id: user, name_or_email: "user@consul.dev", host: "evil.dev" }
+ get :hide_in_moderation_screen, params: { id: user, search: "user@consul.dev", host: "evil.dev" }
- expect(response).to redirect_to "/moderation/users?name_or_email=user%40consul.dev"
+ expect(response).to redirect_to "/moderation/users?search=user%40consul.dev"
end
end
end
diff --git a/spec/system/admin/activity_spec.rb b/spec/system/admin/activity_spec.rb
index d83c29d9f..0accba34a 100644
--- a/spec/system/admin/activity_spec.rb
+++ b/spec/system/admin/activity_spec.rb
@@ -223,7 +223,7 @@ describe "Admin activity" do
scenario "Shows moderation activity from moderation screen" do
user = create(:user)
- visit moderation_users_path(name_or_email: user.username)
+ visit moderation_users_path(search: user.username)
within("#moderation_users") do
click_link "Block"
diff --git a/spec/system/admin/administrators_spec.rb b/spec/system/admin/administrators_spec.rb
index a97f5d389..c8da6fc80 100644
--- a/spec/system/admin/administrators_spec.rb
+++ b/spec/system/admin/administrators_spec.rb
@@ -19,7 +19,7 @@ describe "Admin administrators" do
end
scenario "Create Administrator", :js do
- fill_in "name_or_email", with: user.email
+ fill_in "search", with: user.email
click_button "Search"
expect(page).to have_content user.name
@@ -66,7 +66,7 @@ describe "Admin administrators" do
expect(page).to have_content(administrator1.name)
expect(page).to have_content(administrator2.name)
- fill_in "name_or_email", with: " "
+ fill_in "search", with: " "
click_button "Search"
expect(page).to have_content("Administrators: User search")
@@ -79,10 +79,11 @@ describe "Admin administrators" do
expect(page).to have_content(administrator1.name)
expect(page).to have_content(administrator2.name)
- fill_in "name_or_email", with: "Sumn"
+ fill_in "search", with: "Sumn"
click_button "Search"
expect(page).to have_content("Administrators: User search")
+ expect(page).to have_field "search", with: "Sumn"
expect(page).to have_content(administrator1.name)
expect(page).not_to have_content(administrator2.name)
end
@@ -91,10 +92,11 @@ describe "Admin administrators" do
expect(page).to have_content(administrator1.email)
expect(page).to have_content(administrator2.email)
- fill_in "name_or_email", with: administrator2.email
+ fill_in "search", with: administrator2.email
click_button "Search"
expect(page).to have_content("Administrators: User search")
+ expect(page).to have_field "search", with: administrator2.email
expect(page).to have_content(administrator2.email)
expect(page).not_to have_content(administrator1.email)
end
diff --git a/spec/system/admin/managers_spec.rb b/spec/system/admin/managers_spec.rb
index 081152a46..6b46fa15e 100644
--- a/spec/system/admin/managers_spec.rb
+++ b/spec/system/admin/managers_spec.rb
@@ -15,7 +15,7 @@ describe "Admin managers", :admin do
end
scenario "Create Manager", :js do
- fill_in "name_or_email", with: user.email
+ fill_in "search", with: user.email
click_button "Search"
expect(page).to have_content user.name
@@ -47,7 +47,7 @@ describe "Admin managers", :admin do
expect(page).to have_content(manager1.name)
expect(page).to have_content(manager2.name)
- fill_in "name_or_email", with: " "
+ fill_in "search", with: " "
click_button "Search"
expect(page).to have_content("Managers: User search")
@@ -60,10 +60,11 @@ describe "Admin managers", :admin do
expect(page).to have_content(manager1.name)
expect(page).to have_content(manager2.name)
- fill_in "name_or_email", with: "Taylor"
+ fill_in "search", with: "Taylor"
click_button "Search"
expect(page).to have_content("Managers: User search")
+ expect(page).to have_field "search", with: "Taylor"
expect(page).to have_content(manager1.name)
expect(page).not_to have_content(manager2.name)
end
@@ -72,10 +73,11 @@ describe "Admin managers", :admin do
expect(page).to have_content(manager1.email)
expect(page).to have_content(manager2.email)
- fill_in "name_or_email", with: manager2.email
+ fill_in "search", with: manager2.email
click_button "Search"
expect(page).to have_content("Managers: User search")
+ expect(page).to have_field "search", with: manager2.email
expect(page).to have_content(manager2.email)
expect(page).not_to have_content(manager1.email)
end
diff --git a/spec/system/admin/moderators_spec.rb b/spec/system/admin/moderators_spec.rb
index 8ae8c8e58..df1af19b4 100644
--- a/spec/system/admin/moderators_spec.rb
+++ b/spec/system/admin/moderators_spec.rb
@@ -15,7 +15,7 @@ describe "Admin moderators", :admin do
end
scenario "Create Moderator", :js do
- fill_in "name_or_email", with: user.email
+ fill_in "search", with: user.email
click_button "Search"
expect(page).to have_content user.name
@@ -47,7 +47,7 @@ describe "Admin moderators", :admin do
expect(page).to have_content(moderator1.name)
expect(page).to have_content(moderator2.name)
- fill_in "name_or_email", with: " "
+ fill_in "search", with: " "
click_button "Search"
expect(page).to have_content("Moderators: User search")
@@ -60,10 +60,11 @@ describe "Admin moderators", :admin do
expect(page).to have_content(moderator1.name)
expect(page).to have_content(moderator2.name)
- fill_in "name_or_email", with: "Eliz"
+ fill_in "search", with: "Eliz"
click_button "Search"
expect(page).to have_content("Moderators: User search")
+ expect(page).to have_field "search", with: "Eliz"
expect(page).to have_content(moderator1.name)
expect(page).not_to have_content(moderator2.name)
end
@@ -72,10 +73,11 @@ describe "Admin moderators", :admin do
expect(page).to have_content(moderator1.email)
expect(page).to have_content(moderator2.email)
- fill_in "name_or_email", with: moderator2.email
+ fill_in "search", with: moderator2.email
click_button "Search"
expect(page).to have_content("Moderators: User search")
+ expect(page).to have_field "search", with: moderator2.email
expect(page).to have_content(moderator2.email)
expect(page).not_to have_content(moderator1.email)
end
diff --git a/spec/system/admin/officials_spec.rb b/spec/system/admin/officials_spec.rb
index 2b1e18331..2cd86c085 100644
--- a/spec/system/admin/officials_spec.rb
+++ b/spec/system/admin/officials_spec.rb
@@ -38,7 +38,7 @@ describe "Admin officials", :admin do
scenario "Create an official" do
visit admin_officials_path
- fill_in "name_or_email", with: citizen.email
+ fill_in "search", with: citizen.email
click_button "Search"
expect(page).to have_current_path(search_admin_officials_path, ignore_query: true)
diff --git a/spec/system/admin/organizations_spec.rb b/spec/system/admin/organizations_spec.rb
index 86548e846..7f2d400df 100644
--- a/spec/system/admin/organizations_spec.rb
+++ b/spec/system/admin/organizations_spec.rb
@@ -36,7 +36,7 @@ describe "Admin::Organizations" do
visit admin_organizations_path
expect(page).to have_content("Get up, Stand up")
- fill_in "term", with: " "
+ fill_in "search", with: " "
click_button "Search"
expect(page).to have_current_path(search_admin_organizations_path, ignore_query: true)
@@ -49,7 +49,7 @@ describe "Admin::Organizations" do
visit search_admin_organizations_path
expect(page).not_to have_content("Get up, Stand up")
- fill_in "term", with: "Up, sta"
+ fill_in "search", with: "Up, sta"
click_button "Search"
within("#search-results") do
@@ -61,7 +61,7 @@ describe "Admin::Organizations" do
visit search_admin_organizations_path
expect(page).not_to have_content("Get up, Stand up")
- fill_in "term", with: user.email
+ fill_in "search", with: user.email
click_button "Search"
within("#search-results") do
@@ -73,7 +73,7 @@ describe "Admin::Organizations" do
visit search_admin_organizations_path
expect(page).not_to have_content("Get up, Stand up")
- fill_in "term", with: user.phone_number
+ fill_in "search", with: user.phone_number
click_button "Search"
within("#search-results") do
diff --git a/spec/system/admin/poll/officers_spec.rb b/spec/system/admin/poll/officers_spec.rb
index 51d2fd506..cf08b95a0 100644
--- a/spec/system/admin/poll/officers_spec.rb
+++ b/spec/system/admin/poll/officers_spec.rb
@@ -15,7 +15,7 @@ describe "Admin poll officers", :admin do
end
scenario "Create", :js do
- fill_in "email", with: user.email
+ fill_in "search", with: user.email
click_button "Search"
expect(page).to have_content user.name
diff --git a/spec/system/admin/valuators_spec.rb b/spec/system/admin/valuators_spec.rb
index 388da65bd..f5108dd63 100644
--- a/spec/system/admin/valuators_spec.rb
+++ b/spec/system/admin/valuators_spec.rb
@@ -22,7 +22,7 @@ describe "Admin valuators", :admin do
end
scenario "Create", :js do
- fill_in "name_or_email", with: user.email
+ fill_in "search", with: user.email
click_button "Search"
expect(page).to have_content(user.name)
@@ -72,7 +72,7 @@ describe "Admin valuators", :admin do
expect(page).to have_content(valuator1.name)
expect(page).to have_content(valuator2.name)
- fill_in "name_or_email", with: " "
+ fill_in "search", with: " "
click_button "Search"
expect(page).to have_content("Valuators: User search")
@@ -85,10 +85,11 @@ describe "Admin valuators", :admin do
expect(page).to have_content(valuator1.name)
expect(page).to have_content(valuator2.name)
- fill_in "name_or_email", with: "Foster"
+ fill_in "search", with: "Foster"
click_button "Search"
expect(page).to have_content("Valuators: User search")
+ expect(page).to have_field "search", with: "Foster"
expect(page).to have_content(valuator1.name)
expect(page).not_to have_content(valuator2.name)
end
@@ -97,10 +98,11 @@ describe "Admin valuators", :admin do
expect(page).to have_content(valuator1.email)
expect(page).to have_content(valuator2.email)
- fill_in "name_or_email", with: valuator2.email
+ fill_in "search", with: valuator2.email
click_button "Search"
expect(page).to have_content("Valuators: User search")
+ expect(page).to have_field "search", with: valuator2.email
expect(page).to have_content(valuator2.email)
expect(page).not_to have_content(valuator1.email)
end
diff --git a/spec/system/admin/verifications_spec.rb b/spec/system/admin/verifications_spec.rb
index 69bb37fb2..98961a571 100644
--- a/spec/system/admin/verifications_spec.rb
+++ b/spec/system/admin/verifications_spec.rb
@@ -22,7 +22,7 @@ describe "Incomplete verifications", :admin do
visit admin_verifications_path
- fill_in "name_or_email", with: "juan"
+ fill_in "search", with: "juan"
click_button "Search"
expect(page).to have_content("Juan_anonymous")
diff --git a/spec/system/moderation/users_spec.rb b/spec/system/moderation/users_spec.rb
index d05951eae..62a72d59a 100644
--- a/spec/system/moderation/users_spec.rb
+++ b/spec/system/moderation/users_spec.rb
@@ -58,7 +58,7 @@ describe "Moderate users" do
visit moderation_users_path
expect(page).not_to have_content citizen.name
- fill_in "name_or_email", with: "Wanda"
+ fill_in "search", with: "Wanda"
click_button "Search"
within("#moderation_users") do