autocomplete: move artist/pool/wiki autocompletion to autocomplete.js.

* Move all autocomplete code to autocomplete.js.

* Mark autocompleted fields with `data-autocomplete="<type>"` attributes,
  instead of hardcoding input field IDs in the javascript.
This commit is contained in:
evazion
2018-02-18 16:19:32 -06:00
parent a058a77c07
commit 962842815d
12 changed files with 118 additions and 137 deletions

View File

@@ -5,7 +5,7 @@
<div id="search">
<%= form_tag(artist_versions_path, :method => :get, :class => "simple_form") do %>
<%= search_field "updater_name", :label => "User" %>
<%= search_field "name", :label => "Name" %>
<%= search_field "name", :label => "Name", :data => { autocomplete: "artist" } %>
<%= submit_tag "Search" %>
<% end %>
</div>

View File

@@ -1,3 +1,3 @@
<%= form_tag(artists_path, :method => :get) do %>
<%= text_field "search", "name", :id => "quick_search_name", :placeholder => "Search artists" %>
<%= text_field "search", "name", id: "quick_search_name", placeholder: "Search artists", data: { autocomplete: "artist" } %>
<% end %>

View File

@@ -1,5 +1,5 @@
<%= simple_form_for(:search, url: artists_path, method: :get, defaults: { required: false }, html: { class: "inline-form" }) do |f| %>
<%= f.input :name, label: "Name", hint: "Use * for wildcard", input_html: { value: params[:search][:name] } %>
<%= f.input :name, label: "Name", hint: "Use * for wildcard", input_html: { value: params[:search][:name], data: { autocomplete: "artist" }} %>
<%= f.input :url_matches, label: "URL", as: "string", input_html: { value: params[:search][:url_matches] } %>
<%= f.input :creator_name, label: "Creator", input_html: { value: params[:search][:creator_name] } %>
<%= f.input :is_active, label: "Active?", collection: [["Yes", true], ["No", false]], include_blank: true, selected: params[:search][:is_active] %>

View File

@@ -3,7 +3,7 @@
<div class="input">
<label>Pool Name</label>
<span id="pool-name-container"><%= text_field_tag "pool_name", "", :size => 20 %></span>
<span id="pool-name-container"><%= text_field_tag "pool_name", "", :size => 20, :data => { autocomplete: "pool" } %></span>
<span id="pool-name-hint" class="hint">Search for a pool containing (<%= link_to "see full list", all_select_pool_element_path, :remote => true %>)</span>
</div>

View File

@@ -1,3 +1,3 @@
<%= form_tag(pools_path, :method => :get) do %>
<%= text_field "search", "name_matches", :id => "quick_search_name_matches", :placeholder => "Search pools" %>
<%= text_field "search", "name_matches", id: "quick_search_name_matches", placeholder: "Search pools", data: { autocomplete: "pool" } %>
<% end %>

View File

@@ -5,7 +5,7 @@
<th><label for="search_name_matches">Name</label></th>
<td>
<div class="input">
<%= text_field "search", "name_matches", :value => params[:search][:name_matches] %>
<%= text_field "search", "name_matches", :value => params[:search][:name_matches], :data => { autocomplete: "pool" } %>
</div>
</td>
</tr>

View File

@@ -1,3 +1,3 @@
<%= form_tag(wiki_pages_path, :method => :get) do %>
<%= text_field "search", "title", :id => "quick_search_title", :placeholder => "Search wiki pages" %>
<%= text_field "search", "title", id: "quick_search_title", placeholder: "Search wiki pages", data: { autocomplete: "wiki-page" } %>
<% end %>

View File

@@ -1,7 +1,7 @@
<div id="c-wiki-pages">
<div id="a-search">
<%= form_tag(wiki_pages_path, :method => :get, :class => "simple_form") do %>
<%= search_field "title", :hint => "Use * for wildcard searches" %>
<%= search_field "title", :hint => "Use * for wildcard searches", :data => { :autocomplete => "wiki-page" } %>
<%= search_field "creator_name" %>
<%= search_field "body_matches", :label => "Body" %>
<%= search_field "other_names_match", :label => "Other names", :hint => "Use * for wildcard searches" %>