users: inline search form on /users index page.

* Add the user search form to the /users page.
* Remove the /users/search page.
This commit is contained in:
evazion
2020-12-21 21:34:01 -06:00
parent 7a2f72ce98
commit 8221c8dcba
6 changed files with 9 additions and 26 deletions

View File

@@ -38,9 +38,6 @@ class UsersController < ApplicationController
respond_with(@users) respond_with(@users)
end end
def search
end
def show def show
@user = authorize User.find(params[:id]) @user = authorize User.find(params[:id])
respond_with(@user, methods: @user.full_attributes) do |format| respond_with(@user, methods: @user.full_attributes) do |format|

View File

@@ -133,7 +133,6 @@
<% end %> <% end %>
<li><%= link_to_wiki "Help", "help:users" %></li> <li><%= link_to_wiki "Help", "help:users" %></li>
<li><%= link_to("Listing", users_path) %></li> <li><%= link_to("Listing", users_path) %></li>
<li><%= link_to("Search", search_users_path) %></li>
<li><%= link_to("Bans", bans_path) %></li> <li><%= link_to("Bans", bans_path) %></li>
<li><%= link_to("Feedback", user_feedbacks_path) %></li> <li><%= link_to("Feedback", user_feedbacks_path) %></li>
<li><%= link_to("Terms of Service", terms_of_service_path) %></li> <li><%= link_to("Terms of Service", terms_of_service_path) %></li>

View File

@@ -1,7 +1,6 @@
<% content_for(:secondary_links) do %> <% content_for(:secondary_links) do %>
<%= quick_search_form_for(:name_matches, users_path, "users", autocomplete: "user", redirect: true) %> <%= quick_search_form_for(:name_matches, users_path, "users", autocomplete: "user", redirect: true) %>
<%= subnav_link_to "Listing", users_path %> <%= subnav_link_to "Listing", users_path %>
<%= subnav_link_to "Search", search_users_path %>
<% if CurrentUser.user.is_anonymous? %> <% if CurrentUser.user.is_anonymous? %>
<%= subnav_link_to "Sign up", new_user_path %> <%= subnav_link_to "Sign up", new_user_path %>

View File

@@ -2,6 +2,15 @@
<div id="a-index"> <div id="a-index">
<h1>Users</h1> <h1>Users</h1>
<%= search_form_for(users_path) do |f| %>
<%= f.input :name_matches, label: "Name", hint: "Use * for wildcard", input_html: { value: params[:search][:name_matches], data: { autocomplete: "user" } } %>
<%= f.input :level, collection: User.level_hash.to_a, include_blank: true, selected: params[:search][:level] %>
<%= f.input :can_upload_free, label: "Contributor?", as: :select, include_blank: true, selected: params[:search][:can_upload_free] %>
<%= f.input :can_approve_posts, label: "Approver?", as: :select, include_blank: true, selected: params[:search][:can_approve_posts] %>
<%= f.input :order, collection: [["Joined", "date"], ["Name", "name"], ["Posts", "post_upload_count"], ["Edits", "post_update_count"], ["Notes", "note_count"]], include_blank: true, selected: params[:search][:order] %>
<%= f.submit "Search" %>
<% end %>
<%= table_for @users, width: "100%" do |t| %> <%= table_for @users, width: "100%" do |t| %>
<% t.column column: "control" do |user| %> <% t.column column: "control" do |user| %>
<% if policy(CurrentUser.user).promote? %> <% if policy(CurrentUser.user).promote? %>

View File

@@ -1,20 +0,0 @@
<div id="c-users">
<div id="a-search">
<%= search_form_for(users_path) do |f| %>
<%= f.input :name_matches, label: "Name", hint: "Use * for wildcard", input_html: { value: params[:search][:name_matches], data: { autocomplete: "user" } } %>
<%= f.input :inviter_name, label: "Inviter Name", hint: "Use * for wildcard", input_html: { value: params.dig(:search, :inviter_name), data: { autocomplete: "user" } } %>
<%= f.input :level, collection: User.level_hash.to_a, include_blank: true, selected: params[:search][:level] %>
<%= f.input :min_level, collection: User.level_hash.to_a, include_blank: true, selected: params[:search][:min_level] %>
<%= f.input :max_level, collection: User.level_hash.to_a, include_blank: true, selected: params[:search][:max_level] %>
<%= f.input :can_upload_free, label: "Unrestricted uploads?", collection: [%w[Yes true], %w[No false]], include_blank: true, selected: params[:search][:can_upload_free] %>
<%= f.input :can_approve_posts, label: "Approver?", collection: [%w[Yes true], %w[No false]], include_blank: true, selected: params[:search][:can_approve_posts] %>
<%= f.input :order, collection: [["Join date", "date"], ["Name", "name"], ["Upload count", "post_upload_count"], ["Note count", "note_count"], ["Post update count", "post_update_count"]], selected: params[:search][:order] %>
<%= f.submit "Search" %>
<% end %>
</div>
</div>
<%= render "secondary_links" %>

View File

@@ -243,7 +243,6 @@ Rails.application.routes.draw do
end end
collection do collection do
get :search
get :custom_style get :custom_style
end end
end end