include hide empty option for tag search

This commit is contained in:
albert
2013-02-19 13:33:45 -05:00
parent e7aff87c65
commit bbbb6ceb51
2 changed files with 14 additions and 1 deletions

View File

@@ -400,6 +400,10 @@ class Tag < ActiveRecord::Base
q = q.where("category = ?", params[:category])
end
if params[:hide_empty] == "yes"
q = q.where("post_count > 0")
end
case params[:sort].present?
when "count"
q = q.order("post_count desc")

View File

@@ -1,13 +1,22 @@
<div id="c-tags">
<div id="a-search">
<%= form_tag(tags_path, :method => :get, :class => "simple_form") do %>
<%= search_field "name_matches", :label => "Name" %>
<div class="input">
<label for="search_name">Name</label>
<%= text_field "search", "name_matches" %>
<span class="hint">Use * for wildcard</span>
</div>
<div class="input">
<label for="search_category">Category</label>
<%= select "search", "category", [""] + Danbooru.config.canonical_tag_category_mapping.to_a %>
</div>
<div class="input">
<label for="search_hide_empty">Hide Empty</label>
<%= select "search", "hide_empty", ["no", "yes"] %>
</div>
<div class="input">
<label for="search_sort">Sort</label>
<%= select "search", "sort", %w(name count date) %>