Commit 84b009e8bf28aee3a6482bd1709add576db1a6f9
1 parent
6fe4cacd
Exists in
staging
and in
42 other branches
ActionItem1127: better user interface
Showing
3 changed files
with
18 additions
and
2 deletions
Show diff stats
app/controllers/my_profile/profile_members_controller.rb
... | ... | @@ -76,7 +76,11 @@ class ProfileMembersController < MyProfileController |
76 | 76 | end |
77 | 77 | |
78 | 78 | def find_users |
79 | - @users_found = Person.find_by_contents(params[:query] + '*') | |
79 | + if !params[:query] || params[:query].length <= 2 | |
80 | + @users_found = [] | |
81 | + else | |
82 | + @users_found = Person.find_by_contents(params[:query] + '*') | |
83 | + end | |
80 | 84 | render :layout => false |
81 | 85 | end |
82 | 86 | ... | ... |
app/views/profile_members/add_members.rhtml
1 | 1 | <h2><%= _('Add members to %s') % profile.name %></h2> |
2 | 2 | |
3 | 3 | <% form_remote_tag :url => {:action => 'find_users', :profile => profile.identifier}, :update => 'users-list', :loading => '$("users-list").addClassName("loading")', :complete => '$("users-list").removeClassName("loading")' do %> |
4 | - <%= text_field_tag('query') %> | |
4 | + <%= text_field_tag('query', '', :autocomplete => 'off') %> | |
5 | 5 | <%= submit_tag(_('Search')) %> |
6 | 6 | <% end %> |
7 | 7 | |
8 | 8 | <%= 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")') %> |
9 | +<%= observe_field('query', :frequency => 1, :condition => '$("query").value.length <= 2', :function => '$("users-list").update($("empty-query").innerHTML)') %> | |
9 | 10 | |
10 | 11 | <div id="users-list"> |
11 | 12 | <%= render :partial => 'find_users' %> |
12 | 13 | </div> |
13 | 14 | |
15 | +<div id='empty-query' style='display: none'> | |
16 | + <%= render :partial => 'find_users' %> | |
17 | +</div> | |
18 | + | |
14 | 19 | <div id="members-list" class="add-members"> |
15 | 20 | <%= render :partial => 'members_list' %> |
16 | 21 | </div> | ... | ... |
app/views/profile_members/find_users.rhtml
... | ... | @@ -25,4 +25,11 @@ |
25 | 25 | </td> |
26 | 26 | </tr> |
27 | 27 | <% end if @users_found %> |
28 | + <% if !params[:query] || params[:query].length <= 2 %> | |
29 | + <tr> | |
30 | + <td style='text-align: center'> | |
31 | + <em><%= _('You must type at least 3 characters') %></em> | |
32 | + </td> | |
33 | + </tr> | |
34 | + <% end %> | |
28 | 35 | </table> | ... | ... |