render :layout => !request.xhr?
end
- def roadmap
- @trackers = @project.trackers.find(:all, :order => 'position')
- retrieve_selected_tracker_ids(@trackers, @trackers.select {|t| t.is_in_roadmap?})
- @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
- project_ids = @with_subprojects ? @project.self_and_descendants.collect(&:id) : [@project.id]
-
- @versions = @project.shared_versions || []
- @versions += @project.rolled_up_versions.visible if @with_subprojects
- @versions = @versions.uniq.sort
- @versions.reject! {|version| version.closed? || version.completed? } unless params[:completed]
-
- @issues_by_version = {}
- unless @selected_tracker_ids.empty?
- @versions.each do |version|
- issues = version.fixed_issues.visible.find(:all,
- :include => [:project, :status, :tracker, :priority],
- :conditions => {:tracker_id => @selected_tracker_ids, :project_id => project_ids},
- :order => "#{Project.table_name}.lft, #{Tracker.table_name}.position, #{Issue.table_name}.id")
- @issues_by_version[version] = issues
- end
- end
- @versions.reject! {|version| !project_ids.include?(version.project_id) && @issues_by_version[version].blank?}
- end
-
private
def find_optional_project
return true unless params[:id]
render_404
end
- def retrieve_selected_tracker_ids(selectable_trackers, default_trackers=nil)
- if ids = params[:tracker_ids]
- @selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s }
- else
- @selected_tracker_ids = (default_trackers || selectable_trackers).collect {|t| t.id.to_s }
- end
- end
-
# Validates parent_id param according to user's permissions
# TODO: move it to Project model in a validation that depends on User.current
def validate_parent_id
class VersionsController < ApplicationController
menu_item :roadmap
model_object Version
- before_filter :find_model_object, :except => [:new, :close_completed]
- before_filter :find_project_from_association, :except => [:new, :close_completed]
- before_filter :find_project, :only => [:new, :close_completed]
+ before_filter :find_model_object, :except => [:index, :new, :close_completed]
+ before_filter :find_project_from_association, :except => [:index, :new, :close_completed]
+ before_filter :find_project, :only => [:index, :new, :close_completed]
before_filter :authorize
helper :custom_fields
helper :projects
+
+ def index
+ @trackers = @project.trackers.find(:all, :order => 'position')
+ retrieve_selected_tracker_ids(@trackers, @trackers.select {|t| t.is_in_roadmap?})
+ @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
+ project_ids = @with_subprojects ? @project.self_and_descendants.collect(&:id) : [@project.id]
+
+ @versions = @project.shared_versions || []
+ @versions += @project.rolled_up_versions.visible if @with_subprojects
+ @versions = @versions.uniq.sort
+ @versions.reject! {|version| version.closed? || version.completed? } unless params[:completed]
+
+ @issues_by_version = {}
+ unless @selected_tracker_ids.empty?
+ @versions.each do |version|
+ issues = version.fixed_issues.visible.find(:all,
+ :include => [:project, :status, :tracker, :priority],
+ :conditions => {:tracker_id => @selected_tracker_ids, :project_id => project_ids},
+ :order => "#{Project.table_name}.lft, #{Tracker.table_name}.position, #{Issue.table_name}.id")
+ @issues_by_version[version] = issues
+ end
+ end
+ @versions.reject! {|version| !project_ids.include?(version.project_id) && @issues_by_version[version].blank?}
+ end
def show
@issues = @version.fixed_issues.visible.find(:all,
rescue ActiveRecord::RecordNotFound
render_404
end
+
+ def retrieve_selected_tracker_ids(selectable_trackers, default_trackers=nil)
+ if ids = params[:tracker_ids]
+ @selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s }
+ else
+ @selected_tracker_ids = (default_trackers || selectable_trackers).collect {|t| t.id.to_s }
+ end
+ end
+
end
+++ /dev/null
-<h2><%=l(:label_roadmap)%></h2>
-
-<% if @versions.empty? %>
-<p class="nodata"><%= l(:label_no_data) %></p>
-<% else %>
-<div id="roadmap">
-<% @versions.each do |version| %>
- <h3 class="version"><%= tag 'a', :name => version.name %><%= link_to_version version %></h3>
- <%= render :partial => 'versions/overview', :locals => {:version => version} %>
- <%= render(:partial => "wiki/content", :locals => {:content => version.wiki_page.content}) if version.wiki_page %>
-
- <% if (issues = @issues_by_version[version]) && issues.size > 0 %>
- <% form_tag({}) do -%>
- <table class="list related-issues">
- <caption><%= l(:label_related_issues) %></caption>
- <%- issues.each do |issue| -%>
- <tr class="hascontextmenu">
- <td class="checkbox"><%= check_box_tag 'ids[]', issue.id %></td>
- <td><%= link_to_issue(issue, :project => (@project != issue.project)) %></td>
- </tr>
- <%- end -%>
- </table>
- <% end %>
- <% end %>
- <%= call_hook :view_projects_roadmap_version_bottom, :version => version %>
-<% end %>
-</div>
-<% end %>
-
-<% content_for :sidebar do %>
-<% form_tag({}, :method => :get) do %>
-<h3><%= l(:label_roadmap) %></h3>
-<% @trackers.each do |tracker| %>
- <label><%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s), :id => nil %>
- <%=h tracker.name %></label><br />
-<% end %>
-<br />
-<label for="completed"><%= check_box_tag "completed", 1, params[:completed] %> <%= l(:label_show_completed_versions) %></label>
-<% if @project.descendants.active.any? %>
- <%= hidden_field_tag 'with_subprojects', 0 %>
- <br /><label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label>
-<% end %>
-<p><%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %></p>
-<% end %>
-
-<h3><%= l(:label_version_plural) %></h3>
-<% @versions.each do |version| %>
-<%= link_to format_version_name(version), "##{version.name}" %><br />
-<% end %>
-<% end %>
-
-<% html_title(l(:label_roadmap)) %>
-
-<%= context_menu :controller => 'issues', :action => 'context_menu' %>
--- /dev/null
+<h2><%=l(:label_roadmap)%></h2>
+
+<% if @versions.empty? %>
+<p class="nodata"><%= l(:label_no_data) %></p>
+<% else %>
+<div id="roadmap">
+<% @versions.each do |version| %>
+ <h3 class="version"><%= tag 'a', :name => version.name %><%= link_to_version version %></h3>
+ <%= render :partial => 'versions/overview', :locals => {:version => version} %>
+ <%= render(:partial => "wiki/content", :locals => {:content => version.wiki_page.content}) if version.wiki_page %>
+
+ <% if (issues = @issues_by_version[version]) && issues.size > 0 %>
+ <% form_tag({}) do -%>
+ <table class="list related-issues">
+ <caption><%= l(:label_related_issues) %></caption>
+ <%- issues.each do |issue| -%>
+ <tr class="hascontextmenu">
+ <td class="checkbox"><%= check_box_tag 'ids[]', issue.id %></td>
+ <td><%= link_to_issue(issue, :project => (@project != issue.project)) %></td>
+ </tr>
+ <%- end -%>
+ </table>
+ <% end %>
+ <% end %>
+ <%= call_hook :view_projects_roadmap_version_bottom, :version => version %>
+<% end %>
+</div>
+<% end %>
+
+<% content_for :sidebar do %>
+<% form_tag({}, :method => :get) do %>
+<h3><%= l(:label_roadmap) %></h3>
+<% @trackers.each do |tracker| %>
+ <label><%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s), :id => nil %>
+ <%=h tracker.name %></label><br />
+<% end %>
+<br />
+<label for="completed"><%= check_box_tag "completed", 1, params[:completed] %> <%= l(:label_show_completed_versions) %></label>
+<% if @project.descendants.active.any? %>
+ <%= hidden_field_tag 'with_subprojects', 0 %>
+ <br /><label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label>
+<% end %>
+<p><%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %></p>
+<% end %>
+
+<h3><%= l(:label_version_plural) %></h3>
+<% @versions.each do |version| %>
+<%= link_to format_version_name(version), "##{version.name}" %><br />
+<% end %>
+<% end %>
+
+<% html_title(l(:label_roadmap)) %>
+
+<%= context_menu :controller => 'issues', :action => 'context_menu' %>
project_views.connect 'projects/new', :action => 'add'
project_views.connect 'projects/:id', :action => 'show'
project_views.connect 'projects/:id.:format', :action => 'show'
- project_views.connect 'projects/:id/:action', :action => /roadmap|destroy|settings/
+ project_views.connect 'projects/:id/:action', :action => /destroy|settings/
project_views.connect 'projects/:id/files', :action => 'list_files'
project_views.connect 'projects/:id/files/new', :action => 'add_file'
project_views.connect 'projects/:id/settings/:tab', :action => 'settings'
map.with_options :controller => 'versions' do |versions|
versions.connect 'projects/:project_id/versions/new', :action => 'new'
+ versions.connect 'projects/:project_id/roadmap', :action => 'index'
versions.with_options :conditions => {:method => :post} do |version_actions|
version_actions.connect 'projects/:project_id/versions/close_completed', :action => 'close_completed'
end
# Issue categories
map.permission :manage_categories, {:projects => :settings, :issue_categories => [:new, :edit, :destroy]}, :require => :member
# Issues
- map.permission :view_issues, {:projects => :roadmap,
- :issues => [:index, :show],
+ map.permission :view_issues, {:issues => [:index, :show],
:auto_complete => [:issues],
:context_menus => [:issues],
- :versions => [:show, :status_by],
+ :versions => [:index, :show, :status_by],
:journals => :index,
:queries => :index,
:reports => [:issue_report, :issue_report_details]}
Redmine::MenuManager.map :project_menu do |menu|
menu.push :overview, { :controller => 'projects', :action => 'show' }
menu.push :activity, { :controller => 'activities', :action => 'index' }
- menu.push :roadmap, { :controller => 'projects', :action => 'roadmap' },
+ menu.push :roadmap, { :controller => 'versions', :action => 'index' }, :param => :project_id,
:if => Proc.new { |p| p.shared_versions.any? }
menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural
menu.push :new_issue, { :controller => 'issues', :action => 'new' }, :param => :project_id, :caption => :label_issue_new,
:attributes => { :href => '/attachments/download/9/version_file.zip' }
end
- def test_roadmap
- get :roadmap, :id => 1
- assert_response :success
- assert_template 'roadmap'
- assert_not_nil assigns(:versions)
- # Version with no date set appears
- assert assigns(:versions).include?(Version.find(3))
- # Completed version doesn't appear
- assert !assigns(:versions).include?(Version.find(1))
- end
-
- def test_roadmap_with_completed_versions
- get :roadmap, :id => 1, :completed => 1
- assert_response :success
- assert_template 'roadmap'
- assert_not_nil assigns(:versions)
- # Version with no date set appears
- assert assigns(:versions).include?(Version.find(3))
- # Completed version appears
- assert assigns(:versions).include?(Version.find(1))
- end
-
- def test_roadmap_showing_subprojects_versions
- @subproject_version = Version.generate!(:project => Project.find(3))
- get :roadmap, :id => 1, :with_subprojects => 1
- assert_response :success
- assert_template 'roadmap'
- assert_not_nil assigns(:versions)
-
- assert assigns(:versions).include?(Version.find(4)), "Shared version not found"
- assert assigns(:versions).include?(@subproject_version), "Subproject version not found"
- end
def test_archive
@request.session[:user_id] = 1 # admin
post :archive, :id => 1
User.current = nil
end
+ def test_index
+ get :index, :project_id => 1
+ assert_response :success
+ assert_template 'index'
+ assert_not_nil assigns(:versions)
+ # Version with no date set appears
+ assert assigns(:versions).include?(Version.find(3))
+ # Completed version doesn't appear
+ assert !assigns(:versions).include?(Version.find(1))
+ end
+
+ def test_index_with_completed_versions
+ get :index, :project_id => 1, :completed => 1
+ assert_response :success
+ assert_template 'index'
+ assert_not_nil assigns(:versions)
+ # Version with no date set appears
+ assert assigns(:versions).include?(Version.find(3))
+ # Completed version appears
+ assert assigns(:versions).include?(Version.find(1))
+ end
+
+ def test_index_showing_subprojects_versions
+ @subproject_version = Version.generate!(:project => Project.find(3))
+ get :index, :project_id => 1, :with_subprojects => 1
+ assert_response :success
+ assert_template 'index'
+ assert_not_nil assigns(:versions)
+
+ assert assigns(:versions).include?(Version.find(4)), "Shared version not found"
+ assert assigns(:versions).include?(@subproject_version), "Subproject version not found"
+ end
+
def test_show
get :show, :id => 2
assert_response :success
should_route :get, "/projects/567/destroy", :controller => 'projects', :action => 'destroy', :id => '567'
should_route :get, "/projects/33/files", :controller => 'projects', :action => 'list_files', :id => '33'
should_route :get, "/projects/33/files/new", :controller => 'projects', :action => 'add_file', :id => '33'
- should_route :get, "/projects/33/roadmap", :controller => 'projects', :action => 'roadmap', :id => '33'
+ should_route :get, "/projects/33/roadmap", :controller => 'versions', :action => 'index', :project_id => '33'
should_route :get, "/projects/33/activity", :controller => 'activities', :action => 'index', :id => '33'
should_route :get, "/projects/33/activity.atom", :controller => 'activities', :action => 'index', :id => '33', :format => 'atom'