disable data transform when switching attribute field type. new member stable
This commit is contained in:
1 parent
0d26f48c9a
commit
6dff83339a
13 files changed
+176
-98
No files matched your search
@@ -55,7 +55,19 @@ module AttributeFieldsHelper
|
||||
end
|
||||
|
||||
def render_date
|
||||
control_group_wrapper{date_select(get_field_name_base,nil,@markup_options.merge(:default=>@prefiled_value),:class=>"input-small")}
|
||||
if date_is_range?
|
||||
fill_from = @attribute_value.get_date(:from) rescue nil
|
||||
fill_to = @attribute_value.get_date(:to) rescue nil
|
||||
control_group_wrapper do
|
||||
buf = date_select(get_field_name_base+'[from]',nil,@markup_options.merge(:default=>fill_from),:class=>"input-small")
|
||||
buf << ' ~ '
|
||||
buf << date_select(get_field_name_base+'[to]',nil,@markup_options.merge(:default=>fill_to),:class=>"input-small")
|
||||
buf
|
||||
end
|
||||
else
|
||||
@prefiled_value = @attribute_value.get_date
|
||||
control_group_wrapper{date_select(get_field_name_base,nil,@markup_options.merge(:default=>@prefiled_value),:class=>"input-small")}
|
||||
end
|
||||
end
|
||||
|
||||
def render_date_durnation #Need re-write low priority
|
||||
@@ -66,7 +78,7 @@ module AttributeFieldsHelper
|
||||
@prefiled_value ||=[]
|
||||
control_group_wrapper do
|
||||
self[:option_list].collect do |key,value|
|
||||
label_tag(key,radio_button_tag(get_field_name_base, key , (@prefiled_value.include?(key) ? true : false), {})+value[I18n.locale.to_s],@markup_options.merge(:class=>"control-label"))
|
||||
label_tag(key,radio_button_tag(get_field_name_base, key , (@prefiled_value.include?(key) ? true : false), {})+value[I18n.locale.to_s],@markup_options.merge(:class=>" radio inline"))
|
||||
end.join
|
||||
end
|
||||
end
|
||||
@@ -87,13 +99,23 @@ module AttributeFieldsHelper
|
||||
end
|
||||
|
||||
def render_text_field
|
||||
control_group_wrapper do |key,value|
|
||||
a = control_group_wrapper do |key,value|
|
||||
add_more_blank = can_add_more ? "[]" : ""
|
||||
key_field = can_muti_lang_input? ? "[#{key}]" : ""
|
||||
place_holder= @panel_setting["placeholder"][key] rescue ''
|
||||
text_field_tag([get_field_name_base,add_more_blank,key_field].join, value,@markup_options.merge(:placeholder=>place_holder))
|
||||
end
|
||||
end
|
||||
|
||||
def date_is_range?
|
||||
is_range = "false"
|
||||
data = get_data
|
||||
if !data.nil?
|
||||
is_range = data['is_range'] if data.has_key? "is_range"
|
||||
end
|
||||
is_range == "true"
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def lang_panel_tabbable_wrapper(add_more_params,&block)
|
||||
@@ -117,17 +139,15 @@ protected
|
||||
content_tag(:div,yield(key,value),:class=>div_class)
|
||||
end# of VALID_LOCALES.collect for tabed input
|
||||
buff << link_to((content_tag :i,'',:class=>'icon-edit'),"##{get_pairing_tab_class({})}_m_window",:class=>'btn edit-btn',:type=>'button',:data=>{:toggle=>"modal"}) if self.markup == 'address'
|
||||
buff << link_to((content_tag :i,'',:class=>'icon-trash'),"#") if self.add_more
|
||||
buff << link_to((content_tag :i,'',:class=>'icon-trash'),"#",:class=>"btn removeInput") if self.add_more
|
||||
|
||||
|
||||
# buff << '<a href="#" class="btn removeInput" type="button"><i class="icon-trash"></i></a>' if self.add_more
|
||||
buff.join("\n").html_safe
|
||||
buff.join('').html_safe
|
||||
end
|
||||
tmp << content_tag(:ul,:class=> 'nav nav-pills') do
|
||||
VALID_LOCALES.each.collect do |key|
|
||||
# link_entry = self.add_more ? "#{add_more_tab(:tab_btn,loop_counter,key)}" : "#tab"+id.to_s+"_#{key}"
|
||||
link_entry_ary = [".#{get_pairing_tab_class({})}",".#{key}"]
|
||||
# link_entry_ary << ".add_more_item_#{add_more_counter}" if can_add_more
|
||||
link_entry_ary << ".add_more_item_#{add_more_counter}" if can_add_more
|
||||
link_entry = link_entry_ary.join
|
||||
content_tag(:li,link_to(I18n.t("langs."+key),link_entry,:data=>{:toggle=>"tab"}),:class=>(key == I18n.locale.to_s ? "active" : nil),:for=>key)
|
||||
end.join.html_safe # of VALID_LOCALES.collect for tabs
|
||||
@@ -151,16 +171,18 @@ protected
|
||||
if can_muti_lang_input?
|
||||
result << lang_panel_tabbable_wrapper(add_more_params,&block)
|
||||
result << gen_modal_dialog if self.markup == "address"
|
||||
else
|
||||
else #cross lang field
|
||||
|
||||
value = case can_add_more
|
||||
when true
|
||||
add_more_params[0]
|
||||
else
|
||||
@prefiled_value
|
||||
case can_add_more
|
||||
when true
|
||||
value = add_more_params[0][:value]
|
||||
result << content_tag(:div,:class=>"input-append"){yield(nil,value) + link_to((content_tag :i,'',:class=>'icon-trash'),"#",:class=>"btn removeInput") }
|
||||
else
|
||||
value = @prefiled_value
|
||||
result << yield(nil,value)
|
||||
end
|
||||
|
||||
result << yield(nil,value)
|
||||
|
||||
end
|
||||
|
||||
result.html_safe
|
||||
@@ -173,12 +195,12 @@ protected
|
||||
case self.markup
|
||||
when "text_field"
|
||||
if can_add_more
|
||||
multipleInput_ary = %w{multipleInput editMore}
|
||||
multipleInput_ary = %w{multipleInput}
|
||||
add_more_seri = "add_more_group_#{id}"
|
||||
multipleInputs = content_tag :div,:class=> multipleInput_ary.join(' ') ,:ext_class=>get_pairing_tab_class({}) do
|
||||
@attribute_value.add_more_counter.times.collect do |t|
|
||||
controls_wrapper(:value=>(@prefiled_value[t] rescue nil),:counter=>t,&block)
|
||||
end.join("\n").html_safe # of add_more fields
|
||||
end.join('').html_safe # of add_more fields
|
||||
end # of div multipleInput editMore
|
||||
result = label + multipleInputs + add_more_unt
|
||||
# result = label + 一堆的輸入框(要用 multipleInput editMore 包起來) + add_more btn + hidden_fields
|
||||
@@ -267,7 +289,7 @@ protected
|
||||
if self.markup == "address"
|
||||
return false
|
||||
else
|
||||
locale and LIST[:markups][markup]["ext_support"] && add_more
|
||||
add_more
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
module AttributeValuesHelper
|
||||
def show_west_calender
|
||||
date = get_date
|
||||
def show_west_calender(from_to=nil)
|
||||
case from_to
|
||||
when :to
|
||||
date = get_date(:to)
|
||||
when :from
|
||||
date = get_date(:from)
|
||||
when nil
|
||||
date = get_date
|
||||
end
|
||||
|
||||
case self.attribute_field["typeC"]["format"]
|
||||
when 'format1' # Y/M/D h:m
|
||||
date.strftime("%Y/%m/%d %H:%M")
|
||||
@@ -13,9 +21,16 @@ module AttributeValuesHelper
|
||||
end # of case west cal format
|
||||
end
|
||||
|
||||
def show_minguo_calendar
|
||||
def show_minguo_calendar(from_to=nil)
|
||||
get_minguo
|
||||
date = get_date
|
||||
case from_to
|
||||
when :to
|
||||
date = get_date(:to)
|
||||
when :from
|
||||
date = get_date(:from)
|
||||
when nil
|
||||
date = get_date
|
||||
end
|
||||
year_str = ""
|
||||
unless date.year == 1912
|
||||
m_year = (date.year - 1912).abs.to_s + I18n.t("admin.infos.date.minguo_calendar.year")
|
||||
@@ -52,17 +67,17 @@ module AttributeValuesHelper
|
||||
end # of case
|
||||
end
|
||||
|
||||
def get_date_by_format
|
||||
def get_date_by_format(from_to = nil)
|
||||
case I18n.locale
|
||||
when :zh_tw
|
||||
case
|
||||
when self.attribute_field["typeC"]["claendar"] == "west_claendar"
|
||||
show_west_calender
|
||||
show_west_calender(from_to)
|
||||
when self.attribute_field["typeC"]["claendar"] == "tw_claendar"
|
||||
show_minguo_calendar
|
||||
show_minguo_calendar(from_to)
|
||||
end #case self.attribute_field["typeC"]["claendar"]
|
||||
when :en
|
||||
show_west_calender
|
||||
show_west_calender(from_to)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user