finish a half of predict_tool

This commit is contained in:
BOHUNG 2019-11-23 17:49:18 +08:00
parent 741d440631
commit be9c1f3d05
3 changed files with 32 additions and 12 deletions

View File

@ -1 +1,18 @@
$('.cancer_help_btn') $(document).ready(function(){
$('.cancer_help_btn').append('<i aria-hidden="true" class="fa fa-question"></i>');
$('.cancer_help_btn').off("click").on('click',function(){
var modal_head = "";
try{ modal_head = $(this).parent().find(">label").html()}catch{};
var modal_body = "";
try{ modal_body = $(this).parent().find(">input.help_texts").attr('value')}catch{};
$('#show_help_modal').html("<div class='modal-dialog'><div class='modal-content'><div class='modal-header'><button type='button' aria-hidden='true' class='close'>×</button><h4 class='modal-title'>"+modal_head+"</h4>"+
"</div><div class='modal-body'>"+modal_body+"</div><div class='modal-footer'><button type='button' class='btn btn-default'>Close</button></div></div></div>")
$('#show_help_modal').modal('show');
$('#show_help_modal .close').off("click").on('click',function(){
$('#show_help_modal').modal('hide');
});
$('#show_help_modal .modal-footer button').off("click").on('click',function(){
$('#show_help_modal').modal('hide');
});
});
});

View File

@ -11,7 +11,7 @@ class CancerpredictsController < ApplicationController
tags = OrbitHelper.widget_tags tags = OrbitHelper.widget_tags
categories = OrbitHelper.widget_categories || [] categories = OrbitHelper.widget_categories || []
locale = OrbitHelper.get_site_locale.to_s locale = OrbitHelper.get_site_locale.to_s
@table_str = '<div id="cancer_table">' @table_str = '<div id="cancer_table"><div id="show_help_modal" class="modal fade"></div>'
create_first_field create_first_field
@form_to_show.form_show.each do |num,property| @form_to_show.form_show.each do |num,property|
@table_str += '<div data-key='+num.to_s+'>' @table_str += '<div data-key='+num.to_s+'>'
@ -26,18 +26,21 @@ class CancerpredictsController < ApplicationController
@field_property[key] = @disp_value @field_property[key] = @disp_value
end end
break if @field_property["name"] == "" break if @field_property["name"] == ""
@table_str += '<label for="'+@field_property["variable"]+'" style="float:left;" class="cencer_table_name">' @table_str += '<label for="'+@field_property["variable"]+'" style="float:left;'+(@field_property["comment_text"] == "" ? "margin-right: 2.125em;" : "")+'" class="cencer_table_name">'
@table_str += @field_property["name"] @table_str += @field_property["name"]
@table_str += '</label>' @table_str += '</label>'
if @field_property["comment_text"] != "" if @field_property["comment_text"] != ""
@table_str += '<button tabindex="0" class="cancer_help_btn" data-target="#show_help_modal" style="float:left;"></button>' @table_str += '<button tabindex="0" class="cancer_help_btn" data-target="#show_help_modal" style="float:left;cursor: pointer;padding: 0em 0.475em;font-size: 1.25em;border-radius: 15px;background-color: rgb(210, 106, 2);border-color: rgb(210, 106, 2);color: white;"></button>'
@table_str += '<input class="help_texts" type="hidden" value="'+@field_property["comment_text"]+'" name='+@field_property["variable"]+'>'
else
@table_str += '<div style="margin-right: 2.125em;"></div>'
end end
if @field_property["is_num"] == 1 if @field_property["is_num"] == 1
@table_str += '<input class="num_only" id="'+@field_property["variable"]+'" style="float:left;clear:right;"></input>' @table_str += '<input class="num_only" id="'+@field_property["variable"]+'" style="float:left;clear:right;"></input>'
else else
@table_str += '<div id="'+@field_property["variable"]+'" style="float:left;clear:right;">' @table_str += '<div 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 += '<button class="cancer_table_btn">'+create_choice+'</button>' @table_str += '<button class="cancer_table_btn btn btn-default btn-sm">'+create_choice+'</button>'
@table_str += '<input type="hidden" value="0" name="'+create_choice+'"></input>' @table_str += '<input type="hidden" value="0" name="'+create_choice+'"></input>'
end end
@table_str += '' @table_str += ''

View File

@ -7,13 +7,13 @@ class Cancerpredictfields
include OrbitTag::Taggable include OrbitTag::Taggable
include OrbitCategory::Categorizable include OrbitCategory::Categorizable
field :title ,type:String ,default:"" field :title ,type:String ,default:""
field :form_show , :type=> Hash ,default:{0=>{:variable=>"age",:name=>{"zh_tw"=>"年齡","en"=>"age"},:is_num=>1, :hint=>{'zh_tw'=>'從 18 歲(含)開始至 93 歲','en'=>''} , :comment_text=>{'zh_tw'=>'年齡為該婦女於確診罹患乳癌時之年齡','en'=>''}, :choice_fields=> {"zh_tw"=>[],"en"=>[]},:range=>[18,93]}, field :form_show , :type=> Hash ,default:{0=>{:variable=>"age",:name=>{"zh_tw"=>"年齡","en"=>"age"},:is_num=>1, :hint=>{'zh_tw'=>'從 18 歲(含)開始至 93 歲','en'=>''} , :comment_text=>{'zh_tw'=>'年齡為該婦女於確診罹患乳癌時之年齡','en'=>''}, :choice_fields=> {"zh_tw"=>[],"en"=>[]},:range=>[18,93],:right=>0},
1=>{:variable=>"size",:name=>{"zh_tw"=>"腫瘤大小","en"=>"tumor size"},:is_num=>1,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'若有多個原發腫瘤,請輸入最大尺寸之原發腫瘤','en'=>''}, :choice_fields=> {"zh_tw"=>[],"en"=>[]},:range=>[1]}, 1=>{:variable=>"size",:name=>{"zh_tw"=>"腫瘤大小","en"=>"tumor size"},:is_num=>1,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'若有多個原發腫瘤,請輸入最大尺寸之原發腫瘤','en'=>''}, :choice_fields=> {"zh_tw"=>[],"en"=>[]},:range=>[1],:right=>0},
2=>{:variable=>"ratio",:name=>{"zh_tw"=>"淋巴結陽性比例","en"=>"node-positive ratio"},:is_num=>1,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'','en'=>''}, :choice_fields=> {"zh_tw"=>[],"en"=>[]},:range=>[0,1]}, 2=>{:variable=>"ratio",:name=>{"zh_tw"=>"淋巴結陽性比例","en"=>"node-positive ratio"},:is_num=>1,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'','en'=>''}, :choice_fields=> {"zh_tw"=>[],"en"=>[]},:range=>[0,1],:right=>0},
3=>{:variable=>"grade",:name=>{"zh_tw"=>"腫瘤級數","en"=>"tumor grade"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'腫瘤級數代表腫瘤組織與正常組織間的分化程度,若無分化級數資訊,請選擇“未知”選項,將以級數 1 進行預測。','en'=>''}, :choice_fields=> {"zh_tw"=>['1','2','3','未知'],"en"=>['1','2','3','unknown']},:range=>[]}, 3=>{:variable=>"grade",:name=>{"zh_tw"=>"腫瘤級數","en"=>"tumor grade"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'腫瘤級數代表腫瘤組織與正常組織間的分化程度,若無分化級數資訊,請選擇“未知”選項,將以級數 1 進行預測。','en'=>''}, :choice_fields=> {"zh_tw"=>['1','2','3','未知'],"en"=>['1','2','3','unknown']},:range=>[],:right=>0},
4=>{:variable=>"subtype",:name=>{"zh_tw"=>"乳癌分型","en"=>"breast cancer subtype"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'若無分型資訊,請選擇“未知”選項,將以佔多數比例的管腔類進行預測。','en'=>''}, :choice_fields=> {"zh_tw"=>['分管腔類','人類第二型表皮接受體','三陰型','未知'],"en"=>['Luminal-like','HER2','Triple negative','unknown']},:range=>[]}, 4=>{:variable=>"subtype",:name=>{"zh_tw"=>"乳癌分型","en"=>"breast cancer subtype"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'若無分型資訊,請選擇“未知”選項,將以佔多數比例的管腔類進行預測。','en'=>''}, :choice_fields=> {"zh_tw"=>['分管腔類','人類第二型表皮接受體','三陰型','未知'],"en"=>['Luminal-like','HER2','Triple negative','unknown']},:range=>[],:right=>1},
5=>{:variable=>"pstage",:name=>{"zh_tw"=>"病理分期","en"=>"pathologic stage"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'若無分期資訊,請選擇“未知”選項,將以病理分期第 1 期進行預測。','en'=>''}, :choice_fields=> {"zh_tw"=>['1','2','3','4','未知'],"en"=>['1','2','3','4','unknown']},:range=>[]}, 5=>{:variable=>"pstage",:name=>{"zh_tw"=>"病理分期","en"=>"pathologic stage"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'若無分期資訊,請選擇“未知”選項,將以病理分期第 1 期進行預測。','en'=>''}, :choice_fields=> {"zh_tw"=>['1','2','3','4','未知'],"en"=>['1','2','3','4','unknown']},:range=>[],:right=>1},
6=>{:variable=>"lvi",:name=>{"zh_tw"=>"淋巴管或血管侵犯","en"=>"lymph vessel or vascular invasion, LVI"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'若無淋巴管或血管侵犯資訊,請選擇“未知”選項,將以佔多數比例的淋巴管或血管未侵犯進行預測','en'=>''}, :choice_fields=> {"zh_tw"=>['是','否','未知'],"en"=>['yes','no','unknown']},:range=>[]} 6=>{:variable=>"lvi",:name=>{"zh_tw"=>"淋巴管或血管侵犯","en"=>"lymph vessel or vascular invasion, LVI"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'若無淋巴管或血管侵犯資訊,請選擇“未知”選項,將以佔多數比例的淋巴管或血管未侵犯進行預測','en'=>''}, :choice_fields=> {"zh_tw"=>['是','否','未知'],"en"=>['yes','no','unknown']},:range=>[],:right=>1}
} }
# before_destroy :destroy_email # before_destroy :destroy_email
scope :can_display, ->{where(:is_hidden=>false,:is_preview => false).any_of({:postdate.lt=>Time.now, :deadline.gt=>Time.now},{:postdate.lt=>Time.now, :deadline=>nil}).order_by([:is_top, :desc],[:postdate, :desc])} scope :can_display, ->{where(:is_hidden=>false,:is_preview => false).any_of({:postdate.lt=>Time.now, :deadline.gt=>Time.now},{:postdate.lt=>Time.now, :deadline=>nil}).order_by([:is_top, :desc],[:postdate, :desc])}