Refine constant variables.
This commit is contained in:
parent
64626817e9
commit
d2b3464359
|
@ -330,7 +330,7 @@ class Admin::CancerpredictsController < OrbitAdminController
|
||||||
Dir.chdir("public") do
|
Dir.chdir("public") do
|
||||||
@site_locales = Site.last.in_use_locales.each do |locale|
|
@site_locales = Site.last.in_use_locales.each do |locale|
|
||||||
I18n.with_locale(locale) do
|
I18n.with_locale(locale) do
|
||||||
@file_tmp = File.new('cancer_tool_table_tmp_'+locale.to_s+'.txt', 'w')
|
@file_tmp = File.new("#{Cancerpredictfields::ToolTablePrefix}#{I18n.locale}.txt", 'w')
|
||||||
tmp_table_texts = create_table(locale)
|
tmp_table_texts = create_table(locale)
|
||||||
@file_tmp.write(tmp_table_texts)
|
@file_tmp.write(tmp_table_texts)
|
||||||
@file_tmp.close
|
@file_tmp.close
|
||||||
|
@ -654,7 +654,7 @@ class Admin::CancerpredictsController < OrbitAdminController
|
||||||
Dir.chdir("public") do
|
Dir.chdir("public") do
|
||||||
@site_locales = Site.last.in_use_locales.each do |locale|
|
@site_locales = Site.last.in_use_locales.each do |locale|
|
||||||
I18n.with_locale(locale) do
|
I18n.with_locale(locale) do
|
||||||
@file_tmp = File.new('cancer_tool_table_tmp_'+locale.to_s+'.txt', 'w')
|
@file_tmp = File.new("#{Cancerpredictfields::ToolTablePrefix}#{I18n.locale}.txt", 'w')
|
||||||
tmp_table_texts = create_table(locale)
|
tmp_table_texts = create_table(locale)
|
||||||
@file_tmp.write(tmp_table_texts)
|
@file_tmp.write(tmp_table_texts)
|
||||||
@file_tmp.close
|
@file_tmp.close
|
||||||
|
|
|
@ -147,11 +147,11 @@ class CancerpredictsController < ApplicationController
|
||||||
uid = OrbitHelper.params[:uid] rescue ""
|
uid = OrbitHelper.params[:uid] rescue ""
|
||||||
tags = OrbitHelper.widget_tags
|
tags = OrbitHelper.widget_tags
|
||||||
categories = OrbitHelper.widget_categories || []
|
categories = OrbitHelper.widget_categories || []
|
||||||
@table_str = File.read('public/cancer_tool_table_tmp_'+I18n.locale.to_s+'.txt')
|
@table_str = File.read("#{Cancerpredictfields::ToolTablePrefix}#{I18n.locale}.txt")
|
||||||
preidct_js_url = '/assets/cancer_predict.js'
|
preidct_js_url = '/assets/cancer_predict.js'
|
||||||
if File.exist?('public/cancer_tool_js_filename.txt')
|
if File.exist?(Cancerpredictfields::JSFileName)
|
||||||
js_filename = File.read('public/cancer_tool_js_filename.txt')
|
js_filename = File.read(Cancerpredictfields::JSFileName)
|
||||||
if js_filename.match(/cancer_predict\.js$/)
|
if js_filename.include?('cancer_predict.js')
|
||||||
asset = Rails.application.assets[js_filename]
|
asset = Rails.application.assets[js_filename]
|
||||||
preidct_js_url = "#{Rails.application.config.assets.prefix}/#{asset.digest_path}"
|
preidct_js_url = "#{Rails.application.config.assets.prefix}/#{asset.digest_path}"
|
||||||
else
|
else
|
||||||
|
@ -167,11 +167,11 @@ class CancerpredictsController < ApplicationController
|
||||||
uid = OrbitHelper.params[:uid] rescue ""
|
uid = OrbitHelper.params[:uid] rescue ""
|
||||||
tags = OrbitHelper.widget_tags
|
tags = OrbitHelper.widget_tags
|
||||||
categories = OrbitHelper.widget_categories || []
|
categories = OrbitHelper.widget_categories || []
|
||||||
@table_str = File.read('public/cancer_tool_table_tmp_'+I18n.locale.to_s+'.txt')
|
@table_str = File.read("#{Cancerpredictfields::ToolTablePrefix}#{I18n.locale}.txt")
|
||||||
preidct_js_url = '/assets/cancer_predict.js'
|
preidct_js_url = '/assets/cancer_predict.js'
|
||||||
if File.exist?('public/cancer_tool_js_filename.txt')
|
if File.exist?(Cancerpredictfields::JSFileName)
|
||||||
js_filename = File.read('public/cancer_tool_js_filename.txt')
|
js_filename = File.read(Cancerpredictfields::JSFileName)
|
||||||
if js_filename.match(/cancer_predict\.js$/)
|
if js_filename.include?('cancer_predict.js')
|
||||||
asset = Rails.application.assets[js_filename]
|
asset = Rails.application.assets[js_filename]
|
||||||
preidct_js_url = "#{Rails.application.config.assets.prefix}/#{asset.digest_path}"
|
preidct_js_url = "#{Rails.application.config.assets.prefix}/#{asset.digest_path}"
|
||||||
else
|
else
|
||||||
|
|
|
@ -9,6 +9,8 @@ class Cancerpredictfields
|
||||||
AdvanceFields = ["revert_value","map_values","cancer_predict_mapping_file"]
|
AdvanceFields = ["revert_value","map_values","cancer_predict_mapping_file"]
|
||||||
TherapyFields = ["variable","name","hint","comment_text","choice_fields","lpv_impact","active_choice","disable_condition"]
|
TherapyFields = ["variable","name","hint","comment_text","choice_fields","lpv_impact","active_choice","disable_condition"]
|
||||||
TherapyOnly = ["lpv_impact","active_choice","disable_condition"]
|
TherapyOnly = ["lpv_impact","active_choice","disable_condition"]
|
||||||
|
JSFileName = "public/cancer_tool_js_filename.txt".freeze
|
||||||
|
ToolTablePrefix = "public/cancer_tool_table_tmp_".freeze
|
||||||
field :title ,type:String ,default:""
|
field :title ,type:String ,default:""
|
||||||
field :advance_mode, type: Boolean, default: false
|
field :advance_mode, type: Boolean, default: false
|
||||||
field :form_show , :type=> Hash ,default:{
|
field :form_show , :type=> Hash ,default:{
|
||||||
|
@ -287,7 +289,7 @@ class Cancerpredictfields
|
||||||
end
|
end
|
||||||
def reload_js_asset(path, force_reload=false)
|
def reload_js_asset(path, force_reload=false)
|
||||||
reload_any_asset(path, 'application/javascript', force_reload) do |new_path|
|
reload_any_asset(path, 'application/javascript', force_reload) do |new_path|
|
||||||
File.open("#{Rails.root}/public/cancer_tool_js_filename.txt",'w+'){|f| f.write(new_path)}
|
File.open(JSFileName, 'w+'){|f| f.write(new_path)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def generate_eval_formula
|
def generate_eval_formula
|
||||||
|
@ -482,8 +484,8 @@ class Cancerpredictfields
|
||||||
if need_write
|
if need_write
|
||||||
File.write(save_path,file_texts)
|
File.write(save_path,file_texts)
|
||||||
reload_js_asset(save_path, force_reload)
|
reload_js_asset(save_path, force_reload)
|
||||||
elsif !(File.exist?("#{Rails.root}/public/cancer_tool_js_filename.txt"))
|
elsif !(File.exist?(JSFileName))
|
||||||
File.open("#{Rails.root}/public/cancer_tool_js_filename.txt",'w+'){|f| f.write(save_path)}
|
File.open(JSFileName, 'w+'){|f| f.write(save_path)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def get_years_settings_dict
|
def get_years_settings_dict
|
||||||
|
|
Loading…
Reference in New Issue