new code for attribute fields and values for new member interface
This commit is contained in:
1 parent
293dc80ceb
commit
8b9cffd4f2
15 files changed
+226
-116
No files matched your search
@@ -5,12 +5,15 @@ class AttributeField
|
||||
include AttributeFieldHelper
|
||||
|
||||
field :key
|
||||
field :markup #[select,text_field,email,date,addr]
|
||||
field :markup
|
||||
field :markup_value ,:type => Hash
|
||||
field :markup_options,:type => Hash
|
||||
field :locale, :type => Boolean, :default => true
|
||||
field :list_options, :type => Array
|
||||
# field :list_options, :type => Array
|
||||
field :built_in, :type => Boolean, :default => false
|
||||
field :disabled, :type => Boolean, :default => false
|
||||
field :add_more,:type => Boolean, :default => false
|
||||
|
||||
#field :title, localize: true
|
||||
|
||||
field :locale_title, localize: true
|
||||
@@ -21,6 +24,20 @@ class AttributeField
|
||||
has_many :attribute_values
|
||||
|
||||
# validates_uniqueness_of :key
|
||||
|
||||
def markup_options=(var)
|
||||
self[:markup_options] = (eval(var) rescue {})
|
||||
end
|
||||
|
||||
def markup_options
|
||||
if self[:markup_options].nil?
|
||||
return {}
|
||||
else
|
||||
Hash[self[:markup_options].map{|key,val|[key.to_sym,val]}] rescue {}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def role
|
||||
self.attribute.role
|
||||
end
|
||||
@@ -46,7 +63,7 @@ class AttributeField
|
||||
return self.neutral_title
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def title=(var)
|
||||
# binding.pry
|
||||
if locale
|
||||
@@ -56,15 +73,15 @@ class AttributeField
|
||||
end
|
||||
end
|
||||
|
||||
# Convert the string list_options into an array
|
||||
def select_list_options=(var)
|
||||
self.list_options = var.gsub(' ', '').split(',')
|
||||
end
|
||||
# # 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
|
||||
# # 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
|
||||
|
||||
Reference in new issue
Block a user