|
|
@@ -132,14 +132,9 @@ class Enumeration < ActiveRecord::Base |
|
|
|
# Overrides acts_as_list reset_positions_in_list so that enumeration overrides |
|
|
|
# get the same position as the overriden enumeration |
|
|
|
def reset_positions_in_list |
|
|
|
super |
|
|
|
# TODO: no database specific statement |
|
|
|
if Redmine::Database.mysql? |
|
|
|
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") |
|
|
|
else |
|
|
|
self.class. |
|
|
|
where("parent_id IS NOT NULL"). |
|
|
|
update_all("position = (SELECT MIN(position) FROM #{self.class.table_name} p WHERE p.id = #{self.class.table_name}.parent_id)") |
|
|
|
acts_as_list_class.where(scope_condition).reorder("#{position_column} ASC, id ASC").each_with_index do |item, i| |
|
|
|
acts_as_list_class.where("id = :id OR parent_id = :id", :id => item.id). |
|
|
|
update_all({position_column => (i + 1)}) |
|
|
|
end |
|
|
|
end |
|
|
|
|