implement saved searches, move user boolean settings to bitprefs
This commit is contained in:
9
app/views/saved_searches/_interface.html.erb
Normal file
9
app/views/saved_searches/_interface.html.erb
Normal file
@@ -0,0 +1,9 @@
|
||||
<% if CurrentUser.user.show_saved_searches? %>
|
||||
|
||||
<% if CurrentUser.user.has_saved_searches? && saved_searches.tagged(params[:tags]) %>
|
||||
<%= button_to "Remove this saved search", saved_search_path(saved_searches.tagged(params[:tags]), :tags => params[:tags]), :remote => true, :method => :delete %>
|
||||
<% elsif CurrentUser.user.is_member? %>
|
||||
<%= button_to "Save this search", saved_searches_path(:tags => params[:tags]), :remote => true, :method => :post %>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
6
app/views/saved_searches/create.js.erb
Normal file
6
app/views/saved_searches/create.js.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<% if @saved_search.errors.any? %>
|
||||
Danbooru.error("<%= j @saved_search.errors.full_messages.join(', ') %>");
|
||||
<% else %>
|
||||
Danbooru.notice("Search '<%= j @saved_search.tag_query %>' was saved");
|
||||
$("#saved-searches-nav").html("<%= j render('saved_searches/interface', :saved_searches => CurrentUser.user.saved_searches) %>");
|
||||
<% end %>
|
||||
3
app/views/saved_searches/destroy.js.erb
Normal file
3
app/views/saved_searches/destroy.js.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
Danbooru.notice("Search '<%= j @saved_search.tag_query %>' was deleted");
|
||||
$("#saved-searches-nav").html("<%= j render('saved_searches/interface', :saved_searches => CurrentUser.user.saved_searches) %>");
|
||||
$("#saved-search-<%= @saved_search.id %>").remove();
|
||||
19
app/views/saved_searches/edit.html.erb
Normal file
19
app/views/saved_searches/edit.html.erb
Normal file
@@ -0,0 +1,19 @@
|
||||
<div id="c-saved-searches">
|
||||
<div id="a-edit">
|
||||
<h1>Edit Saved Search</h1>
|
||||
|
||||
<%= error_messages_for :saved_search %>
|
||||
|
||||
<%= simple_form_for(@saved_search) do |f| %>
|
||||
<%= f.input :tag_query %>
|
||||
<%= f.input :category %>
|
||||
<%= f.button :submit %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render "users/secondary_links" %>
|
||||
|
||||
<% content_for(:page_title) do %>
|
||||
Edit Saved Search - <%= Danbooru.config.app_name %>
|
||||
<% end %>
|
||||
34
app/views/saved_searches/index.html.erb
Normal file
34
app/views/saved_searches/index.html.erb
Normal file
@@ -0,0 +1,34 @@
|
||||
<div id="c-saved-searches">
|
||||
<div id="a-index">
|
||||
<h1>Saved Searches</h1>
|
||||
|
||||
<table class="striped" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="80%">Tags</th>
|
||||
<th width="10%">Category</th>
|
||||
<th width="10%"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @saved_searches.each do |saved_search| %>
|
||||
<tr id="saved-search-<%= saved_search.id %>">
|
||||
<td><%= link_to saved_search.tag_query, posts_path(:tags => saved_search.tag_query) %></td>
|
||||
<td><%= saved_search.category %></td>
|
||||
<td>
|
||||
<%= link_to "edit", edit_saved_search_path(saved_search) %> |
|
||||
<%= link_to "delete", saved_search_path(saved_search), :method => :delete, :remote => true %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render "users/secondary_links" %>
|
||||
|
||||
<% content_for(:page_title) do %>
|
||||
Saved Searches - <%= Danbooru.config.app_name %>
|
||||
<% end %>
|
||||
Reference in New Issue
Block a user