##// END OF EJS Templates
Adds 'Blocked by' (#1755) and 'Duplicated by' relation types to the dropdown menu for new relations....
Jean-Philippe Lang -
r3398:d6c299f57d82
parent child
Show More
@@ -21,15 +21,19 class IssueRelation < ActiveRecord::Base
21 21
22 22 TYPE_RELATES = "relates"
23 23 TYPE_DUPLICATES = "duplicates"
24 TYPE_DUPLICATED = "duplicated"
24 25 TYPE_BLOCKS = "blocks"
26 TYPE_BLOCKED = "blocked"
25 27 TYPE_PRECEDES = "precedes"
26 28 TYPE_FOLLOWS = "follows"
27 29
28 30 TYPES = { TYPE_RELATES => { :name => :label_relates_to, :sym_name => :label_relates_to, :order => 1 },
29 31 TYPE_DUPLICATES => { :name => :label_duplicates, :sym_name => :label_duplicated_by, :order => 2 },
30 TYPE_BLOCKS => { :name => :label_blocks, :sym_name => :label_blocked_by, :order => 3 },
31 TYPE_PRECEDES => { :name => :label_precedes, :sym_name => :label_follows, :order => 4 },
32 TYPE_FOLLOWS => { :name => :label_follows, :sym_name => :label_precedes, :order => 5 }
32 TYPE_DUPLICATED => { :name => :label_duplicated_by, :sym_name => :label_duplicates, :order => 3, :reverse => TYPE_DUPLICATES },
33 TYPE_BLOCKS => { :name => :label_blocks, :sym_name => :label_blocked_by, :order => 4 },
34 TYPE_BLOCKED => { :name => :label_blocked_by, :sym_name => :label_blocks, :order => 5, :reverse => TYPE_BLOCKS },
35 TYPE_PRECEDES => { :name => :label_precedes, :sym_name => :label_follows, :order => 6 },
36 TYPE_FOLLOWS => { :name => :label_follows, :sym_name => :label_precedes, :order => 7, :reverse => TYPE_PRECEDES }
33 37 }.freeze
34 38
35 39 validates_presence_of :issue_from, :issue_to, :relation_type
@@ -85,12 +89,13 class IssueRelation < ActiveRecord::Base
85 89
86 90 private
87 91
92 # Reverses the relation if needed so that it gets stored in the proper way
88 93 def reverse_if_needed
89 if (TYPE_FOLLOWS == relation_type)
94 if TYPES.has_key?(relation_type) && TYPES[relation_type][:reverse]
90 95 issue_tmp = issue_to
91 96 self.issue_to = issue_from
92 97 self.issue_from = issue_tmp
93 self.relation_type = TYPE_PRECEDES
98 self.relation_type = TYPES[relation_type][:reverse]
94 99 end
95 100 end
96 101 end
General Comments 0
You need to be logged in to leave comments. Login now