diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index e90196495..debb0a00a 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -426,35 +426,25 @@ class ProjectsController < ApplicationController Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled? redirect_to :controller => 'projects', :action => 'list_files', :id => @project end - @versions = @project.versions + @versions = @project.versions.sort end def list_files - @versions = @project.versions + @versions = @project.versions.sort end # Show changelog for @project def changelog @trackers = Tracker.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position') - retrieve_selected_tracker_ids(@trackers) - - @fixed_issues = @project.issues.find(:all, - :include => [ :fixed_version, :status, :tracker ], - :conditions => [ "#{IssueStatus.table_name}.is_closed=? and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')}) and #{Issue.table_name}.fixed_version_id is not null", true], - :order => "#{Version.table_name}.effective_date DESC, #{Issue.table_name}.id DESC" - ) unless @selected_tracker_ids.empty? - @fixed_issues ||= [] + retrieve_selected_tracker_ids(@trackers) + @versions = @project.versions.sort end def roadmap @trackers = Tracker.find(:all, :conditions => ["is_in_roadmap=?", true], :order => 'position') - retrieve_selected_tracker_ids(@trackers) - conditions = ("1" == params[:completed] ? nil : [ "#{Version.table_name}.effective_date > ?", Date.today]) - - @versions = @project.versions.find(:all, - :conditions => conditions, - :order => "#{Version.table_name}.effective_date ASC" - ) + retrieve_selected_tracker_ids(@trackers) + conditions = ("1" == params[:completed] ? nil : [ "#{Version.table_name}.effective_date > ? OR #{Version.table_name}.effective_date IS NULL", Date.today]) + @versions = @project.versions.find(:all, :conditions => conditions).sort end def activity diff --git a/app/models/query.rb b/app/models/query.rb index 026e79ea9..47468ba12 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -94,7 +94,7 @@ class Query < ActiveRecord::Base @available_filters["assigned_to_id"] = { :type => :list_optional, :order => 4, :values => user_values } @available_filters["author_id"] = { :type => :list, :order => 5, :values => user_values } @available_filters["category_id"] = { :type => :list_optional, :order => 6, :values => @project.issue_categories.collect{|s| [s.name, s.id.to_s] } } - @available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => @project.versions.collect{|s| [s.name, s.id.to_s] } } + @available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => @project.versions.sort.collect{|s| [s.name, s.id.to_s] } } unless @project.children.empty? @available_filters["subproject_id"] = { :type => :list_one_or_more, :order => 13, :values => @project.children.collect{|s| [s.name, s.id.to_s] } } end diff --git a/app/models/version.rb b/app/models/version.rb index 463ca3354..a4e93118e 100644 --- a/app/models/version.rb +++ b/app/models/version.rb @@ -23,7 +23,7 @@ class Version < ActiveRecord::Base validates_presence_of :name validates_uniqueness_of :name, :scope => [:project_id] - validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => :activerecord_error_not_a_date + validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => :activerecord_error_not_a_date, :allow_nil => true def start_date effective_date @@ -37,6 +37,16 @@ class Version < ActiveRecord::Base effective_date && effective_date <= Date.today end + # Versions are sorted by effective_date + # Those with no effective_date are at the end, sorted by name + def <=>(version) + if self.effective_date + version.effective_date ? (self.effective_date <=> version.effective_date) : -1 + else + version.effective_date ? 1 : (self.name <=> version.name) + end + end + private def check_integrity raise "Can't delete version" if self.fixed_issues.find(:first) diff --git a/app/views/projects/changelog.rhtml b/app/views/projects/changelog.rhtml index f42f32c42..c76159471 100644 --- a/app/views/projects/changelog.rhtml +++ b/app/views/projects/changelog.rhtml @@ -11,17 +11,26 @@ <% end %> -<% if @fixed_issues.empty? %>
<%= l(:label_no_data) %>
<% end %> +<% if @versions.empty? %><%= l(:label_no_data) %>
<% end %> -<% ver_id = nil - @fixed_issues.each do |issue| %> - <% unless ver_id == issue.fixed_version_id %> - <% if ver_id %><% end %> -<%= format_date(issue.fixed_version.effective_date) %>
- <%=h issue.fixed_version.description %>
<%= format_date(version.effective_date) %>
+ <% elsif version.effective_date %> +<%=l(:label_roadmap_due_in)%> <%= distance_of_time_in_words Time.now, version.effective_date %> (<%= format_date(version.effective_date) %>)
+ <% end %> +<%=h version.description %>
+ <% issues = version.fixed_issues.find(:all, + :include => [:status, :tracker], + :conditions => ["#{IssueStatus.table_name}.is_closed=? AND #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')})", true], + :order => "#{Tracker.table_name}.position") + %> + <% if !issues.empty? %><%= format_date(version.effective_date) %>
- <% else %> + <% elsif version.effective_date %><%=l(:label_roadmap_due_in)%> <%= distance_of_time_in_words Time.now, version.effective_date %> (<%= format_date(version.effective_date) %>)
<% end %><%=h version.description %>
diff --git a/app/views/projects/settings.rhtml b/app/views/projects/settings.rhtml index 81150dd54..bd73076cc 100644 --- a/app/views/projects/settings.rhtml +++ b/app/views/projects/settings.rhtml @@ -27,7 +27,7 @@<%= l(:label_version) %> | <%= l(:field_effective_date) %> | <%= l(:field_description) %> | -<% for version in @project.versions %> +<% for version in @project.versions.sort %> |
---|---|
<%=h version.name %> | <%= format_date(version.effective_date) %> | diff --git a/app/views/versions/_form.rhtml b/app/views/versions/_form.rhtml index 3d6c9c208..8dca13e36 100644 --- a/app/views/versions/_form.rhtml +++ b/app/views/versions/_form.rhtml @@ -4,7 +4,7 @@