Updated.
This commit is contained in:
parent
3177cd48f8
commit
274ea9c71a
|
@ -158,10 +158,11 @@ module Admin::AsksHelper
|
|||
def field_radio_button_tag(index1,field,show_value,checked,custom_options={})
|
||||
radio_button_tag("#{get_input_name_for_ask}[#{index1}][#{field}]",show_value,checked,custom_options)
|
||||
end
|
||||
def render_date_block(field_name,v,i,value)
|
||||
def render_date_block(field_name,v,i,value, prefix_contents="")
|
||||
case v['format']
|
||||
when 'format1'
|
||||
t1 = text_field_tag("#{field_name}[datetime][date][#{i}]",(value['datetime']['date']["#{i}"] rescue nil),{:required => v['required']=='true',autocomplete: 'off',placeholder: t('ask.datepicker'),title: t('ask.datepicker'),style:'width:100%;'})
|
||||
t1 = text_field_tag("#{field_name}[datetime][date][#{i}]",(value['datetime']['date']["#{i}"] rescue nil),{:required => v['required']=='true',autocomplete: 'off',placeholder: t('ask.datepicker'),title: t('ask.datepicker')})
|
||||
t1 = prefix_contents + t1
|
||||
#t2_value = value['datetime']['h']["#{i}"] rescue nil
|
||||
#t3_value = value['datetime']['m']["#{i}"] rescue nil
|
||||
#t2 = select_tag("#{field_name}[datetime][h][#{i}]",options_for_select((1..24).collect{|v1| v1.to_s.rjust(2, "0")},selected: t2_value))
|
||||
|
@ -175,6 +176,7 @@ module Admin::AsksHelper
|
|||
</script>".html_safe
|
||||
when 'format2'
|
||||
t1 = text_field_tag("#{field_name}[datetime][date][#{i}]",(value['datetime']['date']["#{i}"] rescue nil),{:required => v['required']=='true',autocomplete: 'off',placeholder: t('ask.datepicker'),title: t('ask.datepicker')})
|
||||
t1 = prefix_contents + t1
|
||||
"<div class=\"datetime_selector\">#{t1}</div>
|
||||
<script>
|
||||
jQuery(document).ready(function( $ ) {
|
||||
|
@ -183,7 +185,8 @@ module Admin::AsksHelper
|
|||
</script>".html_safe
|
||||
when 'format3'
|
||||
t1 = text_field_tag("#{field_name}[datetime][date][#{i}]",(value['datetime']['date']["#{i}"] rescue nil),{:required => v['required']=='true',autocomplete: 'off',placeholder: t('ask.datepicker'),title: t('ask.datepicker'),:class => 'yearpicker'})
|
||||
"#{t1}
|
||||
t1 = prefix_contents + t1
|
||||
"<div class=\"datetime_selector\">#{t1}</div>
|
||||
<script>
|
||||
jQuery(document).ready(function( $ ) {
|
||||
$(\"input[name='#{field_name}[datetime][date][#{i}]']\").ui_datepicker({dateFormat: 'yy-mm',show_view: 'month'});
|
||||
|
@ -192,7 +195,8 @@ module Admin::AsksHelper
|
|||
"
|
||||
when 'format4'
|
||||
t1 = text_field_tag("#{field_name}[datetime][date][#{i}]",(value['datetime']['date']["#{i}"] rescue nil),{:required => v['required']=='true',autocomplete: 'off',placeholder: t('ask.datepicker'),title: t('ask.datepicker'),:class => 'yearpicker'})
|
||||
"#{t1}
|
||||
t1 = prefix_contents + t1
|
||||
"<div class=\"datetime_selector\">#{t1}</div>
|
||||
<script>
|
||||
jQuery(document).ready(function( $ ) {
|
||||
$(\"input[name='#{field_name}[datetime][date][#{i}]']\").ui_datepicker({dateFormat: 'yy',show_view: 'year'});
|
||||
|
@ -278,9 +282,9 @@ module Admin::AsksHelper
|
|||
"#{DateTime.parse(tmp['0']).strftime(format_str) rescue ''}~#{DateTime.parse(tmp['1']).strftime(format_str) rescue ''}"
|
||||
else
|
||||
"<div style=\"display:inline-flex;flex-direction:column;\">
|
||||
#{render_date_block(field_name,v,0,value)}
|
||||
#{render_date_block(field_name,v,0,value, t('ask.start') + ': ')}
|
||||
<div style=\"display: inline-flex;align-items: center;writing-mode: tb-rl;padding: 0.3em;\">~</div>
|
||||
#{render_date_block(field_name,v,1,value)}
|
||||
#{render_date_block(field_name,v,1,value, t('ask.end') + ': ')}
|
||||
</div>".html_safe
|
||||
end
|
||||
else
|
||||
|
|
|
@ -160,13 +160,14 @@ class AskSetting
|
|||
end
|
||||
return sort_number
|
||||
end
|
||||
is_default_setting = (ask_setting.class == self)
|
||||
if override_sort_number.present?
|
||||
sort_number = override_sort_number
|
||||
else
|
||||
sort_number = ask_setting.sort_number
|
||||
if ask_setting.use_default
|
||||
if ask_setting.default_sort_number.blank?
|
||||
sort_number = ((ask_setting.class == self) ? sort_number : self.first.sort_number)
|
||||
sort_number = (is_default_setting ? sort_number : self.first.sort_number)
|
||||
else
|
||||
sort_number = ask_setting.default_sort_number
|
||||
end
|
||||
|
@ -174,7 +175,7 @@ class AskSetting
|
|||
ask_setting = self.first
|
||||
end
|
||||
end
|
||||
default_ask_setting = ask_setting.class == self ? ask_setting : self.first
|
||||
default_ask_setting = is_default_setting ? ask_setting : self.first
|
||||
disp_fields = self::All_default_fields
|
||||
disp_fields_infos = {}
|
||||
locale = I18n.locale.to_s
|
||||
|
@ -222,10 +223,12 @@ class AskSetting
|
|||
end
|
||||
max_sort_number = disp_fields_infos.values.map{|v| v}.compact.max
|
||||
if max_sort_number
|
||||
max_sort_number = max_sort_number + 1
|
||||
disp_fields_infos.each_with_index do |(k,v), i|
|
||||
if v.blank?
|
||||
disp_fields_infos[k] = max_sort_number + i
|
||||
if !use_cache || (is_default_setting && override_sort_number.nil?)
|
||||
max_sort_number = max_sort_number + 1
|
||||
disp_fields_infos.each_with_index do |(k,v), i|
|
||||
if v.blank?
|
||||
disp_fields_infos[k] = max_sort_number + i
|
||||
end
|
||||
end
|
||||
end
|
||||
disp_fields_infos = disp_fields_infos.sort_by {|_key, value| value}.to_h
|
||||
|
@ -245,6 +248,7 @@ class AskSetting
|
|||
ask_setting = self.first if ask_setting.nil?
|
||||
ask_setting = self.create() if ask_setting.nil?
|
||||
end
|
||||
is_default_setting = (ask_setting.class == self)
|
||||
sort_number = nil
|
||||
if only_display && use_cache
|
||||
if override_sort_number
|
||||
|
@ -259,7 +263,7 @@ class AskSetting
|
|||
sort_number = override_sort_number
|
||||
elsif ask_setting.use_default
|
||||
if ask_setting.default_sort_number.blank?
|
||||
sort_number = ((ask_setting.class == self) ? sort_number : self.first.sort_number)
|
||||
sort_number = (is_default_setting ? sort_number : self.first.sort_number)
|
||||
else
|
||||
sort_number = ask_setting.default_sort_number
|
||||
end
|
||||
|
@ -267,7 +271,7 @@ class AskSetting
|
|||
ask_setting = self.first
|
||||
end
|
||||
end
|
||||
default_ask_setting = ask_setting.class == self ? ask_setting : self.first
|
||||
default_ask_setting = is_default_setting ? ask_setting : self.first
|
||||
disp_fields = self::All_default_fields
|
||||
disp_fields_infos = {}
|
||||
locale = I18n.locale.to_s
|
||||
|
@ -331,7 +335,7 @@ class AskSetting
|
|||
end
|
||||
max_sort_number = disp_fields_infos.values.map{|h| h["sort_number"]}.compact.max
|
||||
if max_sort_number
|
||||
unless use_cache
|
||||
if !use_cache || (is_default_setting && override_sort_number.nil?)
|
||||
max_sort_number = max_sort_number + 1
|
||||
disp_fields_infos.each_with_index do |(k,h), i|
|
||||
if h["sort_number"].blank?
|
||||
|
|
|
@ -66,7 +66,9 @@
|
|||
.ask-question .form-horizontal input[type="text"],.ask-question .form-horizontal select{
|
||||
width: 97%;
|
||||
}
|
||||
|
||||
.ask-question .form-horizontal input[type="text"].hasDatepicker{
|
||||
width: auto;
|
||||
}
|
||||
.ask-question .form-horizontal .form-actions{
|
||||
position: relative;
|
||||
padding: 1em 0 0 0;
|
||||
|
|
|
@ -2,6 +2,8 @@ en:
|
|||
situation: Status
|
||||
sex: Sex
|
||||
ask:
|
||||
start: "Start"
|
||||
end: "End"
|
||||
options: "Options"
|
||||
please_select: '--Please Select--'
|
||||
default_option: Default Option
|
||||
|
|
|
@ -6,6 +6,8 @@ zh_tw:
|
|||
errors:
|
||||
verification_failed: 驗證碼錯誤
|
||||
ask:
|
||||
start: "開始"
|
||||
end: "結束"
|
||||
options: "選項"
|
||||
please_select: '--請選擇--'
|
||||
default_option: 預設選項
|
||||
|
|
|
@ -41,6 +41,9 @@
|
|||
.ask-question .form-horizontal input[type="text"],.ask-question .form-horizontal select{
|
||||
width: 97%;
|
||||
}
|
||||
.ask-question .form-horizontal input[type="text"].hasDatepicker{
|
||||
width: auto;
|
||||
}
|
||||
.ask-question .form-horizontal .form-actions{
|
||||
position: relative;
|
||||
padding: 1em 0 0 0;
|
||||
|
|
Loading…
Reference in New Issue