TagSetPresenter: refactor to pass options explicitly.
Refactor tag_list_html, split_tag_list_html, and inline_tag_list_html to take the `show_extra_links` and `current_query` options explicitly, rather than implicitly relying on CurrentUser or taking `params[:tags]` from the template.
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
module PostSetPresenters
|
||||
class Favorite < Base
|
||||
attr_accessor :post_set, :tag_set_presenter
|
||||
delegate :favorites, :to => :post_set
|
||||
delegate :favorites, :posts, :to => :post_set
|
||||
delegate :tag_list_html, to: :tag_set_presenter
|
||||
|
||||
def initialize(post_set)
|
||||
@post_set = post_set
|
||||
@@ -11,13 +12,5 @@ module PostSetPresenters
|
||||
).map {|x| x[0]}
|
||||
)
|
||||
end
|
||||
|
||||
def tag_list_html(template)
|
||||
tag_set_presenter.tag_list_html(template)
|
||||
end
|
||||
|
||||
def posts
|
||||
@posts ||= post_set.posts
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,10 +12,6 @@ module PostSetPresenters
|
||||
)
|
||||
end
|
||||
|
||||
def tag_list_html(template)
|
||||
tag_set_presenter.tag_list_html(template)
|
||||
end
|
||||
|
||||
def post_previews_html(template)
|
||||
html = ""
|
||||
|
||||
|
||||
@@ -67,12 +67,8 @@ module PostSetPresenters
|
||||
SavedSearch.labels_for(CurrentUser.user.id).map {|x| "search:#{x}"}
|
||||
end
|
||||
|
||||
def tag_list_html(template, options = {})
|
||||
if post_set.is_saved_search?
|
||||
options[:name_only] = true
|
||||
end
|
||||
|
||||
tag_set_presenter.tag_list_html(template, options)
|
||||
def tag_list_html(**options)
|
||||
tag_set_presenter.tag_list_html(name_only: post_set.is_saved_search?, **options)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user