Compare commits
2 Commits
b055208a04
...
fe1ad046c9
Author | SHA1 | Date |
---|---|---|
|
fe1ad046c9 | |
|
e4a7c057de |
|
@ -230,10 +230,6 @@ class Admin::Coloncancerpredict1sController < OrbitAdminController
|
|||
end
|
||||
@size = ['small','medium','large']
|
||||
@size.each{|size| @form_to_show[size] = params["coloncancerpredictfields1s"][size].to_h}
|
||||
@file_path = Rails.root.to_s + '/app/assets/images/predict_tool'
|
||||
if !Dir.exist? @file_path
|
||||
FileUtils.mkdir_p @file_path
|
||||
end
|
||||
@images = params["coloncancerpredictfields1s"]['head_images']
|
||||
@head_images_id = @form_to_show.head_images_id
|
||||
@delete_index = []
|
||||
|
@ -321,29 +317,23 @@ class Admin::Coloncancerpredict1sController < OrbitAdminController
|
|||
@form_to_show.auto_write_predict_js
|
||||
end
|
||||
end
|
||||
@index = 0
|
||||
Dir.chdir("public") do
|
||||
while File.exist?('colon_cancerfield_back'+@index.to_s+'1.txt')
|
||||
@index += 1
|
||||
@site_locales = Site.last.in_use_locales.each do |locale|
|
||||
I18n.with_locale(locale) do
|
||||
@file_tmp = File.new(Coloncancerpredictfields1s::ToolTableMap[I18n.locale], 'w')
|
||||
tmp_table_texts = create_table(locale)
|
||||
@file_tmp.write(tmp_table_texts)
|
||||
@file_tmp.close
|
||||
end
|
||||
end
|
||||
Dir.chdir("public") do
|
||||
@site_locales = Site.last.in_use_locales.each do |locale|
|
||||
I18n.with_locale(locale) do
|
||||
@file_tmp = File.new(Coloncancerpredictfields1s::ToolTableMap[I18n.locale], 'w')
|
||||
tmp_table_texts = create_table(locale)
|
||||
@file_tmp.write(tmp_table_texts)
|
||||
@file_tmp.close
|
||||
end
|
||||
end
|
||||
idx = 0
|
||||
while File.exist?("public/colon_cancerfield_back#{idx}1.txt")
|
||||
idx += 1
|
||||
end
|
||||
Dir.chdir("public") do
|
||||
@file_back = File.open('colon_cancerfield_back'+@index.to_s+'1.txt', 'w')
|
||||
@file_back.write(@form_to_show.attributes)
|
||||
@file_back.close
|
||||
@file_org = File.open('colon_cancerfield_org'+@index.to_s+'1.txt', 'w')
|
||||
@file_org.write(Coloncancerpredictfields1s.where("title"=>@app_title+'_back').first.attributes)
|
||||
@file_org.close
|
||||
File.open("public/colon_cancerfield_back#{idx}1.txt", 'w') do |f|
|
||||
f.write(@form_to_show.attributes)
|
||||
end
|
||||
File.open("public/colon_cancerfield_org#{idx}1.txt", 'w') do |f|
|
||||
f.write(Coloncancerpredictfields1s.where("title"=>@app_title+'_back').first.attributes)
|
||||
end
|
||||
redirect_to admin_coloncancerpredict1s_path
|
||||
end
|
||||
|
@ -631,12 +621,10 @@ class Admin::Coloncancerpredict1sController < OrbitAdminController
|
|||
#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
|
||||
@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(@filename, 'w') do |f|
|
||||
f.write render_to_string( :handlers=> [:axlsx], :formats=> [:xlsx] ,:partial=> 'export_cancer_tool_record.xlsx',:locals=> {:results=>cancer_records} )
|
||||
end
|
||||
File.open("#{dir_path}#{@filename}", 'w') do |f|
|
||||
f.write render_to_string( :handlers=> [:axlsx], :formats=> [:xlsx] ,:partial=> 'export_cancer_tool_record.xlsx',:locals=> {:results=>cancer_records} )
|
||||
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)
|
||||
end
|
||||
def create_first_field
|
||||
|
@ -651,14 +639,12 @@ class Admin::Coloncancerpredict1sController < OrbitAdminController
|
|||
@form_to_show.title=@app_title
|
||||
@form_to_show.save
|
||||
@form_to_show = Coloncancerpredictfields1s.where("title"=>@app_title).first
|
||||
Dir.chdir("public") do
|
||||
@site_locales = Site.last.in_use_locales.each do |locale|
|
||||
I18n.with_locale(locale) do
|
||||
@file_tmp = File.new(Coloncancerpredictfields1s::ToolTableMap[I18n.locale], 'w')
|
||||
tmp_table_texts = create_table(locale)
|
||||
@file_tmp.write(tmp_table_texts)
|
||||
@file_tmp.close
|
||||
end
|
||||
@site_locales = Site.last.in_use_locales.each do |locale|
|
||||
I18n.with_locale(locale) do
|
||||
@file_tmp = File.new(Coloncancerpredictfields1s::ToolTableMap[I18n.locale], 'w')
|
||||
tmp_table_texts = create_table(locale)
|
||||
@file_tmp.write(tmp_table_texts)
|
||||
@file_tmp.close
|
||||
end
|
||||
end
|
||||
else
|
||||
|
|
|
@ -148,10 +148,10 @@ class Coloncancerpredict1sController < ApplicationController
|
|||
tags = OrbitHelper.widget_tags
|
||||
categories = OrbitHelper.widget_categories || []
|
||||
@table_str = File.read(Coloncancerpredictfields1s::ToolTableMap[I18n.locale])
|
||||
preidct_js_url = '/assets/colon_cancer_predict1.js'
|
||||
preidct_js_url = "/assets/#{Coloncancerpredictfields1s::JS}"
|
||||
if File.exist?(Coloncancerpredictfields1s::JSFileName)
|
||||
js_filename = File.read(Coloncancerpredictfields1s::JSFileName)
|
||||
if js_filename.include?('colon_cancer_predict1.js')
|
||||
if js_filename.include?(Coloncancerpredictfields1s::JS)
|
||||
asset = Rails.application.assets[js_filename]
|
||||
preidct_js_url = "#{Rails.application.config.assets.prefix}/#{asset.digest_path}"
|
||||
else
|
||||
|
@ -168,10 +168,10 @@ class Coloncancerpredict1sController < ApplicationController
|
|||
tags = OrbitHelper.widget_tags
|
||||
categories = OrbitHelper.widget_categories || []
|
||||
@table_str = File.read(Coloncancerpredictfields1s::ToolTableMap[I18n.locale])
|
||||
preidct_js_url = '/assets/colon_cancer_predict1.js'
|
||||
preidct_js_url = "/assets/#{Coloncancerpredictfields1s::JS}"
|
||||
if File.exist?(Coloncancerpredictfields1s::JSFileName)
|
||||
js_filename = File.read(Coloncancerpredictfields1s::JSFileName)
|
||||
if js_filename.include?('colon_cancer_predict1.js')
|
||||
if js_filename.include?(Coloncancerpredictfields1s::JS)
|
||||
asset = Rails.application.assets[js_filename]
|
||||
preidct_js_url = "#{Rails.application.config.assets.prefix}/#{asset.digest_path}"
|
||||
else
|
||||
|
|
|
@ -9,6 +9,8 @@ class Coloncancerpredictfields1s
|
|||
AdvanceFields = ["revert_value","map_values","coloncancer_predict_mapping_file1"]
|
||||
TherapyFields = ["variable","name","hint","comment_text","choice_fields","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 = "colon_cancer_predict1.js"
|
||||
JSFileName = "public/cc1_tool_js_filename.txt"
|
||||
ToolTableMap = I18n.available_locales.map do |locale|
|
||||
[locale, "public/colon_cancer_tool_table_tmp_#{locale}1.txt".freeze]
|
||||
|
@ -389,8 +391,7 @@ class Coloncancerpredictfields1s
|
|||
end
|
||||
def auto_write_predict_js(force_reload=true)
|
||||
js_codes = generate_jscode
|
||||
module_app_path = Pathname.new(File.expand_path(__dir__)).dirname.dirname.to_s
|
||||
save_path = module_app_path + '/app/assets/javascripts/colon_cancer_predict1.js'
|
||||
save_path = "#{ModuleAppPath}/app/assets/javascripts/#{JS}"
|
||||
file_texts = File.read(save_path)
|
||||
need_write = false
|
||||
str1 = "/* auto add start */"
|
||||
|
|
Loading…
Reference in New Issue