fixes #1754; include category in wiki page api
This commit is contained in:
@@ -9,7 +9,9 @@
|
|||||||
|
|
||||||
Danbooru.WikiPage.initialize_typeahead = function() {
|
Danbooru.WikiPage.initialize_typeahead = function() {
|
||||||
if (Danbooru.meta("enable-auto-complete") === "true") {
|
if (Danbooru.meta("enable-auto-complete") === "true") {
|
||||||
$("#search_title,#quick_search_title").autocomplete({
|
var $fields = $("#search_title,#quick_search_title");
|
||||||
|
|
||||||
|
$fields.autocomplete({
|
||||||
minLength: 1,
|
minLength: 1,
|
||||||
source: function(req, resp) {
|
source: function(req, resp) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@@ -20,16 +22,26 @@
|
|||||||
},
|
},
|
||||||
method: "get",
|
method: "get",
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
resp($.map(data, function(tag) {
|
resp($.map(data, function(wiki_page) {
|
||||||
return {
|
return {
|
||||||
label: tag.title.replace(/_/g, " "),
|
label: wiki_page.title.replace(/_/g, " "),
|
||||||
value: tag.title
|
value: wiki_page.title,
|
||||||
|
category: wiki_page.category_name
|
||||||
};
|
};
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var render_wiki_page = function(list, wiki_page) {
|
||||||
|
var $link = $("<a/>").addClass("tag-type-" + wiki_page.category).text(wiki_page.label);
|
||||||
|
return $("<li/>").data("item.autocomplete", wiki_page).append($link).appendTo(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
$fields.each(function(i, field) {
|
||||||
|
$(field).data("uiAutocomplete")._renderItem = render_wiki_page;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class WikiPage < ActiveRecord::Base
|
|||||||
options[:except] += hidden_attributes
|
options[:except] += hidden_attributes
|
||||||
unless options[:builder]
|
unless options[:builder]
|
||||||
options[:methods] ||= []
|
options[:methods] ||= []
|
||||||
options[:methods] += [:creator_name]
|
options[:methods] += [:creator_name, :category_name]
|
||||||
end
|
end
|
||||||
hash = super(options)
|
hash = super(options)
|
||||||
hash
|
hash
|
||||||
|
|||||||
Reference in New Issue
Block a user