2019-11-15 09:02:17 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
require 'rubyXL'
|
|
|
|
class CancerpredictsController < ApplicationController
|
|
|
|
def initialize
|
|
|
|
super
|
|
|
|
@app_title = "cancerpredict"
|
|
|
|
end
|
|
|
|
|
|
|
|
def index
|
|
|
|
uid = OrbitHelper.params[:uid] rescue ""
|
|
|
|
tags = OrbitHelper.widget_tags
|
|
|
|
categories = OrbitHelper.widget_categories || []
|
|
|
|
locale = OrbitHelper.get_site_locale.to_s
|
2019-11-23 09:49:18 +00:00
|
|
|
@table_str = '<div id="cancer_table"><div id="show_help_modal" class="modal fade"></div>'
|
2019-11-23 08:14:56 +00:00
|
|
|
create_first_field
|
|
|
|
@form_to_show.form_show.each do |num,property|
|
|
|
|
@table_str += '<div data-key='+num.to_s+'>'
|
|
|
|
@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"] == ""
|
2019-11-23 09:49:18 +00:00
|
|
|
@table_str += '<label for="'+@field_property["variable"]+'" style="float:left;'+(@field_property["comment_text"] == "" ? "margin-right: 2.125em;" : "")+'" class="cencer_table_name">'
|
2019-11-23 08:14:56 +00:00
|
|
|
@table_str += @field_property["name"]
|
|
|
|
@table_str += '</label>'
|
|
|
|
if @field_property["comment_text"] != ""
|
2019-11-23 09:49:18 +00:00
|
|
|
@table_str += '<button tabindex="0" class="cancer_help_btn" data-target="#show_help_modal" style="float:left;cursor: pointer;padding: 0em 0.475em;font-size: 1.25em;border-radius: 15px;background-color: rgb(210, 106, 2);border-color: rgb(210, 106, 2);color: white;"></button>'
|
|
|
|
@table_str += '<input class="help_texts" type="hidden" value="'+@field_property["comment_text"]+'" name='+@field_property["variable"]+'>'
|
|
|
|
else
|
|
|
|
@table_str += '<div style="margin-right: 2.125em;"></div>'
|
2019-11-23 08:14:56 +00:00
|
|
|
end
|
|
|
|
if @field_property["is_num"] == 1
|
|
|
|
@table_str += '<input class="num_only" id="'+@field_property["variable"]+'" style="float:left;clear:right;"></input>'
|
|
|
|
else
|
|
|
|
@table_str += '<div id="'+@field_property["variable"]+'" style="float:left;clear:right;">'
|
|
|
|
@field_property["choice_fields"].each do |create_choice|
|
2019-11-23 09:49:18 +00:00
|
|
|
@table_str += '<button class="cancer_table_btn btn btn-default btn-sm">'+create_choice+'</button>'
|
2019-11-23 08:14:56 +00:00
|
|
|
@table_str += '<input type="hidden" value="0" name="'+create_choice+'"></input>'
|
|
|
|
end
|
|
|
|
@table_str += ''
|
|
|
|
end
|
|
|
|
if @field_property["hint"].to_s != ""
|
|
|
|
@table_str +='<div style="color: rgb(104, 104, 104);font-size:0.75em;clear:both;">'+@field_property["hint"]+'</div>'
|
|
|
|
end
|
|
|
|
@table_str += '</div><div style="clear:both;"></div>'
|
|
|
|
end
|
|
|
|
@table_str+='</div>'
|
|
|
|
{
|
|
|
|
"cancerpredict" => [],
|
|
|
|
"extras"=>{"table"=> @table_str}
|
|
|
|
}
|
2019-11-15 09:02:17 +00:00
|
|
|
end
|
|
|
|
def widget
|
|
|
|
uid = OrbitHelper.params[:uid] rescue ""
|
|
|
|
tags = OrbitHelper.widget_tags
|
|
|
|
categories = OrbitHelper.widget_categories || []
|
|
|
|
locale = OrbitHelper.get_site_locale.to_s
|
|
|
|
end
|
2019-11-23 08:14:56 +00:00
|
|
|
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
|
2019-11-15 09:02:17 +00:00
|
|
|
end
|
|
|
|
end
|