OSDN Git Service

t#31650:remove tree
[pettanr/pettanr.git] / app / models / panel.rb
index c64dfdd..7674df5 100644 (file)
@@ -97,10 +97,6 @@ class Panel < ActiveRecord::Base
     self.tag_id + f.to_s
   end
   
-  def field_tree f
-    'panels-' + tag_panel_id + '-' + f.to_s
-  end
-  
   def self.default_page_size
     25
   end
@@ -321,6 +317,9 @@ class Panel < ActiveRecord::Base
     self.overwrite au
     res = false
     Panel.transaction do
+      self.panel_elements.each do |elm|
+        elm.new_panel = self
+      end
 #self.publish = nil
       res = self.save
       unless validate_child
@@ -367,11 +366,9 @@ class Panel < ActiveRecord::Base
   
   def copy
     attr = self.copy_attributes
-    attr.merge! PanelPicture.panelize(self.panel_pictures.map {|elm|  elm.copy_attributes})
-    attr.merge! SpeechBalloon.panelize(self.speech_balloons.map {|elm|  elm.copy_attributes})
-    attr.merge! GroundPicture.panelize(self.ground_pictures.map {|elm|  elm.copy_attributes})
-    attr.merge! GroundColor.panelize(self.ground_colors.map {|elm|  elm.copy_attributes})
-    p attr
+    Panel.each_element_class_names do |n|
+      attr.merge! Panel.class_name_to_class(n).panelize(self.elements_by_class_name(n).map {|elm|  elm.copy_attributes})
+    end
     attr
   end