Commit a890f7a5b0ec3776bf03304cfa0aef90fb6a4234
1 parent
dd378570
Exists in
master
and in
29 other branches
ActionItem36: selecting groups when adding friends
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1501 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
9 changed files
with
53 additions
and
5 deletions
Show diff stats
app/controllers/my_profile/friends_controller.rb
| ... | ... | @@ -7,8 +7,9 @@ class FriendsController < MyProfileController |
| 7 | 7 | def add |
| 8 | 8 | @friend = Person.find(params[:id]) |
| 9 | 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 | 13 | # FIXME shouldn't redirect to the friend's page? |
| 13 | 14 | redirect_to :action => 'index' |
| 14 | 15 | end | ... | ... |
app/helpers/application_helper.rb
| ... | ... | @@ -383,4 +383,13 @@ module ApplicationHelper |
| 383 | 383 | :help => _('Click on this icon to go to the <b>%s</b>\'s home page') % profile.name ) |
| 384 | 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 | 395 | end | ... | ... |
app/views/friends/add.rhtml
| ... | ... | @@ -12,6 +12,15 @@ |
| 12 | 12 | |
| 13 | 13 | <% form_tag do %> |
| 14 | 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 | 24 | <%= submit_button(:ok, _("Yes, I want to add %s as my friend") % @friend.name) %> |
| 16 | 25 | <%= button(:cancel, _("No, I don't want"), :action => 'index') %> |
| 17 | 26 | <% end %> | ... | ... |
app/views/profile_editor/index.rhtml
| ... | ... | @@ -9,6 +9,8 @@ |
| 9 | 9 | |
| 10 | 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 | 14 | <%= file_manager_button(_('Edit Visual Design'), 'icons-app/design-editor.png', :controller => 'profile_design', :action => 'index') %> |
| 13 | 15 | |
| 14 | 16 | <%= file_manager_button(_('Manage Content'), 'icons-app/cms.png', :controller => 'cms') %> | ... | ... |
app/views/tasks/_add_friend.rhtml
| ... | ... | @@ -7,16 +7,22 @@ |
| 7 | 7 | <% form_for('task', task, :url => { :action => 'close', :id => task.id } ) do |f| %> |
| 8 | 8 | |
| 9 | 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 | 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 | 21 | <% end %> |
| 16 | 22 | </div> |
| 17 | 23 | |
| 18 | 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 | 26 | <%= _('Ignore') %> |
| 21 | 27 | </div> |
| 22 | 28 | ... | ... |
public/images/icons-app/README
2.21 KB
public/stylesheets/common.css
| ... | ... | @@ -425,3 +425,22 @@ th { |
| 425 | 425 | color: black; |
| 426 | 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 | +} | ... | ... |