Code cleanup, use named routes.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11077 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-12-23 15:55:57 +00:00
parent 3ef7f5855e
commit 4ac43ab876
8 changed files with 36 additions and 64 deletions

View File

@ -35,4 +35,9 @@ module ReportsHelper
a = aggregate data, criteria a = aggregate data, criteria
a > 0 ? link_to(h(a), *args) : '-' a > 0 ? link_to(h(a), *args) : '-'
end end
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)
end
end end

View File

@ -28,4 +28,12 @@ module RoutesHelper
issues_path(*args) issues_path(*args)
end end
end end
def _project_calendar_path(project, *args)
project ? project_calendar_path(project, *args) : issues_calendar_path(*args)
end
def _project_gantt_path(project, *args)
project ? project_gantt_path(project, *args) : issues_gantt_path(*args)
end
end end

View File

@ -1,15 +1,15 @@
<h3><%= l(:label_issue_plural) %></h3> <h3><%= l(:label_issue_plural) %></h3>
<%= link_to l(:label_issue_view_all), { :controller => 'issues', :action => 'index', :project_id => @project, :set_filter => 1 } %><br /> <%= link_to l(:label_issue_view_all), _project_issues_path(@project, :set_filter => 1) %><br />
<% if @project %> <% if @project %>
<%= link_to l(:field_summary), :controller => 'reports', :action => 'issue_report', :id => @project %><br /> <%= link_to l(:field_summary), project_issues_report_path(@project) %><br />
<% end %> <% end %>
<%= call_hook(:view_issues_sidebar_issues_bottom) %> <%= call_hook(:view_issues_sidebar_issues_bottom) %>
<% if User.current.allowed_to?(:view_calendar, @project, :global => true) %> <% if User.current.allowed_to?(:view_calendar, @project, :global => true) %>
<%= link_to(l(:label_calendar), :controller => 'calendars', :action => 'show', :project_id => @project) %><br /> <%= link_to l(:label_calendar), _project_calendar_path(@project) %><br />
<% end %> <% end %>
<% if User.current.allowed_to?(:view_gantt, @project, :global => true) %> <% if User.current.allowed_to?(:view_gantt, @project, :global => true) %>
<%= link_to(l(:label_gantt), :controller => 'gantts', :action => 'show', :project_id => @project) %><br /> <%= link_to l(:label_gantt), _project_gantt_path(@project) %><br />
<% end %> <% end %>
<%= call_hook(:view_issues_sidebar_planning_bottom) %> <%= call_hook(:view_issues_sidebar_planning_bottom) %>

View File

@ -15,36 +15,13 @@
<tbody> <tbody>
<% for row in rows %> <% for row in rows %>
<tr class="<%= cycle("odd", "even") %>"> <tr class="<%= cycle("odd", "even") %>">
<td><%= link_to h(row.name), :controller => 'issues', :action => 'index', :project_id => ((row.is_a?(Project) ? row : @project)), <td><%= link_to h(row.name), aggregate_path(@project, field_name, row) %></td>
:set_filter => 1,
:subproject_id => '!*',
"#{field_name}" => row.id %></td>
<% for status in @statuses %> <% for status in @statuses %>
<td align="center"><%= aggregate_link data, { field_name => row.id, "status_id" => status.id }, <td align="center"><%= aggregate_link data, { field_name => row.id, "status_id" => status.id }, aggregate_path(@project, field_name, row, :status_id => status.id) %></td>
:controller => 'issues', :action => 'index', :project_id => ((row.is_a?(Project) ? row : @project)),
:set_filter => 1,
:subproject_id => '!*',
"status_id" => status.id,
"#{field_name}" => row.id %></td>
<% end %> <% end %>
<td align="center"><%= aggregate_link data, { field_name => row.id, "closed" => 0 }, <td align="center"><%= aggregate_link data, { field_name => row.id, "closed" => 0 }, aggregate_path(@project, field_name, row, :status_id => "o") %></td>
:controller => 'issues', :action => 'index', :project_id => ((row.is_a?(Project) ? row : @project)), <td align="center"><%= aggregate_link data, { field_name => row.id, "closed" => 1 }, aggregate_path(@project, field_name, row, :status_id => "c") %></td>
:set_filter => 1, <td align="center"><%= aggregate_link data, { field_name => row.id }, aggregate_path(@project, field_name, row, :status_id => "*") %></td>
:subproject_id => '!*',
"#{field_name}" => row.id,
"status_id" => "o" %></td>
<td align="center"><%= aggregate_link data, { field_name => row.id, "closed" => 1 },
:controller => 'issues', :action => 'index', :project_id => ((row.is_a?(Project) ? row : @project)),
:set_filter => 1,
:subproject_id => '!*',
"#{field_name}" => row.id,
"status_id" => "c" %></td>
<td align="center"><%= aggregate_link data, { field_name => row.id },
:controller => 'issues', :action => 'index', :project_id => ((row.is_a?(Project) ? row : @project)),
:set_filter => 1,
:subproject_id => '!*',
"#{field_name}" => row.id,
"status_id" => "*" %></td>
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>

View File

@ -11,28 +11,10 @@
<tbody> <tbody>
<% for row in rows %> <% for row in rows %>
<tr class="<%= cycle("odd", "even") %>"> <tr class="<%= cycle("odd", "even") %>">
<td><%= link_to h(row.name), :controller => 'issues', :action => 'index', :project_id => ((row.is_a?(Project) ? row : @project)), <td><%= link_to h(row.name), aggregate_path(@project, field_name, row) %></td>
:set_filter => 1, <td align="center"><%= aggregate_link data, { field_name => row.id, "closed" => 0 }, aggregate_path(@project, field_name, row, :status_id => "o") %></td>
:subproject_id => '!*', <td align="center"><%= aggregate_link data, { field_name => row.id, "closed" => 1 }, aggregate_path(@project, field_name, row, :status_id => "c") %></td>
"#{field_name}" => row.id %></td> <td align="center"><%= aggregate_link data, { field_name => row.id }, aggregate_path(@project, field_name, row, :status_id => "*") %></td>
<td align="center"><%= aggregate_link data, { field_name => row.id, "closed" => 0 },
:controller => 'issues', :action => 'index', :project_id => ((row.is_a?(Project) ? row : @project)),
:set_filter => 1,
:subproject_id => '!*',
"#{field_name}" => row.id,
"status_id" => "o" %></td>
<td align="center"><%= aggregate_link data, { field_name => row.id, "closed" => 1 },
:controller => 'issues', :action => 'index', :project_id => ((row.is_a?(Project) ? row : @project)),
:set_filter => 1,
:subproject_id => '!*',
"#{field_name}" => row.id,
"status_id" => "c" %></td>
<td align="center"><%= aggregate_link data, { field_name => row.id },
:controller => 'issues', :action => 'index', :project_id => ((row.is_a?(Project) ? row : @project)),
:set_filter => 1,
:subproject_id => '!*',
"#{field_name}" => row.id,
"status_id" => "*" %></td>
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>

View File

@ -1,31 +1,31 @@
<h2><%=l(:label_report_plural)%></h2> <h2><%=l(:label_report_plural)%></h2>
<div class="splitcontentleft"> <div class="splitcontentleft">
<h3><%=l(:field_tracker)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :action => 'issue_report_details', :detail => 'tracker' %></h3> <h3><%=l(:field_tracker)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), project_issues_report_details_path(@project, :detail => 'tracker') %></h3>
<%= render :partial => 'simple', :locals => { :data => @issues_by_tracker, :field_name => "tracker_id", :rows => @trackers } %> <%= render :partial => 'simple', :locals => { :data => @issues_by_tracker, :field_name => "tracker_id", :rows => @trackers } %>
<br /> <br />
<h3><%=l(:field_priority)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :action => 'issue_report_details', :detail => 'priority' %></h3> <h3><%=l(:field_priority)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), project_issues_report_details_path(@project, :detail => 'priority') %></h3>
<%= render :partial => 'simple', :locals => { :data => @issues_by_priority, :field_name => "priority_id", :rows => @priorities } %> <%= render :partial => 'simple', :locals => { :data => @issues_by_priority, :field_name => "priority_id", :rows => @priorities } %>
<br /> <br />
<h3><%=l(:field_assigned_to)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :action => 'issue_report_details', :detail => 'assigned_to' %></h3> <h3><%=l(:field_assigned_to)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), project_issues_report_details_path(@project, :detail => 'assigned_to') %></h3>
<%= render :partial => 'simple', :locals => { :data => @issues_by_assigned_to, :field_name => "assigned_to_id", :rows => @assignees } %> <%= render :partial => 'simple', :locals => { :data => @issues_by_assigned_to, :field_name => "assigned_to_id", :rows => @assignees } %>
<br /> <br />
<h3><%=l(:field_author)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :action => 'issue_report_details', :detail => 'author' %></h3> <h3><%=l(:field_author)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), project_issues_report_details_path(@project, :detail => 'author') %></h3>
<%= render :partial => 'simple', :locals => { :data => @issues_by_author, :field_name => "author_id", :rows => @authors } %> <%= render :partial => 'simple', :locals => { :data => @issues_by_author, :field_name => "author_id", :rows => @authors } %>
<br /> <br />
<%= call_hook(:view_reports_issue_report_split_content_left, :project => @project) %> <%= call_hook(:view_reports_issue_report_split_content_left, :project => @project) %>
</div> </div>
<div class="splitcontentright"> <div class="splitcontentright">
<h3><%=l(:field_version)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :action => 'issue_report_details', :detail => 'version' %></h3> <h3><%=l(:field_version)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), project_issues_report_details_path(@project, :detail => 'version') %></h3>
<%= render :partial => 'simple', :locals => { :data => @issues_by_version, :field_name => "fixed_version_id", :rows => @versions } %> <%= render :partial => 'simple', :locals => { :data => @issues_by_version, :field_name => "fixed_version_id", :rows => @versions } %>
<br /> <br />
<% if @project.children.any? %> <% if @project.children.any? %>
<h3><%=l(:field_subproject)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :action => 'issue_report_details', :detail => 'subproject' %></h3> <h3><%=l(:field_subproject)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), project_issues_report_details_path(@project, :detail => 'subproject') %></h3>
<%= render :partial => 'simple', :locals => { :data => @issues_by_subproject, :field_name => "project_id", :rows => @subprojects } %> <%= render :partial => 'simple', :locals => { :data => @issues_by_subproject, :field_name => "project_id", :rows => @subprojects } %>
<br /> <br />
<% end %> <% end %>
<h3><%=l(:field_category)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :action => 'issue_report_details', :detail => 'category' %></h3> <h3><%=l(:field_category)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), project_issues_report_details_path(@project, :detail => 'category') %></h3>
<%= render :partial => 'simple', :locals => { :data => @issues_by_category, :field_name => "category_id", :rows => @categories } %> <%= render :partial => 'simple', :locals => { :data => @issues_by_category, :field_name => "category_id", :rows => @categories } %>
<br /> <br />
<%= call_hook(:view_reports_issue_report_split_content_right, :project => @project) %> <%= call_hook(:view_reports_issue_report_split_content_right, :project => @project) %>

View File

@ -3,5 +3,5 @@
<h3><%=@report_title%></h3> <h3><%=@report_title%></h3>
<%= render :partial => 'details', :locals => { :data => @data, :field_name => @field, :rows => @rows } %> <%= render :partial => 'details', :locals => { :data => @data, :field_name => @field, :rows => @rows } %>
<br /> <br />
<%= link_to l(:button_back), :action => 'issue_report' %> <%= link_to l(:button_back), project_issues_report_path(@project) %>

View File

@ -57,8 +57,8 @@ RedmineApp::Application.routes.draw do
get '/projects/:project_id/issues/calendar', :to => 'calendars#show', :as => 'project_calendar' get '/projects/:project_id/issues/calendar', :to => 'calendars#show', :as => 'project_calendar'
get '/issues/calendar', :to => 'calendars#show' get '/issues/calendar', :to => 'calendars#show'
match 'projects/:id/issues/report', :to => 'reports#issue_report', :via => :get get 'projects/:id/issues/report', :to => 'reports#issue_report', :as => 'project_issues_report'
match 'projects/:id/issues/report/:detail', :to => 'reports#issue_report_details', :via => :get get 'projects/:id/issues/report/:detail', :to => 'reports#issue_report_details', :as => 'project_issues_report_details'
match 'my/account', :controller => 'my', :action => 'account', :via => [:get, :post] match 'my/account', :controller => 'my', :action => 'account', :via => [:get, :post]
match 'my/account/destroy', :controller => 'my', :action => 'destroy', :via => [:get, :post] match 'my/account/destroy', :controller => 'my', :action => 'destroy', :via => [:get, :post]