2015-11-13 13:10:00 +00:00
|
|
|
class UTable
|
|
|
|
include Mongoid::Document
|
|
|
|
include Mongoid::Timestamps
|
|
|
|
include OrbitCategory::Categorizable
|
|
|
|
include Slug
|
|
|
|
|
|
|
|
field :title, as: :slug_title, localize: true
|
|
|
|
|
|
|
|
has_many :table_columns, :dependent => :destroy
|
|
|
|
has_many :table_entries, :dependent => :destroy
|
|
|
|
|
|
|
|
accepts_nested_attributes_for :table_columns, :allow_destroy => true
|
|
|
|
|
|
|
|
FIELD_TYPES = ["text", "editor", "image", "date", "period"]
|
2015-11-18 15:51:49 +00:00
|
|
|
DATE_FORMATS = ["yyyy/MM/dd hh:mm", "yyyy/MM/dd","yyyy/MM", "yyyy"]
|
2022-02-24 09:31:45 +00:00
|
|
|
def default_ordered_field
|
|
|
|
f = self.table_columns.where(default_ordered_field: true).first
|
|
|
|
f ? (f.key||f.title) : 'created_at'
|
|
|
|
end
|
2015-11-13 13:10:00 +00:00
|
|
|
end
|