fix bugs(choose float field will get no value) in version 1.

This commit is contained in:
BOHUNG 2020-03-04 12:04:55 +08:00
parent 05a2a18763
commit ce2c172f6b
1 changed files with 51 additions and 39 deletions

View File

@ -265,22 +265,26 @@ class Admin::CancerpredictsController < OrbitAdminController
end
if @field_property["is_num"] == 1
if @field_property["is_float"] == 1
@table_str_left += '<div class="num_group"><input class="num_only float_num cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'"/></div>'
@table_str_left += '<div class="num_group"><input class="num_only float_num cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'"/><input class="num_only_value" type="hidden" /></div>'
else
@table_str_left += '<div class="num_group"><form class="for_num">'
@table_str_left += '<input class="num_only cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'" onkeyup="value=value.replace(/[^\d]/g,\'\') "onbeforepaste="clipboardData.setData(\'text\',clipboardData.getData(\'text\').replace(/[^\d]/g,\'\'))"/>'
@table_str_left += '<input class="num_only_value" type="hidden" value="0"/>'
@please_choice = (current_locale.to_s == "zh_tw") ? "請選擇" : "Please choice"
@table_str_left += '<select class="select_num"><option value="">'+@please_choice+'</option>'
if @field_property["choice_fields"] != []
@field_property["choice_fields"].each do |choice|
@table_str_left += ('<option value="0">' + choice.to_s.titleize + '</option>')
if @field_property["range"] == []
@table_str_left += '<div class="num_group"><input class="num_only float_num cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'"/></div>'
else
@table_str_left += '<div class="num_group"><form class="for_num">'
@table_str_left += '<input class="num_only cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'" onkeyup="value=value.replace(/[^\d]/g,\'\') "onbeforepaste="clipboardData.setData(\'text\',clipboardData.getData(\'text\').replace(/[^\d]/g,\'\'))"/>'
@table_str_left += '<input class="num_only_value" type="hidden" value="0"/>'
@please_choice = (current_locale.to_s == "zh_tw") ? "請選擇" : "Please choice"
@table_str_left += '<select class="select_num"><option value="">'+@please_choice+'</option>'
if @field_property["choice_fields"] != []
@field_property["choice_fields"].each do |choice|
@table_str_left += ('<option value="0">' + choice.to_s.titleize + '</option>')
end
end
for @num in @field_property["range"][0] .. @field_property["range"][1]
@table_str_left += ('<option value="' + @num.to_s + '">' + @num.to_s + '</option>')
end
@table_str_left += '</select></form></div>'
end
for @num in @field_property["range"][0] .. @field_property["range"][1]
@table_str_left += ('<option value="' + @num.to_s + '">' + @num.to_s + '</option>')
end
@table_str_left += '</select></form></div>'
end
else
@table_str_left += '<div class= "cancer-btn-group cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;">'
@ -320,22 +324,26 @@ class Admin::CancerpredictsController < OrbitAdminController
end
if @field_property["is_num"] == 1
if @field_property["is_float"] == 1
@table_str_right += '<div class="num_group"><input class="num_only float_num cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'"/><button class="btn-sub"></button><button class="btn-add"></button></div>'
@table_str_right += '<div class="num_group"><input class="num_only float_num cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'"/><input class="num_only_value" type="hidden" /></div>'
else
@table_str_right += '<div class="num_group"><form class="for_num">'
@table_str_right += '<input class="num_only cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'" onkeyup="value=value.replace(/[^\d]/g,\'\') "onbeforepaste="clipboardData.setData(\'text\',clipboardData.getData(\'text\').replace(/[^\d]/g,\'\'))"/>'
@table_str_right += '<input class="num_only_value" type="hidden" value="0"/>'
@please_choice = (current_locale.to_s == "zh_tw") ? "請選擇" : "Please choice"
@table_str_right += '<select class="select_num"><option value="">'+@please_choice+'</option>'
if @field_property["choice_fields"] != []
@field_property["choice_fields"].each do |choice|
@table_str_right += ('<option value="0">' + choice.to_s.titleize + '</option>')
if @field_property["range"] == []
@table_str_left += '<div class="num_group"><input class="num_only float_num cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'"/></div>'
else
@table_str_right += '<div class="num_group"><form class="for_num">'
@table_str_right += '<input class="num_only cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'" onkeyup="value=value.replace(/[^\d]/g,\'\') "onbeforepaste="clipboardData.setData(\'text\',clipboardData.getData(\'text\').replace(/[^\d]/g,\'\'))"/>'
@table_str_right += '<input class="num_only_value" type="hidden" value="0"/>'
@please_choice = (current_locale.to_s == "zh_tw") ? "請選擇" : "Please choice"
@table_str_right += '<select class="select_num"><option value="">'+@please_choice+'</option>'
if @field_property["choice_fields"] != []
@field_property["choice_fields"].each do |choice|
@table_str_right += ('<option value="0">' + choice.to_s.titleize + '</option>')
end
end
for @num in @field_property["range"][0] .. @field_property["range"][1]
@table_str_right += ('<option value="' + @num.to_s + '">' + @num.to_s + '</option>')
end
@table_str_right += '</select></form></div>'
end
for @num in @field_property["range"][0] .. @field_property["range"][1]
@table_str_right += ('<option value="' + @num.to_s + '">' + @num.to_s + '</option>')
end
@table_str_right += '</select></form></div>'
end
else
@table_str_right += '<div class= "cancer-btn-group cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;">'
@ -407,22 +415,26 @@ class Admin::CancerpredictsController < OrbitAdminController
end
if @field_property["is_num"] == 1
if @field_property["is_float"] == 1
@table_result_choice_fileds += '<div class="num_group"><input class="num_only float_num cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'"/><button class="btn-sub"></button><button class="btn-add"></button>'
@table_result_choice_fileds += '<div class="num_group"><input class="num_only float_num cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'"/><input class="num_only_value" type="hidden" /></button>'
else
@table_result_choice_fileds += '<div class="num_group"><form class="for_num">'
@table_result_choice_fileds += '<input class="num_only cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'" onkeyup="value=value.replace(/[^\d]/g,\'\') "onbeforepaste="clipboardData.setData(\'text\',clipboardData.getData(\'text\').replace(/[^\d]/g,\'\'))"/><button class="btn-sub"></button><button class="btn-add"></button></div>'
@table_str_left += '<input class="num_only_value" type="hidden" value="0"/>'
@please_choice = (current_locale.to_s == "zh_tw") ? "請選擇" : "Please choice"
@table_result_choice_fileds += '<select class="select_num"><option value="">'+@please_choice+'</option>'
if @field_property["choice_fields"] != []
@field_property["choice_fields"].each do |choice|
@table_result_choice_fileds += ('<option value="0">' + choice.to_s.titleize + '</option>')
if @field_property["range"] == []
@table_str_left += '<div class="num_group"><input class="num_only float_num cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'"/></div>'
else
@table_result_choice_fileds += '<div class="num_group"><form class="for_num">'
@table_result_choice_fileds += '<input class="num_only cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'" onkeyup="value=value.replace(/[^\d]/g,\'\') "onbeforepaste="clipboardData.setData(\'text\',clipboardData.getData(\'text\').replace(/[^\d]/g,\'\'))"/><button class="btn-sub"></button><button class="btn-add"></button></div>'
@table_str_left += '<input class="num_only_value" type="hidden" value="0"/>'
@please_choice = (current_locale.to_s == "zh_tw") ? "請選擇" : "Please choice"
@table_result_choice_fileds += '<select class="select_num"><option value="">'+@please_choice+'</option>'
if @field_property["choice_fields"] != []
@field_property["choice_fields"].each do |choice|
@table_result_choice_fileds += ('<option value="0">' + choice.to_s.titleize + '</option>')
end
end
for @num in @field_property["range"][0] .. @field_property["range"][1]
@table_result_choice_fileds += ('<option value="' + @num.to_s + '">' + @num.to_s + '</option>')
end
@table_result_choice_fileds += '</select></form></div>'
end
for @num in @field_property["range"][0] .. @field_property["range"][1]
@table_result_choice_fileds += ('<option value="' + @num.to_s + '">' + @num.to_s + '</option>')
end
@table_result_choice_fileds += '</select></form></div>'
end
else
@table_result_choice_fileds += '<div class= "cancer-btn-group cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;">'