Commit 43c129008fc88237babbc991d1551946d336a7d0
1 parent
ad29f61a
Exists in
staging
and in
42 other branches
[suggestion] Update friends suggestions list
After asking friendship or removing suggestion, the list is updated (ActionItem3234)
Showing
8 changed files
with
79 additions
and
65 deletions
Show diff stats
app/controllers/my_profile/friends_controller.rb
| ... | ... | @@ -3,7 +3,7 @@ class FriendsController < MyProfileController |
| 3 | 3 | protect 'manage_friends', :profile |
| 4 | 4 | |
| 5 | 5 | def index |
| 6 | - @suggestions = profile.profile_suggestions.of_person.includes(:suggestion).limit(per_page) | |
| 6 | + @suggestions = profile.profile_suggestions.of_person.enabled.includes(:suggestion).limit(per_page) | |
| 7 | 7 | if is_cache_expired?(profile.manage_friends_cache_key(params)) |
| 8 | 8 | @friends = profile.friends.paginate(:per_page => per_page, :page => params[:npage]) |
| 9 | 9 | end |
| ... | ... | @@ -26,7 +26,8 @@ class FriendsController < MyProfileController |
| 26 | 26 | redirect_to :action => 'suggest' unless @person |
| 27 | 27 | if @person && request.post? |
| 28 | 28 | profile.remove_suggestion(@person) |
| 29 | - session[:notice] = _('Suggestion removed') | |
| 29 | + @suggestions = profile.profile_suggestions.of_person.enabled.includes(:suggestion).limit(per_page) | |
| 30 | + render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :friends_suggestions } | |
| 30 | 31 | end |
| 31 | 32 | end |
| 32 | 33 | ... | ... |
app/views/friends/index.html.erb
| ... | ... | @@ -28,14 +28,9 @@ |
| 28 | 28 | |
| 29 | 29 | <% unless @suggestions.empty? %> |
| 30 | 30 | <br style="clear:both" /> |
| 31 | + <h2><%= _("Friends suggestions") %></h2> | |
| 31 | 32 | <div class="profiles-suggestions"> |
| 32 | - <h2><%= _("Friends suggestions") %></h2> | |
| 33 | - | |
| 34 | - <%= render :partial => 'shared/profile_list', :locals => { :suggestions => @suggestions, :collection => :friends_suggestions } %> | |
| 35 | - | |
| 36 | - <% button_bar do %> | |
| 37 | - <%= link_to _('See more suggestions...'), :action => 'suggest' %> | |
| 38 | - <% end %> | |
| 33 | + <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :friends_suggestions } %> | |
| 39 | 34 | </div> |
| 40 | 35 | <% end %> |
| 41 | 36 | ... | ... |
app/views/friends/suggest.html.erb
| 1 | -<div class='profiles-suggestions'> | |
| 2 | - <h1><%= _("Friends suggestions for %s") % profile.name %></h1> | |
| 1 | +<h1><%= _("Friends suggestions for %s") % profile.name %></h1> | |
| 3 | 2 | |
| 4 | - <% button_bar do %> | |
| 5 | - <%= button(:back, _('Go to friends list'), :controller => 'friends') %> | |
| 6 | - <% end %> | |
| 3 | +<% button_bar do %> | |
| 4 | + <%= button(:back, _('Go to friends list'), :controller => 'friends') %> | |
| 5 | +<% end %> | |
| 7 | 6 | |
| 8 | - <% if @suggestions.empty? %> | |
| 9 | - <p> | |
| 10 | - <em> | |
| 11 | - <%= _('You have no suggestions yet.') %> | |
| 12 | - <%= link_to _('Do you want to see other people in this environment?'), :controller => 'search', :action => 'assets', :asset => 'people' %> | |
| 13 | - </em> | |
| 14 | - </p> | |
| 15 | - <% else %> | |
| 16 | - <%= render :partial => 'shared/profile_list', :locals => { :suggestions => @suggestions, :collection => :friends_suggestions } %> | |
| 17 | - <% end %> | |
| 18 | - <br style="clear:both" /> | |
| 7 | +<div class="profiles-suggestions"> | |
| 8 | + <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :friends_suggestions } %> | |
| 19 | 9 | </div> | ... | ... |
app/views/memberships/suggest.html.erb
| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | </em> |
| 14 | 14 | </p> |
| 15 | 15 | <% else %> |
| 16 | - <%= render :partial => 'shared/profile_list', :locals => { :suggestions => @suggestions, :collection => :communities_suggestions } %> | |
| 16 | + <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :communities_suggestions } %> | |
| 17 | 17 | <% end %> |
| 18 | 18 | <br style="clear:both" /> |
| 19 | 19 | </div> | ... | ... |
app/views/shared/_profile_list.html.erb
| ... | ... | @@ -1,38 +0,0 @@ |
| 1 | -<ul class="profile-list"> | |
| 2 | - <% suggestions.each do |s| %> | |
| 3 | - <li> | |
| 4 | - <%= link_to_profile profile_image(s.suggestion, :minor) + '<br/>' + s.suggestion.short_name, | |
| 5 | - s.suggestion.identifier, :class => 'profile-link' %> | |
| 6 | - <%= button_without_text :help, content_tag('span',_('info about suggestion')), | |
| 7 | - { :action => '#' }, | |
| 8 | - :class => 'explain-suggestion', | |
| 9 | - :title => _('Why this suggestion?') %> | |
| 10 | - <div class='extra_info' style='display:none'> | |
| 11 | - <%= profile_suggestion_categories(s) %> | |
| 12 | - </div> | |
| 13 | - <div class="controll"> | |
| 14 | - <% if collection == :friends_suggestions %> | |
| 15 | - <%= button_without_text :add, content_tag('span',_('add')), | |
| 16 | - s.suggestion.add_url, | |
| 17 | - :class => 'add-friend', | |
| 18 | - :title => _('Add friend') %> | |
| 19 | - <%= button_without_text :remove, content_tag('span',_('remove')), | |
| 20 | - { :action => 'remove_suggestion', :id => s.suggestion.identifier }, | |
| 21 | - :title => _('Remove suggestion'), | |
| 22 | - :method => 'post', | |
| 23 | - :confirm => _('Are you sure you want to remove this suggestion?') %> | |
| 24 | - <% elsif collection == :communities_suggestions %> | |
| 25 | - <%= button_without_text :add, content_tag('span',_('join')), | |
| 26 | - s.suggestion.join_url, | |
| 27 | - :class => 'join-community', | |
| 28 | - :title => _("Join %s") % s.suggestion.name %> | |
| 29 | - <%= button_without_text :remove, content_tag('span',_('remove')), | |
| 30 | - { :action => 'remove_suggestion', :id => s.suggestion.identifier }, | |
| 31 | - :title => _('Remove suggestion'), | |
| 32 | - :method => 'post', | |
| 33 | - :confirm => _('Are you sure you want to remove this suggestion?') %> | |
| 34 | - <% end %> | |
| 35 | - </div><!-- end class="controll" --> | |
| 36 | - </li> | |
| 37 | - <% end %> | |
| 38 | -</ul> |
| ... | ... | @@ -0,0 +1,48 @@ |
| 1 | +<% if suggestions.empty? %> | |
| 2 | + <p> | |
| 3 | + <em> | |
| 4 | + <%= _('You have no suggestions yet.') %> | |
| 5 | + <%= link_to _('Do you want to see other people in this environment?'), :controller => 'search', :action => 'assets', :asset => 'people' %> | |
| 6 | + </em> | |
| 7 | + </p> | |
| 8 | +<% else %> | |
| 9 | + <ul class="profile-list"> | |
| 10 | + <% suggestions.each do |s| %> | |
| 11 | + <li> | |
| 12 | + <%= link_to_profile profile_image(s.suggestion, :minor) + '<br/>' + s.suggestion.short_name, | |
| 13 | + s.suggestion.identifier, :class => 'profile-link' %> | |
| 14 | + <%= button_without_text :help, content_tag('span',_('info about suggestion')), | |
| 15 | + { :action => '#' }, | |
| 16 | + :class => 'explain-suggestion', | |
| 17 | + :title => _('Why this suggestion?') %> | |
| 18 | + <div class='extra_info' style='display:none'> | |
| 19 | + <%= profile_suggestion_categories(s) %> | |
| 20 | + </div> | |
| 21 | + <div class="controll"> | |
| 22 | + <% if collection == :friends_suggestions %> | |
| 23 | + <%= button_without_text :add, content_tag('span',_('add')), | |
| 24 | + s.suggestion.add_url, | |
| 25 | + :class => 'add-friend accept-suggestion', | |
| 26 | + :title => _('Add friend') %> | |
| 27 | + <%= button_without_text :remove, content_tag('span',_('remove')), | |
| 28 | + { :action => 'remove_suggestion', :id => s.suggestion.identifier }, | |
| 29 | + :class => 'remove-suggestion', | |
| 30 | + :title => _('Remove suggestion'), | |
| 31 | + :confirm => _('Are you sure you want to remove this suggestion?') %> | |
| 32 | + <% elsif collection == :communities_suggestions %> | |
| 33 | + <%= button_without_text :add, content_tag('span',_('join')), | |
| 34 | + s.suggestion.join_url, | |
| 35 | + :class => 'join-community', | |
| 36 | + :title => _("Join %s") % s.suggestion.name %> | |
| 37 | + <%= button_without_text :remove, content_tag('span',_('remove')), | |
| 38 | + { :action => 'remove_suggestion', :id => s.suggestion.identifier }, | |
| 39 | + :title => _('Remove suggestion'), | |
| 40 | + :method => 'post', | |
| 41 | + :confirm => _('Are you sure you want to remove this suggestion?') %> | |
| 42 | + <% end %> | |
| 43 | + </div><!-- end class="controll" --> | |
| 44 | + </li> | |
| 45 | + <% end %> | |
| 46 | + </ul> | |
| 47 | +<% end %> | |
| 48 | +<br style="clear:both" /> | ... | ... |
public/javascripts/add-and-join.js
| ... | ... | @@ -120,4 +120,23 @@ jQuery(function($) { |
| 120 | 120 | return false; |
| 121 | 121 | }) |
| 122 | 122 | |
| 123 | + $(".remove-suggestion").live('click', function(){ | |
| 124 | + clicked = $(this) | |
| 125 | + url = clicked.attr("href"); | |
| 126 | + loading_for_button(this); | |
| 127 | + $.post(url, function(data){ | |
| 128 | + clicked.fadeOut(); | |
| 129 | + clicked.parents('.profiles-suggestions').html(data); | |
| 130 | + }); | |
| 131 | + return false; | |
| 132 | + }) | |
| 133 | + | |
| 134 | + /* After adding a suggestion need to remove it from list */ | |
| 135 | + $(".accept-suggestion").live('click', function(){ | |
| 136 | + clicked = $(this) | |
| 137 | + loading_for_button(this); | |
| 138 | + clicked.parents('li').fadeOut(); | |
| 139 | + return false; | |
| 140 | + }) | |
| 141 | + | |
| 123 | 142 | }); | ... | ... |
public/javascripts/application.js
| ... | ... | @@ -1055,7 +1055,6 @@ function showHideTermsOfUse() { |
| 1055 | 1055 | |
| 1056 | 1056 | jQuery('.profiles-suggestions .explain-suggestion').live('click', function() { |
| 1057 | 1057 | var clicked = jQuery(this); |
| 1058 | - jQuery('.profiles-suggestions .extra_info').hide(); | |
| 1059 | 1058 | clicked.toggleClass('active'); |
| 1060 | 1059 | clicked.next('.extra_info').toggle(); |
| 1061 | 1060 | return false; | ... | ... |