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
) + "\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
<%= 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) %>
</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 %>
<% 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)) %>
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