app/views/admin/users/_user_search.html.erb
<h2>Search users</h2>
<%= simple_form_for :search, url: admin_users_path, method: "GET", html: { class: 'form' } do |f| %>
<%= f.input :email, as: :string, input_html: {value: params[:search].present? ? params[:search]["email"]: ''} %>
<%= f.submit "Search", class: "btn btn-primary" %>
<%= link_to 'Clear', admin_users_path, class: "btn btn-primary" %>
<% end %>
<div id='search_results'>
<% if @search_users.any? %>
<div class="row mt-4">
<div class="col">
<p>First 50 users with email matching search...</p>
</div>
</div>
<table class="table table-sm table-sorted">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>School or group</th>
<th>Role</th>
<th>Confirmed</th>
<th>Last signed in</th>
<th>Language</th>
<th>Locked?</th>
<th></th>
</tr>
</thead>
<tbody>
<% @search_users.each do |user| %>
<tr class="<%= 'table-danger' if user.access_locked? %>">
<td><%= user.name %></td>
<td><%= user.pupil? ? "N/A" : user.email %></td>
<td>
<% if user.group_admin? %>
<%= link_to user.school_group.name, admin_school_group_path(user.school_group) %>
<% elsif user.school.present? %>
<%= link_to user.school.name, school_users_path(user.school) %>
<% end %>
</td>
<td><%= user.role.titleize %></td>
<td><%= y_n(user.confirmed?) %></td>
<td><%= y_n(user.access_locked?) %></td>
<td data-order="<%=user.last_sign_in_at.iso8601 if user.last_sign_in_at %>"><%= display_last_signed_in_as(user) %></td>
<td><%= I18n.t("languages.#{user.preferred_locale}") %></td>
<td>
<div class="btn-group">
<%= link_to 'Edit', edit_admin_user_path(user), class: 'btn btn-primary btn-sm' %>
<%= link_to 'Delete', admin_user_path(user), method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger btn-sm' %>
<%= button_to 'Resend confirmation', admin_user_confirmation_path(user), class: 'btn btn-warning btn-sm' unless user.confirmed? %>
<%= link_to 'Unlock', admin_user_unlock_path(user_id: user.id), class: 'btn btn-warning btn-sm' if user.access_locked? %>
</div>
</td>
</tr>
<% end %>
</tbody>
</table>
<% elsif params[:search].present? %>
<div class="row mt-4">
<div class="col">
<p>No users found</p>
</div>
</div>
<% end %>
</div>