summaryrefslogtreecommitdiffstats
path: root/vendor
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-04-21 12:19:56 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-04-21 12:19:56 +0000
commitbb44430b631eba1d33b218c97cb5d506073aeb08 (patch)
tree7e37b43149c5fceebb2a61a08f4c0d814c009615 /vendor
parent65cbd94e422ed7119edc474f2c66bdb675f32f98 (diff)
downloadredmine-bb44430b631eba1d33b218c97cb5d506073aeb08.tar.gz
redmine-bb44430b631eba1d33b218c97cb5d506073aeb08.zip
Ask user what to do with child pages when deleting a parent wiki page (#3202).
3 options are available: * move child pages as root pages * move child pages to another parent page * delete all descendants git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2676 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'vendor')
-rw-r--r--vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb b/vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb
index 6a6827ee6..54b4373ef 100644
--- a/vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb
+++ b/vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb
@@ -40,11 +40,11 @@ module ActiveRecord
# * <tt>order</tt> - makes it possible to sort the children according to this SQL snippet.
# * <tt>counter_cache</tt> - keeps a count in a +children_count+ column if set to +true+ (default: +false+).
def acts_as_tree(options = {})
- configuration = { :foreign_key => "parent_id", :order => nil, :counter_cache => nil }
+ configuration = { :foreign_key => "parent_id", :dependent => :destroy, :order => nil, :counter_cache => nil }
configuration.update(options) if options.is_a?(Hash)
belongs_to :parent, :class_name => name, :foreign_key => configuration[:foreign_key], :counter_cache => configuration[:counter_cache]
- has_many :children, :class_name => name, :foreign_key => configuration[:foreign_key], :order => configuration[:order], :dependent => :destroy
+ has_many :children, :class_name => name, :foreign_key => configuration[:foreign_key], :order => configuration[:order], :dependent => configuration[:dependent]
class_eval <<-EOV
include ActiveRecord::Acts::Tree::InstanceMethods
@@ -77,6 +77,13 @@ module ActiveRecord
children + children.collect(&:children).flatten
end
+ # Returns list of descendants and a reference to the current node.
+ #
+ # root.self_and_descendants # => [root, child1, subchild1, subchild2]
+ def self_and_descendants
+ [self] + descendants
+ end
+
# Returns the root node of the tree.
def root
node = self