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

223 lines
8.1 KiB
Plaintext
Raw Normal View History

2015-12-29 11:35:44 +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" : '' %>">
<!-- course title-->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_course.title") %></label>
<div class="controls">
<%= f.fields_for :title_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_course.title"), value: (@course.title_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- course objective -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_course.objective") %></label>
<div class="controls">
<%= f.fields_for :objective_translations do |f| %>
2016-01-15 06:56:15 +00:00
<%= f.text_area locale, class: "input-block-level ckeditor", placeholder: t("personal_course.objective"), value: (@course.objective_translations[locale] rescue nil) %>
2015-12-29 11:35:44 +00:00
<% end %>
</div>
</div>
</div>
<% end %>
<!-- File -->
<%
files_hash = {}
2020-09-15 09:12:42 +00:00
["course_syllabus_file", "course_progress_file", "course_activity_file", "course_multimedia_file", "course_material_file", "course_supplement_file", "course_evaluation_file"].each do |file|
2015-12-29 11:35:44 +00:00
hash = {}
hash["html"] = add_attribute("form_file", f, file.pluralize.to_sym)
hash["count"] = @course.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.new_record? && hash["count"] > 0 %>
<div class="exist">
<% @course.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 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>
<li>
<a href="#status" data-toggle="tab"><%= t(:status) %></a>
</li>
<li>
<a href="#students" data-toggle="tab"><%= t("personal_course.students") %></a>
</li>
2015-12-29 11:35:44 +00:00
</ul>
<!-- Module -->
<div class="tab-content module-area">
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<% if !@member.nil? %>
<div class="control-group big-group">
<label class="control-label muted"><%= t("personal_plugins.author") %></label>
<div class="controls">
<%= @member.name rescue ''%>
<%= f.hidden_field :member_profile_id, :value => @member.id %>
</div>
</div>
<% else %>
<div class="control-group big-group">
<label class="control-label muted"><%= t("personal_plugins.author") %></label>
<div class="controls">
<% members = !@course.member_profile.nil? ? @course.member_profile.to_a : [] %>
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'course[member_profile_id]', email_members: members,index:'0',select_name:'member_profile_id'} %>
2015-12-29 11:35:44 +00:00
</div>
</div>
<% end %>
<!-- year -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_course.year") %></label>
<div class="controls">
<%= select_year((@course.year ? @course.year.to_i : DateTime.now.year), {:start_year => DateTime.now.year + 5, :end_year => 1930}, {:name => 'course[year]',:class => 'span1'} ) %>
2015-12-29 11:35:44 +00:00
</div>
</div>
<!-- course_category -->
<div class="control-group big-group">
<label class="control-label muted"><%= t("personal_course.course_category") %></label>
<div class="controls">
<%= f.select :course_category_id, CourseCategory.all.collect {|t| [ t.title, t.id ]} %>
</div>
</div>
<!-- course_semester -->
<div class="control-group big-group">
<label class="control-label muted"><%= t("personal_course.course_semester") %></label>
<div class="controls">
<%= f.select :course_semester_id, CourseSemester.all.collect {|t| [ t.title, t.id ]} %>
</div>
</div>
</div>
<!-- Status Module -->
<div class="tab-pane fade" id="status">
<div class="control-group">
<label class="control-label muted"><%= t(:status) %></label>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn <%= 'active' if @course.is_hidden? %>">
<%= f.check_box :is_hidden %> <%= t(:hide) %>
</label>
</div>
</div>
</div>
<div class="tab-pane fade" id="students">
<div class="control-group">
<label class="control-label muted"><%= t("personal_course.students") %></label>
<div class="controls" data-toggle="buttons-checkbox">
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'course[student_ids][]', email_members: @course.students,index:'1',select_name:'student_ids'} %>
</div>
</div>
</div>
2015-12-29 11:35:44 +00:00
</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' %>
2015-12-29 16:50:29 +00:00
<%= link_to t('cancel'), request.referer, :class=>"btn" %>
2015-12-29 11:35:44 +00:00
</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();
}
});
</script>