2016-06-29 06:57:45 +00:00
|
|
|
module Admin::SeminarsFieldHelper
|
|
|
|
|
|
|
|
include ActionView::Helpers::FormTagHelper
|
|
|
|
include ActionView::Helpers::FormOptionsHelper
|
|
|
|
include ActionView::Helpers::DateHelper
|
|
|
|
include ActionView::Helpers::TagHelper
|
|
|
|
include ActionView::Helpers::RenderingHelper
|
|
|
|
include ActionView::Context
|
|
|
|
include OrbitBasis::RenderAnywhere
|
2023-10-10 14:49:16 +00:00
|
|
|
include ::MemberHelper
|
2016-06-29 06:57:45 +00:00
|
|
|
|
|
|
|
include OrbitFormHelper
|
|
|
|
|
2023-04-12 03:33:32 +00:00
|
|
|
def block_helper(seminar_main,index,disable = false,attribute_type=nil,signup=nil, to_require=true)
|
2016-06-29 06:57:45 +00:00
|
|
|
unless self.disabled
|
|
|
|
@index = index
|
|
|
|
@require = to_require
|
|
|
|
@markup_options = markup_options.merge(:disabled=>disable, :required => to_require)
|
2023-04-12 03:33:32 +00:00
|
|
|
@seminar_main = seminar_main
|
|
|
|
@attribute_value = @seminar_main.get_value_from_field_id(id,signup)
|
2016-06-29 06:57:45 +00:00
|
|
|
@attribute_type = attribute_type
|
|
|
|
@new_attribute = @attribute_value.nil?
|
|
|
|
@attribute_value = @attribute_value || signup.seminar_signup_values.build(seminar_signup_field_id: id)
|
|
|
|
@prefiled_value = @attribute_value.value rescue nil
|
|
|
|
return instance_eval("render_#{markup}") rescue ""
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def lang_tab(str,lang)
|
|
|
|
content_tag(:div,str,:class=>"tab-pane fade",:id=>(get_field_name_base+"tab_#{lang}"))
|
|
|
|
end
|
|
|
|
|
|
|
|
def render_address
|
2023-03-08 03:18:13 +00:00
|
|
|
control_group_wrapper_for_sm do |key,value|
|
|
|
|
value = (can_muti_lang_input_for_sm? ? @prefiled_value[key] : @prefiled_value) rescue nil
|
|
|
|
key_field = can_muti_lang_input_for_sm? ? "[#{key}]" : ""
|
2016-06-29 06:57:45 +00:00
|
|
|
place_holder= @panel_setting["placeholder"][key] rescue ''
|
|
|
|
# result = text_area_tag(get_field_name_base + key_field, value,@markup_options.merge({:placeholder=>place_holder,:for=>key}))
|
|
|
|
result = text_field_tag(get_field_name_base + key_field, value,@markup_options.merge({:placeholder=>place_holder,:for=>key}))
|
|
|
|
|
|
|
|
add_ext= @attribute_value.address_key[key] rescue {}
|
|
|
|
|
2021-04-03 16:23:52 +00:00
|
|
|
result << hidden_field_tag(get_basic_field_name_base+"[address_key][#{key}][county]",add_ext["county"],:class=>"county_#{key}", :id=>nil)
|
|
|
|
result << hidden_field_tag(get_basic_field_name_base+"[address_key][#{key}][street_address]",add_ext["street_address"],:class=>"street_address_#{key}", :id=>nil)
|
|
|
|
result << hidden_field_tag(get_basic_field_name_base+"[address_key][#{key}][city]",add_ext["city"],:class=>"city_#{key}", :id=>nil)
|
|
|
|
result << hidden_field_tag(get_basic_field_name_base+"[address_key][#{key}][zip]",add_ext["zip"],:class=>"zip_#{key}", :id=>nil)
|
|
|
|
result << hidden_field_tag(get_basic_field_name_base+"[address_key][#{key}][country]",add_ext["country"],:class=>"country_#{key}", :id=>nil)
|
|
|
|
result << hidden_field_tag(get_basic_field_name_base+"[address_key][#{key}][indicator]",add_ext["indicator"],:class=>"indicator_#{key}", :id=>nil)
|
2016-06-29 06:57:45 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def render_checkbox
|
|
|
|
@prefiled_value ||=[]
|
2023-10-07 14:34:07 +00:00
|
|
|
control_group_wrapper_for_sm do
|
2016-06-29 06:57:45 +00:00
|
|
|
a = self.typeE[:option_list].collect do |key,value|
|
2021-03-24 13:06:49 +00:00
|
|
|
label_tag("#{get_basic_field_name_org}_#{self.id}_#{key}",check_box_tag(get_field_name_base+"[#{key}]", true , (@prefiled_value.include?(key) ? true : false), { :id=>"#{get_basic_field_name_org}_#{self.id}_#{key}"})+value[I18n.locale.to_s],@markup_options.merge(:class=>"checkbox inline"))
|
2019-11-26 15:52:52 +00:00
|
|
|
end.join.html_safe rescue ""
|
2016-06-29 06:57:45 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-10-07 14:34:07 +00:00
|
|
|
def render_date
|
2016-06-29 06:57:45 +00:00
|
|
|
d = DateTime.now()
|
|
|
|
|
|
|
|
if date_is_range?
|
|
|
|
# fill_from = @attribute_value.get_date(:from) rescue nil
|
|
|
|
# fill_to = @attribute_value.get_date(:to) rescue nil
|
2023-03-08 03:18:13 +00:00
|
|
|
control_group_wrapper_for_sm do
|
2016-06-29 06:57:45 +00:00
|
|
|
|
|
|
|
case self.typeC['format']
|
|
|
|
when 'format1'
|
|
|
|
fill_from = (@prefiled_value && @prefiled_value["from"] ) ? @prefiled_value["from"] : d.strftime("%Y/%m/%d %H:%M")
|
|
|
|
fill_to = (@prefiled_value && @prefiled_value["to"] ) ? @prefiled_value["to"] : d.strftime("%Y/%m/%d %H:%M")
|
|
|
|
buf = datetime_picker(get_field_name_base+'[from]', fill_from, 'yyyy/MM/dd hh:mm', true)
|
|
|
|
buf << ' ~ '
|
|
|
|
buf << datetime_picker(get_field_name_base+'[to]', fill_to, 'yyyy/MM/dd hh:mm', true)
|
|
|
|
when 'format2'
|
|
|
|
fill_from = (@prefiled_value && @prefiled_value["from"] ) ? @prefiled_value["from"] : d.strftime("%Y/%m/%d")
|
|
|
|
fill_to = (@prefiled_value && @prefiled_value["to"] ) ? @prefiled_value["to"] : d.strftime("%Y/%m/%d")
|
|
|
|
buf = datetime_picker(get_field_name_base+'[from]', fill_from, 'yyyy/MM/dd')
|
|
|
|
buf << ' ~ '
|
|
|
|
buf << datetime_picker(get_field_name_base+'[to]', fill_to, 'yyyy/MM/dd')
|
|
|
|
when 'format3'
|
|
|
|
fill_from = (@prefiled_value && @prefiled_value["from"] ) ? @prefiled_value["from"] : d.strftime("%Y/%m")
|
|
|
|
fill_to = (@prefiled_value && @prefiled_value["to"] ) ? @prefiled_value["to"] : d.strftime("%Y/%m/")
|
2023-10-07 14:34:07 +00:00
|
|
|
buf = datetime_picker(get_field_name_base+'[from]', fill_from, 'yyyy/MM')
|
2016-06-29 06:57:45 +00:00
|
|
|
buf << ' ~ '
|
|
|
|
buf << datetime_picker(get_field_name_base+'[to]', fill_to, 'yyyy/MM')
|
|
|
|
when 'format4'
|
|
|
|
fill_from = (@prefiled_value && @prefiled_value["from"] ) ? @prefiled_value["from"] : d.strftime("%Y")
|
|
|
|
fill_to = (@prefiled_value && @prefiled_value["to"] ) ? @prefiled_value["to"] : d.strftime("%Y")
|
2023-10-07 14:34:07 +00:00
|
|
|
buf = datetime_picker(get_field_name_base+'[from]', fill_from, 'yyyy')
|
2016-06-29 06:57:45 +00:00
|
|
|
buf << ' ~ '
|
|
|
|
buf << datetime_picker(get_field_name_base+'[to]', fill_to, 'yyyy')
|
|
|
|
end
|
|
|
|
|
|
|
|
# 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
|
|
|
|
# @prefiled_value = @attribute_value.get_date
|
|
|
|
|
|
|
|
case self.typeC['format']
|
|
|
|
when 'format1'
|
|
|
|
tmp = datetime_picker(get_field_name_base, (@prefiled_value ? @prefiled_value : d.strftime("%Y/%m/%d %H:%M")), 'yyyy/MM/dd hh:mm', true)
|
|
|
|
when 'format2'
|
|
|
|
tmp = datetime_picker(get_field_name_base, (@prefiled_value ? @prefiled_value : d.strftime("%Y/%m/%d")), 'yyyy/MM/dd')
|
|
|
|
when 'format3'
|
2023-10-07 14:34:07 +00:00
|
|
|
tmp = datetime_picker(get_field_name_base, (@prefiled_value ? @prefiled_value : d.strftime("%Y/%m")), 'yyyy/MM')
|
2016-06-29 06:57:45 +00:00
|
|
|
when 'format4'
|
2023-10-07 14:34:07 +00:00
|
|
|
tmp = datetime_picker(get_field_name_base, (@prefiled_value ? @prefiled_value : d.strftime("%Y")), 'yyyy')
|
2016-06-29 06:57:45 +00:00
|
|
|
end
|
2023-10-07 14:34:07 +00:00
|
|
|
|
|
|
|
control_group_wrapper_for_sm{tmp}
|
|
|
|
# control_group_wrapper_for_sm{date_select(get_field_name_base,nil,@markup_options.merge(:default=>@prefiled_value),:class=>"input-small")}
|
2016-06-29 06:57:45 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def seminar_datetime_picker(object_name, value, format, time=false)
|
|
|
|
content_tag :div, :class => "input-append datetimepick", "data-date-format"=>format, "data-picktime"=>"#{time}" do
|
|
|
|
concat text_field_tag(object_name, value, :placeholder=>format)
|
|
|
|
concat (content_tag :span, :class => 'add-on clearDate' do
|
|
|
|
content_tag :i, nil, :class => 'icons-cross-3'
|
|
|
|
end)
|
|
|
|
concat (content_tag :span, :class => 'add-on iconbtn' do
|
|
|
|
content_tag :i, nil, 'data-time-icon' => 'icons-clock', 'data-date-icon' => 'icons-calendar', :class=>"icons-calendar"
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def render_date_durnation #Need re-write low priority
|
2023-10-07 14:34:07 +00:00
|
|
|
|
2016-06-29 06:57:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def render_radio_button
|
|
|
|
@prefiled_value ||=[]
|
2023-03-08 03:18:13 +00:00
|
|
|
control_group_wrapper_for_sm do
|
2016-06-29 06:57:45 +00:00
|
|
|
self.typeE[:option_list].collect do |key,value|
|
2021-03-24 13:06:49 +00:00
|
|
|
label_tag("#{get_basic_field_name_org}_#{self.id}_#{key}",radio_button_tag(get_field_name_base, key , (@prefiled_value.include?(key) ? true : false), {:required=>@require,:id=>"#{get_basic_field_name_org}_#{self.id}_#{key}"})+value[I18n.locale.to_s],@markup_options.merge(:class=>"radio inline"))
|
2019-11-26 15:52:52 +00:00
|
|
|
end.join.html_safe
|
2016-06-29 06:57:45 +00:00
|
|
|
end
|
|
|
|
end
|
2021-04-24 10:41:50 +00:00
|
|
|
def render_seminar_preferred_session
|
|
|
|
@prefiled_value ||=[]
|
|
|
|
@prefiled_value = Array(@prefiled_value)
|
2023-03-08 03:18:13 +00:00
|
|
|
control_group_wrapper_for_sm do
|
2023-04-12 03:33:32 +00:00
|
|
|
@seminar_main.summary_chioices.map.with_index do |value,key|
|
2021-04-24 10:41:50 +00:00
|
|
|
key = key.to_s
|
|
|
|
label_tag("#{get_basic_field_name_org}_#{self.id}_#{key}",radio_button_tag(get_field_name_base, key , ((@prefiled_value.include?(key) || @prefiled_value.include?(key.to_i)) ? true : false), {:required=>@require,:id=>"#{get_basic_field_name_org}_#{self.id}_#{key}"})+value,@markup_options.merge(:class=>"radio inline"))
|
|
|
|
end.join.html_safe
|
2023-04-12 03:33:32 +00:00
|
|
|
end if @seminar_main.enable_summary_choice
|
2021-04-24 10:41:50 +00:00
|
|
|
end
|
2016-06-29 06:57:45 +00:00
|
|
|
def render_select
|
|
|
|
prompt = @panel_setting["initial"][I18n.locale.to_s] rescue nil
|
|
|
|
@markup_options.merge!(:prompt => prompt) unless prompt.nil?
|
2023-03-08 03:18:13 +00:00
|
|
|
control_group_wrapper_for_sm{select_tag( get_field_name_base,options_for_select(self.typeB["option_list"].collect{|p| [p[1][I18n.locale.to_s],p[0]]},@prefiled_value),@markup_options)} rescue ""
|
2016-06-29 06:57:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def render_text_area
|
2023-03-08 03:18:13 +00:00
|
|
|
control_group_wrapper_for_sm do |key,value|
|
2019-11-26 15:52:52 +00:00
|
|
|
if !@prefiled_value.nil?
|
2023-03-08 03:18:13 +00:00
|
|
|
value = can_muti_lang_input_for_sm? ? @prefiled_value[key] : @prefiled_value
|
2019-11-26 15:52:52 +00:00
|
|
|
else
|
|
|
|
value = nil
|
|
|
|
end
|
2023-03-08 03:18:13 +00:00
|
|
|
key = can_muti_lang_input_for_sm? ? "#{key}" : I18n.locale
|
2019-11-26 15:52:52 +00:00
|
|
|
place_holder= typeD["placeholder"][key] rescue ''
|
2023-03-08 03:18:13 +00:00
|
|
|
name1 = can_muti_lang_input_for_sm? ? (get_field_name_base + "[#{key}]") : get_field_name_base
|
2023-10-16 02:51:51 +00:00
|
|
|
text_area_tag(name1, value, @markup_options.merge(:placeholder=>place_holder,:class=>'input-medium form-control', :maxlength=> 300, :style => "width:500px;height:200px"))
|
2016-06-29 06:57:45 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def render_text_field
|
2023-03-08 03:18:13 +00:00
|
|
|
a = control_group_wrapper_for_sm do |key,value|
|
2016-06-29 06:57:45 +00:00
|
|
|
add_more_blank = can_add_more ? "[]" : ""
|
2023-03-08 03:18:13 +00:00
|
|
|
key_field = can_muti_lang_input_for_sm? ? "#{key}" : I18n.locale
|
2019-11-26 15:52:52 +00:00
|
|
|
place_holder= typeA["placeholder"][key_field] rescue ''
|
2023-03-08 03:18:13 +00:00
|
|
|
name1 = can_muti_lang_input_for_sm? ? ([get_field_name_base,add_more_blank,"[#{key_field}]"].join) : ([get_field_name_base,add_more_blank].join)
|
2023-04-12 03:33:32 +00:00
|
|
|
text_field_tag(name1, value, @markup_options.merge(:placeholder=>place_holder,:class=>'input-medium form-control'))
|
2023-10-07 14:34:07 +00:00
|
|
|
end
|
2016-06-29 06:57:45 +00:00
|
|
|
end
|
|
|
|
|
2023-09-27 14:56:21 +00:00
|
|
|
def render_file_field
|
|
|
|
a = control_group_wrapper_for_sm do |key,value|
|
|
|
|
add_more_blank = can_add_more ? "[]" : ""
|
|
|
|
key_field = can_muti_lang_input? ? "[#{key}]" : ""
|
|
|
|
field_name = [get_field_name_base,add_more_blank,key_field].join
|
2023-10-10 14:49:16 +00:00
|
|
|
file_required =@require && !value ? 'required="required"' : ''
|
2023-09-27 14:56:21 +00:00
|
|
|
"<div class=\"file-selector\"><label class=\"ui-button\">
|
2023-10-10 14:49:16 +00:00
|
|
|
<input style=\"position: absolute;width:0.1em;opacity: 0;padding: 0;border: 0;opacity: 0;left: 50%;top: 0;\" class=\"upload\" name=\"#{field_name}\" #{file_required} type=\"file\" accept=\".pdf,.png,.jpg,.odf\" onchange=\"if(this.files[0].size > 1048576*20){alert('#{I18n.t("seminar.file_limit_hint")}');this.value = '';}else{var ext = this.value.match(/\.([^\.]+)$/)[1];if (!['pdf','png','jpg','odf'].includes(ext)){alert('#{I18n.t("seminar.file_format_hint")}');this.value='';}}\" />
|
2023-09-27 14:56:21 +00:00
|
|
|
<i class=\"fa fa-file\"></i> #{I18n.t('file.upload')}
|
|
|
|
</label><div class=\"filename\"></div></div>#{value}".html_safe
|
2023-10-07 14:34:07 +00:00
|
|
|
end
|
2023-09-27 14:56:21 +00:00
|
|
|
end
|
|
|
|
|
2023-10-10 14:49:16 +00:00
|
|
|
def render_email
|
|
|
|
a = control_group_wrapper_for_sm do |key,value|
|
|
|
|
place_holder= typeA["placeholder"][I18n.locale] rescue ''
|
|
|
|
email_field_tag(get_field_name_base, value, @markup_options.merge(:placeholder=>place_holder,:class=>'input-medium form-control', title: I18n.t("seminar.email_hint"))) +
|
|
|
|
(content_tag :div,:class=>"loader" do
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def render_phone
|
|
|
|
a = control_group_wrapper_for_sm do |key,value|
|
|
|
|
place_holder= typeA["placeholder"][I18n.locale] rescue ''
|
2023-10-11 00:47:59 +00:00
|
|
|
text_field_tag(get_field_name_base, value, @markup_options.merge(:placeholder=>place_holder,:class=>'input-medium form-control', pattern: "[\\d\\+\\-\\(\\)]{10,13}", title: I18n.t("seminar.phone_hint"))) + (content_tag :p do
|
2023-10-10 14:49:16 +00:00
|
|
|
"(#{I18n.t("seminar.phone_hint")})"
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-06-29 06:57:45 +00:00
|
|
|
def date_is_range?
|
|
|
|
is_range = "false"
|
|
|
|
data = get_data
|
|
|
|
if !data.nil?
|
2023-10-07 14:34:07 +00:00
|
|
|
is_range = data['is_range'] if data.has_key? "is_range"
|
2016-06-29 06:57:45 +00:00
|
|
|
end
|
2023-10-07 14:34:07 +00:00
|
|
|
is_range == "true"
|
2016-06-29 06:57:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def valid_locales
|
|
|
|
site = Site.first
|
|
|
|
[I18n.locale]+(site.valid_locales-[I18n.locale])
|
|
|
|
end
|
|
|
|
|
2023-09-27 16:14:43 +00:00
|
|
|
def lang_panel_tabbable_wrapper_for_sm(add_more_params,&block)
|
2016-06-29 06:57:45 +00:00
|
|
|
add_more_counter = ''
|
|
|
|
|
2019-11-26 15:52:52 +00:00
|
|
|
if self.markup=='text_area' #or self.markup=='address'
|
2016-06-29 06:57:45 +00:00
|
|
|
tmp1 = valid_locales.collect do |key|
|
2019-11-26 15:52:52 +00:00
|
|
|
if !@prefiled_value.nil?
|
2021-04-03 16:23:52 +00:00
|
|
|
value = @prefiled_value[key] || @prefiled_value[key.to_s] rescue nil
|
2019-11-26 15:52:52 +00:00
|
|
|
else
|
|
|
|
value = nil
|
|
|
|
end
|
2016-06-29 06:57:45 +00:00
|
|
|
# div_class_ary = ["tab-pane" ,"fade","#{get_pairing_tab_class({})}_#{key}"]
|
|
|
|
div_class_ary = ["tab-pane" ,"fade"]
|
2023-03-08 03:18:13 +00:00
|
|
|
if @show_set_field_for_sm && @markup=='text_area'
|
2020-01-12 06:39:32 +00:00
|
|
|
div_id = "ckeditor_#{get_pairing_tab_class({})}_#{key}"
|
|
|
|
else
|
|
|
|
div_id = "#{get_pairing_tab_class({})}_#{key}"
|
|
|
|
end
|
2016-06-29 06:57:45 +00:00
|
|
|
if can_add_more
|
|
|
|
add_more_value = add_more_params[0][:value]
|
|
|
|
add_more_counter = add_more_params[0][:counter]
|
|
|
|
value = add_more_value[key] rescue nil
|
|
|
|
div_class_ary << "add_more_item_#{add_more_counter}"
|
|
|
|
end
|
|
|
|
|
|
|
|
div_class = div_class_ary.join(" ")
|
|
|
|
div_class << (key == I18n.locale ? " active in" : '')
|
|
|
|
content_tag(:div,yield(key,value), :id=>div_id,:class=>div_class)
|
|
|
|
end# of VALID_LOCALES.collect for tabed input
|
2023-10-07 14:34:07 +00:00
|
|
|
tmp2 = content_tag(:div,:class => 'btn-group', :data=>{:toggle=>"buttons-radio"}) do
|
2016-06-29 06:57:45 +00:00
|
|
|
buff2 = valid_locales.each.collect do |key|
|
|
|
|
# link_entry = self.add_more ? "#{add_more_tab(:tab_btn,loop_counter,key)}" : "#tab"+id.to_s+"_#{key}"
|
2023-03-08 03:18:13 +00:00
|
|
|
if @show_set_field_for_sm && @markup=='text_area'
|
2020-01-12 06:39:32 +00:00
|
|
|
link_entry_ary = ["#ckeditor_#{get_pairing_tab_class({})}","_#{key}"]
|
|
|
|
else
|
|
|
|
link_entry_ary = ["##{get_pairing_tab_class({})}","_#{key}"]
|
|
|
|
end
|
2016-06-29 06:57:45 +00:00
|
|
|
link_entry_ary << ".add_more_item_#{add_more_counter}" if can_add_more
|
|
|
|
link_entry = link_entry_ary.join
|
|
|
|
link_to(I18n.t(key),link_entry,:data=>{:toggle=>"tab"},:class=>"btn #{(key == I18n.locale ? "active" : nil)}",:for=>key)
|
|
|
|
end # of VALID_LOCALES.collect for tabs
|
|
|
|
|
|
|
|
buff2 << link_to((content_tag :i,'',:class=>'icon-edit'),"##{get_pairing_tab_class({})}_m_window", :role=>"button",:class=>'btn',:data=>{:toggle=>"modal"}) if self.markup == 'address'
|
|
|
|
buff2 << link_to((content_tag :i,'',:class=>'icon-trash'),"#",:class=>"btn remove-input") if self.add_more
|
|
|
|
buff2.join.html_safe
|
|
|
|
end # of content ul
|
|
|
|
tmp = content_tag :div,:class=> "tab-content textarea-lang" do
|
|
|
|
tmp2 << tmp1.join('').html_safe
|
|
|
|
end
|
|
|
|
else
|
|
|
|
|
|
|
|
# tmp = content_tag :div,:class=> (add_more || self.markup=='address') ? "input-append" : "tab-content" do
|
2023-10-07 14:34:07 +00:00
|
|
|
tmp1 =
|
2016-06-29 06:57:45 +00:00
|
|
|
content_tag :div,:class=> "tab-content" do
|
|
|
|
|
|
|
|
buff = valid_locales.collect do |key|
|
2021-04-03 16:23:52 +00:00
|
|
|
value = @prefiled_value[key] || @prefiled_value[key.to_s] rescue nil
|
2016-06-29 06:57:45 +00:00
|
|
|
# div_class_ary = ["tab-pane" ,"fade","#{get_pairing_tab_class({})}_#{key}"]
|
|
|
|
div_class_ary = ["tab-pane" ,"fade"]
|
|
|
|
|
|
|
|
div_id = "#{get_pairing_tab_class({})}_#{key}"
|
|
|
|
|
|
|
|
|
|
|
|
if can_add_more
|
|
|
|
add_more_value = add_more_params[0][:value]
|
|
|
|
add_more_counter = add_more_params[0][:counter]
|
|
|
|
value = add_more_value[key] rescue nil
|
|
|
|
div_class_ary << "add_more_item_#{add_more_counter}"
|
|
|
|
end
|
|
|
|
|
|
|
|
div_class = div_class_ary.join(" ")
|
|
|
|
div_class << (key == I18n.locale ? " active in" : '')
|
|
|
|
content_tag(:div,yield(key,value), :id=>div_id,:class=>div_class)
|
|
|
|
end# of VALID_LOCALES.collect for tabed input
|
|
|
|
|
|
|
|
buff.join('').html_safe
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2023-10-07 14:34:07 +00:00
|
|
|
tmp2 = content_tag(:div,:class => 'btn-group', :data=>{:toggle=>"buttons-radio"}) do
|
2016-06-29 06:57:45 +00:00
|
|
|
buff2 = 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 = link_entry_ary.join
|
|
|
|
link_to(I18n.t(key),link_entry,:data=>{:toggle=>"tab"},:class=>"btn #{(key == I18n.locale ? "active" : nil)}",:for=>key)
|
|
|
|
end # of VALID_LOCALES.collect for tabs
|
|
|
|
|
|
|
|
buff2 << link_to((content_tag :i,'',:class=>'icon-edit'),"#address-field", :role=>"button",:class=>'btn',:data=>{:toggle=>"modal"}) if self.markup == 'address'
|
|
|
|
buff2 << link_to((content_tag :i,'',:class=>'icon-trash'),"#",:class=>"btn remove-input") if self.add_more
|
|
|
|
buff2.join.html_safe
|
|
|
|
end # of content ul
|
|
|
|
|
|
|
|
|
2023-10-07 14:34:07 +00:00
|
|
|
|
2016-06-29 06:57:45 +00:00
|
|
|
tmp = content_tag :div,:class=> "input-append" do
|
|
|
|
tmp1 << tmp2
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2023-03-08 03:18:13 +00:00
|
|
|
def controls_wrapper_for_sm(*add_more_params,&block)
|
2023-04-12 03:33:32 +00:00
|
|
|
result = Array.new
|
|
|
|
add_more_counter = ""
|
2016-06-29 06:57:45 +00:00
|
|
|
|
2023-04-12 03:33:32 +00:00
|
|
|
if can_add_more
|
2023-10-07 14:34:07 +00:00
|
|
|
add_more_counter = add_more_params[0][:counter]
|
|
|
|
add_more_value = add_more_params[0][:value]
|
2023-04-12 03:33:32 +00:00
|
|
|
end
|
2016-06-29 06:57:45 +00:00
|
|
|
|
2023-03-08 03:18:13 +00:00
|
|
|
if can_muti_lang_input_for_sm?
|
2023-09-27 16:14:43 +00:00
|
|
|
result << lang_panel_tabbable_wrapper_for_sm(add_more_params,&block)
|
2016-06-29 06:57:45 +00:00
|
|
|
result << gen_modal_dialog if self.markup == "address"
|
|
|
|
# result << add_more_unt if can_add_more
|
|
|
|
else #cross lang field
|
|
|
|
case can_add_more
|
|
|
|
when true
|
2023-10-07 14:34:07 +00:00
|
|
|
value = add_more_params[0][:value]
|
2016-06-29 06:57:45 +00:00
|
|
|
result << content_tag(:div,:class=>"input-append"){yield(nil,value) + link_to((content_tag :i,'',:class=>'icon-trash'),"#",:class=>"btn remove-input") }
|
|
|
|
# result << add_more_unt
|
|
|
|
else
|
|
|
|
value = @prefiled_value
|
|
|
|
result << yield(nil,value)
|
|
|
|
end
|
|
|
|
end
|
2019-11-26 15:52:52 +00:00
|
|
|
if self.markup == "address"
|
|
|
|
result
|
|
|
|
else
|
|
|
|
result[0]
|
|
|
|
end
|
2016-06-29 06:57:45 +00:00
|
|
|
|
2023-03-08 03:18:13 +00:00
|
|
|
end # of def controls_wrapper_for_sm(&block)
|
2016-06-29 06:57:45 +00:00
|
|
|
|
2023-10-07 14:34:07 +00:00
|
|
|
def control_group_wrapper_for_sm(&block)
|
2023-03-08 03:18:13 +00:00
|
|
|
div_class = can_muti_lang_input_for_sm? ? "col-sm-10 controls" : "col-sm-10 controls"
|
|
|
|
# div_class = can_muti_lang_input_for_sm? ? "control-group language-swich" : "control-group"
|
2019-11-26 15:52:52 +00:00
|
|
|
result = ""
|
2016-06-29 06:57:45 +00:00
|
|
|
|
|
|
|
case self.markup
|
|
|
|
|
|
|
|
when "text_field"
|
|
|
|
|
|
|
|
if can_add_more
|
|
|
|
|
2023-10-07 14:34:07 +00:00
|
|
|
multipleInputs =
|
2016-06-29 06:57:45 +00:00
|
|
|
content_tag(:div,:class=>"add-target") do
|
|
|
|
@attribute_value.add_more_counter.times.collect do |t|
|
2023-03-08 03:18:13 +00:00
|
|
|
controls_wrapper_for_sm(:value=>(@prefiled_value[t] rescue nil),:counter=>t,&block)
|
2016-06-29 06:57:45 +00:00
|
|
|
end.join('').html_safe # of add_more fields
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
temp = content_tag(:div, multipleInputs + add_more_unt, :class=>'add-input')
|
2023-10-07 14:34:07 +00:00
|
|
|
|
|
|
|
result = form_label + content_tag(:div,temp,:class=>div_class)
|
2016-06-29 06:57:45 +00:00
|
|
|
|
|
|
|
# result = label + multipleInputs + add_more_unt
|
|
|
|
# result = label + 一堆的輸入框(要用 multipleInput editMore 包起來) + add_more btn + hidden_fields
|
|
|
|
else
|
2023-03-08 03:18:13 +00:00
|
|
|
result = form_label + content_tag(:div,controls_wrapper_for_sm(&block),:class=>div_class)
|
2016-06-29 06:57:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
when "address"
|
|
|
|
|
|
|
|
# address = content_tag :div,:class=>"multipleInput editMore" do
|
|
|
|
address = content_tag :div,:class=>"col-sm-10" do
|
2023-03-08 03:18:13 +00:00
|
|
|
form_label + content_tag(:div, controls_wrapper_for_sm(&block), :class=>'add-input')
|
2016-06-29 06:57:45 +00:00
|
|
|
end # of div multipleInput editMore
|
|
|
|
|
|
|
|
result = address
|
|
|
|
|
|
|
|
else
|
2023-03-08 03:18:13 +00:00
|
|
|
result = form_label + content_tag(:div,controls_wrapper_for_sm(&block),:class=>div_class)
|
2016-06-29 06:57:45 +00:00
|
|
|
end
|
2019-11-26 15:52:52 +00:00
|
|
|
result = result + end_block
|
2016-06-29 06:57:45 +00:00
|
|
|
result.html_safe
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2023-10-07 14:34:07 +00:00
|
|
|
def add_more_unt
|
2016-06-29 06:57:45 +00:00
|
|
|
temp_field_name = get_basic_field_name_base + '[temp]'
|
|
|
|
add_more = content_tag :p,:class=> 'add-btn' do
|
2023-03-08 03:18:13 +00:00
|
|
|
content = link_to (content_tag :i,I18n.t(:add),:class=>"icon-plus"),"#","data-roles"=>"role_a",:class=>"trigger #{can_muti_lang_input_for_sm? ? 'textLengInput' : 'textInput' } btn btn-small btn-primary"
|
2021-04-03 16:23:52 +00:00
|
|
|
content << hidden_field_tag("#{temp_field_name}[count]",@attribute_value.add_more_counter ,:class=>"list_count", :id=>nil)
|
|
|
|
content << hidden_field_tag("#{temp_field_name}[count]",get_basic_field_name_base,:class=>"field_name", :id=>nil)
|
2016-06-29 06:57:45 +00:00
|
|
|
content
|
|
|
|
end # of div
|
|
|
|
# add_more = content_tag :div,:class=> 'controls' do
|
|
|
|
# content_tag :span,:class=> 'help-block' do
|
|
|
|
# content = link_to (content_tag :i,I18n.t(:add),:class=>"icon-plus-sign"),"#",:class=>'addinput'
|
|
|
|
# content << hidden_field_tag("#{temp_field_name}[count]",@attribute_value.add_more_counter ,:class=>"list_count")
|
|
|
|
# content << hidden_field_tag("#{temp_field_name}[count]",get_basic_field_name_base,:class=>"field_name")
|
|
|
|
# content
|
|
|
|
# end # of span
|
|
|
|
# end # of div
|
|
|
|
end
|
|
|
|
|
|
|
|
def end_block
|
|
|
|
if @new_attribute
|
2021-04-03 16:23:52 +00:00
|
|
|
hidden_field_tag(get_basic_field_name_base+"[#{get_basic_field_name}_id]",id,:for=>"field_#{@index}", :id=>nil)
|
2016-06-29 06:57:45 +00:00
|
|
|
else
|
2021-04-03 16:23:52 +00:00
|
|
|
hidden_field_tag(get_basic_field_name_base+"[id]",@attribute_value.id,:for=>"field_#{@index}", :id=>nil)
|
2016-06-29 06:57:45 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def add_more_tab(mode,counter,key)
|
|
|
|
case mode
|
|
|
|
when :input_field
|
|
|
|
get_pairing_tab_class(:suffix=>['','tab'+counter.to_s,key].join('-'))
|
|
|
|
when :tab_btn
|
|
|
|
".#{get_pairing_tab_class(:suffix=>['','tab'+counter.to_s,key].join('-'))}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_pairing_tab_class(opts)
|
|
|
|
prefix = opts[:prefix]
|
|
|
|
suffix = opts[:suffix]
|
|
|
|
str = get_basic_field_name_base.gsub("[","_").gsub("]",'')
|
2023-10-07 14:34:07 +00:00
|
|
|
str = prefix.nil? ? str : prefix+ str
|
2016-06-29 06:57:45 +00:00
|
|
|
suffix.nil? ? str : str + suffix
|
|
|
|
end
|
|
|
|
|
2019-11-26 15:52:52 +00:00
|
|
|
def get_basic_field_name_org
|
|
|
|
"seminar_signup_values"
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_basic_field_name
|
|
|
|
"seminar_signup_field"
|
|
|
|
end
|
|
|
|
|
2016-06-29 06:57:45 +00:00
|
|
|
def get_basic_field_name_base
|
2019-11-26 15:52:52 +00:00
|
|
|
"#{get_basic_field_name_org}[#{@index}]"
|
2016-06-29 06:57:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def get_field_name_base
|
|
|
|
get_basic_field_name_base + "[value]"
|
|
|
|
end
|
|
|
|
|
|
|
|
def form_label
|
2019-11-26 15:52:52 +00:00
|
|
|
if self.markup == "text_area"
|
2023-10-07 14:34:07 +00:00
|
|
|
# plc = typeD["placeholder"][I18n.locale].to_s.blank? ? nil : "(#{typeD["placeholder"][I18n.locale]})"
|
|
|
|
plc = nil
|
2022-10-22 07:58:10 +00:00
|
|
|
label_tag(key, '' , :class=>"col-sm-2 control-label muted") do
|
|
|
|
concat (!@require.blank? ? '*'+title : title)
|
2022-10-22 08:04:50 +00:00
|
|
|
if plc
|
2022-10-22 08:04:06 +00:00
|
|
|
concat tag(:br)
|
|
|
|
concat plc
|
|
|
|
end
|
2022-10-22 07:58:10 +00:00
|
|
|
end
|
2019-11-26 15:52:52 +00:00
|
|
|
else
|
|
|
|
label_tag(key,(!@require.blank? ? '*'+title : title),:class=>"col-sm-2 control-label muted")
|
|
|
|
end
|
2016-06-29 06:57:45 +00:00
|
|
|
end
|
|
|
|
|
2023-03-08 03:18:13 +00:00
|
|
|
def can_muti_lang_input_for_sm?
|
2016-06-29 06:57:45 +00:00
|
|
|
if self.markup == "address"
|
|
|
|
return true
|
|
|
|
else
|
2023-10-07 14:34:07 +00:00
|
|
|
$seminar_list[:markups][markup]["muti_lang_input_supprt"] and !(get_data["cross_lang"] == "true")
|
2016-06-29 06:57:45 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def can_add_more
|
|
|
|
if self.markup == "address"
|
|
|
|
return false
|
|
|
|
else
|
|
|
|
add_more
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def gen_modal_dialog
|
|
|
|
render_anywhere("shared/attribute_field/address_modal_dialog",{
|
|
|
|
:field_name=>title,
|
|
|
|
:html_id=>"address-field",
|
|
|
|
:btn_class => "#{get_pairing_tab_class({})}",
|
|
|
|
:field_name_basic => get_basic_field_name_base
|
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
2023-03-08 03:18:13 +00:00
|
|
|
def show_set_field_for_sm(field_sets,key_field,key_index,field,markup='text_field')
|
|
|
|
@show_set_field_for_sm = true
|
|
|
|
def self.can_muti_lang_input_for_sm?
|
2019-11-26 15:52:52 +00:00
|
|
|
true
|
|
|
|
end
|
|
|
|
def self.can_add_more
|
|
|
|
false
|
|
|
|
end
|
2020-01-12 06:39:32 +00:00
|
|
|
@markup = markup
|
2019-11-26 15:52:52 +00:00
|
|
|
def self.markup
|
2020-01-12 06:39:32 +00:00
|
|
|
@markup
|
2019-11-26 15:52:52 +00:00
|
|
|
end
|
|
|
|
def self.add_more
|
|
|
|
false
|
|
|
|
end
|
|
|
|
@new_attribute = false
|
|
|
|
@key_index = key_index
|
|
|
|
def self.key
|
|
|
|
@key_index
|
|
|
|
end
|
|
|
|
def self.form_label
|
|
|
|
''
|
|
|
|
end
|
|
|
|
def self.end_block
|
2021-04-03 16:23:52 +00:00
|
|
|
unless @attribute_value.new_record?
|
|
|
|
hidden_field_tag("seminar_main[#{@key_field}][#{@key_index}]"+"[id]",
|
|
|
|
@attribute_value.id,:for=>"field_#{@key_index}", :id=>nil)
|
|
|
|
else
|
|
|
|
""
|
|
|
|
end
|
2019-11-26 15:52:52 +00:00
|
|
|
end
|
|
|
|
@key_field = key_field
|
|
|
|
@field = field
|
|
|
|
def self.get_basic_field_name_base
|
|
|
|
"seminar_main[#{@key_field}][#{@key_index}][#{@field}]"
|
|
|
|
end
|
|
|
|
def self.get_field_name_base
|
|
|
|
"seminar_main[#{@key_field}][#{@key_index}][#{@field}]"
|
|
|
|
end
|
|
|
|
@attribute_value = field_sets
|
|
|
|
@prefiled_value = field_sets[field]
|
2023-03-08 03:18:13 +00:00
|
|
|
a = control_group_wrapper_for_sm do |key,value|
|
2020-01-12 06:39:32 +00:00
|
|
|
add_more_blank = ""
|
|
|
|
if markup=='text_field'
|
|
|
|
if key_field == 'seminar_email_sets'
|
|
|
|
inside = text_field_tag([get_field_name_base,"[#{key}]"].join,value,:class=>'input-medium form-control')
|
2023-10-07 14:34:07 +00:00
|
|
|
else
|
2020-01-12 06:39:32 +00:00
|
|
|
inside = text_field_tag([get_field_name_base,"[#{key}]"].join,value)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
inside = cktext_area("seminar_main[#{@key_field}][#{@key_index}][#{@field}]","#{key}",value:value)
|
|
|
|
end
|
|
|
|
inside
|
2019-11-26 15:52:52 +00:00
|
|
|
end
|
|
|
|
@key_field = nil
|
|
|
|
@key_index = nil
|
|
|
|
@field = nil
|
2023-03-08 03:18:13 +00:00
|
|
|
@show_set_field_for_sm = nil
|
2019-11-26 15:52:52 +00:00
|
|
|
return a.html_safe
|
|
|
|
end
|
2023-10-07 14:34:07 +00:00
|
|
|
end
|