Project

General

Profile

Feature #4403 » ro4403-copy_improvements.patch

Patch created against trunk @ r7630. - Mischa The Evil, 2011-10-20 22:26

View differences:

app/models/issue_relation.rb (working copy)
26 26
  TYPE_BLOCKED      = "blocked"
27 27
  TYPE_PRECEDES     = "precedes"
28 28
  TYPE_FOLLOWS      = "follows"
29
  TYPE_COPIES       = "copied to"
30
  TYPE_COPIED       = "copied from"
29 31

  
30 32
  TYPES = { TYPE_RELATES =>     { :name => :label_relates_to, :sym_name => :label_relates_to, :order => 1, :sym => TYPE_RELATES },
31 33
            TYPE_DUPLICATES =>  { :name => :label_duplicates, :sym_name => :label_duplicated_by, :order => 2, :sym => TYPE_DUPLICATED },
......
33 35
            TYPE_BLOCKS =>      { :name => :label_blocks, :sym_name => :label_blocked_by, :order => 4, :sym => TYPE_BLOCKED },
34 36
            TYPE_BLOCKED =>     { :name => :label_blocked_by, :sym_name => :label_blocks, :order => 5, :sym => TYPE_BLOCKS, :reverse => TYPE_BLOCKS },
35 37
            TYPE_PRECEDES =>    { :name => :label_precedes, :sym_name => :label_follows, :order => 6, :sym => TYPE_FOLLOWS },
36
            TYPE_FOLLOWS =>     { :name => :label_follows, :sym_name => :label_precedes, :order => 7, :sym => TYPE_PRECEDES, :reverse => TYPE_PRECEDES }
38
            TYPE_FOLLOWS =>     { :name => :label_follows, :sym_name => :label_precedes, :order => 7, :sym => TYPE_PRECEDES, :reverse => TYPE_PRECEDES },
39
            TYPE_COPIES =>      { :name => :label_copied_to, :sym_name => :label_copied_from, :order => 8, :sym => TYPE_COPIED },
40
            TYPE_COPIED =>      { :name => :label_copied_from, :sym_name => :label_copied_to, :order => 9, :sym => TYPE_COPIES, :reverse => TYPE_COPIES }
37 41
          }.freeze
38 42

  
39 43
  validates_presence_of :issue_from, :issue_to, :relation_type
app/models/issue.rb (working copy)
208 208
          end
209 209
        end
210 210
      end
211
      if options[:relation_type]
212
        relation = IssueRelation.new(
213
          :relation_type => options[:relation_type],
214
          :issue_from => self,
215
          :issue_to => issue)
216
        unless relation.save
217
          issue.destroy
218
          return false
219
        end
220
      end
211 221
    else
212 222
      return false
213 223
    end
app/controllers/issue_moves_controller.rb (working copy)
22 22
  before_filter :find_issues, :check_project_uniqueness
23 23
  before_filter :authorize
24 24

  
25
  helper :issue_relations
26
  include IssueRelationsHelper
27

  
25 28
  def new
26 29
    prepare_for_issue_move
27 30
    render :layout => false if request.xhr?
......
32 35

  
33 36
    if request.post?
34 37
      new_tracker = params[:new_tracker_id].blank? ? nil : @target_project.trackers.find_by_id(params[:new_tracker_id])
38
      relation_type = params[:relation_type].blank? ? nil : params[:relation_type]
35 39
      unsaved_issue_ids = []
36 40
      moved_issues = []
37 41
      @issues.each do |issue|
......
39 43
        issue.init_journal(User.current)
40 44
        issue.current_journal.notes = @notes if @notes.present?
41 45
        call_hook(:controller_issues_move_before_save, { :params => params, :issue => issue, :target_project => @target_project, :copy => !!@copy })
42
        if r = issue.move_to_project(@target_project, new_tracker, {:copy => @copy, :attributes => extract_changed_attributes_for_move(params)})
46
        if r = issue.move_to_project(@target_project, new_tracker, {:copy => @copy, :relation_type => relation_type, :attributes => extract_changed_attributes_for_move(params)})
43 47
          moved_issues << r
44 48
        else
45 49
          unsaved_issue_ids << issue.id
app/views/issue_moves/new.html.erb (working copy)
22 22
                                            :update => 'content',
23 23
                                            :with => "Form.serialize('move_form')") %></p>
24 24

  
25
<% if @copy && (@project == @target_project || Setting.cross_project_issue_relations?) %>
26
  <p>
27
    <label for="relation_type"><%= l(:label_relation_new) %></label>
28
    <%= select_tag('relation_type', content_tag('option', l(:label_none), :value => '') + 
29
                                    options_for_select(collection_for_relation_type_select)) %>
30
  </p>
31
<% end %>
32

  
25 33
<p><label for="new_tracker_id"><%=l(:field_tracker)%>:</label>
26 34
<%= select_tag "new_tracker_id", "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(@trackers, "id", "name") %></p>
27 35

  
config/locales/en.yml (working copy)
714 714
  label_blocked_by: blocked by
715 715
  label_precedes: precedes
716 716
  label_follows: follows
717
  label_copied_to: copied to
718
  label_copied_from: copied from
717 719
  label_end_to_start: end to start
718 720
  label_end_to_end: end to end
719 721
  label_start_to_start: start to start
(4-4/5)