Patch #1667 » default_tracker.patch
| app/controllers/issues_controller.rb (working copy) | ||
|---|---|---|
|
@issue.copy_from(params[:copy_from]) if params[:copy_from]
|
||
|
@issue.project = @project
|
||
|
# Tracker must be set before custom field values
|
||
|
@issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first)
|
||
|
if @issue.tracker.nil?
|
||
|
flash.now[:error] = 'No tracker is associated to this project. Please check the Project settings.'
|
||
|
render :nothing => true, :layout => true
|
||
|
return
|
||
|
unless @issue.tracker
|
||
|
if @project.trackers.empty?
|
||
|
flash.now[:error] = 'No tracker is associated to this project. Please check the Project settings.'
|
||
|
render :nothing => true, :layout => true
|
||
|
return
|
||
|
end
|
||
|
tracker_id = (params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id]
|
||
|
@issue.tracker = @project.trackers.find_by_id(tracker_id) unless tracker_id.blank?
|
||
|
@issue.tracker ||= @project.trackers.find_by_id(@project.default_tracker_id)
|
||
|
end
|
||
|
@issue.attributes = params[:issue]
|
||
|
@issue.author = User.current
|
||
| app/models/issue.rb (working copy) | ||
|---|---|---|
|
end
|
||
|
|
||
|
def validate_on_create
|
||
|
errors.add :tracker_id, :activerecord_error_invalid unless project.trackers.include?(tracker)
|
||
|
errors.add :tracker_id, :activerecord_error_invalid if !tracker.blank? && !project.trackers.include?(tracker)
|
||
|
end
|
||
|
|
||
|
def before_create
|
||
| app/views/issues/_form.rhtml (working copy) | ||
|---|---|---|
|
<% if @issue.new_record? %>
|
||
|
<p><%= f.select :tracker_id, @project.trackers.collect {|t| [t.name, t.id]}, :required => true %></p>
|
||
|
<p><%= f.select :tracker_id, @project.trackers.collect {|t| [t.name, t.id]}, {:required => true, :include_blank => true} %></p>
|
||
|
<%= observe_field :issue_tracker_id, :url => { :action => :new },
|
||
|
:update => :content,
|
||
|
:with => "Form.serialize('issue-form')" %>
|
||
| app/views/projects/_form.rhtml (working copy) | ||
|---|---|---|
|
<% @project.custom_field_values.each do |value| %>
|
||
|
<p><%= custom_field_tag_with_label :project, value %></p>
|
||
|
<% end %>
|
||
|
<p><%= f.select :default_tracker_id, (@trackers.collect {|p| [p.name, p.id]}), { :include_blank => true } %></p>
|
||
|
</div>
|
||
|
<% unless @trackers.empty? %>
|
||
| db/migrate/095_add_default_tracker_id.rb (revision 0) | ||
|---|---|---|
|
class AddDefaultTrackerId < ActiveRecord::Migration
|
||
|
def self.up
|
||
|
add_column :projects, :default_tracker_id, :integer
|
||
|
end
|
||
|
def self.down
|
||
|
remove_column :projects, :default_tracker_id
|
||
|
end
|
||
|
end
|
||
| lang/en.yml (working copy) | ||
|---|---|---|
|
field_searchable: Searchable
|
||
|
field_default_value: Default value
|
||
|
field_comments_sorting: Display comments
|
||
|
field_default_tracker: Default tracker
|
||
|
setting_app_title: Application title
|
||
|
setting_app_subtitle: Application subtitle
|
||