class GroundColor < ActiveRecord::Base
+ include ElementInspire
belongs_to :panel
belongs_to :color
self.panel.remove_element(self, au)
end
- 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_ground_color = GroundColor.new self.copy_attributes
- new_ground_color.t = to_panel.new_t
- new_ground_color.z = to_panel.new_z
- new_attr = GroundColor.panelize new_ground_color.copy_attributes
- r = {} #Panel.panelize to_panel
- r.merge! new_attr
- r
- end
-
- def self.panelize ground_colors_attributes
- ground_colors_attributes = [ground_colors_attributes] unless ground_colors_attributes.is_a?(Array)
- hash = {}
- index = 0
- ground_colors_attributes.each do |ground_color_attributes|
- n = if ground_color_attributes['id']
- ground_color_attributes['id'].to_s
- else
- index += 1
- 'new' + index.to_s
- end
- hash[n] = ground_color_attributes
- end
- {self.to_s.tableize + '_attributes' => hash}
- end
-
def scenario
if caption.blank?
''