Commit a890f7a5b0ec3776bf03304cfa0aef90fb6a4234

Authored by AntonioTerceiro
1 parent dd378570

ActionItem36: selecting groups when adding friends


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1501 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/my_profile/friends_controller.rb
@@ -7,8 +7,9 @@ class FriendsController < MyProfileController @@ -7,8 +7,9 @@ class FriendsController < MyProfileController
7 def add 7 def add
8 @friend = Person.find(params[:id]) 8 @friend = Person.find(params[:id])
9 if request.post? && params[:confirmation] 9 if request.post? && params[:confirmation]
10 - AddFriend.create!(:person => profile, :friend => @friend) 10 + AddFriend.create!(:person => profile, :friend => @friend, :group_for_person => params[:group])
11 11
  12 + flash[:notice] = _('%s still needs to accept being your friend.') % @friend.name
12 # FIXME shouldn't redirect to the friend's page? 13 # FIXME shouldn't redirect to the friend's page?
13 redirect_to :action => 'index' 14 redirect_to :action => 'index'
14 end 15 end
app/helpers/application_helper.rb
@@ -383,4 +383,13 @@ module ApplicationHelper @@ -383,4 +383,13 @@ module ApplicationHelper
383 :help => _('Click on this icon to go to the <b>%s</b>\'s home page') % profile.name ) 383 :help => _('Click on this icon to go to the <b>%s</b>\'s home page') % profile.name )
384 end 384 end
385 385
  386 + def text_field_with_local_autocomplete(name, choices, html_options = {})
  387 + id = html_options[:id] || name
  388 +
  389 + text_field_tag(name, '', html_options) +
  390 + content_tag('div', '', :id => "autocomplete-for-#{id}", :class => 'auto-complete', :style => 'display: none;') +
  391 + javascript_tag('new Autocompleter.Local(%s, %s, %s)' % [ id.to_json, "autocomplete-for-#{id}".to_json, choices.to_json ] )
  392 +
  393 + end
  394 +
386 end 395 end
app/views/friends/add.rhtml
@@ -12,6 +12,15 @@ @@ -12,6 +12,15 @@
12 12
13 <% form_tag do %> 13 <% form_tag do %>
14 <%= hidden_field_tag(:confirmation, 1) %> 14 <%= hidden_field_tag(:confirmation, 1) %>
  15 +
  16 + <div>
  17 + <%= _('Classify your new friend %s: ') % @friend.name %>
  18 + <%= text_field_with_local_autocomplete('group', profile.suggested_friend_groups) %>
  19 + <p>
  20 + <%= _('Suggestions: %s') % profile.suggested_friend_groups.join(', ') %>
  21 + </p>
  22 + </div>
  23 +
15 <%= submit_button(:ok, _("Yes, I want to add %s as my friend") % @friend.name) %> 24 <%= submit_button(:ok, _("Yes, I want to add %s as my friend") % @friend.name) %>
16 <%= button(:cancel, _("No, I don't want"), :action => 'index') %> 25 <%= button(:cancel, _("No, I don't want"), :action => 'index') %>
17 <% end %> 26 <% end %>
app/views/profile_editor/index.rhtml
@@ -9,6 +9,8 @@ @@ -9,6 +9,8 @@
9 9
10 <%= file_manager_button(_('Edit Profile'), 'icons-app/edit-profile.png', :controller => 'profile_editor', :action => 'edit') %> 10 <%= file_manager_button(_('Edit Profile'), 'icons-app/edit-profile.png', :controller => 'profile_editor', :action => 'edit') %>
11 11
  12 + <%= file_manager_button(_('Pending tasks'), 'icons-app/todo.png', :controller => 'tasks', :action => 'index') %>
  13 +
12 <%= file_manager_button(_('Edit Visual Design'), 'icons-app/design-editor.png', :controller => 'profile_design', :action => 'index') %> 14 <%= file_manager_button(_('Edit Visual Design'), 'icons-app/design-editor.png', :controller => 'profile_design', :action => 'index') %>
13 15
14 <%= file_manager_button(_('Manage Content'), 'icons-app/cms.png', :controller => 'cms') %> 16 <%= file_manager_button(_('Manage Content'), 'icons-app/cms.png', :controller => 'cms') %>
app/views/tasks/_add_friend.rhtml
@@ -7,16 +7,22 @@ @@ -7,16 +7,22 @@
7 <% form_for('task', task, :url => { :action => 'close', :id => task.id } ) do |f| %> 7 <% form_for('task', task, :url => { :action => 'close', :id => task.id } ) do |f| %>
8 8
9 <div> 9 <div>
10 - <%= radio_button_tag(:decision, 'finish', true, :id => "decision-finish-#{task.id}", :onclick => "Element.show('group-for-person-#{task.id}')") %> 10 + <%= radio_button_tag(:decision, 'finish', true, :id => "decision-finish-#{task.id}", :onclick => "Element.show('group-for-friend-#{task.id}')") %>
11 <%= _('Accept') %> 11 <%= _('Accept') %>
12 12
13 - <% content_tag('div', :id => "group-for-person-#{task.id}") do %>  
14 - <%= labelled_form_field(_('Add %s to the following group:') % task.requestor.name, f.text_field(:group_for_person)) %> 13 + <%
  14 + content_tag('div', :id => "group-for-friend-#{task.id}", :help => _('You can select one of the existing groups or type the name of a new group.')) do %>
  15 + <%= _('Classify your new friend %s: ') % task.requestor.name %>
  16 + <%= text_field_with_local_autocomplete("task[group_for_friend]", profile.suggested_friend_groups, :id => "field-group-for-friend-#{task.id}") %>
  17 + <p>
  18 + <%= _('Suggestions: %s') % profile.suggested_friend_groups.join(', ') %>
  19 + </p>
  20 +
15 <% end %> 21 <% end %>
16 </div> 22 </div>
17 23
18 <div> 24 <div>
19 - <%= radio_button_tag(:decision, 'cancel', false, :id => "decision-cancel-#{task.id}", :onclick => "Element.hide('group-for-person-#{task.id}')") %> 25 + <%= radio_button_tag(:decision, 'cancel', false, :id => "decision-cancel-#{task.id}", :onclick => "Element.hide('group-for-friend-#{task.id}')") %>
20 <%= _('Ignore') %> 26 <%= _('Ignore') %>
21 </div> 27 </div>
22 28
public/images/icons-app/README
@@ -26,6 +26,7 @@ user_icon.png dlg-neu @@ -26,6 +26,7 @@ user_icon.png dlg-neu
26 gnome-home.png Nuovo 26 gnome-home.png Nuovo
27 gtk-yes.png dlg-neu 27 gtk-yes.png dlg-neu
28 users.png (locally modified) dlg-neu 28 users.png (locally modified) dlg-neu
  29 +stock_todo.png Nuovo
29 30
30 Icons rasterization 31 Icons rasterization
31 =================== 32 ===================
public/images/icons-app/stock_todo.png 0 → 100644

2.21 KB

public/images/icons-app/todo.png 0 → 120000
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +stock_todo.png
0 \ No newline at end of file 2 \ No newline at end of file
public/stylesheets/common.css
@@ -425,3 +425,22 @@ th { @@ -425,3 +425,22 @@ th {
425 color: black; 425 color: black;
426 font-weight: bold; 426 font-weight: bold;
427 } 427 }
  428 +
  429 +div.auto-complete {
  430 + background: #729FCF;
  431 + border: 2px solid #204A87;
  432 +}
  433 +div.auto-complete ul {
  434 + margin: 0px;
  435 + padding: 0px;
  436 +}
  437 +div.auto-complete li {
  438 + list-style: none;
  439 + margin: 0px;
  440 + padding: 0px;
  441 + color: #204A87;
  442 +}
  443 +div.auto-complete li.selected {
  444 + background: #B8CFE7;
  445 + color: #204A87;
  446 +}