personal-course/app/views/admin/courses/_form_assignment.html.erb

203 lines
8.3 KiB
Plaintext
Raw Permalink Normal View History

2020-09-20 09:20:43 +00:00
<% # encoding: utf-8 %>
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/fileupload" %>
<%= stylesheet_link_tag "lib/main-list" %>
<%= stylesheet_link_tag "lib/main-form-col2" %>
<style type="text/css">
.ui-helper-hidden-accessible{
display: none;
}
</style>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
<%= javascript_include_tag "lib/file-type" %>
<%= javascript_include_tag "lib/module-area" %>
<% end %>
<!-- Input Area -->
<div class="input-area">
<!-- Language Tabs -->
<div class="nav-name"><strong><%= t(:language) %></strong></div>
<ul class="nav nav-pills language-nav">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<li class="<%= 'active' if i == 0 %>">
<a data-toggle="tab" href=".<%= locale %>"><%= t(locale) %></a>
</li>
<% end %>
<li class="pull-right">
<%= copy_to_all_language_button(".language-nav", ".language-area") %>
</li>
</ul>
<!-- Language -->
<div class="tab-content language-area">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
<!-- Assignment title -->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_course.name") %></label>
<div class="controls">
<%= f.fields_for :name_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_course.name"), value: (@course_assignment.name_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- Detail -->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_course.detail") %></label>
<div class="controls">
<%= f.fields_for :detail_translations do |f| %>
2020-09-21 15:29:30 +00:00
<%= f.text_area locale, class: "input-block-level ckeditor", placeholder: t("personal_course.detail"), value: (@course_assignment.detail_translations[locale] rescue nil) %>
2020-09-20 09:20:43 +00:00
<% end %>
</div>
</div>
</div>
<% end %>
</div>
<div class="nav-name"><strong><%= t(:module) %></strong></div>
<ul class="nav nav-pills module-nav">
<li></li>
<li class="active">
<a href="#basic" data-toggle="tab"><%= t(:basic) %></a>
</li>
</ul>
<!-- Module -->
<div class="tab-content module-area">
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<% if params[:id].present? %>
<%= f.hidden_field :course_id, :value => params[:id] %>
<% end %>
<!-- assign_date -->
<div class="control-group big-group">
<label class="control-label muted">
<%= t("personal_course.assign_date") %>
<button tabindex="0" class="help_btn" data-target="#show_assign_date_modal" style="cursor: pointer;padding: 0em 0.475em;font-size: 1.25em;border-radius: 1em;margin-left: 0.5em;background-color: #666666;border-color: #666666;color: white;" onclick="$('#show_assign_date_modal').modal('show')" type="button"><i aria-hidden="true" class="fa fa-info"></i></button>
</label>
<div class="controls">
<%= f.datetime_picker :assign_date, :no_label => true, :new_record => @course_assignment.new_record?, :data=>{"picker-type" => "range", "range" => "start"} %>
</div>
</div>
<!-- deadline -->
<div class="control-group big-group">
<label class="control-label muted">
<%= t("personal_course.deadline") %>
<button tabindex="0" class="help_btn" data-target="#show_deadline_modal" style="cursor: pointer;padding: 0em 0.475em;font-size: 1.25em;border-radius: 1em;margin-left: 0.5em;background-color: #666666;border-color: #666666;color: white;" onclick="$('#show_deadline_modal').modal('show')" type="button"><i aria-hidden="true" class="fa fa-info"></i></button>
</label>
<div class="controls">
<%= f.datetime_picker :deadline, :no_label => true, :new_record => @course_assignment.new_record?, :data=>{"picker-type" => "range", "range" => "start"} %>
</div>
</div>
<!-- Attachment -->
<%
files_hash = {}
["course_attachment"].each do |file|
hash = {}
hash["html"] = add_attribute("form_file", f, file.pluralize.to_sym)
hash["count"] = @course_assignment.send(file.pluralize).count rescue 0
files_hash[file] = hash
%>
<div class="control-group">
<label class="control-label muted"><%= t("personal_course.#{file}") %></label>
<div class="controls">
<!-- Exist -->
<% if !@course_assignment.new_record? && hash["count"] > 0 %>
<div class="exist">
<% @course_assignment.send(file.pluralize).each_with_index do |obj, i| %>
<% if !obj.new_record? %>
<%= f.fields_for file.pluralize.to_sym, obj do |f| %>
<%= render :partial => "form_file", :object => obj, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
<% end %>
<hr>
</div>
<% end %>
<!-- Add -->
<div class="add-target" for="<%= file %>">
</div>
<p class="add-btn">
<a class="add_file trigger btn btn-small btn-primary" for="<%= file %>"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
</div>
</div>
<% end %>
</div>
<div id="show_deadline_modal" class="modal fade" style="color: #333;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" aria-hidden="true" class="close" data-target="show_deadline_modal">×</button>
<h4 class="modal-title"><%= t("personal_course.deadline") %></h4>
</div>
<div class="modal-body"><%= t("personal_course.deadline_hint") %></div>
<div class="modal-footer"><button type="button" class="btn btn-default close" data-target="show_deadline_modal">Close</button></div>
</div>
</div>
</div>
<div id="show_assign_date_modal" class="modal fade" style="color: #333;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" aria-hidden="true" class="close" data-target="show_assign_date_modal">×</button>
<h4 class="modal-title"><%= t("personal_course.assign_date") %></h4>
</div>
<div class="modal-body"><%= t("personal_course.assign_date_hint") %></div>
<div class="modal-footer"><button type="button" class="btn btn-default close" data-target="show_assign_date_modal">Close</button></div>
</div>
</div>
</div>
<!-- Status Module -->
<div class="tab-pane fade" id="status">
</div>
</div>
</div>
<!-- Form Actions -->
<div class="form-actions">
<%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %>
<input type="hidden" name="referer_url" value="<%= request.referer %>">
<%= f.submit t('submit'), class: 'btn btn-primary' %>
<%= link_to t('cancel'), request.referer, :class=>"btn" %>
</div>
<script type="text/javascript">
var files = <%= files_hash.to_json.html_safe %>;
$("a.add_file").on("click",function(){
var type = $(this).attr("for"),
html = files[type].html,
count = parseInt(files[type].count),
replaceReg = new RegExp("new_" + type + "s","g");
html = html.replace(replaceReg,count);
$(".add-target[for=" + type + "]").append(html);
count++;
files[type].count = count;
return false;
})
$(document).on('click', '.delete_file', 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();
}
});
$('.modal .close').click(function(){
$("#"+$(this).attr("data-target")).modal('hide');
})
</script>