1 class Balloon < Peta::Content
2 include Peta::ElementPart
3 belongs_to :speech_balloon
4 belongs_to :system_picture
6 validates :speech_balloon_id, :numericality => {:allow_blank => true}
7 validates :system_picture_id, :presence => true, :numericality => true, :existence => {:both => false}
8 validates :x, :presence => true, :numericality => true
9 validates :y, :presence => true, :numericality => true
10 validates :width, :presence => true, :numericality => true, :natural_number => true
11 validates :height, :presence => true, :numericality => true, :natural_number => true
12 validates :r, :presence => true, :numericality => true
13 # validates :caption, :presence => true
14 validates :settings, :extend_balloon => true
17 self.speech_balloon.panel
20 def self.valid_encode_columns
24 def self.colum_structures
25 @@colum_structures ||= {
27 :helper => 'panels/tail_angle_helper'
33 '/system_pictures/' + self.system_picture.filename
36 def visible? operators
37 return false unless super
38 self.owner_model.visible? operators
47 self.system_picture_id = 1
51 self.get_parent.speech_balloon_template.symbol_option
55 self.speech_balloon || @new_parent
58 def tag_element_part_type
67 'balloons.updated_at desc'
71 {:speech_balloon => {:panel => {:author => {}}, :speech => {}, :speech_balloon_template => {} }}
74 def self.list_json_opt
75 {:include => {:speech_balloon => {:include => {:panel => {:include => {:author => {} }}, :speech => {}, :speech_balloon_template => {} }}}}
79 {:include => {:speech_balloon => {:panel => {:author => {}}, :speech => {}, :speech_balloon_template => {} }}}
82 def self.show_json_opt
83 {:include => {:speech_balloon => {:include => {:panel => {:include => {:author => {} }}, :speech => {}, :speech_balloon_template => {} }}}}
89 r.delete 'speech_balloon_id'
95 def self.panelize balloon_attributes
96 {'balloon_attributes' => balloon_attributes}