diff --git a/app/controllers/modules/users_filter.rb b/app/controllers/modules/users_filter.rb
index 1b6ba4c53..7d2c78e5f 100644
--- a/app/controllers/modules/users_filter.rb
+++ b/app/controllers/modules/users_filter.rb
@@ -1,6 +1,6 @@
module Modules::UsersFilter
def filtered_users(base_collection)
- search_param = params["search-field"]
+ search_param = params["search"]
if search_param.present?
base_collection.search_by(search_param)
else
diff --git a/app/controllers/organisations_controller.rb b/app/controllers/organisations_controller.rb
index 40f49ea9b..387ab035f 100644
--- a/app/controllers/organisations_controller.rb
+++ b/app/controllers/organisations_controller.rb
@@ -19,7 +19,7 @@ class OrganisationsController < ApplicationController
def users
@pagy, @users = pagy(filtered_users(@organisation.users))
- @searched = params["search-field"].presence
+ @searched = params["search"].presence
render "users/index"
end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 102e9b464..2b576d187 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -11,7 +11,7 @@ class UsersController < ApplicationController
redirect_to users_organisation_path(current_user.organisation) unless current_user.support?
@pagy, @users = pagy(filtered_users(User.all))
- @searched = params["search-field"].presence
+ @searched = params["search"].presence
respond_to do |format|
format.html
diff --git a/app/views/users/_user_list.html.erb b/app/views/users/_user_list.html.erb
new file mode 100644
index 000000000..f1719b15c
--- /dev/null
+++ b/app/views/users/_user_list.html.erb
@@ -0,0 +1,54 @@
+<%= govuk_table do |table| %>
+ <%= table.caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %>
+
+ <% if searched %>
+ <% item_label = pagy.count > 1 ? "users" : "user" %>
+ <%= pagy.count %> <%= item_label %> found matching ‘<%= searched %>’ of <%= User.count %> total users. <%= govuk_link_to("Clear search", request.path) %>
+ <% else %>
+ <%= pagy.count %> total users.
+ <% end %>
+
+ <% if current_user.support? %>
+ <%= govuk_link_to "Download (CSV)", "/users.csv", type: "text/csv" %>
+ <% end %>
+ <% end %>
+ <%= table.head do |head| %>
+ <%= head.row do |row| %>
+ <% row.cell(header: true, text: "Name and email adress", html_attributes: {
+ scope: "col",
+ }) %>
+ <% row.cell(header: true, text: "Organisation and role", html_attributes: {
+ scope: "col",
+ }) %>
+ <% row.cell(header: true, text: "Last logged in", html_attributes: {
+ scope: "col",
+ }) %>
+ <% end %>
+ <% end %>
+ <% users.each do |user| %>
+ <%= table.body do |body| %>
+ <%= body.row do |row| %>
+ <% row.cell(header: true, html_attributes: {
+ scope: "row",
+ }) do %>
+ <%= simple_format(user_cell(user), {}, wrapper_tag: "span") %>
+ <% if user.is_data_protection_officer? || user.is_key_contact? %>
+
+ <% end %>
+ <%= user.is_data_protection_officer? ? govuk_tag(
+ classes: "app-tag--small",
+ colour: "turquoise",
+ text: "Data protection officer",
+ ) : "" %>
+ <%= user.is_key_contact? ? govuk_tag(
+ classes: "app-tag--small",
+ colour: "turquoise",
+ text: "Key contact",
+ ) : "" %>
+ <% end %>
+ <% row.cell(text: simple_format(org_cell(user), {}, wrapper_tag: "div")) %>
+ <% row.cell(text: user.last_sign_in_at&.to_formatted_s(:govuk_date)) %>
+ <% end %>
+ <% end %>
+ <% end %>
+<% end %>
diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb
index 692a9deeb..752f1e52c 100644
--- a/app/views/users/index.html.erb
+++ b/app/views/users/index.html.erb
@@ -1,4 +1,5 @@
-<% content_for :title, "Your organisation (Users)" %>
+<% title = "Your organisation (Users)" %>
+<% content_for :title, title %>
<% content_for :tab_title do %>
<%= "Users" %>
@@ -10,58 +11,5 @@
<%= render SearchComponent.new(current_user:, search_label: "Search by name or email address", value: @searched) %>
-<%= govuk_table do |table| %>
- <%= table.caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %>
-
- <% if @searched %>
- <% item_label = @pagy.count > 1 ? "users" : "user" %>
- <%= @pagy.count %> <%= item_label %> found matching ‘<%= @searched %>’ of <%= User.count %> total users. <%= govuk_link_to("Clear search", request.path) %>
- <% else %>
- <%= @pagy.count %> total users.
- <% end %>
-
- <% if current_user.support? %>
- <%= govuk_link_to "Download (CSV)", "/users.csv", type: "text/csv" %>
- <% end %>
- <% end %>
- <%= table.head do |head| %>
- <%= head.row do |row| %>
- <% row.cell(header: true, text: "Name and email adress", html_attributes: {
- scope: "col",
- }) %>
- <% row.cell(header: true, text: "Organisation and role", html_attributes: {
- scope: "col",
- }) %>
- <% row.cell(header: true, text: "Last logged in", html_attributes: {
- scope: "col",
- }) %>
- <% end %>
- <% end %>
- <% @users.each do |user| %>
- <%= table.body do |body| %>
- <%= body.row do |row| %>
- <% row.cell(header: true, html_attributes: {
- scope: "row",
- }) do %>
- <%= simple_format(user_cell(user), {}, wrapper_tag: "span") %>
- <% if user.is_data_protection_officer? || user.is_key_contact? %>
-
- <% end %>
- <%= user.is_data_protection_officer? ? govuk_tag(
- classes: "app-tag--small",
- colour: "turquoise",
- text: "Data protection officer",
- ) : "" %>
- <%= user.is_key_contact? ? govuk_tag(
- classes: "app-tag--small",
- colour: "turquoise",
- text: "Key contact",
- ) : "" %>
- <% end %>
- <% row.cell(text: simple_format(org_cell(user), {}, wrapper_tag: "div")) %>
- <% row.cell(text: user.last_sign_in_at&.to_formatted_s(:govuk_date)) %>
- <% end %>
- <% end %>
- <% end %>
-<% end %>
+<%= render partial: "user_list", locals: { users: @users, title:, pagy: @pagy, searched: @searched } %>
<%== render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "users" } %>