Commit 4a00fbd9335f7dc7098f5d11ffba2d50ca147ae4
1 parent
9b2304e3
Exists in
master
and in
29 other branches
Fixed network activities
Showing
17 changed files
with
38 additions
and
20 deletions
Show diff stats
app/controllers/public/profile_controller.rb
@@ -8,9 +8,9 @@ class ProfileController < PublicController | @@ -8,9 +8,9 @@ class ProfileController < PublicController | ||
8 | helper TagsHelper | 8 | helper TagsHelper |
9 | 9 | ||
10 | def index | 10 | def index |
11 | - @network_activities = !@profile.is_a?(Person) ? @profile.tracked_notifications.paginate(:per_page => 15, :page => params[:page]) : [] | 11 | + @network_activities = !@profile.is_a?(Person) ? @profile.tracked_notifications.visible.paginate(:per_page => 15, :page => params[:page]) : [] |
12 | if logged_in? && current_person.follows?(@profile) | 12 | if logged_in? && current_person.follows?(@profile) |
13 | - @network_activities = @profile.tracked_notifications.paginate(:per_page => 15, :page => params[:page]) if @network_activities.empty? | 13 | + @network_activities = @profile.tracked_notifications.visible.paginate(:per_page => 15, :page => params[:page]) if @network_activities.empty? |
14 | @activities = @profile.activities.paginate(:per_page => 15, :page => params[:page]) | 14 | @activities = @profile.activities.paginate(:per_page => 15, :page => params[:page]) |
15 | end | 15 | end |
16 | @tags = profile.article_tags | 16 | @tags = profile.article_tags |
@@ -178,7 +178,7 @@ class ProfileController < PublicController | @@ -178,7 +178,7 @@ class ProfileController < PublicController | ||
178 | @scrap.receiver= receiver | 178 | @scrap.receiver= receiver |
179 | @tab_action = params[:tab_action] | 179 | @tab_action = params[:tab_action] |
180 | @message = @scrap.save ? _("Message successfully sent.") : _("You can't leave an empty message.") | 180 | @message = @scrap.save ? _("Message successfully sent.") : _("You can't leave an empty message.") |
181 | - activities = @profile.activities.paginate(:per_page => 30, :page => params[:page]) if params[:not_load_scraps].nil? | 181 | + activities = @profile.activities.paginate(:per_page => 15, :page => params[:page]) if params[:not_load_scraps].nil? |
182 | render :partial => 'profile_activities_list', :locals => {:activities => activities} | 182 | render :partial => 'profile_activities_list', :locals => {:activities => activities} |
183 | end | 183 | end |
184 | 184 | ||
@@ -189,8 +189,13 @@ class ProfileController < PublicController | @@ -189,8 +189,13 @@ class ProfileController < PublicController | ||
189 | @comment.source_type, @comment.source_id = (@activity.target_type == 'Article' ? ['Article', @activity.target_id] : [@activity.class.to_s, @activity.id]) | 189 | @comment.source_type, @comment.source_id = (@activity.target_type == 'Article' ? ['Article', @activity.target_id] : [@activity.class.to_s, @activity.id]) |
190 | @tab_action = params[:tab_action] | 190 | @tab_action = params[:tab_action] |
191 | @message = @comment.save ? _("Comment successfully added.") : _("You can't leave an empty comment.") | 191 | @message = @comment.save ? _("Comment successfully added.") : _("You can't leave an empty comment.") |
192 | - activities = @profile.activities.paginate(:per_page => 30, :page => params[:page]) if params[:not_load_scraps].nil? | ||
193 | - render :partial => 'profile_activities_list', :locals => {:activities => activities} | 192 | + if @tab_action == 'wall' |
193 | + activities = @profile.activities.paginate(:per_page => 15, :page => params[:page]) if params[:not_load_scraps].nil? | ||
194 | + render :partial => 'profile_activities_list', :locals => {:activities => activities} | ||
195 | + else | ||
196 | + network_activities = @profile.tracked_notifications.visible.paginate(:per_page => 15, :page => params[:page]) | ||
197 | + render :partial => 'profile_network_activities', :locals => {:network_activities => network_activities} | ||
198 | + end | ||
194 | end | 199 | end |
195 | 200 | ||
196 | def view_more_activities | 201 | def view_more_activities |
app/views/profile/_add_member_in_community.rhtml
app/views/profile/_create_article.rhtml
app/views/profile/_default_activity.rhtml
app/views/profile/_join_community.rhtml
@@ -1 +0,0 @@ | @@ -1 +0,0 @@ | ||
1 | -<%= render :partial => 'default_activity', :locals => {:activity => activity} %> |
app/views/profile/_new_friendship.rhtml
@@ -1 +0,0 @@ | @@ -1 +0,0 @@ | ||
1 | -<%= render :partial => 'default_activity', :locals => {:activity => activity} %> |
app/views/profile/_profile_activities_list.rhtml
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | <% activities.each do |a| %> | 2 | <% activities.each do |a| %> |
3 | <% activity = a.klass.constantize.find(a.id) %> | 3 | <% activity = a.klass.constantize.find(a.id) %> |
4 | <% if activity.kind_of?(ActionTracker::Record) %> | 4 | <% if activity.kind_of?(ActionTracker::Record) %> |
5 | - <%= render :partial => 'profile_activity', :locals => {:activity => activity} if activity.visible? %> | 5 | + <%= render :partial => 'profile_activity', :locals => { :activity => activity, :tab_action => 'wall' } if activity.visible? %> |
6 | <% else %> | 6 | <% else %> |
7 | <%= render :partial => 'profile_scrap', :locals => {:scrap => activity } %> | 7 | <%= render :partial => 'profile_scrap', :locals => {:scrap => activity } %> |
8 | <% end %> | 8 | <% end %> |
app/views/profile/_profile_activity.rhtml
1 | <li class='profile-activity-item <%= activity.verb %>' id='profile-activity-item-<%= activity.id %>'> | 1 | <li class='profile-activity-item <%= activity.verb %>' id='profile-activity-item-<%= activity.id %>'> |
2 | - <%= render :partial => activity.verb, :locals => { :activity => activity }%> | 2 | + <%= render :partial => activity.verb, :locals => { :activity => activity, :tab_action => tab_action }%> |
3 | <hr /> | 3 | <hr /> |
4 | </li> | 4 | </li> |
app/views/profile/_profile_comment_form.rhtml
1 | <div id='profile-wall-reply-<%= activity.id%>'> | 1 | <div id='profile-wall-reply-<%= activity.id%>'> |
2 | <div id='profile-wall-reply-form-<%= activity.id%>'> | 2 | <div id='profile-wall-reply-form-<%= activity.id%>'> |
3 | <p class='profile-wall-reply'> | 3 | <p class='profile-wall-reply'> |
4 | - <% form_remote_tag :url => {:controller => 'profile', :action => 'leave_comment_on_activity'}, :update => 'profile_activities', :html => { :class => 'profile-wall-reply-form' } do %> | 4 | + <% update_area = tab_action == 'wall' ? 'profile_activities' : 'network-activities' %> |
5 | + <% form_remote_tag :url => {:controller => 'profile', :action => 'leave_comment_on_activity', :tab_action => tab_action}, :html => { :class => 'profile-wall-reply-form', 'data-update' => update_area } do %> | ||
5 | <%= text_area :comment, :body, {:id => "reply_content_#{activity.id}", | 6 | <%= text_area :comment, :body, {:id => "reply_content_#{activity.id}", |
6 | :cols => 50, | 7 | :cols => 50, |
7 | :rows => 1, | 8 | :rows => 1, |
@@ -0,0 +1,13 @@ | @@ -0,0 +1,13 @@ | ||
1 | +<hr /> | ||
2 | + | ||
3 | +<% if activity.comments_count > 2 %> | ||
4 | + <div class='view-all-comments icon-chat'> | ||
5 | + <%= link_to(_("View all %s comments") % activity.comments_count, '#') %> | ||
6 | + </div> | ||
7 | +<% end %> | ||
8 | + | ||
9 | +<ul class="profile-wall-activities-comments" style="<%= 'display:none;' if (activity.comments_count > 2) %>" > | ||
10 | + <%= render :partial => 'comment', :collection => activity.comments %> | ||
11 | +</ul> | ||
12 | + | ||
13 | +<%= render :partial => 'profile_comment_form', :locals => { :activity => activity, :tab_action => tab_action } %> |
app/views/profile/_profile_network.rhtml
1 | <h3><%= _("%s's network activity") % @profile.name %></h3> | 1 | <h3><%= _("%s's network activity") % @profile.name %></h3> |
2 | -<ul> | 2 | +<ul id='network-activities' class='profile-activities'> |
3 | <%= render :partial => 'profile_network_activities', :locals => {:network_activities => @network_activities} %> | 3 | <%= render :partial => 'profile_network_activities', :locals => {:network_activities => @network_activities} %> |
4 | </ul> | 4 | </ul> |
app/views/profile/_profile_network_activities.rhtml
1 | <% network_activities.each do |activity| %> | 1 | <% network_activities.each do |activity| %> |
2 | - <li class='profile-activity-item <%= activity.verb %>' id='profile-network-item-<%= activity.id %>'> | ||
3 | - <%= render :partial => activity.verb, :locals => { :activity => activity }%> | ||
4 | - <hr/> | ||
5 | - </li> | 2 | + <%= render :partial => 'profile_activity', :locals => { :activity => activity, :tab_action => 'network' } if activity.visible? %> |
6 | <% end %> | 3 | <% end %> |
7 | <% if network_activities.current_page < network_activities.total_pages %> | 4 | <% if network_activities.current_page < network_activities.total_pages %> |
8 | <div id='profile_network_activities_page_<%= network_activities.current_page %>'> | 5 | <div id='profile_network_activities_page_<%= network_activities.current_page %>'> |
app/views/profile/_upload_image.rhtml
@@ -14,7 +14,7 @@ | @@ -14,7 +14,7 @@ | ||
14 | <div title='<%= activity.target.class.short_description %>' class='profile-activity-icon icon-new icon-newgallery'></div> | 14 | <div title='<%= activity.target.class.short_description %>' class='profile-activity-icon icon-new icon-newgallery'></div> |
15 | 15 | ||
16 | <% if activity.get_view_url.size == 1 %> | 16 | <% if activity.get_view_url.size == 1 %> |
17 | - <%= render :partial => 'profile_comments', :locals => { :activity => activity } %> | 17 | + <%= render :partial => 'profile_comments', :locals => { :activity => activity, :tab_action => tab_action } %> |
18 | <% end %> | 18 | <% end %> |
19 | 19 | ||
20 | <br/> | 20 | <br/> |
public/javascripts/application.js
@@ -724,7 +724,8 @@ jQuery(function($){ | @@ -724,7 +724,8 @@ jQuery(function($){ | ||
724 | loading_for_button($(field)); | 724 | loading_for_button($(field)); |
725 | }, | 725 | }, |
726 | success: function(data) { | 726 | success: function(data) { |
727 | - $('#profile_activities').html(data); | 727 | + var update = form.attr('data-update'); |
728 | + $('#'+update).html(data); | ||
728 | $(field).val($(field).attr('title')); | 729 | $(field).val($(field).attr('title')); |
729 | } | 730 | } |
730 | }); | 731 | }); |
vendor/plugins/action_tracker/lib/action_tracker_model.rb
@@ -24,6 +24,7 @@ module ActionTracker | @@ -24,6 +24,7 @@ module ActionTracker | ||
24 | RECENT_DELAY = 30 | 24 | RECENT_DELAY = 30 |
25 | 25 | ||
26 | named_scope :recent, :conditions => ['created_at >= ?', RECENT_DELAY.days.ago] | 26 | named_scope :recent, :conditions => ['created_at >= ?', RECENT_DELAY.days.ago] |
27 | + named_scope :visible, :conditions => { :visible => true } | ||
27 | 28 | ||
28 | def self.current_user_from_model | 29 | def self.current_user_from_model |
29 | u = new | 30 | u = new |