diff --git a/app/controllers/my_profile/followers_controller.rb b/app/controllers/my_profile/followers_controller.rb
index 1be40ae..7c1df81 100644
--- a/app/controllers/my_profile/followers_controller.rb
+++ b/app/controllers/my_profile/followers_controller.rb
@@ -8,7 +8,9 @@ class FollowersController < MyProfileController
if request.method == "GET"
render :partial => "set_category_modal", :locals => { :followed_profile_id => params[:followed_profile_id] }
elsif request.method == "POST"
+ params[:followed_profile_id] ||= profile.id
follower = ProfileFollower.find_by(follower_id: current_person.id, profile_id: params[:followed_profile_id])
+
follower.update_attributes(:group => params[:category_name]) if follower
redirect_to url_for(:controller => "followers", :action => "index")
end
diff --git a/app/controllers/public/profile_controller.rb b/app/controllers/public/profile_controller.rb
index 50e8a1c..b5629be 100644
--- a/app/controllers/public/profile_controller.rb
+++ b/app/controllers/public/profile_controller.rb
@@ -159,8 +159,13 @@ class ProfileController < PublicController
if !current_person.follows?(profile)
group = params['follow'] ? params['follow']['category'] : ''
current_person.follow(profile, group)
+
+ categories = ["Friends", "Family", "Work", "Interesting"]
+ render :partial => 'blocks/profile_info_actions/follow_categories', :locals => { :categories => categories }
+ else
+ # TODO return error
+ return "error"
end
- redirect_to profile.url
end
def unfollow
diff --git a/app/views/blocks/profile_info_actions/_follow_categories.html.erb b/app/views/blocks/profile_info_actions/_follow_categories.html.erb
new file mode 100644
index 0000000..d303cfd
--- /dev/null
+++ b/app/views/blocks/profile_info_actions/_follow_categories.html.erb
@@ -0,0 +1,10 @@
+
+
<%= _("You can set a category for %s") % profile.name %>
+ <% categories.each do |category| %>
+
+ <% end %>
+
diff --git a/app/views/blocks/profile_info_actions/_person.html.erb b/app/views/blocks/profile_info_actions/_person.html.erb
index b523369..4f6035b 100644
--- a/app/views/blocks/profile_info_actions/_person.html.erb
+++ b/app/views/blocks/profile_info_actions/_person.html.erb
@@ -11,12 +11,9 @@
<% if user.follows?(profile) %>
<%= button(:unfollow, content_tag('span', _('Unfollow')), {:profile => profile.identifier, :controller => 'profile', :action => 'unfollow'}) %>
<% else %>
-
+ <%= button(:follow, content_tag('span', _('Follow')), {:profile => profile.identifier, :controller => 'profile', :action => 'follow'}, :class => 'action-follow') %>
+
+
<% end %>
diff --git a/public/javascripts/followers.js b/public/javascripts/followers.js
index d7fcece..b56efc3 100644
--- a/public/javascripts/followers.js
+++ b/public/javascripts/followers.js
@@ -1,5 +1,26 @@
-$("#follower-container").live("mouseenter", function() {
- $("#category-form").fadeIn();
-}).live("mouseleave", function() {
- $("#category-form").fadeOut();
+$(".action-follow").live("click", function() {
+ var button = $(this);
+ var url = button.attr("href");
+
+ // TODO: add progress cursor and error handling
+ $.post(url, function(data) {
+ button.fadeOut('fast', function() {
+ $("#follow-categories-container").html(data);
+ $("#follow-categories-container").fadeIn();
+ });
+ });
+
+ return false;
+});
+
+$(".action-change-category").live("click", function() {
+ var category = $(this).text().trim();
+ var url = $(this).attr("href");
+
+ // TODO: add progress cursor and error handling
+ $.post(url, { 'category_name': category }, function(data) {
+ $("#follow-categories-container").fadeOut();
+ });
+
+ return false;
});
diff --git a/public/stylesheets/blocks/profile-info.scss b/public/stylesheets/blocks/profile-info.scss
index b1d8611..6548502 100644
--- a/public/stylesheets/blocks/profile-info.scss
+++ b/public/stylesheets/blocks/profile-info.scss
@@ -99,16 +99,11 @@
margin: 0px 0px 5px 0px;
padding: 2px;
}
-#follower-container:hover {
+#follow-categories-container {
background-color: #eee;
- -o-transition:.5s;
- -ms-transition:.5s;
- -moz-transition:.5s;
- -webkit-transition:.5s;
- transition:.5s;
- padding-top: 5px;
- padding-bottom: 5px;
+ padding: 5px;
}
-#follower-container #category-form {
+#follow-categories-container p {
+ font-size: 12px;
margin-bottom: 5px;
}
diff --git a/test/functional/followers_controller_test.rb b/test/functional/followers_controller_test.rb
index 30f9076..5ddefb5 100644
--- a/test/functional/followers_controller_test.rb
+++ b/test/functional/followers_controller_test.rb
@@ -12,7 +12,7 @@ class FollowersControllerTest < ActionController::TestCase
fast_create(ProfileFollower, :profile_id => person.id, :follower_id => @profile.id)
get :index, :profile => @profile.identifier
- assert_includes assigns(:followed_people), person
+ assert_includes assigns(:followed_people), person
end
should 'redirect to login page if not logged in' do
--
libgit2 0.21.2