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

268 lines
13 KiB
Plaintext
Raw Normal View History

<%= stylesheet_link_tag "lib/fileupload"%>
<%= javascript_include_tag 'lib/bootstrap-fileupload' %>
2019-11-15 00:44:28 +00:00
<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.fields_for :title_texts do |locale_fields|%>
<%=locale_fields.text_field I18n.locale.to_s ,{:value => @form_to_show.title_texts[I18n.locale.to_s],:id=>"title_text"} %>
<% end %>
<% 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>
2019-12-14 04:21:09 +00:00
<span class="show_span"><%= t('cancerpredict.text_descibe') %></span>
<div style="clear:both;"></div>
2020-02-03 07:27:29 +00:00
<textarea class="ckeditor" id="cancerpredictfields_text_descibe_<%=I18n.locale.to_s%>" name="cancerpredictfields[text_descibe][<%=I18n.locale.to_s%>]">
<%= @form_to_show.text_descibe[I18n.locale.to_s] %>
</textarea>
2019-12-14 04:21:09 +00:00
<span class="show_span"><%= t('cancerpredict.font_size') %></span>
<div style="clear:both;"></div>
<% @size=['small','medium','large'] %>
<% @size.each do |size|%>
2019-12-28 09:57:13 +00:00
<%= 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%>
2019-12-14 04:21:09 +00:00
<%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>
2019-11-23 08:14:56 +00:00
<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%>
2019-11-23 08:14:56 +00:00
<%end%>
</tr>
2019-11-23 08:14:56 +00:00
<%end%>
<%end%>
<%end%>
</tbody>
</table>
<span class="show_span"><%=t('cancerpredict.table.Results')%></span>
<div style="clear:both;"></div>
2019-12-14 04:21:09 +00:00
<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>
2019-11-15 00:44:28 +00:00
<%end%>
<div style="clear:both;"></div>
2020-01-28 10:24:52 +00:00
<% @create_items = ['years','table_above_texts','text_above_texts','surgery_only_texts','extra_texts','extra_therapy_texts','danger_texts','texts_between_Result_and_result_block'] %>
<% @create_items.each do |item|%>
2020-02-03 07:27:29 +00:00
<label for="<%=item%>" style="float: left;margin-right:1em;width:11em;"><%= t('cancerpredict.'+item)+':' %></label>
<% if @form_to_show[item].class == BSON::Document || @form_to_show[item].class == Hash %>
<%= form.fields_for item do |locale_fields|%>
2020-02-03 07:27:29 +00:00
<%= locale_fields.text_field I18n.locale.to_s,{:value=>@form_to_show[item][I18n.locale.to_s] ,:id=> item,:style=>'width:calc(100% - 16em)'} %>
<% end %>
<% else %>
2020-02-03 07:27:29 +00:00
<%= form.text_field item,{:value=>@form_to_show[item],:id=> item,:style=>'width:calc(100% - 16em)'} %>
<% end %>
<div style="clear:both;"></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%>
<link href="/assets/admin/cancerpredict.css" media="screen" rel="stylesheet">
2019-12-28 09:57:13 +00:00
<script>
$('.text_choice').click(function(){
$('.text_choice').prop('checked' , false);
$(this).prop('checked' , true);
});
</script>