diff --git a/app/assets/javascripts/cancer_predict.js b/app/assets/javascripts/cancer_predict.js
new file mode 100644
index 0000000..033118f
--- /dev/null
+++ b/app/assets/javascripts/cancer_predict.js
@@ -0,0 +1 @@
+$('.cancer_help_btn')
\ No newline at end of file
diff --git a/app/controllers/admin/cancerpredicts_controller.rb b/app/controllers/admin/cancerpredicts_controller.rb
index 439c4c9..8d4be00 100644
--- a/app/controllers/admin/cancerpredicts_controller.rb
+++ b/app/controllers/admin/cancerpredicts_controller.rb
@@ -19,20 +19,22 @@ class Admin::CancerpredictsController < OrbitAdminController
render :partial => "index"
end
end
+ def edit
+ end
def create_first_field
- if Cancerpredictfields.where("title"=>(@app_title + "_back")).take_while{true}.count == 0
- @form_to_show = Cancerpredictfields.new()
- @form_to_show.title = @app_title +"_back"
- @form_to_show.save
- end
- @form_to_show
- if Cancerpredictfields.where("title"=>@app_title).take_while{true}.count == 0
- @form_to_show = Cancerpredictfields.new()
- @form_to_show.title=@app_title
- @form_to_show.save
- @form_to_show = Cancerpredictfields.where("title"=>@app_title).first
- else
- @form_to_show = Cancerpredictfields.where("title"=>@app_title).first
- end
+ if Cancerpredictfields.where("title"=>(@app_title + "_back")).take_while{true}.count == 0
+ @form_to_show = Cancerpredictfields.new()
+ @form_to_show.title = @app_title +"_back"
+ @form_to_show.save
end
+ @form_to_show
+ if Cancerpredictfields.where("title"=>@app_title).take_while{true}.count == 0
+ @form_to_show = Cancerpredictfields.new()
+ @form_to_show.title=@app_title
+ @form_to_show.save
+ @form_to_show = Cancerpredictfields.where("title"=>@app_title).first
+ else
+ @form_to_show = Cancerpredictfields.where("title"=>@app_title).first
+ end
+ end
end
\ No newline at end of file
diff --git a/app/controllers/cancerpredict_controller.rb b/app/controllers/cancerpredict_controller.rb
deleted file mode 100644
index d1eec6f..0000000
--- a/app/controllers/cancerpredict_controller.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-# encoding: utf-8
-require 'rubyXL'
-class CancerpredictsController < ApplicationController
- before_filter :set_I18n
- before_action ->(module_app = @app_title) { set_variables module_app }
- #before_action :load_access_levels
- def initialize
- super
- @app_title = "cancerpredict"
- end
-
- def index
- @tags = @module_app.tags
- @categories = @module_app.categories.enabled
- @filter_fields = filter_fields(@categories, @tags)
- @table_fields = [:status, :category, :title, :start_date, :end_date, :last_modified]
- if request.xhr?
- render :partial => "index"
- end
- end
- def set_I18n
- I18n.locale = params[:lang] if params[:lang].present?
- end
-end
\ No newline at end of file
diff --git a/app/controllers/cancerpredicts_controller.rb b/app/controllers/cancerpredicts_controller.rb
index 0812c49..e17d328 100644
--- a/app/controllers/cancerpredicts_controller.rb
+++ b/app/controllers/cancerpredicts_controller.rb
@@ -1,9 +1,6 @@
# encoding: utf-8
require 'rubyXL'
class CancerpredictsController < ApplicationController
- before_filter :set_I18n
- before_action ->(module_app = @app_title) { set_variables module_app }
- #before_action :load_access_levels
def initialize
super
@app_title = "cancerpredict"
@@ -14,6 +11,47 @@ class CancerpredictsController < ApplicationController
tags = OrbitHelper.widget_tags
categories = OrbitHelper.widget_categories || []
locale = OrbitHelper.get_site_locale.to_s
+ @table_str = '
'
+ create_first_field
+ @form_to_show.form_show.each do |num,property|
+ @table_str += '
'
+ @field_property = {}
+ property.each do |key,value|
+ @value= value
+ if @value.class == BSON::Document || @value.class == Hash
+ @disp_value = @value[I18n.locale.to_s] rescue ""
+ else
+ @disp_value = @value
+ end
+ @field_property[key] = @disp_value
+ end
+ break if @field_property["name"] == ""
+ @table_str += '
'
+ @table_str += @field_property["name"]
+ @table_str += ' '
+ if @field_property["comment_text"] != ""
+ @table_str += '
'
+ end
+ if @field_property["is_num"] == 1
+ @table_str += '
'
+ else
+ @table_str += '
'
+ @field_property["choice_fields"].each do |create_choice|
+ @table_str += '
'+create_choice+' '
+ @table_str += '
'
+ end
+ @table_str += ''
+ end
+ if @field_property["hint"].to_s != ""
+ @table_str +='
'+@field_property["hint"]+'
'
+ end
+ @table_str += '
'
+ end
+ @table_str+='
'
+ {
+ "cancerpredict" => [],
+ "extras"=>{"table"=> @table_str}
+ }
end
def widget
uid = OrbitHelper.params[:uid] rescue ""
@@ -21,7 +59,20 @@ class CancerpredictsController < ApplicationController
categories = OrbitHelper.widget_categories || []
locale = OrbitHelper.get_site_locale.to_s
end
- def set_I18n
- I18n.locale = params[:lang] if params[:lang].present?
+ def create_first_field
+ if Cancerpredictfields.where("title"=>(@app_title + "_back")).take_while{true}.count == 0
+ @form_to_show = Cancerpredictfields.new()
+ @form_to_show.title = @app_title +"_back"
+ @form_to_show.save
+ end
+ @form_to_show
+ if Cancerpredictfields.where("title"=>@app_title).take_while{true}.count == 0
+ @form_to_show = Cancerpredictfields.new()
+ @form_to_show.title=@app_title
+ @form_to_show.save
+ @form_to_show = Cancerpredictfields.where("title"=>@app_title).first
+ else
+ @form_to_show = Cancerpredictfields.where("title"=>@app_title).first
+ end
end
end
\ No newline at end of file
diff --git a/app/models/cancerpredictfields.rb b/app/models/cancerpredictfields.rb
index f9f171f..4f08cb4 100644
--- a/app/models/cancerpredictfields.rb
+++ b/app/models/cancerpredictfields.rb
@@ -7,30 +7,18 @@ class Cancerpredictfields
include OrbitTag::Taggable
include OrbitCategory::Categorizable
field :title ,type:String ,default:""
- field :form_show , :type=> Hash ,default:{"cancer_form"=>{:names=>{0=>{:variable=>"age",:name=>{"zh_tw"=>"年齡","en"=>"age"},:is_num=>1,:hint=>{'zh_tw'=>'從 18 歲(含)開始至 93 歲','en'=>}, :comment_text=>{'zh_tw'=>'年齡為該婦女於確診罹患乳癌時之年齡','en'=>''}, :fields=> {"zh_tw"=>[],"en"=>[]},range=[18,93]},
- 1=>{:variable=>"size",:name=>{"zh_tw"=>"腫瘤大小","en"=>"tumor size"},:is_num=>1,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'若有多個原發腫瘤,請輸入最大尺寸之原發腫瘤','en'=>''}, :fields=> {"zh_tw"=>[],"en"=>[]},range=[1]},
- 2=>{:variable=>"ratio",:name=>{"zh_tw"=>"淋巴結陽性比例","en"=>"node-positive ratio"},:is_num=>1,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'','en'=>''}, :fields=> {"zh_tw"=>[],"en"=>[]},range=[0,1]},
- 3=>{:variable=>"grade",:name=>{"zh_tw"=>"腫瘤級數","en"=>"tumor grade"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'腫瘤級數代表腫瘤組織與正常組織間的分化程度,若無分化級數資訊,請選擇“未知”選項,將以級數 1 進行預測。','en'=>''}, :fields=> {"zh_tw"=>['1','2','3','未知'],"en"=>['1','2','3','unknown']},range=[0,1]},
- 4=>{:variable=>"subtype",:name=>{"zh_tw"=>"乳癌分型","en"=>"breast cancer subtype"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'若無分型資訊,請選擇“未知”選項,將以佔多數比例的管腔類進行預測。','en'=>''}, :fields=> {"zh_tw"=>['分管腔類','人類第二型表皮接受體','三陰型','未知'],"en"=>['Luminal-like','HER2','Triple negative','unknown']},range=[0,1]},
- 5=>{:variable=>"pstage",:name=>{"zh_tw"=>"病理分期","en"=>"pathologic stage"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'若無分期資訊,請選擇“未知”選項,將以病理分期第 1 期進行預測。','en'=>''}, :fields=> {"zh_tw"=>['1','2','3','4','未知'],"en"=>['1','2','3','4','unknown']},range=[0,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'=>''}, :fields=> {"zh_tw"=>['是','否','未知'],"en"=>['yes','no','unknown']},range=[0,1]},
- }},
+ 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]},
+ 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]},
+ 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]},
+ 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=>[]},
+ 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=>[]},
+ 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=>[]},
+ 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=>[]}
+ }
# 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 :is_approved, ->{where(:approved => true)}
- before_create :delete_empty_font ,:get_font_to_store,:set_un_used_font , :set_used_font
- before_update :delete_empty_font ,:get_font_to_store,:set_un_used_font , :set_used_font
- before_save :delete_empty_font ,:get_font_to_store,:set_un_used_font , :set_used_font
- after_update :set_config
- after_save :set_config
#before_create :set_expire
- def delete_empty_font
- self.font_array.each do |font,istrue|
- if font.strip == ""
- self.font_array.delete(font)
- end
- end
- end
def update_user
User.find(update_user_id) rescue nil
end
diff --git a/app/views/admin/cancerpredicts/index.html.erb b/app/views/admin/cancerpredicts/index.html.erb
index 1d2a332..92a7b84 100644
--- a/app/views/admin/cancerpredicts/index.html.erb
+++ b/app/views/admin/cancerpredicts/index.html.erb
@@ -1,35 +1,45 @@
<% @i = 0 %>
-
<%= (I18n.locale.to_s == "zh_tw") ? "全選" : "select all" %>
-
<%= (I18n.locale.to_s == "zh_tw") ? "取消全選" : "unselect all" %>
-<%=form_for @form_to_show ,:url=>{:controller=>"patchfiles" ,:action=>"edit"} do |file|%>
- <%= file.fields_for :file_show do |filefield|%>
-