disable data transform when switching attribute field type. new member stable

This commit is contained in:
Matthew K. Fu JuYuan authored and chris committed 2012-11-22 21:10:35 +08:00
1 parent edf38644c9
commit 77386f0284
12 files changed
+174 -95

No files matched your search

+23 -7
View File
@@ -49,7 +49,12 @@ class AttributeValue
when "text_field"
case self.attribute_field.add_more
when true
add_more_index.nil? ? self.value.collect{|t| t[locale]}.join(",") : self.value(add_more_index)[locale]
if self.attribute_field.locale
add_more_index.nil? ? self.value.collect{|t| t[locale]}.join(",") : self.value(add_more_index)[locale]
else
add_more_index.nil? ? self.value.join(",") : self.value(add_more_index)
end
when false
self.attribute_field.locale ? self[locale.to_s] : self.value
end
@@ -62,7 +67,11 @@ class AttributeValue
self.attribute_field.locale ? self[locale.to_s] : self.value
when "date"
get_date_by_format
if self.attribute_field.date_is_range?
get_date_by_format(:from) + ' ~ ' + get_date_by_format(:to)
else
get_date_by_format
end
when "address"
self.value[locale.to_s]
@@ -83,6 +92,18 @@ class AttributeValue
end
end
def get_date(item = nil)
case item
when :from
data = self[:val]["from"]
when :to
data = self[:val]["to"]
when nil
data = self[:val]
end
Date.new(data["(1i)"].to_i,data["(2i)"].to_i,data["(3i)"].to_i) rescue nil
end
protected
@@ -130,9 +151,4 @@ def unset_all_lang_values
end
end
def get_date
Date.new(self[:val]["(1i)"].to_i,self[:val]["(2i)"].to_i,self[:val]["(3i)"].to_i) rescue nil
end
end