2019-11-15 00:44:28 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
require 'rubyXL'
|
|
|
|
class Admin::CancerpredictsController < OrbitAdminController
|
2019-11-15 09:02:17 +00:00
|
|
|
#include Admin::CancerpredictsHelper
|
2019-11-15 00:44:28 +00:00
|
|
|
before_action ->(module_app = @app_title) { set_variables module_app }
|
2019-11-23 03:15:11 +00:00
|
|
|
before_action :create_first_field
|
2019-11-15 00:44:28 +00:00
|
|
|
#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]
|
|
|
|
end
|
2019-11-23 08:14:56 +00:00
|
|
|
def edit
|
2019-12-11 15:59:17 +00:00
|
|
|
params["cancerpredictfields"]["form_show"].each do |num,property|
|
|
|
|
property.each do |key,value|
|
|
|
|
if value != "0" && value != "1"
|
|
|
|
if key != params[:locale]
|
|
|
|
if @form_to_show.form_show[num.to_s][key.to_s].class != Array
|
|
|
|
@form_to_show.form_show[num.to_s][key.to_s] = value
|
|
|
|
else
|
|
|
|
if value.length > 2
|
|
|
|
@form_to_show.form_show[num.to_s][key.to_s] = value[1..-2].split(',').collect!{|n| n.to_i}
|
|
|
|
else
|
|
|
|
@form_to_show.form_show[num.to_s][key.to_s] = []
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
value.each do |sub_property,sub_value|
|
|
|
|
if @form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s].class != Array
|
|
|
|
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = sub_value
|
|
|
|
else
|
|
|
|
if sub_value.length > 2
|
|
|
|
#render :html => sub_value.gsub('"','') and return
|
|
|
|
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = sub_value.gsub('"','')[1..-2].split(',').collect!{|n| n}
|
|
|
|
else
|
|
|
|
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = []
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
@form_to_show.form_show[num.to_s][key.to_s] = value.to_i
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@form_to_show.save
|
|
|
|
redirect_to admin_cancerpredicts_path
|
|
|
|
end
|
|
|
|
def showSubmit
|
|
|
|
@results = Cancerpredictrecord.where("title"=>@app_title).take_while{true}
|
|
|
|
@variables = []
|
|
|
|
@names = []
|
|
|
|
@form_to_show.form_show.each do |num,property|
|
|
|
|
property.each do |key,value|
|
|
|
|
if key == "variable"
|
|
|
|
@variables.push value
|
|
|
|
elsif key == "name"
|
|
|
|
@names.push value[I18n.locale.to_s]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@result_variables = []
|
|
|
|
@result_names = []
|
|
|
|
@indexs=[]
|
|
|
|
@results[0].result.each{|key,value| @result_variables.push key}
|
|
|
|
@result_variables.each do |variable|
|
|
|
|
@index = @variables.index(variable.to_s)
|
|
|
|
@result_names.push @names[@index] if !@index.nil?
|
|
|
|
@indexs.push @index if !@index.nil?
|
|
|
|
end
|
|
|
|
@choicenames=[]
|
|
|
|
@indexs.each do |index|
|
|
|
|
if @form_to_show.form_show[index.to_s]["is_num"] == 1 || @form_to_show.form_show[index.to_s]["is_float"] == 1
|
|
|
|
@choicenames.push ""
|
|
|
|
else
|
|
|
|
@choicenames.push @form_to_show.form_show[index.to_s]["choice_fields"][I18n.locale.to_s]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
#render :html => @result_names.to_s
|
2019-11-23 08:14:56 +00:00
|
|
|
end
|
2019-11-23 03:15:11 +00:00
|
|
|
def create_first_field
|
2019-11-23 08:14:56 +00:00
|
|
|
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
|
2019-11-23 03:15:11 +00:00
|
|
|
end
|
2019-11-23 08:14:56 +00:00
|
|
|
end
|
2019-11-15 00:44:28 +00:00
|
|
|
end
|