self.panel.remove_element(self, au)
end
- def copy from_panel
- r = PanelPicture.new self.attributes
- r.panel_id = from_panel.id
- r.t = r.panel.new_t
- r.z = r.panel.new_z
+ def copy_attributes
+ r = self.attributes
+ r.delete 'id'
+ r.delete 'panel_id'
+ r.delete 'created_at'
+ r.delete 'updated_at'
r
end
+ def copy to_panel
+ new_panel_picture = PanelPicture.new self.copy_attributes
+ new_panel_picture.t = to_panel.new_t
+ new_panel_picture.z = to_panel.new_z
+ new_attr = PanelPicture.panelize new_panel_picture.copy_attributes
+ r = {} #Panel.panelize to_panel
+ r.merge! new_attr
+ r
+ end
+
+ def self.panelize panel_pictures_attributes
+ panel_pictures_attributes = [panel_pictures_attributes] unless panel_pictures_attributes.is_a?(Array)
+ hash = {}
+ index = 0
+ panel_pictures_attributes.each do |panel_picture_attributes|
+ n = if panel_picture_attributes['id']
+ panel_picture_attributes['id'].to_s
+ else
+ index += 1
+ 'new' + index.to_s
+ end
+ hash[n] = panel_picture_attributes
+ end
+ {self.to_s.tableize + '_attributes' => hash}
+ end
+
def scenario
if caption.blank?
''