Commit f3859afe authored by jplang's avatar jplang

Version sharing (#465) + optional inclusion of subprojects in the roadmap view (#2666).

Each version of a project can be shared with:
* subprojects
* projects in the project hierarchy: ancestors + descendants (needs versions management permission on the root project)
* projects in the project tree: root project + all its descendants (same as above)
* all projects (can be set by admin users only)

Notes:
* when sharing a version of a private project with others projects, its name will be visible within the other projects
* a project with versions used by non descendant projects can not be archived

git-svn-id: https://svn.redmine.org/redmine/trunk@3123 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 91a256b0
...@@ -239,7 +239,7 @@ class IssuesController < ApplicationController ...@@ -239,7 +239,7 @@ class IssuesController < ApplicationController
priority = params[:priority_id].blank? ? nil : IssuePriority.find_by_id(params[:priority_id]) priority = params[:priority_id].blank? ? nil : IssuePriority.find_by_id(params[:priority_id])
assigned_to = (params[:assigned_to_id].blank? || params[:assigned_to_id] == 'none') ? nil : User.find_by_id(params[:assigned_to_id]) assigned_to = (params[:assigned_to_id].blank? || params[:assigned_to_id] == 'none') ? nil : User.find_by_id(params[:assigned_to_id])
category = (params[:category_id].blank? || params[:category_id] == 'none') ? nil : @project.issue_categories.find_by_id(params[:category_id]) category = (params[:category_id].blank? || params[:category_id] == 'none') ? nil : @project.issue_categories.find_by_id(params[:category_id])
fixed_version = (params[:fixed_version_id].blank? || params[:fixed_version_id] == 'none') ? nil : @project.versions.find_by_id(params[:fixed_version_id]) fixed_version = (params[:fixed_version_id].blank? || params[:fixed_version_id] == 'none') ? nil : @project.shared_versions.find_by_id(params[:fixed_version_id])
custom_field_values = params[:custom_field_values] ? params[:custom_field_values].reject {|k,v| v.blank?} : nil custom_field_values = params[:custom_field_values] ? params[:custom_field_values].reject {|k,v| v.blank?} : nil
unsaved_issue_ids = [] unsaved_issue_ids = []
......
...@@ -174,7 +174,11 @@ class ProjectsController < ApplicationController ...@@ -174,7 +174,11 @@ class ProjectsController < ApplicationController
end end
def archive def archive
@project.archive if request.post? && @project.active? if request.post?
unless @project.archive
flash[:error] = l(:error_can_not_archive_project)
end
end
redirect_to(url_for(:controller => 'admin', :action => 'projects', :status => params[:status])) redirect_to(url_for(:controller => 'admin', :action => 'projects', :status => params[:status]))
end end
...@@ -224,7 +228,12 @@ class ProjectsController < ApplicationController ...@@ -224,7 +228,12 @@ class ProjectsController < ApplicationController
# Add a new version to @project # Add a new version to @project
def add_version def add_version
@version = @project.versions.build(params[:version]) @version = @project.versions.build
if params[:version]
attributes = params[:version].dup
attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing'])
@version.attributes = attributes
end
if request.post? and @version.save if request.post? and @version.save
flash[:notice] = l(:notice_successful_create) flash[:notice] = l(:notice_successful_create)
redirect_to :action => 'settings', :tab => 'versions', :id => @project redirect_to :action => 'settings', :tab => 'versions', :id => @project
...@@ -278,15 +287,53 @@ class ProjectsController < ApplicationController ...@@ -278,15 +287,53 @@ class ProjectsController < ApplicationController
# Show changelog for @project # Show changelog for @project
def changelog def changelog
@trackers = @project.trackers.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position') @trackers = @project.trackers.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position')
retrieve_selected_tracker_ids(@trackers) retrieve_selected_tracker_ids(@trackers)
@versions = @project.versions.sort @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.sort
@issues_by_version = {}
unless @selected_tracker_ids.empty?
@versions.each do |version|
conditions = {:tracker_id => @selected_tracker_ids, "#{IssueStatus.table_name}.is_closed" => true}
if !@project.versions.include?(version)
conditions.merge!(:project_id => project_ids)
end
issues = version.fixed_issues.visible.find(:all,
:include => [:status, :tracker, :priority],
:conditions => conditions,
:order => "#{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].empty?}
end end
def roadmap def roadmap
@trackers = @project.trackers.find(:all, :conditions => ["is_in_roadmap=?", true]) @trackers = @project.trackers.find(:all, :conditions => ["is_in_roadmap=?", true], :order => 'position')
retrieve_selected_tracker_ids(@trackers) retrieve_selected_tracker_ids(@trackers)
@versions = @project.versions.sort @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
@versions = @versions.select {|v| !v.completed? } unless params[:completed] project_ids = @with_subprojects ? @project.self_and_descendants.collect(&:id) : [@project.id]
@versions = @project.shared_versions.sort
@versions.reject! {|version| version.closed? || version.completed? } unless params[:completed]
@issues_by_version = {}
unless @selected_tracker_ids.empty?
@versions.each do |version|
conditions = {:tracker_id => @selected_tracker_ids}
if !@project.versions.include?(version)
conditions.merge!(:project_id => project_ids)
end
issues = version.fixed_issues.visible.find(:all,
:include => [:status, :tracker, :priority],
:conditions => conditions,
:order => "#{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].empty?}
end end
def activity def activity
......
...@@ -22,14 +22,19 @@ class VersionsController < ApplicationController ...@@ -22,14 +22,19 @@ class VersionsController < ApplicationController
before_filter :authorize before_filter :authorize
helper :custom_fields helper :custom_fields
helper :projects
def show def show
end end
def edit def edit
if request.post? and @version.update_attributes(params[:version]) if request.post? && params[:version]
flash[:notice] = l(:notice_successful_update) attributes = params[:version].dup
redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project attributes.delete('sharing') unless @version.allowed_sharings.include?(attributes['sharing'])
if @version.update_attributes(attributes)
flash[:notice] = l(:notice_successful_update)
redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
end
end end
end end
......
...@@ -126,6 +126,14 @@ module ApplicationHelper ...@@ -126,6 +126,14 @@ module ApplicationHelper
h(truncate(text.to_s, :length => 120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...')).gsub(/[\r\n]+/, "<br />") h(truncate(text.to_s, :length => 120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...')).gsub(/[\r\n]+/, "<br />")
end end
def format_version_name(version)
if version.project == @project
h(version)
else
h("#{version.project} - #{version}")
end
end
def due_date_distance_in_words(date) def due_date_distance_in_words(date)
if date if date
l((date < Date.today ? :label_roadmap_overdue : :label_roadmap_due_in), distance_of_date_in_words(Date.today, date)) l((date < Date.today ? :label_roadmap_overdue : :label_roadmap_due_in), distance_of_date_in_words(Date.today, date))
......
...@@ -91,8 +91,8 @@ module IssuesHelper ...@@ -91,8 +91,8 @@ module IssuesHelper
c = IssueCategory.find_by_id(detail.value) and value = c.name if detail.value c = IssueCategory.find_by_id(detail.value) and value = c.name if detail.value
c = IssueCategory.find_by_id(detail.old_value) and old_value = c.name if detail.old_value c = IssueCategory.find_by_id(detail.old_value) and old_value = c.name if detail.old_value
when 'fixed_version_id' when 'fixed_version_id'
v = Version.find_by_id(detail.value) and value = v.name if detail.value v = Version.find_by_id(detail.value) and value = format_version_name(v) if detail.value
v = Version.find_by_id(detail.old_value) and old_value = v.name if detail.old_value v = Version.find_by_id(detail.old_value) and old_value = format_version_name(v) if detail.old_value
when 'estimated_hours' when 'estimated_hours'
value = "%0.02f" % detail.value.to_f unless detail.value.blank? value = "%0.02f" % detail.value.to_f unless detail.value.blank?
old_value = "%0.02f" % detail.old_value.to_f unless detail.old_value.blank? old_value = "%0.02f" % detail.old_value.to_f unless detail.old_value.blank?
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
module ProjectsHelper module ProjectsHelper
def link_to_version(version, options = {}) def link_to_version(version, options = {})
return '' unless version && version.is_a?(Version) return '' unless version && version.is_a?(Version)
link_to h(version.name), { :controller => 'versions', :action => 'show', :id => version }, options link_to_if version.visible?, format_version_name(version), { :controller => 'versions', :action => 'show', :id => version }, options
end end
def project_settings_tabs def project_settings_tabs
...@@ -69,4 +69,27 @@ module ProjectsHelper ...@@ -69,4 +69,27 @@ module ProjectsHelper
end end
s s
end end
# Returns a set of options for a select field, grouped by project.
def version_options_for_select(versions, selected=nil)
grouped = Hash.new {|h,k| h[k] = []}
versions.each do |version|
grouped[version.project.name] << [h(version.name), version.id]
end
# Add in the selected
if selected && !versions.include?(selected)
grouped[selected.project.name] << [h(selected.name), selected.id]
end
if grouped.keys.size > 1
grouped_options_for_select(grouped, selected && selected.id)
else
options_for_select(grouped.values.first, selected && selected.id)
end
end
def format_version_sharing(sharing)
sharing = 'none' unless Version::VERSION_SHARINGS.include?(sharing)
l("label_version_sharing_#{sharing}")
end
end end
...@@ -100,7 +100,10 @@ class Issue < ActiveRecord::Base ...@@ -100,7 +100,10 @@ class Issue < ActiveRecord::Base
# reassign to the category with same name if any # reassign to the category with same name if any
new_category = issue.category.nil? ? nil : new_project.issue_categories.find_by_name(issue.category.name) new_category = issue.category.nil? ? nil : new_project.issue_categories.find_by_name(issue.category.name)
issue.category = new_category issue.category = new_category
issue.fixed_version = nil # Keep the fixed_version if it's still valid in the new_project
unless new_project.shared_versions.include?(issue.fixed_version)
issue.fixed_version = nil
end
issue.project = new_project issue.project = new_project
end end
if new_tracker if new_tracker
...@@ -242,7 +245,7 @@ class Issue < ActiveRecord::Base ...@@ -242,7 +245,7 @@ class Issue < ActiveRecord::Base
# Versions that the issue can be assigned to # Versions that the issue can be assigned to
def assignable_versions def assignable_versions
@assignable_versions ||= (project.versions.open + [Version.find_by_id(fixed_version_id_was)]).compact.uniq.sort @assignable_versions ||= (project.shared_versions.open + [Version.find_by_id(fixed_version_id_was)]).compact.uniq.sort
end end
# Returns true if this issue is blocked by another issue that is still open # Returns true if this issue is blocked by another issue that is still open
...@@ -336,6 +339,23 @@ class Issue < ActiveRecord::Base ...@@ -336,6 +339,23 @@ class Issue < ActiveRecord::Base
s << ' assigned-to-me' if User.current.logged? && assigned_to_id == User.current.id s << ' assigned-to-me' if User.current.logged? && assigned_to_id == User.current.id
s s
end end
# Update all issues so their versions are not pointing to a
# fixed_version that is outside of the issue's project hierarchy.
#
# OPTIMIZE: does a full table scan of Issues with a fixed_version.
def self.update_fixed_versions_from_project_hierarchy_change
Issue.all(:conditions => ['fixed_version_id IS NOT NULL'],
:include => [:project, :fixed_version]
).each do |issue|
next if issue.project.nil? || issue.fixed_version.nil?
unless issue.project.shared_versions.include?(issue.fixed_version)
issue.init_journal(User.current)
issue.fixed_version = nil
issue.save
end
end
end
private private
......
...@@ -219,13 +219,20 @@ class Project < ActiveRecord::Base ...@@ -219,13 +219,20 @@ class Project < ActiveRecord::Base
self.status == STATUS_ACTIVE self.status == STATUS_ACTIVE
end end
# Archives the project and its descendants recursively # Archives the project and its descendants
def archive def archive
# Archive subprojects if any # Check that there is no issue of a non descendant project that is assigned
children.each do |subproject| # to one of the project or descendant versions
subproject.archive v_ids = self_and_descendants.collect {|p| p.version_ids}.flatten
if v_ids.any? && Issue.find(:first, :include => :project,
:conditions => ["(#{Project.table_name}.lft < ? OR #{Project.table_name}.rgt > ?)" +
" AND #{Issue.table_name}.fixed_version_id IN (?)", lft, rgt, v_ids])
return false
end end
update_attribute :status, STATUS_ARCHIVED Project.transaction do
archive!
end
true
end end
# Unarchives the project # Unarchives the project
...@@ -297,6 +304,7 @@ class Project < ActiveRecord::Base ...@@ -297,6 +304,7 @@ class Project < ActiveRecord::Base
# move_to_child_of adds the project in last (ie.right) position # move_to_child_of adds the project in last (ie.right) position
move_to_child_of(p) move_to_child_of(p)
end end
Issue.update_fixed_versions_from_project_hierarchy_change
true true
else else
# Can not move to the given target # Can not move to the given target
...@@ -324,6 +332,19 @@ class Project < ActiveRecord::Base ...@@ -324,6 +332,19 @@ class Project < ActiveRecord::Base
end end
end end
# Returns a scope of the Versions used by the project
def shared_versions
@shared_versions ||=
Version.scoped(:include => :project,
:conditions => "#{Project.table_name}.id = #{id}" +
" OR (#{Project.table_name}.status = #{Project::STATUS_ACTIVE} AND (" +
" #{Version.table_name}.sharing = 'system'" +
" OR (#{Project.table_name}.lft >= #{root.lft} AND #{Project.table_name}.rgt <= #{root.rgt} AND #{Version.table_name}.sharing = 'tree')" +
" OR (#{Project.table_name}.lft < #{lft} AND #{Project.table_name}.rgt > #{rgt} AND #{Version.table_name}.sharing = 'hierarchy')" +
" OR (#{Project.table_name}.lft > #{lft} AND #{Project.table_name}.rgt < #{rgt} AND #{Version.table_name}.sharing IN ('hierarchy', 'descendants'))" +
"))")
end
# Returns a hash of project users grouped by role # Returns a hash of project users grouped by role
def users_by_role def users_by_role
members.find(:all, :include => [:user, :roles]).inject({}) do |h, m| members.find(:all, :include => [:user, :roles]).inject({}) do |h, m|
...@@ -605,4 +626,12 @@ class Project < ActiveRecord::Base ...@@ -605,4 +626,12 @@ class Project < ActiveRecord::Base
self.time_entry_activities.active self.time_entry_activities.active
end end
end end
# Archives subprojects recursively
def archive!
children.each do |subproject|
subproject.send :archive!
end
update_attribute :status, STATUS_ARCHIVED
end
end end
...@@ -200,8 +200,8 @@ class Query < ActiveRecord::Base ...@@ -200,8 +200,8 @@ class Query < ActiveRecord::Base
unless @project.issue_categories.empty? unless @project.issue_categories.empty?
@available_filters["category_id"] = { :type => :list_optional, :order => 6, :values => @project.issue_categories.collect{|s| [s.name, s.id.to_s] } } @available_filters["category_id"] = { :type => :list_optional, :order => 6, :values => @project.issue_categories.collect{|s| [s.name, s.id.to_s] } }
end end
unless @project.versions.empty? unless @project.shared_versions.empty?
@available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => @project.versions.sort.collect{|s| [s.name, s.id.to_s] } } @available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => @project.shared_versions.sort.collect{|s| ["#{s.project.name} - #{s.name}", s.id.to_s] } }
end end
unless @project.descendants.active.empty? unless @project.descendants.active.empty?
@available_filters["subproject_id"] = { :type => :list_subprojects, :order => 13, :values => @project.descendants.visible.collect{|s| [s.name, s.id.to_s] } } @available_filters["subproject_id"] = { :type => :list_subprojects, :order => 13, :values => @project.descendants.visible.collect{|s| [s.name, s.id.to_s] } }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
class Version < ActiveRecord::Base class Version < ActiveRecord::Base
before_destroy :check_integrity before_destroy :check_integrity
after_update :update_issue_versions
belongs_to :project belongs_to :project
has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id' has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id'
acts_as_customizable acts_as_customizable
...@@ -24,15 +25,24 @@ class Version < ActiveRecord::Base ...@@ -24,15 +25,24 @@ class Version < ActiveRecord::Base
:delete_permission => :manage_files :delete_permission => :manage_files
VERSION_STATUSES = %w(open locked closed) VERSION_STATUSES = %w(open locked closed)
VERSION_SHARINGS = %w(none descendants hierarchy tree system)
validates_presence_of :name validates_presence_of :name
validates_uniqueness_of :name, :scope => [:project_id] validates_uniqueness_of :name, :scope => [:project_id]
validates_length_of :name, :maximum => 60 validates_length_of :name, :maximum => 60
validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => :not_a_date, :allow_nil => true validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => :not_a_date, :allow_nil => true
validates_inclusion_of :status, :in => VERSION_STATUSES validates_inclusion_of :status, :in => VERSION_STATUSES
validates_inclusion_of :sharing, :in => VERSION_SHARINGS
named_scope :open, :conditions => {:status => 'open'} named_scope :open, :conditions => {:status => 'open'}
named_scope :visible, lambda {|*args| { :include => :project,
:conditions => Project.allowed_to_condition(args.first || User.current, :view_issues) } }
# Returns true if +user+ or current user is allowed to view the version
def visible?(user=User.current)
user.allowed_to?(:view_issues, self.project)
end
def start_date def start_date
effective_date effective_date
end end
...@@ -54,6 +64,10 @@ class Version < ActiveRecord::Base ...@@ -54,6 +64,10 @@ class Version < ActiveRecord::Base
def closed? def closed?
status == 'closed' status == 'closed'
end end
def open?
status == 'open'
end
# Returns true if the version is completed: due date reached and no open issues # Returns true if the version is completed: due date reached and no open issues
def completed? def completed?
...@@ -120,10 +134,38 @@ class Version < ActiveRecord::Base ...@@ -120,10 +134,38 @@ class Version < ActiveRecord::Base
end end
end end
# Returns the sharings that +user+ can set the version to
def allowed_sharings(user = User.current)
VERSION_SHARINGS.select do |s|
if sharing == s
true
else
case s
when 'system'
# Only admin users can set a systemwide sharing
user.admin?
when 'hierarchy', 'tree'
# Only users allowed to manage versions of the root project can
# set sharing to hierarchy or tree
project.nil? || user.allowed_to?(:manage_versions, project.root)
else
true
end
end
end
end
private private
def check_integrity def check_integrity
raise "Can't delete version" if self.fixed_issues.find(:first) raise "Can't delete version" if self.fixed_issues.find(:first)
end end
# Update the issue's fixed versions. Used if a version's sharing changes.
def update_issue_versions
if sharing_changed?
Issue.update_fixed_versions_from_project_hierarchy_change
end
end
# Returns the average estimated time of assigned issues # Returns the average estimated time of assigned issues
# or 1 if no issue has an estimated time # or 1 if no issue has an estimated time
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
:tabindex => 199) if authorize_for('projects', 'add_issue_category') %></p> :tabindex => 199) if authorize_for('projects', 'add_issue_category') %></p>
<% end %> <% end %>
<% unless @issue.assignable_versions.empty? %> <% unless @issue.assignable_versions.empty? %>
<p><%= f.select :fixed_version_id, (@issue.assignable_versions.collect {|v| [v.name, v.id]}), :include_blank => true %></p> <p><%= f.select :fixed_version_id, version_options_for_select(@issue.assignable_versions, @issue.fixed_version), :include_blank => true %></p>
<% end %> <% end %>
</div> </div>
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<label><%= l(:field_fixed_version) %>: <label><%= l(:field_fixed_version) %>:
<%= select_tag('fixed_version_id', content_tag('option', l(:label_no_change_option), :value => '') + <%= select_tag('fixed_version_id', content_tag('option', l(:label_no_change_option), :value => '') +
content_tag('option', l(:label_none), :value => 'none') + content_tag('option', l(:label_none), :value => 'none') +
options_from_collection_for_select(@project.versions.open.sort, :id, :name)) %></label> version_options_for_select(@project.shared_versions.open)) %></label>
</p> </p>
<p> <p>
......
...@@ -38,12 +38,12 @@ ...@@ -38,12 +38,12 @@
<% end -%> <% end -%>
</ul> </ul>
</li> </li>
<% unless @project.nil? || @project.versions.open.empty? -%> <% unless @project.nil? || @project.shared_versions.open.empty? -%>
<li class="folder"> <li class="folder">
<a href="#" class="submenu"><%= l(:field_fixed_version) %></a> <a href="#" class="submenu"><%= l(:field_fixed_version) %></a>
<ul> <ul>
<% @project.versions.open.sort.each do |v| -%> <% @project.shared_versions.open.sort.each do |v| -%>
<li><%= context_menu_link v.name, {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), 'fixed_version_id' => v, :back_to => @back}, :method => :post, <li><%= context_menu_link format_version_name(v), {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), 'fixed_version_id' => v, :back_to => @back}, :method => :post,
:selected => (@issue && v == @issue.fixed_version), :disabled => !@can[:update] %></li> :selected => (@issue && v == @issue.fixed_version), :disabled => !@can[:update] %></li>
<% end -%> <% end -%>
<li><%= context_menu_link l(:label_none), {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), 'fixed_version_id' => 'none', :back_to => @back}, :method => :post, <li><%= context_menu_link l(:label_none), {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), 'fixed_version_id' => 'none', :back_to => @back}, :method => :post,
......
...@@ -50,8 +50,8 @@ ...@@ -50,8 +50,8 @@
<br /> <br />
<% end %></p> <% end %></p>
<% if @project && @project.descendants.active.any? %> <% if @project && @project.descendants.active.any? %>
<%= hidden_field_tag 'with_subprojects', 0 %>
<p><label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label></p> <p><label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label></p>
<%= hidden_field_tag 'with_subprojects', 0 %>
<% end %> <% end %>
<%= hidden_field_tag('user_id', params[:user_id]) unless params[:user_id].blank? %> <%= hidden_field_tag('user_id', params[:user_id]) unless params[:user_id].blank? %>
<p><%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %></p> <p><%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %></p>
......
...@@ -6,15 +6,15 @@ ...@@ -6,15 +6,15 @@
<% @versions.each do |version| %> <% @versions.each do |version| %>
<%= tag 'a', :name => version.name %> <%= tag 'a', :name => version.name %>
<h3 class="icon22 icon22-package"><%= link_to h(version.name), :controller => 'versions', :action => 'show', :id => version %></h3> <h3 class="icon22 icon22-package"><%= link_to_version version %></h3>
<% if version.effective_date %> <% if version.effective_date %>
<p><%= format_date(version.effective_date) %></p> <p><%= format_date(version.effective_date) %></p>
<% end %> <% end %>
<p><%=h version.description %></p> <p><%=h version.description %></p>
<% issues = version.fixed_issues.find(:all, <% issues = version.fixed_issues.visible.find(:all,
:include => [:status, :tracker, :priority], :include => [:status, :tracker, :priority],
:conditions => ["#{IssueStatus.table_name}.is_closed=? AND #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')})", true], :conditions => ["#{Issue.table_name}.project_id = ? AND #{IssueStatus.table_name}.is_closed=? AND #{Issue.table_name}.tracker_id in (?)", @project.id, true, @selected_tracker_ids],
:order => "#{Tracker.table_name}.position") unless @selected_tracker_ids.empty? :order => "#{Tracker.table_name}.position") unless @selected_tracker_ids.empty?
issues ||= [] issues ||= []
%> %>
<% if !issues.empty? %> <% if !issues.empty? %>
...@@ -33,11 +33,15 @@ ...@@ -33,11 +33,15 @@
<label><%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %> <label><%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %>
<%= tracker.name %></label><br /> <%= tracker.name %></label><br />
<% end %> <% end %>
<% 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' %></p> <p><%= submit_tag l(:button_apply), :class => 'button-small' %></p>
<% end %> <% end %>
<h3><%= l(:label_version_plural) %></h3> <h3><%= l(:label_version_plural) %></h3>
<% @versions.each do |version| %> <% @versions.each do |version| %>
<%= link_to version.name, :anchor => version.name %><br /> <%= link_to format_version_name(version), :anchor => version.name %><br />
<% end %> <% end %>
<% end %> <% end %>
...@@ -6,17 +6,11 @@ ...@@ -6,17 +6,11 @@
<div id="roadmap"> <div id="roadmap">
<% @versions.each do |version| %> <% @versions.each do |version| %>
<%= tag 'a', :name => version.name %> <%= tag 'a', :name => version.name %>
<h3 class="icon22 icon22-package"><%= link_to h(version.name), :controller => 'versions', :action => 'show', :id => version %></h3> <h3 class="icon22 icon22-package"><%= link_to_version version %></h3>
<%= render :partial => 'versions/overview', :locals => {:version => version} %> <%= render :partial => 'versions/overview', :locals => {:version => version} %>
<%= render(:partial => "wiki/content", :locals => {:content => version.wiki_page.content}) if version.wiki_page %> <%= render(:partial => "wiki/content", :locals => {:content => version.wiki_page.content}) if version.wiki_page %>
<% issues = version.fixed_issues.find(:all, <% if (issues = @issues_by_version[version]) && issues.size > 0 %>
:include => [:status, :tracker, :priority],
:conditions => ["tracker_id in (#{@selected_tracker_ids.join(',')})"],
:order => "#{Tracker.table_name}.position, #{Issue.table_name}.id") unless @selected_tracker_ids.empty?
issues ||= []
%>
<% if issues.size > 0 %>
<fieldset class="related-issues"><legend><%= l(:label_related_issues) %></legend> <fieldset class="related-issues"><legend><%= l(:label_related_issues) %></legend>
<ul> <ul>
<%- issues.each do |issue| -%> <%- issues.each do |issue| -%>
...@@ -39,12 +33,16 @@ ...@@ -39,12 +33,16 @@
<% end %> <% end %>
<br /> <br />
<label for="completed"><%= check_box_tag "completed", 1, params[:completed] %> <%= l(:label_show_completed_versions) %></label> <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> <p><%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %></p>
<% end %> <% end %>
<h3><%= l(:label_version_plural) %></h3> <h3><%= l(:label_version_plural) %></h3>
<% @versions.each do |version| %> <% @versions.each do |version| %>
<%= link_to version.name, "##{version.name}" %><br /> <%= link_to format_version_name(version), "##{version.name}" %><br />
<% end %> <% end %>
<% end %> <% end %>
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<th><%= l(:field_effective_date) %></th> <th><%= l(:field_effective_date) %></th>
<th><%= l(:field_description) %></th>