From 84b009e8bf28aee3a6482bd1709add576db1a6f9 Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Fri, 7 Aug 2009 17:41:56 -0300 Subject: [PATCH] ActionItem1127: better user interface --- app/controllers/my_profile/profile_members_controller.rb | 6 +++++- app/views/profile_members/add_members.rhtml | 7 ++++++- app/views/profile_members/find_users.rhtml | 7 +++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/controllers/my_profile/profile_members_controller.rb b/app/controllers/my_profile/profile_members_controller.rb index 0c35a99..148c4ee 100644 --- a/app/controllers/my_profile/profile_members_controller.rb +++ b/app/controllers/my_profile/profile_members_controller.rb @@ -76,7 +76,11 @@ class ProfileMembersController < MyProfileController end def find_users - @users_found = Person.find_by_contents(params[:query] + '*') + if !params[:query] || params[:query].length <= 2 + @users_found = [] + else + @users_found = Person.find_by_contents(params[:query] + '*') + end render :layout => false end diff --git a/app/views/profile_members/add_members.rhtml b/app/views/profile_members/add_members.rhtml index ec84364..4119e76 100644 --- a/app/views/profile_members/add_members.rhtml +++ b/app/views/profile_members/add_members.rhtml @@ -1,16 +1,21 @@

<%= _('Add members to %s') % profile.name %>

<% form_remote_tag :url => {:action => 'find_users', :profile => profile.identifier}, :update => 'users-list', :loading => '$("users-list").addClassName("loading")', :complete => '$("users-list").removeClassName("loading")' do %> - <%= text_field_tag('query') %> + <%= text_field_tag('query', '', :autocomplete => 'off') %> <%= submit_tag(_('Search')) %> <% end %> <%= observe_field('query', :url => {:action => 'find_users', :profile => profile.identifier}, :update => 'users-list', :frequency => 1, :with => 'query', :condition => '$("query").value.length > 2', :loading => '$("users-list").addClassName("loading")', :complete => '$("users-list").removeClassName("loading")') %> +<%= observe_field('query', :frequency => 1, :condition => '$("query").value.length <= 2', :function => '$("users-list").update($("empty-query").innerHTML)') %>
<%= render :partial => 'find_users' %>
+ +
<%= render :partial => 'members_list' %>
diff --git a/app/views/profile_members/find_users.rhtml b/app/views/profile_members/find_users.rhtml index 01aa587..14ec72d 100644 --- a/app/views/profile_members/find_users.rhtml +++ b/app/views/profile_members/find_users.rhtml @@ -25,4 +25,11 @@ <% end if @users_found %> + <% if !params[:query] || params[:query].length <= 2 %> + + + <%= _('You must type at least 3 characters') %> + + + <% end %> -- libgit2 0.21.2