From 4ac43ab876319acb828aedc1c7cc0210f4cb0d9e Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 23 Dec 2012 15:55:57 +0000 Subject: [PATCH] Code cleanup, use named routes. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11077 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/reports_helper.rb | 5 +++ app/helpers/routes_helper.rb | 8 +++++ app/views/issues/_sidebar.html.erb | 8 ++--- app/views/reports/_details.html.erb | 33 +++---------------- app/views/reports/_simple.html.erb | 26 +++------------ app/views/reports/issue_report.html.erb | 14 ++++---- .../reports/issue_report_details.html.erb | 2 +- config/routes.rb | 4 +-- 8 files changed, 36 insertions(+), 64 deletions(-) diff --git a/app/helpers/reports_helper.rb b/app/helpers/reports_helper.rb index 545f4d034..756f0a811 100644 --- a/app/helpers/reports_helper.rb +++ b/app/helpers/reports_helper.rb @@ -35,4 +35,9 @@ module ReportsHelper a = aggregate data, criteria a > 0 ? link_to(h(a), *args) : '-' 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 diff --git a/app/helpers/routes_helper.rb b/app/helpers/routes_helper.rb index f52dc6df0..afb77aa8b 100644 --- a/app/helpers/routes_helper.rb +++ b/app/helpers/routes_helper.rb @@ -28,4 +28,12 @@ module RoutesHelper issues_path(*args) 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 diff --git a/app/views/issues/_sidebar.html.erb b/app/views/issues/_sidebar.html.erb index c7b4a6a34..24b8a4fa4 100644 --- a/app/views/issues/_sidebar.html.erb +++ b/app/views/issues/_sidebar.html.erb @@ -1,15 +1,15 @@

<%= l(:label_issue_plural) %>

-<%= link_to l(:label_issue_view_all), { :controller => 'issues', :action => 'index', :project_id => @project, :set_filter => 1 } %>
+<%= link_to l(:label_issue_view_all), _project_issues_path(@project, :set_filter => 1) %>
<% if @project %> -<%= link_to l(:field_summary), :controller => 'reports', :action => 'issue_report', :id => @project %>
+<%= link_to l(:field_summary), project_issues_report_path(@project) %>
<% end %> <%= call_hook(:view_issues_sidebar_issues_bottom) %> <% if User.current.allowed_to?(:view_calendar, @project, :global => true) %> - <%= link_to(l(:label_calendar), :controller => 'calendars', :action => 'show', :project_id => @project) %>
+ <%= link_to l(:label_calendar), _project_calendar_path(@project) %>
<% end %> <% if User.current.allowed_to?(:view_gantt, @project, :global => true) %> - <%= link_to(l(:label_gantt), :controller => 'gantts', :action => 'show', :project_id => @project) %>
+ <%= link_to l(:label_gantt), _project_gantt_path(@project) %>
<% end %> <%= call_hook(:view_issues_sidebar_planning_bottom) %> diff --git a/app/views/reports/_details.html.erb b/app/views/reports/_details.html.erb index 47eda9909..4a01c7333 100644 --- a/app/views/reports/_details.html.erb +++ b/app/views/reports/_details.html.erb @@ -15,36 +15,13 @@ <% for row in rows %> "> - <%= link_to h(row.name), :controller => 'issues', :action => 'index', :project_id => ((row.is_a?(Project) ? row : @project)), - :set_filter => 1, - :subproject_id => '!*', - "#{field_name}" => row.id %> + <%= link_to h(row.name), aggregate_path(@project, field_name, row) %> <% for status in @statuses %> - <%= aggregate_link data, { field_name => row.id, "status_id" => status.id }, - :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 %> + <%= aggregate_link data, { field_name => row.id, "status_id" => status.id }, aggregate_path(@project, field_name, row, :status_id => status.id) %> <% end %> - <%= 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" %> - <%= 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" %> - <%= 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" => "*" %> + <%= aggregate_link data, { field_name => row.id, "closed" => 0 }, aggregate_path(@project, field_name, row, :status_id => "o") %> + <%= aggregate_link data, { field_name => row.id, "closed" => 1 }, aggregate_path(@project, field_name, row, :status_id => "c") %> + <%= aggregate_link data, { field_name => row.id }, aggregate_path(@project, field_name, row, :status_id => "*") %> <% end %> diff --git a/app/views/reports/_simple.html.erb b/app/views/reports/_simple.html.erb index 46f4a9fd4..8ea18f16f 100644 --- a/app/views/reports/_simple.html.erb +++ b/app/views/reports/_simple.html.erb @@ -11,28 +11,10 @@ <% for row in rows %> "> - <%= link_to h(row.name), :controller => 'issues', :action => 'index', :project_id => ((row.is_a?(Project) ? row : @project)), - :set_filter => 1, - :subproject_id => '!*', - "#{field_name}" => row.id %> - <%= 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" %> - <%= 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" %> - <%= 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" => "*" %> + <%= link_to h(row.name), aggregate_path(@project, field_name, row) %> + <%= aggregate_link data, { field_name => row.id, "closed" => 0 }, aggregate_path(@project, field_name, row, :status_id => "o") %> + <%= aggregate_link data, { field_name => row.id, "closed" => 1 }, aggregate_path(@project, field_name, row, :status_id => "c") %> + <%= aggregate_link data, { field_name => row.id }, aggregate_path(@project, field_name, row, :status_id => "*") %> <% end %> diff --git a/app/views/reports/issue_report.html.erb b/app/views/reports/issue_report.html.erb index d70d429bb..d40841dae 100644 --- a/app/views/reports/issue_report.html.erb +++ b/app/views/reports/issue_report.html.erb @@ -1,31 +1,31 @@

<%=l(:label_report_plural)%>

-

<%=l(:field_tracker)%>  <%= link_to image_tag('zoom_in.png'), :action => 'issue_report_details', :detail => 'tracker' %>

+

<%=l(:field_tracker)%>  <%= link_to image_tag('zoom_in.png'), project_issues_report_details_path(@project, :detail => 'tracker') %>

<%= render :partial => 'simple', :locals => { :data => @issues_by_tracker, :field_name => "tracker_id", :rows => @trackers } %>
-

<%=l(:field_priority)%>  <%= link_to image_tag('zoom_in.png'), :action => 'issue_report_details', :detail => 'priority' %>

+

<%=l(:field_priority)%>  <%= link_to image_tag('zoom_in.png'), project_issues_report_details_path(@project, :detail => 'priority') %>

<%= render :partial => 'simple', :locals => { :data => @issues_by_priority, :field_name => "priority_id", :rows => @priorities } %>
-

<%=l(:field_assigned_to)%>  <%= link_to image_tag('zoom_in.png'), :action => 'issue_report_details', :detail => 'assigned_to' %>

+

<%=l(:field_assigned_to)%>  <%= link_to image_tag('zoom_in.png'), project_issues_report_details_path(@project, :detail => 'assigned_to') %>

<%= render :partial => 'simple', :locals => { :data => @issues_by_assigned_to, :field_name => "assigned_to_id", :rows => @assignees } %>
-

<%=l(:field_author)%>  <%= link_to image_tag('zoom_in.png'), :action => 'issue_report_details', :detail => 'author' %>

+

<%=l(:field_author)%>  <%= link_to image_tag('zoom_in.png'), project_issues_report_details_path(@project, :detail => 'author') %>

<%= render :partial => 'simple', :locals => { :data => @issues_by_author, :field_name => "author_id", :rows => @authors } %>
<%= call_hook(:view_reports_issue_report_split_content_left, :project => @project) %>
-

<%=l(:field_version)%>  <%= link_to image_tag('zoom_in.png'), :action => 'issue_report_details', :detail => 'version' %>

+

<%=l(:field_version)%>  <%= link_to image_tag('zoom_in.png'), project_issues_report_details_path(@project, :detail => 'version') %>

<%= render :partial => 'simple', :locals => { :data => @issues_by_version, :field_name => "fixed_version_id", :rows => @versions } %>
<% if @project.children.any? %> -

<%=l(:field_subproject)%>  <%= link_to image_tag('zoom_in.png'), :action => 'issue_report_details', :detail => 'subproject' %>

+

<%=l(:field_subproject)%>  <%= link_to image_tag('zoom_in.png'), project_issues_report_details_path(@project, :detail => 'subproject') %>

<%= render :partial => 'simple', :locals => { :data => @issues_by_subproject, :field_name => "project_id", :rows => @subprojects } %>
<% end %> -

<%=l(:field_category)%>  <%= link_to image_tag('zoom_in.png'), :action => 'issue_report_details', :detail => 'category' %>

+

<%=l(:field_category)%>  <%= link_to image_tag('zoom_in.png'), project_issues_report_details_path(@project, :detail => 'category') %>

<%= render :partial => 'simple', :locals => { :data => @issues_by_category, :field_name => "category_id", :rows => @categories } %>
<%= call_hook(:view_reports_issue_report_split_content_right, :project => @project) %> diff --git a/app/views/reports/issue_report_details.html.erb b/app/views/reports/issue_report_details.html.erb index 6b4b42232..be7259d6b 100644 --- a/app/views/reports/issue_report_details.html.erb +++ b/app/views/reports/issue_report_details.html.erb @@ -3,5 +3,5 @@

<%=@report_title%>

<%= render :partial => 'details', :locals => { :data => @data, :field_name => @field, :rows => @rows } %>
-<%= link_to l(:button_back), :action => 'issue_report' %> +<%= link_to l(:button_back), project_issues_report_path(@project) %> diff --git a/config/routes.rb b/config/routes.rb index 209c70162..6b45c65f0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -57,8 +57,8 @@ RedmineApp::Application.routes.draw do get '/projects/:project_id/issues/calendar', :to => 'calendars#show', :as => 'project_calendar' get '/issues/calendar', :to => 'calendars#show' - match 'projects/:id/issues/report', :to => 'reports#issue_report', :via => :get - match 'projects/:id/issues/report/:detail', :to => 'reports#issue_report_details', :via => :get + 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' match 'my/account', :controller => 'my', :action => 'account', :via => [:get, :post] match 'my/account/destroy', :controller => 'my', :action => 'destroy', :via => [:get, :post]