Feature #2595 » 2595-without-tests.patch
| app/controllers/reports_controller.rb | ||
|---|---|---|
|
class ReportsController < ApplicationController
|
||
|
menu_item :issues
|
||
|
before_action :find_project, :authorize, :find_issue_statuses
|
||
|
before_action :find_project, :authorize, :if => proc { params[:id].present? }
|
||
|
before_action :find_issue_statuses
|
||
|
def issue_report
|
||
|
@trackers = @project.rolled_up_trackers(false).visible
|
||
|
@versions = @project.shared_versions.sort
|
||
|
@priorities = IssuePriority.all.reverse
|
||
|
@categories = @project.issue_categories
|
||
|
@assignees = (Setting.issue_group_assignment? ? @project.principals : @project.users).sort
|
||
|
@authors = @project.users.sort
|
||
|
@subprojects = @project.descendants.visible
|
||
|
if @project
|
||
|
@trackers = @project.rolled_up_trackers(false).visible
|
||
|
@versions = @project.shared_versions.sort
|
||
|
@priorities = IssuePriority.all.reverse
|
||
|
@categories = @project.issue_categories
|
||
|
@assignees = (Setting.issue_group_assignment? ? @project.principals : @project.users).sort
|
||
|
@authors = @project.users.sort
|
||
|
@subprojects = @project.descendants.visible
|
||
|
@issues_by_subproject = Issue.by_subproject(@project) || []
|
||
|
else
|
||
|
@trackers = Tracker.visible.sorted
|
||
|
@versions = []
|
||
|
@priorities = IssuePriority.all.reverse
|
||
|
@categories = []
|
||
|
@assignees = (Setting.issue_group_assignment? ? Principal.active : User.active).sort
|
||
|
@authors = User.active.sort
|
||
|
@projects = Project.visible.sorted
|
||
|
@issues_by_project = Issue.count_and_group_by(:association => :project)
|
||
|
end
|
||
|
with_subprojects = Setting.display_subprojects_issues?
|
||
|
@issues_by_tracker = Issue.by_tracker(@project, with_subprojects)
|
||
|
@issues_by_version = Issue.by_version(@project, with_subprojects)
|
||
| ... | ... | |
|
@issues_by_category = Issue.by_category(@project, with_subprojects)
|
||
|
@issues_by_assigned_to = Issue.by_assigned_to(@project, with_subprojects)
|
||
|
@issues_by_author = Issue.by_author(@project, with_subprojects)
|
||
|
@issues_by_subproject = Issue.by_subproject(@project) || []
|
||
|
render :template => "reports/issue_report"
|
||
|
end
|
||
| ... | ... | |
|
case params[:detail]
|
||
|
when "tracker"
|
||
|
@field = "tracker_id"
|
||
|
@rows = @project.rolled_up_trackers(false).visible
|
||
|
@rows = @project ? @project.rolled_up_trackers(false).visible : Tracker.visible.sorted
|
||
|
@data = Issue.by_tracker(@project, with_subprojects)
|
||
|
@report_title = l(:field_tracker)
|
||
|
when "version"
|
||
|
(render_404; return) unless @project.present?
|
||
|
@field = "fixed_version_id"
|
||
|
@rows = @project.shared_versions.sort
|
||
|
@data = Issue.by_version(@project, with_subprojects)
|
||
| ... | ... | |
|
@data = Issue.by_priority(@project, with_subprojects)
|
||
|
@report_title = l(:field_priority)
|
||
|
when "category"
|
||
|
(render_404; return) unless @project.present?
|
||
|
@field = "category_id"
|
||
|
@rows = @project.issue_categories
|
||
|
@data = Issue.by_category(@project, with_subprojects)
|
||
|
@report_title = l(:field_category)
|
||
|
when "assigned_to"
|
||
|
@field = "assigned_to_id"
|
||
|
@rows = (Setting.issue_group_assignment? ? @project.principals : @project.users).sort
|
||
|
@rows = @project ? (Setting.issue_group_assignment? ? @project.principals : @project.users).sort :
|
||
|
(Setting.issue_group_assignment? ? Principal.active : User.active).sort
|
||
|
@data = Issue.by_assigned_to(@project, with_subprojects)
|
||
|
@report_title = l(:field_assigned_to)
|
||
|
when "author"
|
||
|
@field = "author_id"
|
||
|
@rows = @project.users.sort
|
||
|
@rows = @project ? @project.users.sort : User.active.sort
|
||
|
@data = Issue.by_author(@project, with_subprojects)
|
||
|
@report_title = l(:field_author)
|
||
|
when "subproject"
|
||
|
(render_404; return) unless @project.present?
|
||
|
@field = "project_id"
|
||
|
@rows = @project.descendants.visible
|
||
|
@data = Issue.by_subproject(@project) || []
|
||
|
@report_title = l(:field_subproject)
|
||
|
when "project"
|
||
|
@field = "project_id"
|
||
|
@rows = Project.visible.sorted
|
||
|
@data = Issue.count_and_group_by(:association => :project)
|
||
|
@report_title = l(:field_project)
|
||
|
else
|
||
|
render_404
|
||
|
end
|
||
| ... | ... | |
|
private
|
||
|
def find_issue_statuses
|
||
|
@statuses = @project.rolled_up_statuses.sorted.to_a
|
||
|
@statuses = @project ? @project.rolled_up_statuses.sorted.to_a : IssueStatus.sorted.to_a
|
||
|
end
|
||
|
end
|
||
| app/helpers/reports_helper.rb | ||
|---|---|---|
|
def aggregate_path(project, field, row, options={})
|
||
|
parameters = {:set_filter => 1, :subproject_id => '!*', field => row.id}.merge(options)
|
||
|
project_issues_path(row.is_a?(Project) ? row : project, parameters)
|
||
|
parameters[:subproject_id] = nil if project
|
||
|
return project_issues_path(row, parameters) if row.is_a?(Project)
|
||
|
return project_issues_path(project, parameters) if project.is_a?(Project)
|
||
|
return issues_path(parameters)
|
||
|
end
|
||
|
def report_details_path(project, options)
|
||
|
if project
|
||
|
project_issues_report_details_path(project, options)
|
||
|
else
|
||
|
issues_report_details_path(options)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| app/models/issue.rb | ||
|---|---|---|
|
# * with_subprojects - Includes subprojects issues if set to true.
|
||
|
# * association - Symbol. Association for grouping.
|
||
|
def self.count_and_group_by(options)
|
||
|
visible_conditions = {:project => options[:project], :with_subprojects => options[:with_subprojects]}
|
||
|
visible_conditions.delete(:project) if options[:project].nil?
|
||
|
assoc = reflect_on_association(options[:association])
|
||
|
select_field = assoc.foreign_key
|
||
|
Issue.
|
||
|
visible(User.current, :project => options[:project], :with_subprojects => options[:with_subprojects]).
|
||
|
visible(User.current, visible_conditions).
|
||
|
joins(:status, assoc.name).
|
||
|
group(:status_id, :is_closed, select_field).
|
||
|
count.
|
||
| app/views/issues/_sidebar.html.erb | ||
|---|---|---|
|
<ul>
|
||
|
<li><%= link_to l(:label_issue_view_all), _project_issues_path(@project, :set_filter => 1) %></li>
|
||
|
<% if @project %>
|
||
|
<li><%= link_to l(:field_summary), project_issues_report_path(@project) %></li>
|
||
|
<% end %>
|
||
|
<li><%= link_to l(:field_summary), @project ? project_issues_report_path(@project) : issues_report_path %></li>
|
||
|
<% if User.current.allowed_to?(:import_issues, @project, :global => true) %>
|
||
|
<li><%= link_to l(:button_import), new_issues_import_path %></li>
|
||
| app/views/reports/_details.html.erb | ||
|---|---|---|
|
<tbody>
|
||
|
<% for row in rows %>
|
||
|
<tr>
|
||
|
<td class="name"><%= link_to row.name, aggregate_path(@project, field_name, row, :subproject_id => nil) %></td>
|
||
|
<td class="name"><%= link_to row.name, aggregate_path(@project, field_name, row) %></td>
|
||
|
<% for status in @statuses %>
|
||
|
<td><%= aggregate_link data, { field_name => row.id, "status_id" => status.id }, aggregate_path(@project, field_name, row, :status_id => status.id, :subproject_id => nil) %></td>
|
||
|
<td><%= aggregate_link data, { field_name => row.id, "status_id" => status.id }, aggregate_path(@project, field_name, row, {:status_id => status.id}) %></td>
|
||
|
<% end %>
|
||
|
<td><%= aggregate_link data, { field_name => row.id, "closed" => 0 }, aggregate_path(@project, field_name, row, :status_id => "o", :subproject_id => nil) %></td>
|
||
|
<td><%= aggregate_link data, { field_name => row.id, "closed" => 1 }, aggregate_path(@project, field_name, row, :status_id => "c", :subproject_id => nil) %></td>
|
||
|
<td><%= aggregate_link data, { field_name => row.id }, aggregate_path(@project, field_name, row, :status_id => "*", :subproject_id => nil) %></td>
|
||
|
<td><%= aggregate_link data, { field_name => row.id, "closed" => 0 }, aggregate_path(@project, field_name, row, {:status_id => "o"}) %></td>
|
||
|
<td><%= aggregate_link data, { field_name => row.id, "closed" => 1 }, aggregate_path(@project, field_name, row, {:status_id => "c"}) %></td>
|
||
|
<td><%= aggregate_link data, { field_name => row.id }, aggregate_path(@project, field_name, row, {:status_id => "*"}) %></td>
|
||
|
</tr>
|
||
|
<% end %>
|
||
|
</tbody>
|
||
| app/views/reports/_simple.html.erb | ||
|---|---|---|
|
<tbody>
|
||
|
<% for row in rows %>
|
||
|
<tr>
|
||
|
<td class="name"><%= link_to row.name, aggregate_path(@project, field_name, row, :subproject_id => nil) %></td>
|
||
|
<td><%= aggregate_link data, { field_name => row.id, "closed" => 0 }, aggregate_path(@project, field_name, row, :status_id => "o", :subproject_id => nil) %></td>
|
||
|
<td><%= aggregate_link data, { field_name => row.id, "closed" => 1 }, aggregate_path(@project, field_name, row, :status_id => "c", :subproject_id => nil) %></td>
|
||
|
<td><%= aggregate_link data, { field_name => row.id }, aggregate_path(@project, field_name, row, :status_id => "*", :subproject_id => nil) %></td>
|
||
|
<td class="name"><%= link_to row.name, aggregate_path(@project, field_name, row) %></td>
|
||
|
<td><%= aggregate_link data, { field_name => row.id, "closed" => 0 }, aggregate_path(@project, field_name, row, {:status_id => "o"}) %></td>
|
||
|
<td><%= aggregate_link data, { field_name => row.id, "closed" => 1 }, aggregate_path(@project, field_name, row, {:status_id => "c"}) %></td>
|
||
|
<td><%= aggregate_link data, { field_name => row.id }, aggregate_path(@project, field_name, row, {:status_id => "*"}) %></td>
|
||
|
</tr>
|
||
|
<% end %>
|
||
|
</tbody>
|
||
| app/views/reports/issue_report.html.erb | ||
|---|---|---|
|
<h3>
|
||
|
<%=l(:field_tracker)%>
|
||
|
<%= link_to l(:label_details),
|
||
|
project_issues_report_details_path(@project, :detail => 'tracker'),
|
||
|
report_details_path(@project, :detail => 'tracker'),
|
||
|
:class => 'icon-only icon-zoom-in',
|
||
|
:title => l(:label_details) %>
|
||
|
</h3>
|
||
| ... | ... | |
|
<h3>
|
||
|
<%=l(:field_priority)%>
|
||
|
<%= link_to l(:label_details),
|
||
|
project_issues_report_details_path(@project, :detail => 'priority'),
|
||
|
report_details_path(@project, :detail => 'priority'),
|
||
|
:class => 'icon-only icon-zoom-in',
|
||
|
:title => l(:label_details) %>
|
||
|
</h3>
|
||
| ... | ... | |
|
<h3>
|
||
|
<%=l(:field_assigned_to)%>
|
||
|
<%= link_to l(:label_details),
|
||
|
project_issues_report_details_path(@project, :detail => 'assigned_to'),
|
||
|
report_details_path(@project, :detail => 'assigned_to'),
|
||
|
:class => 'icon-only icon-zoom-in',
|
||
|
:title => l(:label_details) %>
|
||
|
</h3>
|
||
| ... | ... | |
|
<h3>
|
||
|
<%=l(:field_author)%>
|
||
|
<%= link_to l(:label_details),
|
||
|
project_issues_report_details_path(@project, :detail => 'author'),
|
||
|
report_details_path(@project, :detail => 'author'),
|
||
|
:class => 'icon-only icon-zoom-in',
|
||
|
:title => l(:label_details) %>
|
||
|
</h3>
|
||
| ... | ... | |
|
</div>
|
||
|
<div class="splitcontentright">
|
||
|
<% if @issues_by_version.present? && @versions.present? %>
|
||
|
<h3>
|
||
|
<%=l(:field_version)%>
|
||
|
<%= link_to l(:label_details),
|
||
|
project_issues_report_details_path(@project, :detail => 'version'),
|
||
|
report_details_path(@project, :detail => 'version'),
|
||
|
:class => 'icon-only icon-zoom-in',
|
||
|
:title => l(:label_details) %>
|
||
|
</h3>
|
||
|
<%= render :partial => 'simple', :locals => { :data => @issues_by_version, :field_name => "fixed_version_id", :rows => @versions } %>
|
||
|
<br />
|
||
|
<% if @project.children.any? %>
|
||
|
<% end %>
|
||
|
<% if @project && @project.children.any? %>
|
||
|
<h3>
|
||
|
<%=l(:field_subproject)%>
|
||
|
<%= link_to l(:label_details),
|
||
|
project_issues_report_details_path(@project, :detail => 'subproject'),
|
||
|
report_details_path(@project, :detail => 'subproject'),
|
||
|
:class => 'icon-only icon-zoom-in',
|
||
|
:title => l(:label_details) %>
|
||
|
</h3>
|
||
|
<%= render :partial => 'simple', :locals => { :data => @issues_by_subproject, :field_name => "project_id", :rows => @subprojects } %>
|
||
|
<br />
|
||
|
<% end %>
|
||
|
<% if @issues_by_category.present? && @categories.present? %>
|
||
|
<h3>
|
||
|
<%=l(:field_category)%>
|
||
|
<%= link_to l(:label_details),
|
||
|
project_issues_report_details_path(@project, :detail => 'category'),
|
||
|
report_details_path(@project, :detail => 'category'),
|
||
|
:class => 'icon-only icon-zoom-in',
|
||
|
:title => l(:label_details) %>
|
||
|
</h3>
|
||
|
<%= render :partial => 'simple', :locals => { :data => @issues_by_category, :field_name => "category_id", :rows => @categories } %>
|
||
|
<br />
|
||
|
<% end %>
|
||
|
<% if @issues_by_project.present? && @projects.present? %>
|
||
|
<h3>
|
||
|
<%=l(:field_project)%>
|
||
|
<%= link_to l(:label_details),
|
||
|
report_details_path(@project, :detail => 'project'),
|
||
|
:class => 'icon-only icon-zoom-in',
|
||
|
:title => l(:label_details) %>
|
||
|
</h3>
|
||
|
<%= render :partial => 'simple', :locals => { :data => @issues_by_project, :field_name => "project_id", :rows => @projects } %>
|
||
|
<br />
|
||
|
<% end %>
|
||
|
<%= call_hook(:view_reports_issue_report_split_content_right, :project => @project) %>
|
||
|
</div>
|
||
| app/views/reports/issue_report_details.html.erb | ||
|---|---|---|
|
<h3><%=@report_title%></h3>
|
||
|
<%= render :partial => 'details', :locals => { :data => @data, :field_name => @field, :rows => @rows } %>
|
||
|
<br />
|
||
|
<%= link_to l(:button_back), project_issues_report_path(@project) %>
|
||
|
<%= link_to l(:button_back), @project ? project_issues_report_path(@project) : issues_report_path %>
|
||
| config/routes.rb | ||
|---|---|---|
|
get 'projects/:id/issues/report', :to => 'reports#issue_report', :as => 'project_issues_report'
|
||
|
get 'projects/:id/issues/report/:detail', :to => 'reports#issue_report_details', :as => 'project_issues_report_details'
|
||
|
get 'issues/report', :to => 'reports#issue_report', :as => 'issues_report'
|
||
|
get 'issues/report/:detail', :to => 'reports#issue_report_details', :as => 'issues_report_details'
|
||
|
get '/issues/imports/new', :to => 'imports#new', :as => 'new_issues_import'
|
||
|
post '/imports', :to => 'imports#create', :as => 'imports'
|
||
- « Previous
- 1
- 2
- 3
- Next »