This commit is contained in:
Toks
2015-06-29 15:01:41 -04:00
parent 7ea182c890
commit 9c70b69d28
4 changed files with 14 additions and 5 deletions

View File

@@ -838,11 +838,20 @@ class Post < ActiveRecord::Base
favorited_user_ids.map {|id| User.find(id)}
end
def favorite_groups
def favorite_groups(active_id=nil)
@favorite_groups ||= begin
CurrentUser.user.favorite_groups.select do |favgroup|
groups = []
if active_id.present?
active_group = FavoriteGroup.where(:id => active_id.to_i).first
groups << active_group if active_group && active_group.contains?(self.id)
end
groups += CurrentUser.user.favorite_groups.select do |favgroup|
favgroup.contains?(self.id)
end
groups.uniq
end
end
end

View File

@@ -205,7 +205,7 @@ class PostPresenter < Presenter
end
def has_nav_links?(template)
(CurrentUser.user.enable_sequential_post_navigation && template.params[:tags].present? && template.params[:tags] !~ /(?:^|\s)(?:order|ordfav|ordpool):/) || @post.pools.any? || @post.favorite_groups.any?
(CurrentUser.user.enable_sequential_post_navigation && template.params[:tags].present? && template.params[:tags] !~ /(?:^|\s)(?:order|ordfav|ordpool):/) || @post.pools.any? || @post.favorite_groups(active_id=template.params[:favgroup_id]).any?
end
def post_footer_for_pool_html(template)

View File

@@ -1,6 +1,6 @@
<div id="favgroup-nav">
<ul>
<% post.favorite_groups.each do |favgroup| %>
<% post.favorite_groups(active_id=params[:favgroup_id]).each do |favgroup| %>
<li>
<% klass = "active" if favgroup.id == params[:favgroup_id].to_i %>

View File

@@ -8,7 +8,7 @@
<%= render "posts/partials/show/pools", :post => post %>
<% end %>
<% if post.favorite_groups.any? %>
<% if post.favorite_groups(active_id=params[:favgroup_id]).any? %>
<%= render "posts/partials/show/favorite_groups", :post => post %>
<% end %>
</div>