autocomplete: add username autocompletion sitewide.
This commit is contained in:
@@ -31,6 +31,7 @@ Autocomplete.initialize_all = function() {
|
||||
this.initialize_mention_autocomplete($(".autocomplete-mentions textarea"));
|
||||
this.initialize_artist_autocomplete($('[data-autocomplete="artist"]'));
|
||||
this.initialize_pool_autocomplete($('[data-autocomplete="pool"]'));
|
||||
this.initialize_user_autocomplete($('[data-autocomplete="user"]'));
|
||||
this.initialize_wiki_autocomplete($('[data-autocomplete="wiki-page"]'));
|
||||
}
|
||||
}
|
||||
@@ -145,7 +146,7 @@ Autocomplete.initialize_tag_autocomplete = function() {
|
||||
case "flagger":
|
||||
case "upvote":
|
||||
case "downvote":
|
||||
Autocomplete.user_source(term, resp, metatag);
|
||||
Autocomplete.user_source(term, resp, metatag + ":");
|
||||
break;
|
||||
case "pool":
|
||||
case "ordpool":
|
||||
@@ -216,6 +217,17 @@ Autocomplete.initialize_pool_autocomplete = function($fields) {
|
||||
});
|
||||
};
|
||||
|
||||
Autocomplete.initialize_user_autocomplete = function($fields) {
|
||||
$fields.autocomplete({
|
||||
search: function() {
|
||||
$(this).data("ui-autocomplete").menu.bindings = $();
|
||||
},
|
||||
source: function(req, resp) {
|
||||
Autocomplete.user_source(req.term, resp, "");
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
Autocomplete.initialize_wiki_autocomplete = function($fields) {
|
||||
$fields.autocomplete({
|
||||
search: function() {
|
||||
@@ -423,7 +435,7 @@ Autocomplete.static_metatag_source = function(term, resp, metatag) {
|
||||
resp(matches);
|
||||
}
|
||||
|
||||
Autocomplete.user_source = function(term, resp, metatag) {
|
||||
Autocomplete.user_source = function(term, resp, prefix) {
|
||||
return $.ajax({
|
||||
url: "/users.json",
|
||||
data: {
|
||||
@@ -434,21 +446,10 @@ Autocomplete.user_source = function(term, resp, metatag) {
|
||||
},
|
||||
method: "get",
|
||||
success: function(data) {
|
||||
var prefix = "";
|
||||
var display_name = null;
|
||||
|
||||
if (metatag === "@") {
|
||||
prefix = "@";
|
||||
display_name = function(name) {return name;};
|
||||
} else {
|
||||
prefix = metatag + ":";
|
||||
display_name = function(name) {return name.replace(/_/g, " ");};
|
||||
}
|
||||
|
||||
resp($.map(data, function(user) {
|
||||
return {
|
||||
type: "user",
|
||||
label: display_name(user.name),
|
||||
label: user.name.replace(/_/, " "),
|
||||
value: prefix + user.name,
|
||||
level: user.level_string
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<div id="search">
|
||||
<%= form_tag(artist_versions_path, :method => :get, :class => "simple_form") do %>
|
||||
<%= search_field "updater_name", :label => "User" %>
|
||||
<%= search_field "updater_name", :label => "User", :data => { autocomplete: "user" } %>
|
||||
<%= search_field "name", :label => "Name", :data => { autocomplete: "artist" } %>
|
||||
<%= submit_tag "Search" %>
|
||||
<% end %>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<%= simple_form_for(:search, url: artists_path, method: :get, defaults: { required: false }, html: { class: "inline-form" }) do |f| %>
|
||||
<%= f.input :any_name_matches, label: "Name", hint: "Use * for wildcard", input_html: { value: params[:search][:any_name_matches], data: { autocomplete: "artist" }} %>
|
||||
<%= f.input :url_matches, label: "URL", as: "string", input_html: { value: params[:search][:url_matches] } %>
|
||||
<%= f.input :creator_name, label: "Creator", input_html: { value: params[:search][:creator_name] } %>
|
||||
<%= f.input :creator_name, label: "Creator", input_html: { value: params[:search][:creator_name], data: { autocomplete: "user" } } %>
|
||||
<%= f.input :is_active, label: "Active?", collection: [["Yes", true], ["No", false]], include_blank: true, selected: params[:search][:is_active] %>
|
||||
<%= f.input :is_banned, label: "Banned?", collection: [["Yes", true], ["No", false]], include_blank: true, selected: params[:search][:is_banned] %>
|
||||
<%= f.input :has_tag, label: "Has tag?", collection: [["Yes", true], ["No", false]], include_blank: true, selected: params[:search][:has_tag] %>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<%= simple_form_for(ban) do |f| %>
|
||||
<%= error_messages_for("ban") %>
|
||||
|
||||
<%= f.input :user_name, :as => :string %>
|
||||
<%= f.input :user_name, :as => :string, :input_html => { data: { autocomplete: "user" } } %>
|
||||
<%= f.input :duration, :hint => "in days" %>
|
||||
<%= f.input :reason %>
|
||||
<%= f.button :submit, :value => "Ban" %>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<%= simple_form_for(:search, method: :get, url: bans_path, defaults: { required: false }, html: { class: "inline-form" }) do |f| %>
|
||||
<%= f.input :user_name, label: "User", input_html: { value: params[:search][:user_name] } %>
|
||||
<%= f.input :banner_name, label: "Banner", input_html: { value: params[:search][:banner_name] } %>
|
||||
<%= f.input :user_name, label: "User", input_html: { value: params[:search][:user_name], data: { autocomplete: "user" } } %>
|
||||
<%= f.input :banner_name, label: "Banner", input_html: { value: params[:search][:banner_name], data: { autocomplete: "user" } } %>
|
||||
<%= f.input :reason_matches, label: "Reason", hint: "Use * for wildcard", input_html: { value: params[:search][:reason_matches] } %>
|
||||
<%= f.input :expired, label: "Expired?", collection: [["Yes", true], ["No", false]], include_blank: true, selected: params[:search][:expired] %>
|
||||
<%= f.input :order, include_blank: false, collection: [%w[Created id_desc], %w[Expiration expires_at_desc]], selected: params[:search][:order] %>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<%= simple_form_for(:search, url: bulk_update_requests_path, method: :get, defaults: { required: false }, html: { class: "inline-form" }) do |f| %>
|
||||
<%= f.input :user_name, label: "Creator", input_html: { value: params[:search][:user_name] } %>
|
||||
<%= f.input :approver_name, label: "Approver", input_html: { value: params[:search][:approver_name] } %>
|
||||
<%= f.input :user_name, label: "Creator", input_html: { value: params[:search][:user_name], data: { autocomplete: "user" } } %>
|
||||
<%= f.input :approver_name, label: "Approver", input_html: { value: params[:search][:approver_name], data: { autocomplete: "user" } } %>
|
||||
<%= f.input :title_matches, label: "Title", input_html: { value: params[:search][:title_matches] } %>
|
||||
<%= f.input :script_matches, label: "Script", input_html: { value: params[:search][:script_matches] } %>
|
||||
<%= f.input :status, label: "Status", collection: %w[pending approved rejected], include_blank: true, selected: params[:search][:status] %>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<%= simple_form_for(:search, :method => :get, url: comments_path, defaults: { required: false }, html: { class: "inline-form" }) do |f| %>
|
||||
<%= hidden_field_tag "group_by", "comment", :id => "group_by_full" %>
|
||||
<%= f.input :creator_name, label: "Commenter" %>
|
||||
<%= f.input :creator_name, label: "Commenter", input_html: { data: { autocomplete: "user" } } %>
|
||||
<%= f.input :body_matches, label: "Body" %>
|
||||
<%= f.input :post_tags_match, label: "Tags", input_html: { data: { autocomplete: "tag-query" } } %>
|
||||
<%= f.input :is_deleted, label: "Deleted?", collection: [["Yes", true], ["No", false]] %>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<%= simple_form_for(dmail) do |f| %>
|
||||
<%= f.input :to_name, :label => "To" %>
|
||||
<%= f.input :to_name, :label => "To", :input_html => { data: { autocomplete: "user" } } %>
|
||||
<%= f.input :title, :as => :string %>
|
||||
<%= dtext_field "dmail", "body" %>
|
||||
<%= f.button :submit, "Send", :data => { :disable_with => "Sending..." } %>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<%= f.hidden_field :folder, value: params[:folder] %>
|
||||
<%= f.input :title_matches, label: "Title", hint: "Use * for wildcard", input_html: { value: params[:search][:title_matches] } %>
|
||||
<%= f.input :message_matches, label: "Message", hint: "Use * for wildcard", input_html: { value: params[:search][:messages_matches] } %>
|
||||
<%= f.input :to_name, label: "To", input_html: { value: params[:search][:to_name] } %>
|
||||
<%= f.input :from_name, label: "From", input_html: { value: params[:search][:from_name] } %>
|
||||
<%= f.input :to_name, label: "To", input_html: { value: params[:search][:to_name], data: { autocomplete: "user" } } %>
|
||||
<%= f.input :from_name, label: "From", input_html: { value: params[:search][:from_name], data: { autocomplete: "user" } } %>
|
||||
<%= f.submit "Search" %>
|
||||
<% end %>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<%= form_tag(forum_posts_path, :method => :get, :class => "simple_form") do %>
|
||||
<%= search_field "topic_title_matches", :label => "Title" %>
|
||||
<%= search_field "body_matches", :label => "Body" %>
|
||||
<%= search_field "creator_name", :label => "Author" %>
|
||||
<%= search_field "creator_name", :label => "Author", :data => { autocomplete: "user" } %>
|
||||
<div class="input">
|
||||
<label for="search_topic_category_id">Category</label>
|
||||
<%= select "search", "topic_category_id", ForumTopic::CATEGORIES.invert.to_a, :include_blank => true %>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<%= error_messages_for :janitor_trial %>
|
||||
|
||||
<%= simple_form_for(@janitor_trial) do |f| %>
|
||||
<%= f.input :user_name %>
|
||||
<%= f.input :user_name, input_html: { data: { autocomplete: "user" } } %>
|
||||
<%= f.button :submit, "Submit" %>
|
||||
<%= f.button :submit, "Test" %>
|
||||
<% end %>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<%= simple_form_for(:search, method: :get, url: mod_actions_path, defaults: { required: false }, html: { class: "inline-form" }) do |f| %>
|
||||
<%= f.input :creator_name, label: "Creator", input_html: { value: params[:search][:creator_name] } %>
|
||||
<%= f.input :creator_name, label: "Creator", input_html: { value: params[:search][:creator_name], data: { autocomplete: "user" } } %>
|
||||
<%= f.input :description_matches, label: "Description" %>
|
||||
<%= f.input :category, label: "Category", collection: ModAction.categories.map {|k,v| [k.capitalize.tr("_"," "), v]}, include_blank: true,selected: params[:search][:category] %>
|
||||
<%= f.submit "Search" %>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<%= form_tag(moderator_bulk_revert_path, :class => "simple_form") do %>
|
||||
<div class="input">
|
||||
<label>User Name</label>
|
||||
<%= text_field :constraints, :user_name, :value => @constraints[:user_name] %>
|
||||
<%= text_field :constraints, :user_name, :value => @constraints[:user_name], :data => { autocomplete: "user" } %>
|
||||
</div>
|
||||
|
||||
<div class="input">
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<%= form_tag(moderator_ip_addrs_path, :method => :get, :class => "simple_form") do %>
|
||||
<div class="input">
|
||||
<label for="user_names">Search User Names</label>
|
||||
<%= text_field_tag "search[user_name]", params[:user_names] %>
|
||||
<%= text_field_tag "search[user_name]", params[:user_names], data: { autocomplete: "user" } %>
|
||||
<span class="hint">Separate with commas</span>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<%= f.hidden_field :group_by, value: "note" %>
|
||||
|
||||
<%= f.input :body_matches, label: "Body" %>
|
||||
<%= f.input :creator_name, label: "Author" %>
|
||||
<%= f.input :creator_name, label: "Author", input_html: { data: { autocomplete: "user" } } %>
|
||||
<%= f.input :post_tags_match, label: "Tags", input_html: { data: { autocomplete: "tag-query" } } %>
|
||||
<%= f.submit "Search" %>
|
||||
<% end %>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<th><label for="search_creator_name">Creator</th>
|
||||
<td>
|
||||
<div class="input">
|
||||
<%= text_field "search", "creator_name", :value => params[:search][:creator_name] %>
|
||||
<%= text_field "search", "creator_name", :value => params[:search][:creator_name], :data => { autocomplete: "pool" } %>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<%= f.input :reason_matches, label: "Reason", hint: "Use * for wildcard searches", input_html: { value: params[:search][:reason_matches] } %>
|
||||
<%= f.input :post_tags_match, label: "Tags", input_html: { value: params[:search][:post_tags_match], data: { autocomplete: "tag-query" } } %>
|
||||
<%= f.input :post_id, label: "Post ID", input_html: { value: params[:search][:post_id] } %>
|
||||
<%= f.input :creator_name, label: "Creator", input_html: { value: params[:search][:creator_name] } %>
|
||||
<%= f.input :creator_name, label: "Creator", input_html: { value: params[:search][:creator_name], data: { autocomplete: "user" } } %>
|
||||
<%= f.input :is_resolved, label: "Resolved?", collection: [["Yes", true], ["No", false]], include_blank: true, selected: params[:search][:is_resolved] %>
|
||||
<%= f.submit "Search" %>
|
||||
<% end %>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<%= render "posts/partials/common/inline_blacklist" %>
|
||||
|
||||
<%= simple_form_for(:search, url: post_approvals_path, method: :get, defaults: { required: false }, html: { class: "inline-form" }) do |f| %>
|
||||
<%= f.input :user_name, label: "Approver", input_html: { value: params[:search][:user_name] } %>
|
||||
<%= f.input :user_name, label: "Approver", input_html: { value: params[:search][:user_name], data: { autocomplete: "user" } } %>
|
||||
<%= f.input :post_tags_match, label: "Tags", input_html: { value: params[:search][:post_tags_match], data: { autocomplete: "tag-query" } } %>
|
||||
<%= f.submit "Search" %>
|
||||
<% end %>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<%= f.input :post_tags_match, label: "Tags", input_html: { value: params[:search][:post_tags_match], data: { autocomplete: "tag-query" } } %>
|
||||
<%= f.input :post_id, label: "Post ID", input_html: { value: params[:search][:post_id] } %>
|
||||
<% if CurrentUser.is_moderator? %>
|
||||
<%= f.input :creator_name, label: "Creator", input_html: { value: params[:search][:creator_name] } %>
|
||||
<%= f.input :creator_name, label: "Creator", input_html: { value: params[:search][:creator_name], data: { autocomplete: "user" } } %>
|
||||
<% end %>
|
||||
<%= f.input :is_resolved, label: "Resolved?", collection: [["Yes", true], ["No", false]], include_blank: true, selected: params[:search][:is_resolved] %>
|
||||
<%= f.input :category, label: "Category", collection: ["normal", "unapproved", "rejected", "deleted", "banned", "duplicate"], include_blank: true, selected: params[:search][:category] %>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<%= render "posts/partials/common/inline_blacklist" %>
|
||||
|
||||
<%= simple_form_for(:search, url: post_replacements_path, method: :get, defaults: { required: false }, html: { class: "inline-form" }) do |f| %>
|
||||
<%= f.input :creator_name, label: "Replacer", input_html: { value: params[:search][:creator_name] } %>
|
||||
<%= f.input :creator_name, label: "Replacer", input_html: { value: params[:search][:creator_name], data: { autocomplete: "user" } } %>
|
||||
<%= f.input :post_tags_match, label: "Tags", input_html: { value: params[:search][:post_tags_match], data: { autocomplete: "tag-query" } } %>
|
||||
<%= f.submit "Search" %>
|
||||
<% end %>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<div id="search">
|
||||
<%= form_tag(post_versions_path, :method => :get, :class => "simple_form") do %>
|
||||
<%= search_field "updater_name", :label => "User" %>
|
||||
<%= search_field "updater_name", :label => "User", :data => { autocomplete: "user" } %>
|
||||
<%= search_field "post_id", :label => "Post" %>
|
||||
<%= submit_tag "Search" %>
|
||||
<% end %>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<%= error_messages_for "user_feedback" %>
|
||||
|
||||
<%= simple_form_for(@user_feedback) do |f| %>
|
||||
<%= f.input :user_name, :label => "User" %>
|
||||
<%= f.input :user_name, :label => "User", :input_html => { data: { autocomplete: "user" } } %>
|
||||
<%= f.input :category, :collection => ["positive", "neutral", "negative"], :include_blank => false %>
|
||||
<%= dtext_field "user_feedback", "body" %>
|
||||
<%= f.button :submit, "Submit" %>
|
||||
|
||||
@@ -3,10 +3,8 @@
|
||||
<h1>Search User Feedbacks</h1>
|
||||
|
||||
<%= form_tag(user_feedbacks_path, :method => :get, :class => "simple_form") do %>
|
||||
<%= search_field "user_name", :label => "User" %>
|
||||
|
||||
<%= search_field "creator_name", :label => "Creator" %>
|
||||
|
||||
<%= search_field "user_name", :label => "User", :data => { autocomplete: "user" } %>
|
||||
<%= search_field "creator_name", :label => "Creator", :data => { autocomplete: "user" } %>
|
||||
<%= search_field "body_matches", :label => "Message" %>
|
||||
|
||||
<div class="input">
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<%= form_tag(users_path, :method => :get) do %>
|
||||
<%= text_field "search", "name_matches", :id => "quick_search_name_matches", :placeholder => "Search users" %>
|
||||
<%= text_field "search", "name_matches", :id => "quick_search_name_matches", :placeholder => "Search users", :data => { autocomplete: "user" } %>
|
||||
<% end %>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<div id="c-users">
|
||||
<div id="a-search">
|
||||
<%= simple_form_for(:search, url: users_path, method: :get, defaults: { required: false }, html: { class: "inline-form" }) do |f| %>
|
||||
<%= f.input :name_matches, label: "Name", hint: "Use * for wildcard", input_html: { value: params[:search][:name_matches] } %>
|
||||
<%= f.input :name_matches, label: "Name", hint: "Use * for wildcard", input_html: { value: params[:search][:name_matches], data: { autocomplete: "user" } } %>
|
||||
<%= f.simple_fields_for :inviter do |sub| %>
|
||||
<%= sub.input :name_matches, label: "Inviter Name", hint: "Use * for wildcard", input_html: { value: params.dig(:search, :inviter, :name_matches) } %>
|
||||
<%= sub.input :name_matches, label: "Inviter Name", hint: "Use * for wildcard", input_html: { value: params.dig(:search, :inviter, :name_matches), data: { autocomplete: "user" } } %>
|
||||
<% end %>
|
||||
|
||||
<%= f.input :level, collection: User.level_hash.to_a, include_blank: true, selected: params[:search][:level] %>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div id="a-search">
|
||||
<%= form_tag(wiki_pages_path, :method => :get, :class => "simple_form") do %>
|
||||
<%= search_field "title", :hint => "Use * for wildcard searches", :data => { :autocomplete => "wiki-page" } %>
|
||||
<%= search_field "creator_name" %>
|
||||
<%= search_field "creator_name", :data => { :autocomplete => "user" } %>
|
||||
<%= search_field "body_matches", :label => "Body" %>
|
||||
<%= search_field "other_names_match", :label => "Other names", :hint => "Use * for wildcard searches" %>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user