experiment/app/views/admin/experiments/_form.html.erb

302 lines
11 KiB
Plaintext

<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/fileupload" %>
<%= stylesheet_link_tag "lib/main-list" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
<%= javascript_include_tag "lib/modal-preview" %>
<%= javascript_include_tag "lib/file-type" %>
<% end %>
<%#= f.error_messages %>
<fieldset>
<!-- Input Area -->
<div class="input-area">
<!-- Module Tabs -->
<div class="nav-name"><strong><%= t(:module) %></strong></div>
<ul class="nav nav-pills module-nav">
<li class="active">
<a href="#basic" data-toggle="tab"><%= t(:basic) %></a>
</li>
<!-- <li>
<a href="#status" data-toggle="tab"><%= t(:status) %></a>
</li>
<li>
<a href="#tag" data-toggle="tab"><%= t(:tags) %></a>
</li> -->
<li>
<a href="#imageupload" data-toggle="tab"><%= t(:image) %></a>
</li>
<li>
<a href="#tag" data-toggle="tab"><%= t(:tags) %>(<%=t("experiment.area")%>)</a>
</li>
</ul>
<!-- Module -->
<div class="tab-content module-area">
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<!-- Category -->
<div class="control-group">
<%= f.label :category ,t(:category), :class=>"control-label muted" %>
<div class="controls">
<%= select_category(f, @module_app) %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t("experiment.professor1") %></label>
<div class="controls">
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'subject[email_member_ids][]', email_members: @subject.email_members} %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t("experiment.professor2") %></label>
<div class="controls">
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'subject[co_professor_ids][]', email_members: @subject.co_professors,index:'1',select_name:'co_professors'} %>
</div>
</div>
</div>
<!-- Status Module -->
<div class="tab-pane fade" id="status">
<!-- Status -->
<div class="control-group">
<label class="control-label muted">Status</label>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn <%= 'active' if @subject.is_top? %>">
<%= f.check_box :is_top, :value => @subject.is_top %> <%= t(:top) %>
</label>
<label class="checkbox inline btn <%= 'active' if @subject.is_hot? %>">
<%= f.check_box :is_hot, :value => @subject.is_hot %> <%= t(:hot) %>
</label>
<label class="checkbox inline btn <%= 'active' if @subject.is_hidden? %>">
<%= f.check_box :is_hidden, :value => @subject.is_hidden %> <%= t(:hide) %>
</label>
</div>
</div>
</div>
<!-- Tag Module -->
<div class="tab-pane fade" id="tag">
<!-- Tag -->
<div class="control-group">
<label class="control-label muted"><%=t(:tags)%></label>
<%= select_tags(f, @module_app) %>
</div>
</div>
<!-- Images Module -->
<div class="tab-pane fade" id="imageupload">
<!-- Images Upload -->
<div class="control-group">
<label class="control-label muted"><%= t(:image) %></label>
<div class="controls">
<div class="fileupload fileupload-new clearfix <%= 'fileupload-edit' if @subject.image.file %>" data-provides="fileupload">
<div class="fileupload-new thumbnail pull-left">
<% if @subject.image.file %>
<%= image_tag @subject.image %>
<% else %>
<img src="http://www.placehold.it/50x50/EFEFEF/AAAAAA" />
<% end %>
</div>
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
<span class="btn btn-file">
<span class="fileupload-new"><%= t(:select_image) %></span>
<span class="fileupload-exists"><%= t(:change) %></span>
<%= f.file_field :image %>
</span>
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload"><%= t(:cancel) %></a>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn btn-danger fileupload-remove">
<%= f.check_box :remove_image %><%= t(:remove) %>
</label>
</div>
</div>
</div>
</div>
<% @site_in_use_locales.each do |locale| %>
<%= f.fields_for :image_description_translations do |f| %>
<div class="control-group">
<label class="control-label muted" for="image_description_<%= locale.to_s %>"><%= t(:description) + " (#{t(locale.to_s)})" %></label>
<div class="controls">
<%= f.text_field locale, value: (@subject.image_description_translations[locale.to_s] rescue nil) %>
</div>
</div>
<% end %>
<% end %>
</div>
<div class="tab-pane fade" id="area-tags">
</div>
</div>
<!-- Language Tabs -->
<div class="nav-name"><strong>Language</strong></div>
<ul class="nav nav-pills language-nav">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<li <%= ( i == 0 ) ? "class=active" : '' %>><a data-toggle="tab" href=".<%= locale %>"><%= t(locale.to_s) %></a></li>
<% end %>
</ul>
<!-- Language -->
<div class="tab-content language-area">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
<div class="control-group input-title">
<%= f.label :title , t('experiment.subject'), :class=>"control-label muted" %>
<div class="controls">
<%= f.fields_for :title_translations do |f| %>
<%= f.text_field locale, :class=>'input-block-level', :value => (@subject.title_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- <div class="control-group input-professor2">
<%= f.label :professor2 ,t('experiment.professor2'), :class => "control-label muted" %>
<%= f.fields_for :professor2_translations do |f| %>
<div class="controls">
<%= f.text_field locale, :class=>'post-title', :value => (@subject.professor2_translations[locale] rescue nil) %>
</div>
<% end %>
</div> -->
<div class="control-group input-venue">
<%= f.label :venue ,t('experiment.venue'), :class => "control-label muted" %>
<%= f.fields_for :venue_translations do |f| %>
<div class="controls">
<%= f.text_field locale, :class=>'post-title', :value => (@subject.venue_translations[locale] rescue nil) %>
</div>
<% end %>
</div>
<div class="control-group input-tel">
<%= f.label :tel ,t('experiment.tel'), :class => "control-label muted" %>
<%= f.fields_for :tel_translations do |f| %>
<div class="controls">
<%= f.text_field locale, :class=>'post-title', :value => (@subject.tel_translations[locale] rescue nil) %>
</div>
<% end %>
</div>
<div class="control-group input-facility">
<%= f.label :facility ,t('experiment.facility'), :class => "control-label muted" %>
<%= f.fields_for :facility_translations do |f| %>
<div class="controls">
<%= f.text_area locale, :class=>'input-block-level ckeditor', :value => (@subject.facility_translations[locale] rescue nil) %>
</div>
<% end %>
</div>
<div class="control-group input-direction">
<%= f.label :direction ,t('experiment.direction'), :class => "control-label muted" %>
<%= f.fields_for :direction_translations do |f| %>
<div class="controls">
<%= f.text_area locale, :class=>'input-block-level ckeditor', :value => (@subject.direction_translations[locale] rescue nil) %>
</div>
<% end %>
</div>
<div class="control-group input-student">
<%= f.label :student ,t('experiment.student'), :class => "control-label muted" %>
<%= f.fields_for :student_translations do |f| %>
<div class="controls">
<%= f.text_area locale, :class=>'input-block-level ckeditor', :value => (@subject.student_translations[locale] rescue nil) %>
</div>
<% end %>
</div>
</div>
<% end %>
<!-- Link -->
<div class="control-group">
<label class="control-label muted"><%= t(:link) %></label>
<div class="controls add-input">
<!-- Exist -->
<% if @subject && !@subject.subject_links.blank? %>
<div class="exist">
<% @subject.subject_links.each_with_index do |subject_link, i| %>
<%= f.fields_for :subject_links, subject_link do |f| %>
<%= render :partial => 'form_link', :object => subject_link, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
<hr>
</div>
<% end %>
<!-- Add -->
<div class="add-target"></div>
<p class="add-btn">
<%= hidden_field_tag 'subject_link_field_count', @subject.subject_links.count %>
<a id="add_link" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
</div>
</div>
<!-- Form Actions -->
<div class="form-actions">
<input type="hidden" name="referer_url" value="<%= request.referer %>">
<%= f.submit t('submit'), class: 'btn btn-primary' %>
</div>
</fieldset>
<% content_for :page_specific_javascript do %>
<script>
$(function() {
$(document).on('click', '#add_link', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_subject_links", "g");
var on = $('.language-nav li.active').index();
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_link', f, :subject_links) %>").replace(old_id, new_id));
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.tab-content').children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
formTip();
});
$(document).on('click', '.delete_link', function(){
$(this).parents('.input-prepend').remove();
});
$(document).on('click', '.remove_existing_record', function(){
if(confirm("<%= I18n.t(:sure?)%>")){
$(this).children('.should_destroy').attr('value', 1);
$(this).parents('.start-line').hide();
}
});
$("#status").on('click',"*[data-toggle=buttons-checkbox] input",function(){
var d = $(this).parent().find("input[type=hidden]");
if($(this).is(":checked")){
d.val("1");
}else{
d.val("0");
}
})
$("#status *[data-toggle=buttons-checkbox] .checkbox").each(function(){
if($(this).hasClass("active")){
$(this).find("input[type=hidden]").val("1");
}
})
});
</script>
<% end %>