Index: app/models/issue.rb =================================================================== --- app/models/issue.rb (版本 11981) +++ app/models/issue.rb (工作副本) @@ -1030,6 +1030,10 @@ end end + def parents_count + parent.nil? ? 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 (版本 11981) +++ app/models/version.rb (工作副本) @@ -40,7 +40,7 @@ includes(:project).where(Project.allowed_to_condition(args.first || User.current, :view_issues)) } - safe_attributes 'name', + safe_attributes 'name', 'description', 'effective_date', 'due_date', @@ -205,6 +205,20 @@ scope :sorted, order(fields_for_order_statement) + def sorted_fixed_issues(options = {}) + issues = [] + conditions = {:parent_id => options[:parent]} + conditions[:tracker_id] = options[:trackers] if options[:trackers] + fixed_issues.visible.find(:all, + :conditions => conditions, + :include => [:status, :tracker, :priority], + :order => "#{Tracker.table_name}.position, #{Issue.table_name}.subject").each do |issue| + issues << issue + issues += sorted_fixed_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 (版本 11981) +++ app/controllers/versions_controller.rb (工作副本) @@ -62,15 +62,16 @@ 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 + #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 (版本 11981) +++ app/views/versions/index.html.erb (工作副本) @@ -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 (版本 11981) +++ app/views/versions/show.html.erb (工作副本) @@ -39,9 +39,9 @@ <%- @issues.each do |issue| -%> - + - + <% end %>