Index: app/models/issue.rb =================================================================== --- app/models/issue.rb (revision 11984) +++ app/models/issue.rb (working copy) @@ -1030,6 +1030,10 @@ end end + def parents_count + parent.nil? || parent.project_id != project_id ? 0 : 1 + parent.parents_count + end + # Returns true if issue's project is a valid # parent issue project def valid_parent_project?(issue=parent) Index: app/models/version.rb =================================================================== --- app/models/version.rb (revision 11984) +++ app/models/version.rb (working copy) @@ -205,6 +205,32 @@ scope :sorted, order(fields_for_order_statement) + def sorted_fixed_issues + issues = [] + fixed_issues.visible.find(:all, + :conditions => nil, + :include => [:parent, :status, :tracker, :priority], + :order => "#{Tracker.table_name}.position, #{Issue.table_name}.id").each do |issue| + if issue.parent.nil? || issue.parent.project_id != issue.project_id + issues << issue + issues += find_son_issues({:parent => issue}) + end + end + issues + end + # find all son and grandson issue + def find_son_issues(options) + issues = [] + fixed_issues.visible.find(:all, + :conditions => {:parent_id => options[:parent]}, + :include => [:parent, :status, :tracker, :priority], + :order => "#{Tracker.table_name}.position, #{Issue.table_name}.id").each do |issue| + issues << issue + issues += find_son_issues(options.merge(:parent => issue)) + end + issues + end + # Returns the sharings that +user+ can set the version to def allowed_sharings(user = User.current) VERSION_SHARINGS.select do |s| Index: app/controllers/versions_controller.rb =================================================================== --- app/controllers/versions_controller.rb (revision 11984) +++ app/controllers/versions_controller.rb (working copy) @@ -62,15 +62,7 @@ end def show - respond_to do |format| - format.html { - @issues = @version.fixed_issues.visible. - includes(:status, :tracker, :priority). - reorder("#{Tracker.table_name}.position, #{Issue.table_name}.id"). - all - } - format.api - end + @issues = @version.sorted_fixed_issues end def new Index: app/views/versions/index.html.erb =================================================================== --- app/views/versions/index.html.erb (revision 11984) +++ app/views/versions/index.html.erb (working copy) @@ -13,14 +13,14 @@ <%= 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 %> + <% if (issues = version.sorted_fixed_issues) && issues.size > 0 %> <%= form_tag({}) do -%> <% issues.each do |issue| -%> - + <% end -%> Index: app/views/versions/show.html.erb =================================================================== --- app/views/versions/show.html.erb (revision 11984) +++ app/views/versions/show.html.erb (working copy) @@ -41,7 +41,7 @@ <%- @issues.each do |issue| -%> <%= check_box_tag 'ids[]', issue.id, false, :id => nil %> - <%= link_to_issue(issue, :project => (@project != issue.project)) %> + <%= link_to_issue(issue, :project => (@project != issue.project)) %> <% end %>