changeset 135:6a2f8e88344e cannam-pre-20110113-merge

Bug #51: make New Member box show matching users only when at least 2 characters have been typed in search (avoid really long results lists)
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Wed, 19 Jan 2011 13:27:01 +0000
parents c7d72c765cc6
children bf38a7365edf ddcedb549d4e
files app/controllers/members_controller.rb app/helpers/application_helper.rb app/views/members/autocomplete_for_member.rhtml app/views/projects/settings/_members.rhtml config/locales/en-GB.yml config/locales/en.yml
diffstat 6 files changed, 12 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/app/controllers/members_controller.rb	Wed Jan 19 12:41:34 2011 +0000
+++ b/app/controllers/members_controller.rb	Wed Jan 19 13:27:01 2011 +0000
@@ -94,6 +94,7 @@
   
   def autocomplete_for_member
     @principals = Principal.active.like(params[:q]).find(:all, :limit => 100) - @project.principals
+    logger.debug "Query for #{params[:q]} returned #{@principals.size} results"
     render :layout => false
   end
 
--- a/app/helpers/application_helper.rb	Wed Jan 19 12:41:34 2011 +0000
+++ b/app/helpers/application_helper.rb	Wed Jan 19 13:27:01 2011 +0000
@@ -273,7 +273,7 @@
   def principals_check_box_tags(name, principals)
     s = ''
     principals.sort.each do |principal|
-      s << "<label>#{ check_box_tag name, principal.id, false } #{h principal}</label>\n"
+      s << "<label>#{ check_box_tag name, principal.id, false } #{link_to_user principal}</label>\n"
     end
     s 
   end
--- a/app/views/members/autocomplete_for_member.rhtml	Wed Jan 19 12:41:34 2011 +0000
+++ b/app/views/members/autocomplete_for_member.rhtml	Wed Jan 19 13:27:01 2011 +0000
@@ -1,1 +1,3 @@
-<%= principals_check_box_tags 'member[user_ids][]', @principals %>
\ No newline at end of file
+<% if params[:q] && params[:q].length > 1 %>
+<%= principals_check_box_tags 'member[user_ids][]', @principals %>
+<% end %>
--- a/app/views/projects/settings/_members.rhtml	Wed Jan 19 12:41:34 2011 +0000
+++ b/app/views/projects/settings/_members.rhtml	Wed Jan 19 13:27:01 2011 +0000
@@ -50,7 +50,7 @@
 </div>
 
 
-<% principals = Principal.active.find(:all, :limit => 10, :order => 'type, login, lastname ASC') - @project.principals %>
+<% principals = Principal.active.find(:all, :limit => 100, :order => 'type, login, lastname ASC') - @project.principals %>
 
 <div class="splitcontentright">
 <% if roles.any? && principals.any? %>
@@ -66,9 +66,11 @@
                  :url => { :controller => 'members', :action => 'autocomplete_for_member', :id => @project },
                  :with => 'q')
                   %>
-		
+
 		<div id="principals">
-			<%= principals_check_box_tags 'member[user_ids][]', principals %>
+		<% if params[:q] && params[:q].length > 1 %>
+  		  <%= principals_check_box_tags 'member[user_ids][]', @principals %>
+		<% end %>
 		</div>
 		
     <p><%= l(:label_role_plural) %>:
--- a/config/locales/en-GB.yml	Wed Jan 19 12:41:34 2011 +0000
+++ b/config/locales/en-GB.yml	Wed Jan 19 13:27:01 2011 +0000
@@ -947,7 +947,7 @@
   label_user_mail_option_only_my_events: Only for things I watch or I'm involved in
   label_user_mail_option_only_assigned: Only for things I am assigned to
   notice_not_authorized_archived_project: The project you're trying to access has been archived.
-  label_principal_search: "Search for user or group:"
+  label_principal_search: "Search by name:"
   label_user_search: "Search for user:"
   field_visible: Visible
   setting_emails_header: Emails header
--- a/config/locales/en.yml	Wed Jan 19 12:41:34 2011 +0000
+++ b/config/locales/en.yml	Wed Jan 19 13:27:01 2011 +0000
@@ -795,7 +795,7 @@
   label_profile: Profile
   label_subtask_plural: Subtasks
   label_project_copy_notifications: Send email notifications during the project copy
-  label_principal_search: "Search for user or group:"
+  label_principal_search: "Search by name:"
   label_user_search: "Search for user:"
   
   button_login: Login