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
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
......@@ -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) %>
......@@ -41,6 +41,10 @@
</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 %>
......
......@@ -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)) %>
......@@ -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
......
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