autocomplete: fix favgroup:<name> returning favgroups for other users.
* Fix favgroup:<name> autocompletion to only return favgroups for the current user. * Add favgroup autocomplete to the /favorite_groups search form.
This commit is contained in:
@@ -42,6 +42,7 @@ Autocomplete.initialize_all = function() {
|
|||||||
this.initialize_fields($('[data-autocomplete="pool"]'), Autocomplete.pool_source);
|
this.initialize_fields($('[data-autocomplete="pool"]'), Autocomplete.pool_source);
|
||||||
this.initialize_fields($('[data-autocomplete="user"]'), Autocomplete.user_source);
|
this.initialize_fields($('[data-autocomplete="user"]'), Autocomplete.user_source);
|
||||||
this.initialize_fields($('[data-autocomplete="wiki-page"]'), Autocomplete.wiki_source);
|
this.initialize_fields($('[data-autocomplete="wiki-page"]'), Autocomplete.wiki_source);
|
||||||
|
this.initialize_fields($('[data-autocomplete="favorite-group"]'), Autocomplete.favorite_group_source);
|
||||||
this.initialize_fields($('[data-autocomplete="saved-search-label"]'), Autocomplete.saved_search_source);
|
this.initialize_fields($('[data-autocomplete="saved-search-label"]'), Autocomplete.saved_search_source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -139,7 +140,7 @@ Autocomplete.initialize_tag_autocomplete = function() {
|
|||||||
results = await Autocomplete.pool_source(term, metatag + ":");
|
results = await Autocomplete.pool_source(term, metatag + ":");
|
||||||
break;
|
break;
|
||||||
case "favgroup":
|
case "favgroup":
|
||||||
results = await Autocomplete.favorite_group_source(term, metatag + ":");
|
results = await Autocomplete.favorite_group_source(term, metatag + ":", CurrentUser.data("id"));
|
||||||
break;
|
break;
|
||||||
case "search":
|
case "search":
|
||||||
results = await Autocomplete.saved_search_source(term, metatag + ":");
|
results = await Autocomplete.saved_search_source(term, metatag + ":");
|
||||||
@@ -394,8 +395,9 @@ Autocomplete.pool_source = async function(term, prefix = "") {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Autocomplete.favorite_group_source = async function(term, prefix = "") {
|
Autocomplete.favorite_group_source = async function(term, prefix = "", creator_id = null) {
|
||||||
let favgroups = await $.getJSON("/favorite_groups", {
|
let favgroups = await $.getJSON("/favorite_groups", {
|
||||||
|
"search[creator_id]": creator_id,
|
||||||
"search[name_matches]": term,
|
"search[name_matches]": term,
|
||||||
"limit": Autocomplete.MAX_RESULTS
|
"limit": Autocomplete.MAX_RESULTS
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<div id="c-favorite-groups">
|
<div id="c-favorite-groups">
|
||||||
<div id="a-index">
|
<div id="a-index">
|
||||||
<%= search_form_for(favorite_groups_path) do |f| %>
|
<%= search_form_for(favorite_groups_path) do |f| %>
|
||||||
<%= f.input :name_matches, label: "Name", input_html: { value: params.dig(:search, :name_matches) } %>
|
<%= f.input :name_matches, label: "Name", input_html: { value: params.dig(:search, :name_matches), "data-autocomplete": "favorite-group" } %>
|
||||||
<%= f.input :creator_name, label: "Creator", input_html: { value: params.dig(:search, :creator_name), "data-autocomplete": "user" } %>
|
<%= f.input :creator_name, label: "Creator", input_html: { value: params.dig(:search, :creator_name), "data-autocomplete": "user" } %>
|
||||||
<%= f.input :order, collection: [%w[Created created_at], %w[Updated updated_at], %w[Name name], %w[Post\ count post_count]], include_blank: true, selected: params.dig(:search, :order) %>
|
<%= f.input :order, collection: [%w[Created created_at], %w[Updated updated_at], %w[Name name], %w[Post\ count post_count]], include_blank: true, selected: params.dig(:search, :order) %>
|
||||||
<%= f.submit "Search" %>
|
<%= f.submit "Search" %>
|
||||||
|
|||||||
Reference in New Issue
Block a user