@@ -132,14 +132,9 class Enumeration < ActiveRecord::Base | |||
|
132 | 132 | # Overrides acts_as_list reset_positions_in_list so that enumeration overrides |
|
133 | 133 | # get the same position as the overriden enumeration |
|
134 | 134 | def reset_positions_in_list |
|
135 | super | |
|
136 | # TODO: no database specific statement | |
|
137 | if Redmine::Database.mysql? | |
|
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)") | |
|
135 | acts_as_list_class.where(scope_condition).reorder("#{position_column} ASC, id ASC").each_with_index do |item, i| | |
|
136 | acts_as_list_class.where("id = :id OR parent_id = :id", :id => item.id). | |
|
137 | update_all({position_column => (i + 1)}) | |
|
143 | 138 | end |
|
144 | 139 | end |
|
145 | 140 |
General Comments 0
You need to be logged in to leave comments.
Login now