##// END OF EJS Templates
Update enumeration ovverides with their parents (#19657)....
Jean-Philippe Lang -
r14252:0dcbd13d017c
parent child
Show More
@@ -132,14 +132,9 class Enumeration < ActiveRecord::Base
132 # Overrides acts_as_list reset_positions_in_list so that enumeration overrides
132 # Overrides acts_as_list reset_positions_in_list so that enumeration overrides
133 # get the same position as the overriden enumeration
133 # get the same position as the overriden enumeration
134 def reset_positions_in_list
134 def reset_positions_in_list
135 super
135 acts_as_list_class.where(scope_condition).reorder("#{position_column} ASC, id ASC").each_with_index do |item, i|
136 # TODO: no database specific statement
136 acts_as_list_class.where("id = :id OR parent_id = :id", :id => item.id).
137 if Redmine::Database.mysql?
137 update_all({position_column => (i + 1)})
138 self.class.connection.execute("UPDATE #{self.class.table_name} c JOIN #{self.class.table_name} p on p.id = c.parent_id SET c.position = p.position")
139 else
140 self.class.
141 where("parent_id IS NOT NULL").
142 update_all("position = (SELECT MIN(position) FROM #{self.class.table_name} p WHERE p.id = #{self.class.table_name}.parent_id)")
143 end
138 end
144 end
139 end
145
140
General Comments 0
You need to be logged in to leave comments. Login now