diff --git a/app/controllers/public/profile_controller.rb b/app/controllers/public/profile_controller.rb index c4eb18e..2463ae0 100644 --- a/app/controllers/public/profile_controller.rb +++ b/app/controllers/public/profile_controller.rb @@ -210,6 +210,48 @@ class ProfileController < PublicController render :partial => 'profile_network_activities', :locals => {:network_activities => @activities} end + def more_comments + activity_id = params[:activity].to_i + activity = ActionTracker::Record.find(:first, :conditions => {:id => activity_id, :user_id => @profile.id}) + comments_count = activity.comments.count + comment_page = (params[:comment_page] || 1).to_i + comments_per_page = 5 + no_more_pages = comments_count <= comment_page * comments_per_page + + render :update do |page| + page.insert_html :bottom, 'profile-wall-activities-comments-'+params[:activity], + :partial => 'comment', :collection => activity.comments.paginate(:per_page => comments_per_page, :page => comment_page) + + if no_more_pages + page.remove 'profile-wall-activities-comments-more-'+params[:activity] + else + page.replace_html 'profile-wall-activities-comments-more-'+params[:activity], + :partial => 'more_comments', :locals => {:activity => activity, :comment_page => comment_page} + end + end + end + + def more_replies + activity_id = params[:activity].to_i + activity = Scrap.find(:first, :conditions => {:id => activity_id, :receiver_id => @profile.id, :scrap_id => nil}) + comments_count = activity.replies.count + comment_page = (params[:comment_page] || 1).to_i + comments_per_page = 5 + no_more_pages = comments_count <= comment_page * comments_per_page + + render :update do |page| + page.insert_html :bottom, 'profile-wall-activities-comments-'+params[:activity], + :partial => 'profile_scrap', :collection => activity.replies.paginate(:per_page => comments_per_page, :page => comment_page), :as => :scrap + + if no_more_pages + page.remove 'profile-wall-activities-comments-more-'+params[:activity] + else + page.replace_html 'profile-wall-activities-comments-more-'+params[:activity], + :partial => 'more_replies', :locals => {:activity => activity, :comment_page => comment_page} + end + end + end + def remove_scrap begin scrap = current_user.person.scraps(params[:scrap_id]) @@ -343,6 +385,7 @@ class ProfileController < PublicController end end + protected def check_access_to_profile @@ -393,4 +436,5 @@ class ProfileController < PublicController def relations_to_include [:image, :domains, :preferred_domain, :environment] end + end diff --git a/app/views/profile/_more_comments.rhtml b/app/views/profile/_more_comments.rhtml new file mode 100644 index 0000000..875c1e9 --- /dev/null +++ b/app/views/profile/_more_comments.rhtml @@ -0,0 +1,3 @@ +