cancer_predict/app/views/admin/cancerpredicts/index.html.erb

302 lines
13 KiB
Plaintext

<%= stylesheet_link_tag "lib/fileupload"%>
<%= javascript_include_tag 'lib/bootstrap-fileupload' %>
<div style="clear:both;"></div>
<%=form_for @form_to_show ,:url=>{:controller=>"cancerpredicts" ,:action=>"edit"} do |form|%>
<span class="show_span"><%= t('cancerpredict.title') %></span>
<div style="clear:both;"></div>
<label class="label_left" for="title_text"><%= t('cancerpredict.title_text')+':' %></label> <%=form.text_field :title_texts ,{:value => @form_to_show.title_texts,:id=>"title_text"} %>
<% if @title_images.length != 0%>
<% @title_images.each_with_index do |temp_image,i| %>
<%= form.fields_for "title_images" do |image_fields| %>
<div class="image_field title_images" value="<%=(i+1).to_s%>">
<%= image_fields.fields_for i.to_s do |image_field| %>
<%= render :partial => 'image_form', :object => temp_image, :locals => {:f => image_field, :i => i} %>
<% if i.to_i == @title_images.length - 1%>
<script>
$(document).on('click', '#add_file.title_images', function(){
var old_id = $('.image_field.title_images').eq(-1).attr('value');
if( old_id == undefined)
old_id = 0;
else
old_id = Number(old_id);
var new_id = old_id + 1;
var html = "<%= escape_javascript(render :partial => 'image_form', :object => @head_new_image, :locals => {:f => image_field, :i => i}).gsub("\"","\'").html_safe %>"
$(this).parent().siblings('.add-target.title_images').before(('<div class="image_field title_images" value="'+new_id+'">'+html.replace(old_id, new_id)+'</div>'));
var name = $('.image_field.title_images').eq(-1).find('[type="file"]').attr('name');
$('.image_field.title_images').eq(-1).find('[type="file"]').attr('name',name.replace("<%=i%>",new_id-1));
name = $('.image_field.title_images').eq(-1).find('input.sort_num').attr('name');
$('.image_field.title_images').eq(-1).find('input.sort_num').attr('name',name.replace("<%=i%>",new_id-1));
new_id = $('.image_field.title_images').eq(-2).find('input.sort_num').val();
$('.image_field.title_images').eq(-1).find('input.sort_num').val(Number(new_id)+1);
formTip();
});
</script>
<% end %>
<% end %>
<% end %>
<% end %>
<% else %>
<%= form.fields_for "title_images" do |image_fields| %>
<%= image_fields.fields_for "0" do |image_field| %>
<script>
$(document).on('click', '#add_file.title_images', function(){
var old_id = $('.image_field.title_images').eq(-1).attr('value');
if( old_id == undefined)
old_id = 0;
else
old_id = Number(old_id);
var new_id = old_id + 1;
var html = "<%= escape_javascript(render :partial => 'image_form', :object => @head_new_image, :locals => {:f => image_field, :i => 0}).gsub("\"","\'").html_safe %>"
$(this).parent().siblings('.add-target.title_images').before(('<div class="image_field title_images" value="'+new_id+'">'+html.replace(old_id, new_id)+'</div>'));
var name = $('.image_field.title_images').eq(-1).find('[type="file"]').attr('name');
$('.image_field.title_images').eq(-1).find('[type="file"]').attr('name',name.replace("0",new_id-1));
name = $('.image_field.title_images').eq(-1).find('input.sort_num').attr('name');
$('.image_field.title_images').eq(-1).find('input.sort_num').attr('name',name.replace("0",new_id-1));
new_id = $('.image_field.title_images').eq(-2).find('input.sort_num').val();
if(new_id != undefined)
$('.image_field.title_images').eq(-1).find('input.sort_num').val(Number(new_id)+1);
else
$('.image_field.title_images').eq(-1).find('input.sort_num').val(1);
formTip();
});
</script>
<% end %>
<% end %>
<% end %>
<div class="add-target title_images"></div>
<p class="add-btn">
<%= hidden_field_tag 'title_images_count', @title_images.count %>
<a id="add_file" class="title_images trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t('cancerpredict.add_image') %></a>
</p>
<span class="show_span"><%= t('cancerpredict.tool_head_pictures') %></span>
<div style="clear:both;"></div>
<% if @head_images.length != 0%>
<% @head_images.each_with_index do |temp_image,i| %>
<%= form.fields_for "head_images" do |image_fields| %>
<div class="head_images image_field" value="<%=(i+1).to_s%>">
<%= image_fields.fields_for i.to_s do |image_field| %>
<%= render :partial => 'image_form', :object => temp_image, :locals => {:f => image_field, :i => i} %>
<% if i.to_i == @head_images.length - 1%>
<script>
$(document).on('click', '#add_file.head_images', function(){
var old_id = $('.image_field').eq(-1).attr('value');
if( old_id == undefined)
old_id = 0;
else
old_id = Number(old_id);
var new_id = old_id + 1;
var html = "<%= escape_javascript(render :partial => 'image_form', :object => @head_new_image, :locals => {:f => image_field, :i => i}).gsub("\"","\'").html_safe %>"
$(this).parent().siblings('.add-target.head_images').before(('<div class="image_field" value="'+new_id+'">'+html.replace(old_id, new_id)+'</div>'));
var name = $('.image_field').eq(-1).find('[type="file"]').attr('name');
$('.image_field').eq(-1).find('[type="file"]').attr('name',name.replace("<%=i%>",new_id-1));
name = $('.image_field').eq(-1).find('input.sort_num').attr('name');
$('.image_field').eq(-1).find('input.sort_num').attr('name',name.replace("<%=i%>",new_id-1));
new_id = $('.image_field').eq(-2).find('input.sort_num').val();
$('.image_field').eq(-1).find('input.sort_num').val(Number(new_id)+1);
formTip();
});
</script>
<% end %>
<% end %>
<% end %>
<% end %>
<% else %>
<%= form.fields_for "head_images" do |image_fields| %>
<%= image_fields.fields_for "0" do |image_field| %>
<script>
$(document).on('click', '#add_file.head_images', function(){
var old_id = $('.image_field.head_images').eq(-1).attr('value');
if( old_id == undefined)
old_id = 0;
else
old_id = Number(old_id);
var new_id = old_id + 1;
var html = "<%= escape_javascript(render :partial => 'image_form', :object => @head_new_image, :locals => {:f => image_field, :i => 0}).gsub("\"","\'").html_safe %>"
$(this).parent().siblings('.add-target.head_images').before(('<div class="image_field head_images" value="'+new_id+'">'+html.replace(old_id, new_id)+'</div>'));
var name = $('.image_field.head_images').eq(-1).find('[type="file"]').attr('name');
$('.image_field.head_images').eq(-1).find('[type="file"]').attr('name',name.replace("0",new_id-1));
name = $('.image_field.head_images').eq(-1).find('input.sort_num').attr('name');
$('.image_field.head_images').eq(-1).find('input.sort_num').attr('name',name.replace("0",new_id-1));
new_id = $('.image_field.head_images').eq(-2).find('input.sort_num').val();
if(new_id != undefined)
$('.image_field.head_images').eq(-1).find('input.sort_num').val(Number(new_id)+1);
else
$('.image_field.head_images').eq(-1).find('input.sort_num').val(1);
formTip();
});
</script>
<% end %>
<% end %>
<% end %>
<div class="add-target head_images"></div>
<p class="add-btn">
<%= hidden_field_tag 'head_images_count', @head_images.count %>
<a id="add_file" class="head_images trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t('cancerpredict.add_image') %></a>
</p>
<span class="show_span"><%= t('cancerpredict.text_descibe') %></span>
<div style="clear:both;"></div>
<%= form.text_field 'text_descibe',{:value=> @form_to_show.text_descibe[I18n.locale.to_s],:style=>'width:100%;'} %>
<span class="show_span"><%= t('cancerpredict.font_size') %></span>
<div style="clear:both;"></div>
<% @size=['small','medium','large'] %>
<% @size.each do |size|%>
<%= form.fields_for size do |make_size| %>
<div><label class="label_left" for=<%='font_'+size%>><%=t('cancerpredict.'+size)+':'%></label><%= make_size.text_field 'font_size',{:value=> @form_to_show[size]['font_size'],:id=>'font_'+size} %>
<% if @form_to_show[size]['active'].to_i == 1%>
<%= make_size.check_box 'active',{:checked=>true,:class=>"checkbox text_choice",:style=>"float:left;"}%></div>
<% else%>
<%= make_size.check_box 'active',{:checked=>false,:class=>"checkbox text_choice",:style=>"float:left;"}%></div>
<%end%>
<%end%>
<%end%>
<span class="show_span"><%= t('cancerpredict.Input_fields') %></span>
<div style="clear:both;"></div>
<table>
<thead>
<tr>
<% @form_to_show.form_show.values[1].each do |key,vlaue|%>
<th><%=key%></th>
<%end%>
</tr>
</thead>
<tbody>
<%= form.fields_for :form_show do |formfield|%>
<% @form_to_show.form_show.each do |num,property| %>
<%=formfield.fields_for num.to_s do |make_fields|%>
<tr>
<% 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%>
<% if @value.class == Fixnum %>
<% if @value == 1%>
<td><%= make_fields.check_box key,{:checked=>true,:class=>"checkbox",:style=>"float:left;"}%></td>
<% else%>
<td><%= make_fields.check_box key,{:checked=>false,:class=>"checkbox",:style=>"float:left;"}%></td>
<%end%>
<% elsif @value.class == BSON::Document || @value.class == Hash %>
<%=make_fields.fields_for I18n.locale.to_s do |locale_fields|%>
<td><%= locale_fields.text_field key,{:value=>@disp_value}%></td>
<%end%>
<% else %>
<td><%= make_fields.text_field key,{:value=>@disp_value}%></td>
<%end%>
<%end%>
</tr>
<%end%>
<%end%>
<%end%>
</tbody>
</table>
<span class="show_span"><%=t('cancerpredict.table.Results')%></span>
<div style="clear:both;"></div>
<label for="form_result_is_right" style="float: left;"><%= t('cancerpredict.result_is_right') %></label>
<% if @form_to_show.form_result_is_right.to_i == 1%>
<div><%= form.check_box "form_result_is_right",{:checked=>true,:class=>"checkbox",:style=>"float: left;position: relative;left: 0;transform: none!important;margin-left: 1em;",:id=>"form_result_is_right"}%></div>
<% else%>
<div><%= form.check_box "form_result_is_right",{:checked=>false,:class=>"checkbox",:style=>"float: left;position: relative;left: 0;transform: none!important;margin-left: 1em;",:id=>"form_result_is_right"}%></div>
<%end%>
<table>
<thead>
<tr>
<% @form_to_show.form_show_in_result.values[1].each do |key,vlaue|%>
<th><%=key%></th>
<%end%>
</tr>
</thead>
<tbody>
<%= form.fields_for :form_show_in_result do |formfield|%>
<% @form_to_show.form_show_in_result.each do |num,property| %>
<%=formfield.fields_for num.to_s do |make_fields|%>
<tr>
<% 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%>
<% if @value.class == Fixnum %>
<% if @value == 1%>
<td><%= make_fields.check_box key,{:checked=>true,:class=>"checkbox",:style=>"float:left;"}%></td>
<% else%>
<td><%= make_fields.check_box key,{:checked=>false,:class=>"checkbox",:style=>"float:left;"}%></td>
<%end%>
<% elsif @value.class == BSON::Document || @value.class == Hash %>
<%=make_fields.fields_for I18n.locale.to_s do |locale_fields|%>
<td><%= locale_fields.text_field key,{:value=>@disp_value}%></td>
<%end%>
<% else %>
<td><%= make_fields.text_field key,{:value=>@disp_value}%></td>
<%end%>
<%end%>
</tr>
<%end%>
<%end%>
<%end%>
</tbody>
</table>
<%=form.submit "#{t(:updatefont)}",{:id=>"updatebtn"}%>
<%end%>
<style type="text/css">
thead > tr > th{
border:1px solid;
background: bisque;
}
tbody{
background:white;
}
tbody > tr > td{
border:1px solid;
position: relative;
}
.show_li,.show_li *{
list-style:none;
color:balck;
}
.show_li ul{
display:none;
}
#clicktosee{
color:blue;
cursor:pointer;
}
table .checkbox{
left: 50%;
position: absolute;
transform: translate(-50%, -50%) !important;
top: 50%;
}
#updatebtn{
margin-top: 1em;
right: 1em;
background-color: #0088cc;
color: white;
border: 0em;
padding: 0.125em 0.5em;
border-radius: 0.5em;
}
.show_span{
margin: 1em;
float: left;
background-color: rgb(210, 105, 0);
color: white;
border: 0em;
padding: 0.125em 0.5em;
border-radius: 0.5em;
width: fit-content;
}
.label_left{
float: left;
padding-right: 0.5em;
}
</style>
<script>
$('.text_choice').click(function(){
$('.text_choice').prop('checked' , false);
$(this).prop('checked' , true);
});
</script>