mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-22 16:31:12 +00:00
Update enumeration ovverides with their parents (#19657).
git-svn-id: http://svn.redmine.org/redmine/trunk@14634 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
8eb1e94f4d
commit
0dcbd13d01
@ -132,14 +132,9 @@ class Enumeration < ActiveRecord::Base
|
|||||||
# Overrides acts_as_list reset_positions_in_list so that enumeration overrides
|
# Overrides acts_as_list reset_positions_in_list so that enumeration overrides
|
||||||
# get the same position as the overriden enumeration
|
# get the same position as the overriden enumeration
|
||||||
def reset_positions_in_list
|
def reset_positions_in_list
|
||||||
super
|
acts_as_list_class.where(scope_condition).reorder("#{position_column} ASC, id ASC").each_with_index do |item, i|
|
||||||
# TODO: no database specific statement
|
acts_as_list_class.where("id = :id OR parent_id = :id", :id => item.id).
|
||||||
if Redmine::Database.mysql?
|
update_all({position_column => (i + 1)})
|
||||||
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)")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user