2 class Element < ElementNestableContent
3 self.abstract_class = true
9 return nil if self._skip_load?
11 pm = Manifest.manifest.models[self.my_peta.parent_item_name].classify
12 define_singleton_method("parent_model") do
15 pfk = self.my_peta.parent_item_name + '_id'
16 define_singleton_method("parent_key") do
28 if self.parent_model.element?
29 self.parent_model.root_model
41 pi = self.__send__ self.class.parent_model.item_name
50 self.root.own? operators
53 def visible? operators
54 return false unless self.user_visible? operators
55 self.root.visible? operators
58 def self.list_opt_for_panel
62 def self.show_opt_for_panel
66 def self.json_opt_for_panel
70 def self.panelize elements_attributes
71 elements_attributes = [elements_attributes] unless elements_attributes.is_a?(Array)
74 elements_attributes.each do |element_attributes|
75 hash[self.to_s.tableize + '_attributes'] ||= {}
76 n = if element_attributes['id']
77 element_attributes['id'].to_s
82 hash[self.to_s.tableize + '_attributes'][n] = element_attributes
107 def extend_element_name
108 self.extend_column ? self.attributes[extend_column] : self.element_name
111 def scenario_template with_engine = false
112 self.path_name(with_engine) + '/scenario'
115 def element_face_template with_engine = false
116 self.path_name(with_engine) + '/element_face'
119 def tag_attributes column = nil, opt = {}
121 r.merge({'data-parent_dom_id' => self.parent.dom_item_id}) if self.editize?
125 def merge_opacity s, opacity
127 'opacity' => opacity.to_f/100,
128 'filter' => "alpha(opacity=#{opacity})"
132 def copy_attributes opt = {}
135 r.delete self.parent_key
136 r.delete 't' unless opt[:all] # no problem at balloon, speech
137 r.delete 'z' unless opt[:all] # no problem at balloon, speech
138 r.delete 'created_at'
139 r.delete 'updated_at'