diff --git a/app/controllers/my_profile/friends_controller.rb b/app/controllers/my_profile/friends_controller.rb
index acbdbb3..343566d 100644
--- a/app/controllers/my_profile/friends_controller.rb
+++ b/app/controllers/my_profile/friends_controller.rb
@@ -3,7 +3,7 @@ class FriendsController < MyProfileController
protect 'manage_friends', :profile
def index
- @suggestions = profile.profile_suggestions.of_person.includes(:suggestion).limit(per_page)
+ @suggestions = profile.profile_suggestions.of_person.enabled.includes(:suggestion).limit(per_page)
if is_cache_expired?(profile.manage_friends_cache_key(params))
@friends = profile.friends.paginate(:per_page => per_page, :page => params[:npage])
end
@@ -26,7 +26,8 @@ class FriendsController < MyProfileController
redirect_to :action => 'suggest' unless @person
if @person && request.post?
profile.remove_suggestion(@person)
- session[:notice] = _('Suggestion removed')
+ @suggestions = profile.profile_suggestions.of_person.enabled.includes(:suggestion).limit(per_page)
+ render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :friends_suggestions }
end
end
diff --git a/app/views/friends/index.html.erb b/app/views/friends/index.html.erb
index 2611eae..4798d20 100644
--- a/app/views/friends/index.html.erb
+++ b/app/views/friends/index.html.erb
@@ -28,14 +28,9 @@
<% unless @suggestions.empty? %>
+
<%= _("Friends suggestions") %>
-
<%= _("Friends suggestions") %>
-
- <%= render :partial => 'shared/profile_list', :locals => { :suggestions => @suggestions, :collection => :friends_suggestions } %>
-
- <% button_bar do %>
- <%= link_to _('See more suggestions...'), :action => 'suggest' %>
- <% end %>
+ <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :friends_suggestions } %>
<% end %>
diff --git a/app/views/friends/suggest.html.erb b/app/views/friends/suggest.html.erb
index a5e3839..73a4b37 100644
--- a/app/views/friends/suggest.html.erb
+++ b/app/views/friends/suggest.html.erb
@@ -1,19 +1,9 @@
-
-
<%= _("Friends suggestions for %s") % profile.name %>
+
<%= _("Friends suggestions for %s") % profile.name %>
- <% button_bar do %>
- <%= button(:back, _('Go to friends list'), :controller => 'friends') %>
- <% end %>
+<% button_bar do %>
+ <%= button(:back, _('Go to friends list'), :controller => 'friends') %>
+<% end %>
- <% if @suggestions.empty? %>
-
-
- <%= _('You have no suggestions yet.') %>
- <%= link_to _('Do you want to see other people in this environment?'), :controller => 'search', :action => 'assets', :asset => 'people' %>
-
-
- <% else %>
- <%= render :partial => 'shared/profile_list', :locals => { :suggestions => @suggestions, :collection => :friends_suggestions } %>
- <% end %>
-
+
+ <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :friends_suggestions } %>
diff --git a/app/views/memberships/suggest.html.erb b/app/views/memberships/suggest.html.erb
index 7317d0f..06aa66e 100644
--- a/app/views/memberships/suggest.html.erb
+++ b/app/views/memberships/suggest.html.erb
@@ -13,7 +13,7 @@
<% else %>
- <%= render :partial => 'shared/profile_list', :locals => { :suggestions => @suggestions, :collection => :communities_suggestions } %>
+ <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :communities_suggestions } %>
<% end %>
diff --git a/app/views/shared/_profile_list.html.erb b/app/views/shared/_profile_list.html.erb
deleted file mode 100644
index a0342c5..0000000
--- a/app/views/shared/_profile_list.html.erb
+++ /dev/null
@@ -1,38 +0,0 @@
-
- <% suggestions.each do |s| %>
- -
- <%= link_to_profile profile_image(s.suggestion, :minor) + '
' + s.suggestion.short_name,
- s.suggestion.identifier, :class => 'profile-link' %>
- <%= button_without_text :help, content_tag('span',_('info about suggestion')),
- { :action => '#' },
- :class => 'explain-suggestion',
- :title => _('Why this suggestion?') %>
-
-
- <% if collection == :friends_suggestions %>
- <%= button_without_text :add, content_tag('span',_('add')),
- s.suggestion.add_url,
- :class => 'add-friend',
- :title => _('Add friend') %>
- <%= button_without_text :remove, content_tag('span',_('remove')),
- { :action => 'remove_suggestion', :id => s.suggestion.identifier },
- :title => _('Remove suggestion'),
- :method => 'post',
- :confirm => _('Are you sure you want to remove this suggestion?') %>
- <% elsif collection == :communities_suggestions %>
- <%= button_without_text :add, content_tag('span',_('join')),
- s.suggestion.join_url,
- :class => 'join-community',
- :title => _("Join %s") % s.suggestion.name %>
- <%= button_without_text :remove, content_tag('span',_('remove')),
- { :action => 'remove_suggestion', :id => s.suggestion.identifier },
- :title => _('Remove suggestion'),
- :method => 'post',
- :confirm => _('Are you sure you want to remove this suggestion?') %>
- <% end %>
-
-
- <% end %>
-
diff --git a/app/views/shared/_profile_suggestions_list.html.erb b/app/views/shared/_profile_suggestions_list.html.erb
new file mode 100644
index 0000000..31b0bdd
--- /dev/null
+++ b/app/views/shared/_profile_suggestions_list.html.erb
@@ -0,0 +1,48 @@
+<% if suggestions.empty? %>
+
+
+ <%= _('You have no suggestions yet.') %>
+ <%= link_to _('Do you want to see other people in this environment?'), :controller => 'search', :action => 'assets', :asset => 'people' %>
+
+
+<% else %>
+
+ <% suggestions.each do |s| %>
+ -
+ <%= link_to_profile profile_image(s.suggestion, :minor) + '
' + s.suggestion.short_name,
+ s.suggestion.identifier, :class => 'profile-link' %>
+ <%= button_without_text :help, content_tag('span',_('info about suggestion')),
+ { :action => '#' },
+ :class => 'explain-suggestion',
+ :title => _('Why this suggestion?') %>
+
+
+ <% if collection == :friends_suggestions %>
+ <%= button_without_text :add, content_tag('span',_('add')),
+ s.suggestion.add_url,
+ :class => 'add-friend accept-suggestion',
+ :title => _('Add friend') %>
+ <%= button_without_text :remove, content_tag('span',_('remove')),
+ { :action => 'remove_suggestion', :id => s.suggestion.identifier },
+ :class => 'remove-suggestion',
+ :title => _('Remove suggestion'),
+ :confirm => _('Are you sure you want to remove this suggestion?') %>
+ <% elsif collection == :communities_suggestions %>
+ <%= button_without_text :add, content_tag('span',_('join')),
+ s.suggestion.join_url,
+ :class => 'join-community',
+ :title => _("Join %s") % s.suggestion.name %>
+ <%= button_without_text :remove, content_tag('span',_('remove')),
+ { :action => 'remove_suggestion', :id => s.suggestion.identifier },
+ :title => _('Remove suggestion'),
+ :method => 'post',
+ :confirm => _('Are you sure you want to remove this suggestion?') %>
+ <% end %>
+
+
+ <% end %>
+
+<% end %>
+
diff --git a/public/javascripts/add-and-join.js b/public/javascripts/add-and-join.js
index 470fd2d..fec4001 100644
--- a/public/javascripts/add-and-join.js
+++ b/public/javascripts/add-and-join.js
@@ -120,4 +120,23 @@ jQuery(function($) {
return false;
})
+ $(".remove-suggestion").live('click', function(){
+ clicked = $(this)
+ url = clicked.attr("href");
+ loading_for_button(this);
+ $.post(url, function(data){
+ clicked.fadeOut();
+ clicked.parents('.profiles-suggestions').html(data);
+ });
+ return false;
+ })
+
+ /* After adding a suggestion need to remove it from list */
+ $(".accept-suggestion").live('click', function(){
+ clicked = $(this)
+ loading_for_button(this);
+ clicked.parents('li').fadeOut();
+ return false;
+ })
+
});
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index ece5c08..db437d8 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -1055,7 +1055,6 @@ function showHideTermsOfUse() {
jQuery('.profiles-suggestions .explain-suggestion').live('click', function() {
var clicked = jQuery(this);
- jQuery('.profiles-suggestions .extra_info').hide();
clicked.toggleClass('active');
clicked.next('.extra_info').toggle();
return false;
--
libgit2 0.21.2