-class Sheet < Peta::Content
+class Sheet < Peta::Root
+ load_manifest
has_many :sheet_panels
has_many :story_sheets
belongs_to :author
validates :visible, :presence => true, :numericality => true, :inclusion => {:in => 0..1}
accepts_nested_attributes_for :sheet_panels, :allow_destroy => true
- def self.valid_encode_columns
- super + ['caption']
- end
-
def self.each_element_class_names
{'SheetPanel' => 'sheet_panels'}.each do |k, n|
yield k
end
def visible? operators
- return false unless super
- return true if self.new_record?
- self.visible > 0
+ case super
+ when nil # super return
+ return true
+ when false
+ return false
+ else
+ self.visible > 0
+ end
end
def usable? operators
def symbol_filename
end
- def tag_id
- 'sheet' + self.tag_sheet_id
- end
-
- def tag_sheet_id
- self.new_record? ? '0' : self.id.to_s
- end
-
- def field_tag_id f
- self.tag_id + f.to_s
- end
-
- def self.list_where
+ def self.public_list_where
'sheets.visible > 0'
end
Sheet.validate_elements_serial validate_serial_list
end
- def boost
- @new_element_index = 0
- self.panel_elements.each do |elm|
- if elm.new_record?
- elm.new_index = @new_element_index
- @new_element_index += 1
- end
- end
- end
-
def store attr, operators
if attr == false
self.errors.add :base, I18n.t('errors.invalid_json')