module Peta
- class Element < Content
+ class Element < ElementNestableContent
self.abstract_class = true
# Dynamic ClassMethods
+ def self.load_manifest
+ super
+ # Class Methods
+ self.my_manifest.associations.each_parent_model do |parent_model|
+ define_singleton_method("parent_model") do
+ parent_model
+ end
+ end
+ # Instance Methods
+ end
+
+ def self.element?
+ true
+ end
+
+ def self.root_model
+ if self.parent_model
+ self.parent_model.root_model
+ else
+ self
+ end
+ end
def self.list_opt_for_panel
{}
{}
end
+ def self.panelize elements_attributes
+ elements_attributes = [elements_attributes] unless elements_attributes.is_a?(Array)
+ hash = {}
+ index = 0
+ elements_attributes.each do |element_attributes|
+ hash[self.to_s.tableize + '_attributes'] ||= {}
+ n = if element_attributes['id']
+ element_attributes['id'].to_s
+ else
+ index += 1
+ 'new' + index.to_s
+ end
+ hash[self.to_s.tableize + '_attributes'][n] = element_attributes
+ end
+ hash
+ end
+
def has_picture?
false
end
def tag_attributes column = nil, opt = {}
r = super
- r.merge({'data-parent_dom_id' => self.parent.dom_item_id}) if self.editor
+ r.merge({'data-parent_dom_id' => self.parent.dom_item_id}) if self.editize?
r
end
})
end
+ def copy_attributes opt = {}
+ r = self.attributes
+ r.delete 'id'
+ r.delete 'panel_id'
+ r.delete 't' unless opt[:all]
+ r.delete 'z' unless opt[:all]
+ r.delete 'created_at'
+ r.delete 'updated_at'
+ r
+ end
+
end
end