Option to set category when first creating a saved search
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
|
||||
if ($("#c-posts").length && $("#a-index").length) {
|
||||
this.initialize_excerpt();
|
||||
this.initialize_saved_searches();
|
||||
}
|
||||
|
||||
if ($("#c-posts").length && $("#a-show").length) {
|
||||
@@ -513,11 +514,19 @@
|
||||
});
|
||||
}
|
||||
|
||||
Danbooru.Post.save_search = function() {
|
||||
$.post(
|
||||
"/saved_searches.js",
|
||||
{"saved_search[tag_query]": $("#tags").val()}
|
||||
);
|
||||
Danbooru.Post.initialize_saved_searches = function() {
|
||||
$("#save-search").click(function() {
|
||||
var input = window.prompt("Category for this saved search (optional):");
|
||||
if (input !== null) {
|
||||
$.post(
|
||||
"/saved_searches.js",
|
||||
{
|
||||
"tags": $("#tags").attr("value"),
|
||||
"category": input
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ class SavedSearchesController < ApplicationController
|
||||
end
|
||||
|
||||
def create
|
||||
@saved_search = saved_searches.create(:tag_query => params[:tags])
|
||||
@saved_search = saved_searches.create(:tag_query => params[:tags], :category => params[:category])
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<% 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 %>
|
||||
<%= button_tag "Save this search", :id => "save-search" %>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
@@ -3,4 +3,5 @@
|
||||
<% 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) %>");
|
||||
Danbooru.Post.initialize_saved_searches();
|
||||
<% end %>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
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) %>");
|
||||
Danbooru.Post.initialize_saved_searches();
|
||||
$("#saved-search-<%= @saved_search.id %>").remove();
|
||||
|
||||
Reference in New Issue
Block a user