2011-12-10 10:12:39 +00:00
|
|
|
class AttributeField
|
|
|
|
|
|
|
|
include Mongoid::Document
|
|
|
|
include Mongoid::Timestamps
|
|
|
|
|
|
|
|
field :key
|
|
|
|
field :markup
|
2011-12-18 02:07:42 +00:00
|
|
|
field :locale, :type => Boolean, :default => true
|
2011-12-10 10:12:39 +00:00
|
|
|
field :list_options, :type => Array
|
|
|
|
field :built_in, :type => Boolean, :default => false
|
|
|
|
field :disabled, :type => Boolean, :default => false
|
|
|
|
|
2011-12-18 02:07:42 +00:00
|
|
|
belongs_to :attribute
|
2011-12-10 10:12:39 +00:00
|
|
|
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
|
|
|
|
has_many :attribute_values
|
2011-12-19 13:22:26 +00:00
|
|
|
|
2011-12-20 06:35:28 +00:00
|
|
|
# validates_uniqueness_of :key
|
2011-12-10 10:12:39 +00:00
|
|
|
|
|
|
|
# Convert the string list_options into an array
|
|
|
|
def select_list_options=(var)
|
|
|
|
self.list_options = var.gsub(' ', '').split(',')
|
|
|
|
end
|
|
|
|
|
|
|
|
# Convert the array list_options into a string
|
|
|
|
def select_list_options
|
|
|
|
self.list_options.to_a.join(', ')
|
|
|
|
end
|
|
|
|
|
|
|
|
def is_built_in?
|
|
|
|
self.built_in
|
|
|
|
end
|
|
|
|
|
|
|
|
def is_disabled?
|
|
|
|
self.disabled
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|