Feature #17442 ยป multiple_fixed_versions.patch
| app/models/issue.rb (working copy) | ||
|---|---|---|
|
belongs_to :status, :class_name => 'IssueStatus', :foreign_key => 'status_id'
|
||
|
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||
|
belongs_to :assigned_to, :class_name => 'User', :foreign_key => 'assigned_to_id'
|
||
|
belongs_to :fixed_version, :class_name => 'Version', :foreign_key => 'fixed_version_id'
|
||
|
belongs_to :priority, :class_name => 'Enumeration', :foreign_key => 'priority_id'
|
||
|
belongs_to :category, :class_name => 'IssueCategory', :foreign_key => 'category_id'
|
||
| ... | ... | |
|
has_many :custom_values, :dependent => :delete_all, :as => :customized
|
||
|
has_many :custom_fields, :through => :custom_values
|
||
|
has_and_belongs_to_many :changesets, :order => "revision ASC"
|
||
|
has_and_belongs_to_many :fixed_versions, :class_name => 'Version'
|
||
|
|
||
|
acts_as_watchable
|
||
|
|
||
| app/models/version.rb (working copy) | ||
|---|---|---|
|
class Version < ActiveRecord::Base
|
||
|
before_destroy :check_integrity
|
||
|
belongs_to :project
|
||
|
has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id'
|
||
|
has_and_belongs_to_many :fixed_issues, :class_name => 'Issue'
|
||
|
has_many :attachments, :as => :container, :dependent => :destroy
|
||
|
validates_presence_of :name
|
||
| app/controllers/issues_controller.rb (working copy) | ||
|---|---|---|
|
@priorities = Enumeration::get_values('IPRI')
|
||
|
if request.get?
|
||
|
@custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| @issue.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x, :customized => @issue) }
|
||
|
setup_versions()
|
||
|
else
|
||
|
begin
|
||
|
@issue.init_journal(self.logged_in_user)
|
||
| ... | ... | |
|
@custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) }
|
||
|
@issue.custom_values = @custom_values
|
||
|
@issue.attributes = params[:issue]
|
||
|
ensure_versions_saved()
|
||
|
if @issue.save
|
||
|
flash[:notice] = l(:notice_successful_update)
|
||
|
redirect_to :action => 'show', :id => @issue
|
||
| ... | ... | |
|
def change_status
|
||
|
@status_options = @issue.status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker) if logged_in_user
|
||
|
@new_status = IssueStatus.find(params[:new_status_id])
|
||
|
setup_versions()
|
||
|
if params[:confirm]
|
||
|
begin
|
||
|
journal = @issue.init_journal(self.logged_in_user, params[:notes])
|
||
|
@issue.status = @new_status
|
||
|
if @issue.update_attributes(params[:issue])
|
||
|
ensure_versions_saved()
|
||
|
# Save attachments
|
||
|
params[:attachments].each { |file|
|
||
|
next unless file.size > 0
|
||
| ... | ... | |
|
rescue ActiveRecord::RecordNotFound
|
||
|
render_404
|
||
|
end
|
||
|
def setup_versions
|
||
|
@released_versions = []
|
||
|
@unreleased_versions = []
|
||
|
@project.versions.find(:all, :order => "#{Version.table_name}.effective_date ASC").each { |v| (v.effective_date < Date.today ? @released_versions : @unreleased_versions) << v }
|
||
|
end
|
||
|
def ensure_versions_saved
|
||
|
@issue.fixed_versions = [] unless params[:issue][:fixed_version_ids]
|
||
|
end
|
||
|
end
|
||
| app/controllers/projects_controller.rb (working copy) | ||
|---|---|---|
|
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"
|
||
|
@versions = @project.versions.find(:all,
|
||
|
:conditions => [ "#{Version.table_name}.effective_date<?", Date.today],
|
||
|
:order => "#{Version.table_name}.effective_date DESC"
|
||
|
) unless @selected_tracker_ids.empty?
|
||
|
@fixed_issues ||= []
|
||
|
end
|
||
|
def roadmap
|
||
| app/views/projects/changelog.rhtml (working copy) | ||
|---|---|---|
|
<% end %>
|
||
|
</div>
|
||
|
<% if @fixed_issues.empty? %><p><i><%= l(:label_no_data) %></i></p><% end %>
|
||
|
<% if @versions.empty? %><p><i><%= l(:label_no_data) %></i></p><% end %>
|
||
|
<% ver_id = nil
|
||
|
@fixed_issues.each do |issue| %>
|
||
|
<% unless ver_id == issue.fixed_version_id %>
|
||
|
<% if ver_id %></ul><% end %>
|
||
|
<h3 class="icon22 icon22-package"><%= issue.fixed_version.name %></h3>
|
||
|
<p><%= format_date(issue.fixed_version.effective_date) %><br />
|
||
|
<%=h issue.fixed_version.description %></p>
|
||
|
<% @versions.each do |version| %>
|
||
|
<h3 class="icon22 icon22-package"><%= version.name %></h3>
|
||
|
<p><%= format_date(version.effective_date) %><br />
|
||
|
<p><%=h version.description %></p>
|
||
|
<%
|
||
|
issues = version.fixed_issues.find(:all,
|
||
|
:include => :status,
|
||
|
:conditions => ["tracker_id in (#{@selected_tracker_ids.join(',')}) and is_closed is true"],
|
||
|
:order => "position")
|
||
|
%>
|
||
|
<ul>
|
||
|
<% ver_id = issue.fixed_version_id
|
||
|
end %>
|
||
|
<li><%= link_to_issue issue %>: <%=h issue.subject %></li>
|
||
|
<% if issues.size == 0 %>
|
||
|
<li><%=l(:label_change_log_no_issues)%></li>
|
||
|
<% else %>
|
||
|
<% issues.each do |issue| %>
|
||
|
<li>
|
||
|
<%= link_to_issue(issue) %>: <%=h issue.subject %>
|
||
|
</li>
|
||
|
<% end %>
|
||
|
<% end %>
|
||
|
</ul>
|
||
|
<% end %>
|
||
|
</div>
|
||
|
</div>
|
||
| app/views/issues/show.rhtml (working copy) | ||
|---|---|---|
|
<td><b><%=l(:field_done_ratio)%> :</b></td><td><%= @issue.done_ratio %> %</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td><b><%=l(:field_fixed_version)%> :</b></td><td><%= @issue.fixed_version ? @issue.fixed_version.name : "-" %></td>
|
||
|
<td><b><%=l(:field_fixed_version_plural)%> :</b></td><td><%= @issue.fixed_versions.map{|v| v.name}.join(", ") %></td>
|
||
|
<td><b><%=l(:label_spent_time)%> :</b></td>
|
||
|
<td><%= @issue.spent_hours > 0 ? (link_to lwr(:label_f_hour, @issue.spent_hours), {:controller => 'timelog', :action => 'details', :issue_id => @issue}, :class => 'icon icon-time') : "-" %></td>
|
||
|
</tr>
|
||
| app/views/issues/edit.rhtml (working copy) | ||
|---|---|---|
|
<p><%= custom_field_tag_with_label @custom_value %></p>
|
||
|
<% end %>
|
||
|
<p><%= f.select :fixed_version_id, (@project.versions.collect {|v| [v.name, v.id]}), { :include_blank => true } %></p>
|
||
|
<p><%= render(:partial => 'fixed_versions') %></p>
|
||
|
</div>
|
||
|
<!--[eoform:issue]-->
|
||
|
</div>
|
||
| ... | ... | |
|
<%= javascript_include_tag "calendar/lang/calendar-#{current_language}.js" %>
|
||
|
<%= javascript_include_tag 'calendar/calendar-setup' %>
|
||
|
<%= stylesheet_link_tag 'calendar' %>
|
||
|
<% end %>
|
||
|
<% end %>
|
||
| app/views/issues/_fixed_versions.rhtml (revision 0) | ||
|---|---|---|
|
<% selected_fixed_versions = @issue.fixed_versions.collect { |v| v.id.to_i } %>
|
||
|
<select name="issue[fixed_version_ids][]" multiple="multiple" size="5">
|
||
|
<optgroup label="<%=l(:field_fixed_versions_unreleased)%>">
|
||
|
<%= options_from_collection_for_select @unreleased_versions, "id", "name", selected_fixed_versions %>
|
||
|
</optgroup>
|
||
|
<optgroup label="<%=l(:field_fixed_versions_released)%>">
|
||
|
<%= options_from_collection_for_select @released_versions, "id", "name", selected_fixed_versions %>
|
||
|
</optgroup>
|
||
|
</select>
|
||
| app/views/issues/change_status.rhtml (working copy) | ||
|---|---|---|
|
<p><label><%=l(:label_issue_status_new)%></label> <%= @new_status.name %></p>
|
||
|
<p><%= f.select :assigned_to_id, (@issue.project.members.collect {|m| [m.name, m.user_id]}), :include_blank => true %></p>
|
||
|
<p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></p>
|
||
|
<p><%= f.select :fixed_version_id, (@project.versions.collect {|v| [v.name, v.id]}), { :include_blank => true } %></p>
|
||
|
<p><%= render(:partial => 'fixed_versions') %></p>
|
||
|
<p><label for="notes"><%= l(:field_notes) %></label>
|
||
|
<%= text_area_tag 'notes', @notes, :cols => 60, :rows => 10, :class => 'wiki-edit' %></p>
|
||
| lang/en.yml (working copy) | ||
|---|---|---|
|
field_assigned_to: Assigned to
|
||
|
field_priority: Priority
|
||
|
field_fixed_version: Fixed version
|
||
|
field_fixed_version_plural: Fixed versions
|
||
|
field_fixed_versions_released: Released versions
|
||
|
field_fixed_versions_unreleased: Unreleased versions
|
||
|
field_user: User
|
||
|
field_role: Role
|
||
|
field_homepage: Homepage
|
||
| ... | ... | |
|
label_news_latest: Latest news
|
||
|
label_news_view_all: View all news
|
||
|
label_change_log: Change log
|
||
|
label_change_log_no_issues: No issues for this version
|
||
|
label_settings: Settings
|
||
|
label_overview: Overview
|
||
|
label_version: Version
|
||
| db/migrate/042_issue_version_relationship.rb (revision 0) | ||
|---|---|---|
|
class IssueVersionRelationship < ActiveRecord::Migration
|
||
|
class Issue < ActiveRecord::Base
|
||
|
belongs_to :old_fixed_version, :class_name => 'Version', :foreign_key => 'fixed_version_id'
|
||
|
has_and_belongs_to_many :versions
|
||
|
end
|
||
|
class Version < ActiveRecord::Base
|
||
|
has_and_belongs_to_many :issues
|
||
|
end
|
||
|
def self.up
|
||
|
create_table :issues_versions, :id => false do |t|
|
||
|
t.column :issue_id, :integer
|
||
|
t.column :version_id, :integer
|
||
|
end
|
||
|
Issue.find(:all).each do |issue|
|
||
|
if issue.old_fixed_version
|
||
|
issue.versions << issue.old_fixed_version
|
||
|
end
|
||
|
end
|
||
|
remove_column :issues, :fixed_version_id
|
||
|
end
|
||
|
def self.down
|
||
|
add_column :issues, :fixed_version_id, :integer
|
||
|
Issue.find(:all).each do |issue|
|
||
|
if issue.versions.size > 1
|
||
|
# We cannot rollback if any issues point to multiple versions
|
||
|
remove_column :issues, :fixed_version_id
|
||
|
raise IrreversibleMigration
|
||
|
end
|
||
|
issue.old_fixed_version = issue.versions[0] if issue.versions.size == 1
|
||
|
end
|
||
|
drop_table :issues_versions
|
||
|
end
|
||
|
end
|
||
| public/stylesheets/application.css (working copy) | ||
|---|---|---|
|
padding-left: 26px;
|
||
|
vertical-align: bottom;
|
||
|
}
|
||
|
optgroup {
|
||
|
background-color: #EEE;
|
||
|
font-style: normal;
|
||
|
}
|
||
|
option {
|
||
|
background-color: white;
|
||
|
}
|
||