]> source.dussan.org Git - redmine.git/commitdiff
Moves sidebar queries rendering to QueriesHelper (#14790).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 12 Jul 2016 17:42:40 +0000 (17:42 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 12 Jul 2016 17:42:40 +0000 (17:42 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@15640 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/issues_helper.rb
app/helpers/queries_helper.rb

index a276a61ff8acf968dbfc692c20bd820f6f5dc940..2557b8cc7825b71d5ef9dc923c7bead2b8e5bf20 100644 (file)
@@ -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|
index f24e513273eec8793d758d4f6c788da02ccd9537..76d42bae554ced2966915ad9176f084bff87dbfd 100644 (file)
@@ -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