Fix bug in backend setting.
This commit is contained in:
parent
685aa0ce6c
commit
e49baf5273
|
@ -14,6 +14,9 @@ class Admin::Coloncancerpredict1sController < OrbitAdminController
|
||||||
super
|
super
|
||||||
@app_title = "coloncancerpredict1"
|
@app_title = "coloncancerpredict1"
|
||||||
end
|
end
|
||||||
|
def yaml_load(v)
|
||||||
|
YAML.load(v)
|
||||||
|
end
|
||||||
def index
|
def index
|
||||||
@tags = @module_app.tags
|
@tags = @module_app.tags
|
||||||
@categories = @module_app.categories.enabled
|
@categories = @module_app.categories.enabled
|
||||||
|
@ -69,7 +72,7 @@ class Admin::Coloncancerpredict1sController < OrbitAdminController
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if value.length > 2
|
if value.length > 2
|
||||||
@form_to_show.form_show[num.to_s][key.to_s] = YAML.load(value)
|
@form_to_show.form_show[num.to_s][key.to_s] = yaml_load(value)
|
||||||
else
|
else
|
||||||
@form_to_show.form_show[num.to_s][key.to_s] = []
|
@form_to_show.form_show[num.to_s][key.to_s] = []
|
||||||
end
|
end
|
||||||
|
@ -92,7 +95,7 @@ class Admin::Coloncancerpredict1sController < OrbitAdminController
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if sub_value.length > 2
|
if sub_value.length > 2
|
||||||
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = YAML.load(sub_value)
|
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = yaml_load(sub_value)
|
||||||
else
|
else
|
||||||
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = []
|
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = []
|
||||||
end
|
end
|
||||||
|
@ -157,7 +160,7 @@ class Admin::Coloncancerpredict1sController < OrbitAdminController
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if value.length > 2
|
if value.length > 2
|
||||||
@form_to_show.form_show_in_result[num.to_s][key.to_s] = YAML.load(value)
|
@form_to_show.form_show_in_result[num.to_s][key.to_s] = yaml_load(value)
|
||||||
else
|
else
|
||||||
@form_to_show.form_show_in_result[num.to_s][key.to_s] = []
|
@form_to_show.form_show_in_result[num.to_s][key.to_s] = []
|
||||||
end
|
end
|
||||||
|
@ -180,7 +183,7 @@ class Admin::Coloncancerpredict1sController < OrbitAdminController
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if sub_value.length > 2
|
if sub_value.length > 2
|
||||||
@form_to_show.form_show_in_result[ num.to_s ][ sub_property ][params[:locale].to_s] = YAML.load(sub_value)
|
@form_to_show.form_show_in_result[ num.to_s ][ sub_property ][params[:locale].to_s] = yaml_load(sub_value)
|
||||||
else
|
else
|
||||||
@form_to_show.form_show_in_result[ num.to_s ][ sub_property ][params[:locale].to_s] = []
|
@form_to_show.form_show_in_result[ num.to_s ][ sub_property ][params[:locale].to_s] = []
|
||||||
end
|
end
|
||||||
|
@ -216,7 +219,7 @@ class Admin::Coloncancerpredict1sController < OrbitAdminController
|
||||||
@form_to_show[item] = item_hash
|
@form_to_show[item] = item_hash
|
||||||
elsif @form_to_show[item].class == Array
|
elsif @form_to_show[item].class == Array
|
||||||
if params_cancer[item].class != Array
|
if params_cancer[item].class != Array
|
||||||
@form_to_show[item] = YAML.load(params_cancer[item]) rescue []
|
@form_to_show[item] = yaml_load(params_cancer[item]) rescue []
|
||||||
else
|
else
|
||||||
@form_to_show[item] = params_cancer[item]
|
@form_to_show[item] = params_cancer[item]
|
||||||
end
|
end
|
||||||
|
@ -226,7 +229,7 @@ class Admin::Coloncancerpredict1sController < OrbitAdminController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@size = ['small','medium','large']
|
@size = ['small','medium','large']
|
||||||
@size.each{|size| @form_to_show[size] = params["coloncancerpredictfields1s"][size]}
|
@size.each{|size| @form_to_show[size] = params["coloncancerpredictfields1s"][size].to_h}
|
||||||
@file_path = Rails.root.to_s + '/app/assets/images/predict_tool'
|
@file_path = Rails.root.to_s + '/app/assets/images/predict_tool'
|
||||||
if !Dir.exist? @file_path
|
if !Dir.exist? @file_path
|
||||||
FileUtils.mkdir_p @file_path
|
FileUtils.mkdir_p @file_path
|
||||||
|
@ -422,8 +425,8 @@ class Admin::Coloncancerpredict1sController < OrbitAdminController
|
||||||
else
|
else
|
||||||
@table_str_left += '<div class= "cancer-btn-group cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;">'
|
@table_str_left += '<div class= "cancer-btn-group cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;">'
|
||||||
@field_property["choice_fields"].each do |create_choice|
|
@field_property["choice_fields"].each do |create_choice|
|
||||||
@table_str_left += '<button class="cancer_table_btn btn btn-default btn-sm">'+create_choice.titleize+'</button>'
|
@table_str_left += '<button class="cancer_table_btn btn btn-default btn-sm">'+create_choice.to_s.titleize+'</button>'
|
||||||
@table_str_left += '<input type="hidden" value="0" name="'+create_choice+'"/>'
|
@table_str_left += '<input type="hidden" value="0" name="'+create_choice.to_s+'"/>'
|
||||||
end
|
end
|
||||||
@table_str_left += '</div>'
|
@table_str_left += '</div>'
|
||||||
end
|
end
|
||||||
|
@ -481,8 +484,8 @@ class Admin::Coloncancerpredict1sController < OrbitAdminController
|
||||||
else
|
else
|
||||||
@table_str_right += '<div class= "cancer-btn-group cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;">'
|
@table_str_right += '<div class= "cancer-btn-group cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;">'
|
||||||
@field_property["choice_fields"].each do |create_choice|
|
@field_property["choice_fields"].each do |create_choice|
|
||||||
@table_str_right += '<button class="cancer_table_btn btn btn-default btn-sm">'+create_choice.titleize+'</button>'
|
@table_str_right += '<button class="cancer_table_btn btn btn-default btn-sm">'+create_choice.to_s.titleize+'</button>'
|
||||||
@table_str_right += '<input type="hidden" value="0" name="'+create_choice+'"/>'
|
@table_str_right += '<input type="hidden" value="0" name="'+create_choice.to_s+'"/>'
|
||||||
end
|
end
|
||||||
@table_str_right += '</div>'
|
@table_str_right += '</div>'
|
||||||
end
|
end
|
||||||
|
@ -573,8 +576,8 @@ class Admin::Coloncancerpredict1sController < OrbitAdminController
|
||||||
else
|
else
|
||||||
@table_result_choice_fileds += '<div class= "cancer-btn-group cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;">'
|
@table_result_choice_fileds += '<div class= "cancer-btn-group cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;">'
|
||||||
@field_property["choice_fields"].each do |create_choice|
|
@field_property["choice_fields"].each do |create_choice|
|
||||||
@table_result_choice_fileds += '<button class="cancer_table_btn btn btn-default btn-sm">'+create_choice.titleize+'</button>'
|
@table_result_choice_fileds += '<button class="cancer_table_btn btn btn-default btn-sm">'+create_choice.to_s.titleize+'</button>'
|
||||||
@table_result_choice_fileds += '<input type="hidden" value="0" name="'+create_choice+'"></input>'
|
@table_result_choice_fileds += '<input type="hidden" value="0" name="'+create_choice.to_s+'"></input>'
|
||||||
end
|
end
|
||||||
@table_result_choice_fileds += '</div>'
|
@table_result_choice_fileds += '</div>'
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,13 @@
|
||||||
module Admin::Coloncancerpredict1sHelper
|
module Admin::Coloncancerpredict1sHelper
|
||||||
|
def cc1_yaml_dump(arr)
|
||||||
|
if arr.blank?
|
||||||
|
'[]'
|
||||||
|
elsif arr.class != String
|
||||||
|
'[' + arr.map{|s| (s.is_a?(String) && !(s.is_i?) && s.include?(' ')) ? "\"#{s}\"" : s}.join(', ') + ']'
|
||||||
|
else
|
||||||
|
arr
|
||||||
|
end
|
||||||
|
end
|
||||||
def create_pagination(page=1,fields=Coloncancerpredictrecord1.all,extra_params="")
|
def create_pagination(page=1,fields=Coloncancerpredictrecord1.all,extra_params="")
|
||||||
page = 1 if page == 0
|
page = 1 if page == 0
|
||||||
per_page_num = 10.0
|
per_page_num = 10.0
|
||||||
|
|
|
@ -17,7 +17,7 @@ class Coloncancerpredictfields1s
|
||||||
"2"=>{"variable"=>"lymph_nodes_examined", "name"=>{"zh_tw"=>"區域淋巴結檢查數目<br/>(Regional lymph nodes examined)", "en"=>"Regional lymph nodes examined"}, "is_num"=>1, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>["未知"], "en"=>["unknown"]}, "range"=>[0, 90], "right"=>0, "is_float"=>0, "need_map_values"=>0, "revert_value"=>0, "map_values"=>[]},
|
"2"=>{"variable"=>"lymph_nodes_examined", "name"=>{"zh_tw"=>"區域淋巴結檢查數目<br/>(Regional lymph nodes examined)", "en"=>"Regional lymph nodes examined"}, "is_num"=>1, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>["未知"], "en"=>["unknown"]}, "range"=>[0, 90], "right"=>0, "is_float"=>0, "need_map_values"=>0, "revert_value"=>0, "map_values"=>[]},
|
||||||
"3"=>{"variable"=>"lymph_nodes_positive", "name"=>{"zh_tw"=>"區域淋巴結侵犯數目<br/>(Regional lymph nodes positive)", "en"=>"Regional lymph nodes positive"}, "is_num"=>1, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"此變項為預測重要變數,若無此資訊預測容易失真。", "en"=>"Regional lymph nodes positive is a key predictive variable. If this information is omitted, the prediction result would be biased."}, "choice_fields"=>{"zh_tw"=>["未知"], "en"=>["unknown"]}, "range"=>[0, 90], "right"=>1, "is_float"=>0, "need_map_values"=>0, "revert_value"=>0, "map_values"=>[]},
|
"3"=>{"variable"=>"lymph_nodes_positive", "name"=>{"zh_tw"=>"區域淋巴結侵犯數目<br/>(Regional lymph nodes positive)", "en"=>"Regional lymph nodes positive"}, "is_num"=>1, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"此變項為預測重要變數,若無此資訊預測容易失真。", "en"=>"Regional lymph nodes positive is a key predictive variable. If this information is omitted, the prediction result would be biased."}, "choice_fields"=>{"zh_tw"=>["未知"], "en"=>["unknown"]}, "range"=>[0, 90], "right"=>1, "is_float"=>0, "need_map_values"=>0, "revert_value"=>0, "map_values"=>[]},
|
||||||
"4"=>{"variable"=>"grade", "name"=>{"zh_tw"=>"腫瘤級數<br/>(Tumor grade)", "en"=>"Tumor grade"}, "is_num"=>0, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"腫瘤級數代表腫瘤組織與正常組織間的分化程度,若無分 化級數資訊,請選 擇“未知”選項,將以級數 1 進行預測。", "en"=>"The grade refers to how different the cancer cells are from normal cells. Please select “unknown” if there is no information about grade. The prediction model would use “grade 2” as the alternative variable."}, "choice_fields"=>{"zh_tw"=>["1", "2", "3", "未知"], "en"=>["1", "2", "3", "unknown"]}, "range"=>[], "right"=>0, "is_float"=>0, "need_map_values"=>0, "revert_value"=>0, "map_values"=>[]},
|
"4"=>{"variable"=>"grade", "name"=>{"zh_tw"=>"腫瘤級數<br/>(Tumor grade)", "en"=>"Tumor grade"}, "is_num"=>0, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"腫瘤級數代表腫瘤組織與正常組織間的分化程度,若無分 化級數資訊,請選 擇“未知”選項,將以級數 1 進行預測。", "en"=>"The grade refers to how different the cancer cells are from normal cells. Please select “unknown” if there is no information about grade. The prediction model would use “grade 2” as the alternative variable."}, "choice_fields"=>{"zh_tw"=>["1", "2", "3", "未知"], "en"=>["1", "2", "3", "unknown"]}, "range"=>[], "right"=>0, "is_float"=>0, "need_map_values"=>0, "revert_value"=>0, "map_values"=>[]},
|
||||||
"5"=>{"variable"=>"pstage", "name"=>{"zh_tw"=>"病理分期<br/>(pathologic stage)", "en"=>"Pathologic stage"}, "is_num"=>0, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"若無分期資訊,請選擇“未知”選項,將以病理分期第 1 期進行預測。", "en"=>"ER status describes the status of estrogen receptor. Please select “unknown” if there is no information about ER status. The prediction model would use “Positive” (the majority class) as the alternative variable."}, "choice_fields"=>{"zh_tw"=>["1", "2", "3", "4", "未知"], "en"=>["positive", "negative", "unknown"]}, "range"=>[], "right"=>1, "is_float"=>0, "need_map_values"=>0, "revert_value"=>0, "map_values"=>[]}
|
"5"=>{"variable"=>"pstage", "name"=>{"zh_tw"=>"病理分期<br/>(Pathological stage)", "en"=>"Pathological stage"}, "is_num"=>0, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"若無分期資訊,請選擇“未知”選項,將以分期第 1 期進行預測。", "en"=>"Please select “unknown” if there is no information about “Pathological stage”. The prediction model would use “1th stage” as the alternative variable."}, "choice_fields"=>{"zh_tw"=>["1", "2", "3", "4", "未知"], "en"=>["1", "2", "3", "4", "unknown"]}, "range"=>[], "right"=>0, "is_float"=>0, "need_map_values"=>0, "revert_value"=>0, "map_values"=>[]}
|
||||||
}
|
}
|
||||||
field :form_show_in_result , :type=> Hash ,default: {
|
field :form_show_in_result , :type=> Hash ,default: {
|
||||||
"0"=>{"variable"=>"Chemotherapy", "name"=>{"zh_tw"=>"化學治療", "en"=>"Chemotherapy"}, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>["否", "是"], "en"=>["No", "Yes"]}, "lpv_impact"=>-0.6693, "active_choice"=>2, "disable_condition"=>""}
|
"0"=>{"variable"=>"Chemotherapy", "name"=>{"zh_tw"=>"化學治療", "en"=>"Chemotherapy"}, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>["否", "是"], "en"=>["No", "Yes"]}, "lpv_impact"=>-0.6693, "active_choice"=>2, "disable_condition"=>""}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
<%else%>
|
<%else%>
|
||||||
<% @disp_value = @value %>
|
<% @disp_value = @value %>
|
||||||
<%end%>
|
<%end%>
|
||||||
|
<% @disp_value = cc1_yaml_dump(@disp_value) if value_type == 'Array' %>
|
||||||
<% field_type = ((value_type == 'String' || value_type == 'Array' || value_type == 'Float') ? "text_field" : value_type) %>
|
<% field_type = ((value_type == 'String' || value_type == 'Array' || value_type == 'Float') ? "text_field" : value_type) %>
|
||||||
<% if value_type == 'Fixnum' %>
|
<% if value_type == 'Fixnum' %>
|
||||||
<% if @value == 1%>
|
<% if @value == 1%>
|
||||||
|
|
|
@ -277,15 +277,27 @@
|
||||||
<div><%= form.check_box "form_result_is_right",{:checked=>false,:class=>"checkbox",:style=>"float: left;position: relative;left: 0;transform: none!important;margin-left: 1em;",:id=>"form_result_is_right"}%></div>
|
<div><%= form.check_box "form_result_is_right",{:checked=>false,:class=>"checkbox",:style=>"float: left;position: relative;left: 0;transform: none!important;margin-left: 1em;",:id=>"form_result_is_right"}%></div>
|
||||||
<%end%>
|
<%end%>
|
||||||
<div style="clear:both;"></div>
|
<div style="clear:both;"></div>
|
||||||
<% @create_items = ['years','table_above_texts','text_above_texts','surgery_only_texts','extra_texts','extra_therapy_texts','danger_texts','texts_between_Result_and_result_block'] %>
|
<% @create_items = ['years','table_above_texts','text_above_texts','surgery_only_texts','extra_texts','extra_therapy_texts','danger_texts','texts_between_Result_and_result_block']
|
||||||
<% @create_items.each do |item|%>
|
array_indices = [0]
|
||||||
|
%>
|
||||||
|
<% @create_items.each_with_index do |item, i|%>
|
||||||
<label for="<%=item%>" style="float: left;margin-right:1em;width:11em;"><%= t('coloncancerpredict1.'+item)+':' %></label>
|
<label for="<%=item%>" style="float: left;margin-right:1em;width:11em;"><%= t('coloncancerpredict1.'+item)+':' %></label>
|
||||||
<% if @form_to_show[item].class == BSON::Document || @form_to_show[item].class == Hash %>
|
<% if @form_to_show[item].class == BSON::Document || @form_to_show[item].class == Hash %>
|
||||||
<%= form.fields_for item do |locale_fields|%>
|
<%= form.fields_for item do |locale_fields|%>
|
||||||
<%= locale_fields.text_field I18n.locale.to_s,{:value=>@form_to_show[item][I18n.locale.to_s] ,:id=> item,:style=>'width:calc(100% - 16em)'} %>
|
<% value = @form_to_show[item][I18n.locale.to_s]
|
||||||
|
if array_indices.include?(i)
|
||||||
|
value = cc1_yaml_dump(value)
|
||||||
|
end
|
||||||
|
%>
|
||||||
|
<%= locale_fields.text_field I18n.locale.to_s,{:value=> value,:id=> item,:style=>'width:calc(100% - 16em)'} %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= form.text_field item,{:value=>@form_to_show[item],:id=> item,:style=>'width:calc(100% - 16em)'} %>
|
<% value = @form_to_show[item]
|
||||||
|
if array_indices.include?(i)
|
||||||
|
value = cc1_yaml_dump(value)
|
||||||
|
end
|
||||||
|
%>
|
||||||
|
<%= form.text_field item,{:value=> value,:id=> item,:style=>'width:calc(100% - 16em)'} %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div style="clear:both;"></div>
|
<div style="clear:both;"></div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
Loading…
Reference in New Issue