Files
danbooru/app/views/saved_searches/index.html.erb
2019-09-22 23:38:48 -05:00

61 lines
2.1 KiB
Plaintext

<div id="c-saved-searches">
<div id="a-index">
<h1>
Saved Searches
<% if params[:label] %>
(<%= params[:label] %>)
<% end %>
</h1>
<%= search_form_for(saved_searches_path) do |f| %>
<%= f.input :query_ilike, label: "Query", hint: "Use * for wildcard", input_html: { value: params[:search][:query_ilike] } %>
<%= f.input :label, label: "Label", input_html: { value: params[:search][:label] } %>
<%= f.input :order, collection: [%w[Newest id], %w[Query query], %w[Label label]], include_blank: false, selected: params[:search][:order] %>
<%= f.submit "Search" %>
<% end %>
<table class="striped autofit" width="100%">
<thead>
<tr>
<th data-sort="string">Query</th>
<th data-sort="string">Labels</th>
<th>Posts</th>
<th>Refreshed</th>
<th>Created</th>
<th class="links"></th>
</tr>
</thead>
<tbody>
<% @saved_searches.each do |ss| %>
<tr id="saved-search-<%= ss.id %>">
<td class="col-expand"><%= link_to ss.query, posts_path(tags: ss.query) %></td>
<td>
<% ss.labels.each do |label| %>
<%= link_to label, posts_path(:tags => "search:#{label}") %>
<% end %>
</td>
<td><%= ss.cached_size if ss.cached_size > 0 %></td>
<td>
<% if ss.refreshed_at.present? %>
<%= time_ago_in_words_tagged ss.refreshed_at %>
<% else %>
&gt;<%= SavedSearch::REDIS_EXPIRY.inspect %> ago
<% end %>
</td>
<td><%= time_ago_in_words_tagged ss.created_at %></td>
<td class="links">
<%= link_to "edit", edit_saved_search_path(ss) %>
| <%= link_to "delete", saved_search_path(ss), :method => :delete, :remote => true %>
</td>
</tr>
<% end %>
</tbody>
</table>
<%= numbered_paginator(@saved_searches) %>
</div>
</div>
<%= render "secondary_links" %>