From d8fb4399cf200be5dc3e97c0c98798442ef6cc48 Mon Sep 17 00:00:00 2001 From: evazion Date: Fri, 21 Apr 2017 19:41:21 -0500 Subject: [PATCH 1/6] /artist_commentaries/search: convert to simple form. --- app/views/artist_commentaries/search.html.erb | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/app/views/artist_commentaries/search.html.erb b/app/views/artist_commentaries/search.html.erb index 4e18c7e00..287441607 100644 --- a/app/views/artist_commentaries/search.html.erb +++ b/app/views/artist_commentaries/search.html.erb @@ -1,21 +1,13 @@
From 0ed0fb095b417b79dfea216e1ed19e67cbe611da Mon Sep 17 00:00:00 2001 From: evazion Date: Fri, 21 Apr 2017 19:42:20 -0500 Subject: [PATCH 2/6] /notes/search: convert to simple form. --- app/views/notes/search.html.erb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/notes/search.html.erb b/app/views/notes/search.html.erb index 5a2174aa7..f70315929 100644 --- a/app/views/notes/search.html.erb +++ b/app/views/notes/search.html.erb @@ -2,13 +2,13 @@ From 2db3af56dddcea5780ffb4bcab83cdd30d983c0c Mon Sep 17 00:00:00 2001 From: evazion Date: Fri, 21 Apr 2017 21:01:37 -0500 Subject: [PATCH 3/6] /tags: convert search form to simple form. --- app/views/tags/_search.html.erb | 73 ++++----------------------------- 1 file changed, 9 insertions(+), 64 deletions(-) diff --git a/app/views/tags/_search.html.erb b/app/views/tags/_search.html.erb index 1fc0ae8c0..0686a75a5 100644 --- a/app/views/tags/_search.html.erb +++ b/app/views/tags/_search.html.erb @@ -1,64 +1,9 @@ - - - <%= form_tag(tags_path, :method => :get, :class => "simple_form") do %> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <% end %> - - +<%= simple_form_for(:search, url: tags_path, method: :get, defaults: { required: false }, html: { class: "inline-form" }) do |f| %> + <%= f.input :name_matches, label: "Name", hint: "Use * for wildcard", input_html: { value: params[:search][:name_matches] } %> + <%= f.input :category, label: "Category", collection: Danbooru.config.canonical_tag_category_mapping.to_a, include_blank: true,selected: params[:search][:category] %> + <%= f.input :order, collection: [%w[Newest date], %w[Count count], %w[Name name]], include_blank: false, selected: params[:search][:order] %> + <%= f.input :hide_empty, label: "Hide empty?", collection: %w[yes no], selected: params[:search][:hide_empty] %> + <%= f.input :has_wiki, label: "Has wiki?", collection: %w[yes no], include_blank: true, selected: params[:search][:has_wiki] %> + <%= f.input :has_artist, label: "Has artist?", collection: %w[yes no], include_blank: true, selected: params[:search][:has_artist] %> + <%= f.submit "Search" %> +<% end %> From 738c14a8a32b81704ffa8d29db6c0122a56f88b5 Mon Sep 17 00:00:00 2001 From: evazion Date: Fri, 21 Apr 2017 21:08:16 -0500 Subject: [PATCH 4/6] /tag_aliases: convert to simple form. --- app/views/tag_aliases/index.html.erb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/views/tag_aliases/index.html.erb b/app/views/tag_aliases/index.html.erb index da6341b75..02e6e4eaf 100644 --- a/app/views/tag_aliases/index.html.erb +++ b/app/views/tag_aliases/index.html.erb @@ -1,11 +1,9 @@
- + <%= simple_form_for(:search, method: :get, url: tag_aliases_path, defaults: { required: false }) do |f| %> + <%= f.input :name_matches, label: "Name", input_html: { value: params[:search][:name_matches] } %> + <%= f.submit "Search" %> + <% end %> <%= render "listing", :tag_aliases => @tag_aliases %> From f403763d8b9dba9afa446d780a8fdead78d5bd9e Mon Sep 17 00:00:00 2001 From: evazion Date: Fri, 21 Apr 2017 21:10:08 -0500 Subject: [PATCH 5/6] /tag_implications: convert to simple form. --- app/views/tag_implications/index.html.erb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/views/tag_implications/index.html.erb b/app/views/tag_implications/index.html.erb index ab0e1d0fe..9a5643dfb 100644 --- a/app/views/tag_implications/index.html.erb +++ b/app/views/tag_implications/index.html.erb @@ -1,11 +1,9 @@
- + <%= simple_form_for(:search, method: :get, url: tag_implications_path, defaults: { required: false }) do |f| %> + <%= f.input :name_matches, label: "Name", input_html: { value: params[:search][:name_matches] } %> + <%= f.submit "Search" %> + <% end %> <%= render "listing", :tag_implications => @tag_implications %> From 4631262374f63476ca56bd3beb9d77bd95bd2912 Mon Sep 17 00:00:00 2001 From: evazion Date: Fri, 21 Apr 2017 19:44:03 -0500 Subject: [PATCH 6/6] Fix broken tag autocomplete on multiple pages. Mark all tag s with a `data-autocomplete` attribute, instead of hardcoding a list of html IDs to autocomplete in javascript. This way should be less error prone. It fixes autocomplete in several places: * Autocomplete for the search box on /posts didn't work in the responsive layout. This was because /posts has two search boxes that both have the id `tags`: one in the normal sidebar, and one in the responsive tag list. $("#tags") only initialized autocomplete on the first one. * Autocomplete didn't work on the aliases or implications pages. This was due to selecting the wrong html ids. --- app/assets/javascripts/autocomplete.js | 14 ++------------ app/views/artist_commentaries/search.html.erb | 2 +- app/views/comments/search.html.erb | 2 +- app/views/meta_searches/tags.html.erb | 4 ++-- app/views/moderator/bulk_reverts/new.html.erb | 6 +++--- app/views/moderator/post/queues/show.html.erb | 2 +- app/views/moderator/tags/edit.html.erb | 4 ++-- app/views/notes/search.html.erb | 2 +- app/views/post_appeals/_search.html.erb | 2 +- app/views/post_flags/_search.html.erb | 2 +- app/views/posts/partials/common/_search.html.erb | 2 +- app/views/posts/partials/index/_edit.html.erb | 2 +- app/views/posts/partials/index/_mode_menu.html.erb | 2 +- app/views/posts/partials/show/_edit.html.erb | 2 +- app/views/related_tags/show.html.erb | 4 ++-- app/views/tag_alias_requests/new.html.erb | 4 ++-- app/views/tag_aliases/index.html.erb | 2 +- app/views/tag_implication_requests/new.html.erb | 4 ++-- app/views/tag_implications/index.html.erb | 2 +- app/views/tags/_quick_search.html.erb | 2 +- app/views/tags/_search.html.erb | 2 +- app/views/uploads/new.html.erb | 2 +- app/views/users/edit.html.erb | 4 ++-- app/views/wiki_pages/_form.html.erb | 4 ++-- 24 files changed, 34 insertions(+), 44 deletions(-) diff --git a/app/assets/javascripts/autocomplete.js b/app/assets/javascripts/autocomplete.js index ee20bd969..efb540955 100644 --- a/app/assets/javascripts/autocomplete.js +++ b/app/assets/javascripts/autocomplete.js @@ -87,18 +87,8 @@ } Danbooru.Autocomplete.initialize_tag_autocomplete = function() { - var $fields_multiple = $( - "#tags,#post_tag_string,#upload_tag_string,#tag-script-field,#c-moderator-post-queues #query," + - "#user_blacklisted_tags,#user_favorite_tags,#search_post_tags_match" - ); - var $fields_single = $( - "#c-tags #search_name_matches,#c-tag-aliases #query,#c-tag-implications #query," + - "#wiki_page_title," + - "#tag_alias_request_antecedent_name,#tag_alias_request_consequent_name," + - "#tag_implication_request_antecedent_name,#tag_implication_request_consequent_name," + - "#tag_alias_antecedent_name,#tag_alias_consequent_name," + - "#tag_implication_antecedent_name,#tag_implication_consequent_name" - ); + var $fields_multiple = $('[data-autocomplete="tag-query"], [data-autocomplete="tag-edit"]'); + var $fields_single = $('[data-autocomplete="tag"]'); var prefixes = "-|~|general:|gen:|artist:|art:|copyright:|copy:|co:|character:|char:|ch:"; var metatags = "order|-status|status|-rating|rating|-locked|locked|child|filetype|-filetype|" + diff --git a/app/views/artist_commentaries/search.html.erb b/app/views/artist_commentaries/search.html.erb index 287441607..9d7b3a8d0 100644 --- a/app/views/artist_commentaries/search.html.erb +++ b/app/views/artist_commentaries/search.html.erb @@ -4,7 +4,7 @@ <%= simple_form_for(:search, url: artist_commentaries_path, method: :get, defaults: { required: false }) do |f| %> <%= f.input :text_matches, label: "Text" %> - <%= f.input :post_tags_match, label: "Tags" %> + <%= f.input :post_tags_match, label: "Tags", input_html: { data: { autocomplete: "tag-query" } } %> <%= f.input :original_present, label: "Original present?", collection: ["yes", "no"], include_blank: true %> <%= f.input :translated_present, label: "Translation present?", collection: ["yes", "no"], include_blank: true %> <%= f.submit "Search" %> diff --git a/app/views/comments/search.html.erb b/app/views/comments/search.html.erb index eab275a4e..7d0fb2c48 100644 --- a/app/views/comments/search.html.erb +++ b/app/views/comments/search.html.erb @@ -6,7 +6,7 @@ <%= hidden_field_tag "group_by", "comment", :id => "group_by_full" %> <%= f.input :creator_name, label: "Commenter" %> <%= f.input :body_matches, label: "Body" %> - <%= f.input :post_tags_match, label: "Tags" %> + <%= f.input :post_tags_match, label: "Tags", input_html: { data: { autocomplete: "tag-query" } } %> <%= f.input :is_deleted, label: "Deleted?", collection: [["Yes", true], ["No", false]] %> <%= f.input :is_sticky, label: "Sticky?", collection: [["Yes", true], ["No", false]] %> <%= f.input :do_not_bump_post, label: "Bumping?", collection: [["Yes", false], ["No", true]] %> diff --git a/app/views/meta_searches/tags.html.erb b/app/views/meta_searches/tags.html.erb index 3423ff1c8..bc227b4f6 100644 --- a/app/views/meta_searches/tags.html.erb +++ b/app/views/meta_searches/tags.html.erb @@ -4,7 +4,7 @@
<%= form_tag(meta_searches_tags_path, :method => :get) do %> - <%= text_field_tag "name", params[:name] %> + <%= text_field_tag "name", params[:name], :data => { :autocomplete => "tag" } %> <%= submit_tag "Go" %> <% end %>
@@ -126,4 +126,4 @@ <% content_for(:page_title) do %> MetaSearch - Tags - <%= Danbooru.config.app_name %> -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/moderator/bulk_reverts/new.html.erb b/app/views/moderator/bulk_reverts/new.html.erb index 2d87e13d0..f0b703187 100644 --- a/app/views/moderator/bulk_reverts/new.html.erb +++ b/app/views/moderator/bulk_reverts/new.html.erb @@ -22,13 +22,13 @@
- <%= text_field :constraints, :added_tags, :value => @constraints[:added_tags] %> + <%= text_field :constraints, :added_tags, :value => @constraints[:added_tags], :data => { :autocomplete => "tag" } %>

You must specify a user to add tags

- <%= text_field :constraints, :removed_tags, :value => @constraints[:removed_tags] %> + <%= text_field :constraints, :removed_tags, :value => @constraints[:removed_tags], :data => { :autocomplete => "tag" } %>

You must specify a user to add tags

@@ -96,4 +96,4 @@ }); }); <% end %> -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/moderator/post/queues/show.html.erb b/app/views/moderator/post/queues/show.html.erb index adecac0b7..d59893763 100644 --- a/app/views/moderator/post/queues/show.html.erb +++ b/app/views/moderator/post/queues/show.html.erb @@ -5,7 +5,7 @@