Fix bug.
This commit is contained in:
parent
0cf4dafdd2
commit
6069591060
|
@ -337,29 +337,23 @@ class Admin::HncCancerPredictsController < OrbitAdminController
|
||||||
@form_to_show.auto_write_predict_js
|
@form_to_show.auto_write_predict_js
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@index = 0
|
|
||||||
Dir.chdir("public") do
|
|
||||||
while File.exist?("cancerfield_back" + @index.to_s + ".txt")
|
|
||||||
@index += 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
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(HncCancerPredictfields::ToolTableMap[I18n.locale], "w")
|
File.open(HncCancerPredictfields::ToolTableMap[I18n.locale], "w") do |f|
|
||||||
tmp_table_texts = create_table(locale)
|
tmp_table_texts = create_table(locale)
|
||||||
@file_tmp.write(tmp_table_texts)
|
f.write(tmp_table_texts)
|
||||||
@file_tmp.close
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Dir.chdir("public") do
|
idx = 0
|
||||||
@file_back = File.open("cancerfield_back" + @index.to_s + ".txt", "w")
|
while File.exist?("public/hnc_field_back#{idx}.txt")
|
||||||
@file_back.write(@form_to_show.attributes)
|
idx += 1
|
||||||
@file_back.close
|
end
|
||||||
@file_org = File.open("cancerfield_org" + @index.to_s + ".txt", "w")
|
File.open("public/hnc_field_back#{idx}.txt", "w") do |f|
|
||||||
@file_org.write(HncCancerPredictfields.where("title" => @app_title + "_back").first.attributes)
|
f.write(@form_to_show.attributes)
|
||||||
@file_org.close
|
end
|
||||||
|
File.open("public/hnc_field_org#{idx}.txt", "w") do |f|
|
||||||
|
f.write(HncCancerPredictfields.where("title" => @app_title + "_back").first.attributes)
|
||||||
end
|
end
|
||||||
redirect_to admin_hnc_cancer_predicts_path
|
redirect_to admin_hnc_cancer_predicts_path
|
||||||
end
|
end
|
||||||
|
@ -650,11 +644,9 @@ class Admin::HncCancerPredictsController < OrbitAdminController
|
||||||
#FileUtils.rm_r(dir_path, :force => true) if Dir.exist?(dir_path)
|
#FileUtils.rm_r(dir_path, :force => true) if Dir.exist?(dir_path)
|
||||||
FileUtils.mkdir dir_path if !Dir.exist?(dir_path) #create dir for storing tmp_file if dir doesn't exist
|
FileUtils.mkdir dir_path if !Dir.exist?(dir_path) #create dir for storing tmp_file if dir doesn't exist
|
||||||
@filename = ("#{Time.now.year}_%02s_%02s_export_cancer_tool_record.xlsx" % [Time.now.month, Time.now.day]).gsub(" ", "0")
|
@filename = ("#{Time.now.year}_%02s_%02s_export_cancer_tool_record.xlsx" % [Time.now.month, Time.now.day]).gsub(" ", "0")
|
||||||
Dir.chdir(dir_path) do
|
File.open("#{dir_path}/#{@filename}", "w") do |f|
|
||||||
File.open(@filename, "w") do |f|
|
|
||||||
f.write render_to_string(:handlers => [:axlsx], :formats => [:xlsx], :partial => "export_cancer_tool_record.xlsx", :locals => { :results => cancer_records })
|
f.write render_to_string(:handlers => [:axlsx], :formats => [:xlsx], :partial => "export_cancer_tool_record.xlsx", :locals => { :results => cancer_records })
|
||||||
end
|
end
|
||||||
end
|
|
||||||
tmp_filename_data = File.read(dir_path + @filename)
|
tmp_filename_data = File.read(dir_path + @filename)
|
||||||
send_data(tmp_filename_data, type: "application/xlsx", disposition: "attachment", filename: @filename)
|
send_data(tmp_filename_data, type: "application/xlsx", disposition: "attachment", filename: @filename)
|
||||||
end
|
end
|
||||||
|
@ -671,13 +663,11 @@ class Admin::HncCancerPredictsController < OrbitAdminController
|
||||||
@form_to_show.title = @app_title
|
@form_to_show.title = @app_title
|
||||||
@form_to_show.save
|
@form_to_show.save
|
||||||
@form_to_show = HncCancerPredictfields.where("title" => @app_title).first
|
@form_to_show = HncCancerPredictfields.where("title" => @app_title).first
|
||||||
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(HncCancerPredictfields::ToolTableMap[I18n.locale], "w")
|
File.open(HncCancerPredictfields::ToolTableMap[I18n.locale], "w") do |f|
|
||||||
tmp_table_texts = create_table(locale)
|
tmp_table_texts = create_table(locale)
|
||||||
@file_tmp.write(tmp_table_texts)
|
f.write(tmp_table_texts)
|
||||||
@file_tmp.close
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -156,10 +156,10 @@ class HncCancerPredictsController < ApplicationController
|
||||||
tags = OrbitHelper.widget_tags
|
tags = OrbitHelper.widget_tags
|
||||||
categories = OrbitHelper.widget_categories || []
|
categories = OrbitHelper.widget_categories || []
|
||||||
@table_str = File.read(HncCancerPredictfields::ToolTableMap[I18n.locale])
|
@table_str = File.read(HncCancerPredictfields::ToolTableMap[I18n.locale])
|
||||||
preidct_js_url = "/assets/hnc_cancer_predict.js"
|
preidct_js_url = "/assets/#{HncCancerPredictfields::JS}"
|
||||||
if File.exist?(HncCancerPredictfields::JSFileName)
|
if File.exist?(HncCancerPredictfields::JSFileName)
|
||||||
js_filename = File.read(HncCancerPredictfields::JSFileName)
|
js_filename = File.read(HncCancerPredictfields::JSFileName)
|
||||||
if js_filename.include?("hnc_cancer_predict.js")
|
if js_filename.include?(HncCancerPredictfields::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
|
||||||
|
@ -177,10 +177,10 @@ class HncCancerPredictsController < ApplicationController
|
||||||
tags = OrbitHelper.widget_tags
|
tags = OrbitHelper.widget_tags
|
||||||
categories = OrbitHelper.widget_categories || []
|
categories = OrbitHelper.widget_categories || []
|
||||||
@table_str = File.read(HncCancerPredictfields::ToolTableMap[I18n.locale])
|
@table_str = File.read(HncCancerPredictfields::ToolTableMap[I18n.locale])
|
||||||
preidct_js_url = "/assets/hnc_cancer_predict.js"
|
preidct_js_url = "/assets/#{HncCancerPredictfields::JS}"
|
||||||
if File.exist?("public/cancer_tool_js_filename.txt")
|
if File.exist?("public/cancer_tool_js_filename.txt")
|
||||||
js_filename = File.read("public/cancer_tool_js_filename.txt")
|
js_filename = File.read("public/cancer_tool_js_filename.txt")
|
||||||
if js_filename.match("hnc_cancer_predict.js")
|
if js_filename.include?(HncCancerPredictfields::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 HncCancerPredictfields
|
||||||
AdvanceFields = ["revert_value","map_values","hnc_cancer_predict_mapping_file"]
|
AdvanceFields = ["revert_value","map_values","hnc_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"]
|
||||||
|
ModuleAppPath = Pathname.new(File.expand_path(__dir__)).dirname.dirname.to_s.freeze
|
||||||
|
JS = "hnc_cancer_predict.js"
|
||||||
JSFileName = "public/hnc_tool_js_filename.txt".freeze
|
JSFileName = "public/hnc_tool_js_filename.txt".freeze
|
||||||
ToolTableMap = I18n.available_locales.map do |locale|
|
ToolTableMap = I18n.available_locales.map do |locale|
|
||||||
[locale, "public/hnc_tool_table_tmp_#{locale}.txt".freeze]
|
[locale, "public/hnc_tool_table_tmp_#{locale}.txt".freeze]
|
||||||
|
@ -406,8 +408,7 @@ class HncCancerPredictfields
|
||||||
end
|
end
|
||||||
def auto_write_predict_js(force_reload=true)
|
def auto_write_predict_js(force_reload=true)
|
||||||
js_codes = generate_jscode
|
js_codes = generate_jscode
|
||||||
module_app_path = Pathname.new(File.expand_path(__dir__)).dirname.dirname.to_s
|
save_path = "#{ModuleAppPath}/app/assets/javascripts/#{JS}"
|
||||||
save_path = module_app_path + '/app/assets/javascripts/hnc_cancer_predict.js'
|
|
||||||
file_texts = File.read(save_path)
|
file_texts = File.read(save_path)
|
||||||
need_write = false
|
need_write = false
|
||||||
str1 = "/* auto add start */"
|
str1 = "/* auto add start */"
|
||||||
|
|
Loading…
Reference in New Issue