Commit 7eb4062f authored by jplang's avatar jplang

Display the list of saved queries in the sidebar (#14790).

git-svn-id: https://svn.redmine.org/redmine/trunk@15642 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 43a9d967
...@@ -278,10 +278,12 @@ module QueriesHelper ...@@ -278,10 +278,12 @@ module QueriesHelper
tags tags
end end
def sidebar_queries # Returns the queries that are rendered in the sidebar
@sidebar_queries ||= IssueQuery.visible.global_or_on_project(@project).sorted.to_a def sidebar_queries(klass, project)
klass.visible.global_or_on_project(@project).sorted.to_a
end end
# Renders a group of queries
def query_links(title, queries) def query_links(title, queries)
return '' if queries.empty? return '' if queries.empty?
# links to #index on issues/show # links to #index on issues/show
...@@ -298,10 +300,13 @@ module QueriesHelper ...@@ -298,10 +300,13 @@ module QueriesHelper
) + "\n" ) + "\n"
end 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 = ''.html_safe
out << query_links(l(:label_my_queries), sidebar_queries.select(&:is_private?)) out << query_links(l(:label_my_queries), queries.select(&:is_private?))
out << query_links(l(:label_query_plural), sidebar_queries.reject(&:is_private?)) out << query_links(l(:label_query_plural), queries.reject(&:is_private?))
out out
end end
end end
...@@ -21,5 +21,5 @@ ...@@ -21,5 +21,5 @@
<%= call_hook(:view_issues_sidebar_issues_bottom) %> <%= call_hook(:view_issues_sidebar_issues_bottom) %>
<%= call_hook(:view_issues_sidebar_planning_bottom) %> <%= call_hook(:view_issues_sidebar_planning_bottom) %>
<%= render_sidebar_queries %> <%= render_sidebar_queries(IssueQuery, @project) %>
<%= call_hook(:view_issues_sidebar_queries_bottom) %> <%= call_hook(:view_issues_sidebar_queries_bottom) %>
...@@ -41,6 +41,10 @@ ...@@ -41,6 +41,10 @@
</div> </div>
<% 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_details)) %> <% html_title(@query.new_record? ? l(:label_spent_time) : @query.name, l(:label_details)) %>
<% content_for :header_tags do %> <% content_for :header_tags do %>
......
...@@ -70,5 +70,9 @@ ...@@ -70,5 +70,9 @@
<% end %> <% end %>
<% 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)) %> <% html_title(@query.new_record? ? l(:label_spent_time) : @query.name, l(:label_report)) %>
...@@ -767,6 +767,7 @@ class TimelogControllerTest < ActionController::TestCase ...@@ -767,6 +767,7 @@ class TimelogControllerTest < ActionController::TestCase
get :index, :project_id => 'ecookbook', :query_id => query.id get :index, :project_id => 'ecookbook', :query_id => query.id
assert_response :success assert_response :success
assert_select 'h2', :text => query.name assert_select 'h2', :text => query.name
assert_select '#sidebar a.selected', :text => query.name
end end
def test_index_atom_feed def test_index_atom_feed
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment