From b5d2ddedfa5eb0d11835bde7cd2e93d70bc43eda Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Tue, 12 Jul 2016 17:42:40 +0000 Subject: [PATCH] Moves sidebar queries rendering to QueriesHelper (#14790). git-svn-id: http://svn.redmine.org/redmine/trunk@15640 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/issues_helper.rb | 34 ---------------------------------- app/helpers/queries_helper.rb | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index a276a61ff..2557b8cc7 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -276,40 +276,6 @@ module IssuesHelper users end - def sidebar_queries - unless @sidebar_queries - @sidebar_queries = IssueQuery.visible. - order("#{Query.table_name}.name ASC"). - # Project specific queries and global queries - where(@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id]). - to_a - end - @sidebar_queries - end - - def query_links(title, queries) - return '' if queries.empty? - # links to #index on issues/show - url_params = controller_name == 'issues' ? {:controller => 'issues', :action => 'index', :project_id => @project} : {} - - content_tag('h3', title) + "\n" + - content_tag('ul', - queries.collect {|query| - css = 'query' - css << ' selected' if query == @query - content_tag('li', link_to(query.name, url_params.merge(:query_id => query), :class => css)) - }.join("\n").html_safe, - :class => 'queries' - ) + "\n" - end - - def render_sidebar_queries - out = ''.html_safe - out << query_links(l(:label_my_queries), sidebar_queries.select(&:is_private?)) - out << query_links(l(:label_query_plural), sidebar_queries.reject(&:is_private?)) - out - end - def email_issue_attributes(issue, user) items = [] %w(author status priority assigned_to category fixed_version).each do |attribute| diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb index f24e51327..76d42bae5 100644 --- a/app/helpers/queries_helper.rb +++ b/app/helpers/queries_helper.rb @@ -277,4 +277,38 @@ module QueriesHelper tags end + + def sidebar_queries + unless @sidebar_queries + @sidebar_queries = IssueQuery.visible. + order("#{Query.table_name}.name ASC"). + # Project specific queries and global queries + where(@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id]). + to_a + end + @sidebar_queries + end + + def query_links(title, queries) + return '' if queries.empty? + # links to #index on issues/show + url_params = controller_name == 'issues' ? {:controller => 'issues', :action => 'index', :project_id => @project} : {} + + content_tag('h3', title) + "\n" + + content_tag('ul', + queries.collect {|query| + css = 'query' + css << ' selected' if query == @query + content_tag('li', link_to(query.name, url_params.merge(:query_id => query), :class => css)) + }.join("\n").html_safe, + :class => 'queries' + ) + "\n" + end + + def render_sidebar_queries + out = ''.html_safe + out << query_links(l(:label_my_queries), sidebar_queries.select(&:is_private?)) + out << query_links(l(:label_query_plural), sidebar_queries.reject(&:is_private?)) + out + end end -- 2.39.5