address field. js and style is broken
This commit is contained in:
1 parent
dafe28ffb5
commit
39612b879c
14 files changed
+383
-311
No files matched your search
@@ -5,7 +5,7 @@ module AttributeFieldsHelper
|
||||
include ActionView::Helpers::DateHelper
|
||||
include ActionView::Helpers::TagHelper
|
||||
include ActionView::Helpers::RenderingHelper
|
||||
|
||||
include OrbitBasis::RenderAnywhere
|
||||
def block_helper(user,index,disable = false)
|
||||
unless self.disabled
|
||||
@index = index
|
||||
@@ -26,37 +26,22 @@ module AttributeFieldsHelper
|
||||
end
|
||||
|
||||
def render_address
|
||||
#NP
|
||||
control_group_wrapper do |key,value|
|
||||
result = '<div class="input-append">'.html_safe
|
||||
value = (can_muti_lang_input? ? @prefiled_value[key] : @prefiled_value) rescue nil
|
||||
key_field = can_muti_lang_input? ? "[#{key}]" : ""
|
||||
place_holder= @panel_setting["placeholder"][key] rescue ''
|
||||
result = text_area_tag(get_field_name_base + key_field, value,@markup_options.merge(:placeholder=>place_holder))
|
||||
|
||||
if(add_more and value.is_a?(Array))
|
||||
values = value
|
||||
result << values.each_with_index.collect do |value,index|
|
||||
text_field_tag(get_field_name_base + (key.nil? ? '' : "[#{key}][#{index}]"), value.last,@markup_options)
|
||||
end.join.html_safe
|
||||
else
|
||||
result << text_field_tag(get_field_name_base + (key.nil? ? '' : "[#{key}]"), value,@markup_options)
|
||||
end
|
||||
|
||||
result << ('<a href="#'+self.key+'-edit" class="btn" type="button" data-toggle="modal"><i class="icon-edit"></i></a>').html_safe
|
||||
result << '<a href="#" class="btn" type="button"><i class="icon-trash"></i></a>'.html_safe
|
||||
result << '</div>'.html_safe
|
||||
result << gen_modal_dialog
|
||||
result << hidden_field_tag(get_basic_field_name_base+"[temp][street_address][#{key}]",nil,:class=>"street_address_#{key}")
|
||||
result << hidden_field_tag(get_basic_field_name_base+"[temp][city][#{key}]",nil,:class=>"city_#{key}")
|
||||
result << hidden_field_tag(get_basic_field_name_base+"[temp][zip][#{key}]",nil,:class=>"zip_#{key}")
|
||||
result << hidden_field_tag(get_basic_field_name_base+"[temp][country][#{key}]",nil,:class=>"country_#{key}")
|
||||
result << hidden_field_tag(get_basic_field_name_base+"[temp][indicator][#{key}]",nil,:class=>"indicator_#{key}")
|
||||
end
|
||||
end
|
||||
|
||||
def render_checkbox
|
||||
@prefiled_value ||=[]
|
||||
# @prefiled_value = @prefiled_value.keys unless @prefiled_value ==[]
|
||||
# begin
|
||||
# markup_value = eval(self.markup_value)
|
||||
# rescue
|
||||
# markup_value = self.markup_value
|
||||
# ensure
|
||||
# markup_value ||= {}
|
||||
# end
|
||||
|
||||
control_group_wrapper do
|
||||
a = self[:option_list].collect do |key,value|
|
||||
label_tag(key,check_box_tag(get_field_name_base+"[#{key}]", true , (@prefiled_value.include?(key) ? true : false), {})+value[I18n.locale.to_s],@markup_options.merge(:class=>"control-label"))
|
||||
@@ -65,7 +50,6 @@ module AttributeFieldsHelper
|
||||
end
|
||||
|
||||
def render_date
|
||||
#NP
|
||||
control_group_wrapper{date_select(get_field_name_base,nil,@markup_options.merge(:default=>@prefiled_value),:class=>"input-small")}
|
||||
end
|
||||
|
||||
@@ -75,13 +59,6 @@ module AttributeFieldsHelper
|
||||
|
||||
def render_radio_button
|
||||
@prefiled_value ||=[]
|
||||
# begin
|
||||
# markup_value = eval(self.markup_value)
|
||||
# rescue
|
||||
# markup_value = self.markup_value
|
||||
# ensure
|
||||
# markup_value ||= {}
|
||||
# end
|
||||
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"))
|
||||
@@ -92,25 +69,15 @@ module AttributeFieldsHelper
|
||||
def render_select
|
||||
prompt = @panel_setting["initial"][I18n.locale.to_s] rescue nil
|
||||
@markup_options.merge!(:prompt => prompt) unless prompt.nil?
|
||||
# markup_value = (self.markup_value.is_a?(Hash) ? self.markup_value : eval(self.markup_value) )rescue {}
|
||||
# check self[:option_list].collect{|p| [p[1][I18n.locale.to_s],p[0]]}
|
||||
control_group_wrapper{select_tag( get_field_name_base,options_for_select(self.option_list.collect{|p| [p[1][I18n.locale.to_s],p[0]]},@prefiled_value),@markup_options)} rescue ""
|
||||
end
|
||||
|
||||
def render_text_area
|
||||
control_group_wrapper do |key,value|
|
||||
# if(add_more and value.is_a?(Hash))
|
||||
# values = value
|
||||
# values.each_with_index.collect do |value,index|
|
||||
# place_holder= @panel_setting["placeholder"][key]
|
||||
# text_area_tag(get_field_name_base + (key.nil? ? '' : "[#{key}][#{index}]"), value.last,@markup_options.merge(:placeholder=>place_holder))
|
||||
# end.join.html_safe
|
||||
# else
|
||||
value = can_muti_lang_input ? @prefiled_value[key] : @prefiled_value
|
||||
key = can_muti_lang_input ? "[#{key}]" : ""
|
||||
value = can_muti_lang_input? ? @prefiled_value[key] : @prefiled_value
|
||||
key = can_muti_lang_input? ? "[#{key}]" : ""
|
||||
place_holder= @panel_setting["placeholder"][I18n.locale.to_s] rescue ''
|
||||
text_area_tag(get_field_name_base + key, value,@markup_options.merge(:placeholder=>place_holder))
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -118,10 +85,10 @@ module AttributeFieldsHelper
|
||||
control_group_wrapper do |key,value,add_more_counter|
|
||||
if(add_more)
|
||||
place_holder= @panel_setting["placeholder"][key]
|
||||
text_field_tag(get_field_name_base + (key.nil? ? '' : "[][#{key}]"), value,@markup_options.merge(:placeholder=>place_holder)) + link_to( (content_tag :i,'',:class=>"icon-trash"),'#',:class=> "btn removeInput")
|
||||
text_field_tag(get_field_name_base + (key.nil? ? '' : "[][#{key}]"), value,@markup_options.merge(:placeholder=>place_holder))
|
||||
else
|
||||
value = (can_muti_lang_input ? @prefiled_value[key] : @prefiled_value) rescue nil
|
||||
key_field = can_muti_lang_input ? "[#{key}]" : ""
|
||||
value = (can_muti_lang_input? ? @prefiled_value[key] : @prefiled_value) rescue nil
|
||||
key_field = can_muti_lang_input? ? "[#{key}]" : ""
|
||||
place_holder= @panel_setting["placeholder"][key] rescue ''
|
||||
text_field_tag(get_field_name_base + key_field, value,@markup_options.merge(:placeholder=>place_holder))
|
||||
end
|
||||
@@ -141,50 +108,58 @@ protected
|
||||
def controls_wrapper(&block)
|
||||
loop_time = self.add_more ? @attribute_value.add_more_counter : 1
|
||||
result = ''
|
||||
result << "<div class='multipleInput'>" if self.add_more
|
||||
multi_and_edit_more_class = (self.markup == 'address' ? "multipleInput" : "multipleInput editMore" )
|
||||
result << "<div class='#{multi_and_edit_more_class}'>" if self.add_more
|
||||
result << "<div class='controls'>"
|
||||
loop_time.times do |loop_counter|
|
||||
if can_muti_lang_input
|
||||
|
||||
if can_muti_lang_input?
|
||||
result << "<div class='tabbable'>"
|
||||
|
||||
result << "<div class='tab-content'>"
|
||||
tab_content_class = add_more ? "tab-content input-append" : "tab-content"
|
||||
|
||||
result << "<div class= '#{tab_content_class}'>"
|
||||
VALID_LOCALES.collect do |key|
|
||||
|
||||
value = @prefiled_value[key.to_s] rescue nil
|
||||
div_class = ["tab-pane" ,"fade"].join(" ")
|
||||
div_class << (key == I18n.locale.to_s ? " active in" : '')
|
||||
if self.add_more
|
||||
div_class << " input-append #{add_more_tab(:input_field,loop_counter,key)}"
|
||||
# binding.pry
|
||||
div_class << " #{add_more_tab(:input_field,loop_counter,key)}"
|
||||
add_more_field_value = @prefiled_value[loop_counter][key] rescue ''
|
||||
result << content_tag(:div,yield(key,add_more_field_value,loop_counter),:class=>div_class)#,:id=>"tab"+id.to_s+"_#{key}_#{loop_counter}"
|
||||
else
|
||||
result << content_tag(:div,yield(key,value),:class=>div_class,:id=>"tab"+id.to_s+"_#{key}")
|
||||
end
|
||||
end # of VALID_LOCALES.collect for tabed input
|
||||
|
||||
result << '<a href=".address-edit.' + get_pairing_tab_class({}) + ' " class="btn edit-btn" type="button" data-toggle="modal"><i class="icon-edit"></i></a>' if self.markup == 'address'
|
||||
result << '<a href="#" class="btn removeInput" type="button"><i class="icon-trash"></i></a>' if self.add_more
|
||||
result << "</div>"
|
||||
|
||||
result << "<ul class='nav nav-pills'>"
|
||||
VALID_LOCALES.each do |key|
|
||||
link_entry = self.add_more ? "#{add_more_tab(:tab_btn,loop_counter,key)}" : "#tab"+id.to_s+"_#{key}"
|
||||
result << content_tag(:li,link_to(I18n.t("langs."+key),link_entry,:data=>{:toggle=>"tab"}),:class=>(key == I18n.locale.to_s ? "active" : nil))
|
||||
end # of VALID_LOCALES.collect for tabs
|
||||
result << "</ul>"
|
||||
if can_muti_lang_input?
|
||||
result << "<ul class='nav nav-pills'>"
|
||||
VALID_LOCALES.reverse.each do |key|
|
||||
link_entry = self.add_more ? "#{add_more_tab(:tab_btn,loop_counter,key)}" : "#tab"+id.to_s+"_#{key}"
|
||||
result << content_tag(:li,link_to(I18n.t("langs."+key),link_entry,:data=>{:toggle=>"tab"}),:class=>(key == I18n.locale.to_s ? "active" : nil))
|
||||
end # of VALID_LOCALES.collect for tabs
|
||||
result << "</ul>"
|
||||
end
|
||||
|
||||
result << "</div>"
|
||||
# @prefiled_value.collect do |key,value|
|
||||
# result << yield(key,value)
|
||||
# end
|
||||
result << gen_modal_dialog if self.markup == "address"
|
||||
else
|
||||
|
||||
result << yield
|
||||
end
|
||||
if can_add_more and (loop_counter == loop_time-1)
|
||||
temp_field_name = get_basic_field_name_base + '[temp]'
|
||||
result << '<div class="controls">'
|
||||
result << '<span class="help-block">'
|
||||
result << '<a href="#"><i class="icon-plus-sign"></i>'+I18n.t("admin.infos.add")+' </a>'
|
||||
result << '<a href="#" class="addinput"><i class="icon-plus-sign"></i>'+I18n.t("admin.infos.add")+' </a>'
|
||||
result << hidden_field_tag("#{temp_field_name}[count]",loop_time,:class=>"list_count")
|
||||
result << hidden_field_tag("#{temp_field_name}[count]",get_basic_field_name_base,:class=>"field_name")
|
||||
result << '</span>'
|
||||
result << '</div>'
|
||||
end
|
||||
end # of loop_time
|
||||
result << "</div>"
|
||||
@@ -193,9 +168,8 @@ protected
|
||||
end # of def controls_wrapper(&block)
|
||||
|
||||
def control_group_wrapper(&block)
|
||||
div_class = can_muti_lang_input ? "control-group language-swich" : "control-group"
|
||||
div_class = can_muti_lang_input? ? "control-group language-swich" : "control-group"
|
||||
temp = label + controls_wrapper(&block)
|
||||
|
||||
result = content_tag(:div,temp,:class=>div_class)
|
||||
result << end_block
|
||||
|
||||
@@ -243,36 +217,26 @@ protected
|
||||
label_tag(key,title,:class=>"control-label",:func => "field_label")
|
||||
end
|
||||
|
||||
def can_muti_lang_input
|
||||
LIST[:markups][markup]["muti_lang_input_supprt"] #and locale
|
||||
def can_muti_lang_input?
|
||||
if self.markup == "address"
|
||||
return true
|
||||
else
|
||||
LIST[:markups][markup]["muti_lang_input_supprt"] and !(get_data["cross_lang"] == "true")
|
||||
end
|
||||
end
|
||||
|
||||
def can_add_more
|
||||
locale and LIST[:markups][markup]["ext_support"] && add_more
|
||||
if self.markup == "address"
|
||||
return false
|
||||
else
|
||||
locale and LIST[:markups][markup]["ext_support"] && add_more
|
||||
end
|
||||
end
|
||||
|
||||
def render_anywhere(partial, assigns)
|
||||
view = ActionView::Base.new(Rails::Configuration.new.view_path, assigns)
|
||||
ActionView::Base.helper_modules.each { |helper| view.extend helper }
|
||||
view.extend ApplicationHelper
|
||||
view.render(:partial => partial)
|
||||
end
|
||||
|
||||
|
||||
def gen_modal_dialog
|
||||
result = '<div class="modal hide fade" id="address-edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none; ">'
|
||||
result << '<div class="modal-header">'
|
||||
result << '<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>'
|
||||
result << '<h3 id="myModalLabel">'+title+'</h3>'
|
||||
result << '</div>'
|
||||
result << '<div class="modal-body">'
|
||||
result << '<p>One fine body…</p>'
|
||||
result << '</div>'
|
||||
result << '<div class="modal-footer">'
|
||||
result << '<button class="btn" data-dismiss="modal" aria-hidden="true">'+I18n.t("modal.close")+'</button>'
|
||||
result << '<button class="btn btn-primary">'+I18n.t("modal.save_and_close")+'</button>'
|
||||
result << '</div>'
|
||||
result << '</div>'
|
||||
result.html_safe
|
||||
render_anywhere("shared/attribute_field/address_modal_dialog",{:field_name=>title,:btn_class => "#{get_pairing_tab_class({})}"})
|
||||
end
|
||||
|
||||
end
|
||||
Reference in new issue
Block a user