]> source.dussan.org Git - redmine.git/commitdiff
Display the list of saved queries in the sidebar (#14790).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 12 Jul 2016 17:54:46 +0000 (17:54 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 12 Jul 2016 17:54:46 +0000 (17:54 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@15642 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/queries_helper.rb
app/views/issues/_sidebar.html.erb
app/views/timelog/index.html.erb
app/views/timelog/report.html.erb
test/functional/timelog_controller_test.rb

index 52da20e84a965cb0aefed7b9ced41c415b684a00..d457593d533b66bbb6cb8d882c191ed312dbda6e 100644 (file)
@@ -278,10 +278,12 @@ module QueriesHelper
     tags
   end
 
-  def sidebar_queries
-    @sidebar_queries ||= IssueQuery.visible.global_or_on_project(@project).sorted.to_a
+  # Returns the queries that are rendered in the sidebar
+  def sidebar_queries(klass, project)
+    klass.visible.global_or_on_project(@project).sorted.to_a
   end
 
+  # Renders a group of queries
   def query_links(title, queries)
     return '' if queries.empty?
     # links to #index on issues/show
@@ -298,10 +300,13 @@ module QueriesHelper
       ) + "\n"
   end
 
-  def render_sidebar_queries
+  # Renders the list of queries for the sidebar
+  def render_sidebar_queries(klass, project)
+    queries = sidebar_queries(klass, project)
+
     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 << query_links(l(:label_my_queries), queries.select(&:is_private?))
+    out << query_links(l(:label_query_plural), queries.reject(&:is_private?))
     out
   end
 end
index df9f43b720b96e6f106d62fc00d55140b4a82d5a..7e97c091115a4aa1af211249709d0b243d6bbe42 100644 (file)
@@ -21,5 +21,5 @@
 <%= call_hook(:view_issues_sidebar_issues_bottom) %>
 <%= call_hook(:view_issues_sidebar_planning_bottom) %>
 
-<%= render_sidebar_queries %>
+<%= render_sidebar_queries(IssueQuery, @project) %>
 <%= call_hook(:view_issues_sidebar_queries_bottom) %>
index 6f2c92f4e1f598c5b73e50b3d3bdc58ea21026ab..02d5dbf9b6f96708f6d1d3fc9f3e46e4815336f5 100644 (file)
 </div>
 <% end %>
 
+<% content_for :sidebar do %>
+  <%= render_sidebar_queries(TimeEntryQuery, @project) %>
+<% end %>
+
 <% html_title(@query.new_record? ? l(:label_spent_time) : @query.name, l(:label_details)) %>
 
 <% content_for :header_tags do %>
index d1d2155425941bfe75454ecb8a7e345b7bcff3c4..f3cd6dc6084803ab774323652366f5b2ecb3d719 100644 (file)
@@ -70,5 +70,9 @@
 <% end %>
 <% end %>
 
+<% content_for :sidebar do %>
+  <%= render_sidebar_queries(TimeEntryQuery, @project) %>
+<% end %>
+
 <% html_title(@query.new_record? ? l(:label_spent_time) : @query.name, l(:label_report)) %>
 
index 5ee683f4ccdeb41fc2da4e8c2885ad63a659f497..eafea27c747d1d64352143c77acaf650e738f3ba 100644 (file)
@@ -767,6 +767,7 @@ class TimelogControllerTest < ActionController::TestCase
     get :index, :project_id => 'ecookbook', :query_id => query.id
     assert_response :success
     assert_select 'h2', :text => query.name
+    assert_select '#sidebar a.selected', :text => query.name
   end
 
   def test_index_atom_feed