242 lines
11 KiB
Plaintext
242 lines
11 KiB
Plaintext
<% # 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" : '' %>">
|
|
<!-- selected_course title-->
|
|
<div class="control-group input-title">
|
|
<label class="control-label muted"><%= t("personal_selected_course.course_title") %></label>
|
|
<div class="controls larger">
|
|
<% if @selected_course.course.nil? %>
|
|
<!-- Select Course -->
|
|
<% if i == 0%>
|
|
<% protocol = ("#{URI(request.referer).scheme}://" rescue request.protocol) %>
|
|
<% host_url = protocol+(request.host_with_port) %>
|
|
<% page = Page.where(:module=>"personal_course").first %>
|
|
<%= f.select :course_id, Course.all.collect {|t| [ t.title, t.id ]},{:include_blank=>true}, :onclick=>"var $this=this;(function(){var options=#{Course.all.map{|c| [c.id.to_s,{'course_title'=>c.title_translations,'course_objective'=>c.objective_translations,'course_category'=>c.course_category.title,'course_semester'=>c.course_semester.title,'year'=>c.year,'course_url'=>(page.nil? ? @site_in_use_locales.map{|l| [l.to_s,""]}.to_h : @site_in_use_locales.map{|l| [l.to_s,"#{host_url}/#{I18n.locale}#{page.url}/#{c.to_param}"]}.to_h)}]}.to_h.to_s.gsub("=>",":").gsub("\"","'")};console.log(options);var option=options[$this.value];var locales=#{@site_in_use_locales.map{|l| l.to_s}};var flag;if(window.old_data == undefined){window.old_data = {};flag=true}else{flag=false};if(option != undefined) locales.forEach(function(locale){Object.keys(option).forEach(function(k){(typeof(option[k]) == 'object' ? ( (k == 'course_title' && locale=='#{locale}') ? $('.other_'+k+'.'+locale).addClass('hide') : (($('.'+k+'.'+locale).hasClass('ckeditor') ? ((flag ? window.old_data[k+'_'+locale]=CKEDITOR.instances[$('.'+k+'.'+locale).attr('id')].getData() : null),CKEDITOR.instances[$('.'+k+'.'+locale).attr('id')].setData(option[k][locale])) : $('.'+k+'.'+locale).html(option[k][locale]) ),$('.other_'+k+'.'+locale).addClass('hide')) ) : ($('.'+k).html(option[k]),$('.other_'+k).addClass('hide')) ) })});else if(Object.values(options)[0] != undefined){ option=Object.values(options)[0];Object.keys(option).forEach(function(k){$('.other_'+k).removeClass('hide');$('.'+k+':not(.course_title.#{locale})').html('');if($('.'+k).hasClass('ckeditor')){locales.forEach(function(locale){(flag ? window.old_data[k+'_'+locale]=CKEDITOR.instances[$('.'+k+'.'+locale).attr('id')].getData() : null),CKEDITOR.instances[$('.'+k+'.'+locale).attr('id')].setData(window.old_data[k+'_'+locale])})} }) } })()" %>
|
|
<%= f.fields_for :course_title_translations do |f| %>
|
|
<%= f.text_field locale, class: "input-block-level other_course_title #{locale}", placeholder: t("personal_selected_course.course_title"), value: (@selected_course.course_title_translations[locale] rescue nil) %>
|
|
<% end %>
|
|
<% else %>
|
|
<span id="selected_course_<%=locale.to_s%>" class="course_title <%=locale%>"></span>
|
|
<%= f.fields_for :course_title_translations do |f| %>
|
|
<%= f.text_field locale, class: "input-block-level other_course_title #{locale}", placeholder: t("personal_selected_course.course_title"), value: (@selected_course.course_title_translations[locale] rescue nil) %>
|
|
<% end %>
|
|
<% end %>
|
|
<% else %>
|
|
<%= @selected_course.course_title_translations[locale] %>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
<!-- selected_course url-->
|
|
<div class="control-group input-url">
|
|
<label class="control-label muted"><%= t("personal_selected_course.course_url") %></label>
|
|
<div class="controls larger">
|
|
<% protocol = ("#{URI(request.referer).scheme}://" rescue request.protocol) %>
|
|
<% host_url = protocol+(request.host_with_port) %>
|
|
<% course_url = @selected_course.course_url %>
|
|
<% if course_url != "#" %>
|
|
<span class="course_url <%=locale%>">
|
|
<% course_url = host_url+course_url %>
|
|
<a title="<%=@selected_course.course_title%>" href="<%=course_url%>"><%=course_url%></a>
|
|
</span>
|
|
<% elsif @selected_course.course.nil? %>
|
|
<span class="course_url <%=locale%>">
|
|
</span>
|
|
<%=f.text_field :other_course_url ,:class=>"other_course_url #{locale}" %>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- selected_course objective -->
|
|
<div class="control-group">
|
|
<label class="control-label muted"><%= t("personal_selected_course.course_objective") %></label>
|
|
<div class="controls">
|
|
<%= f.fields_for :course_objective_translations do |f| %>
|
|
<%= f.text_area locale, class: "input-block-level ckeditor course_objective #{locale}", placeholder: t("personal_selected_course.course_objective"), value: (@selected_course.course_objective_translations[locale] rescue nil) %>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
<!-- File -->
|
|
</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>
|
|
</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_selected_course.course_student") %></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_selected_course.course_student") %></label>
|
|
<div class="controls">
|
|
<% members = !@selected_course.member_profile.nil? ? @selected_course.member_profile.to_a : [] %>
|
|
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'selected_course[member_profile_id]', email_members: members,index:'0',select_name:'member_profile_id'} %>
|
|
</div>
|
|
</div>
|
|
|
|
<% end %>
|
|
|
|
<!-- year -->
|
|
<div class="control-group">
|
|
<label class="control-label muted"><%= t("personal_selected_course.year") %></label>
|
|
<div class="controls larger">
|
|
<% if @selected_course.course %>
|
|
<span class="year">
|
|
<%= @selected_course.year %>
|
|
</span>
|
|
<% else %>
|
|
<span class="year">
|
|
</span>
|
|
<%= select_year((@selected_course.year ? @selected_course.year.to_i : DateTime.now.year), {:start_year => DateTime.now.year, :end_year => 1930}, {:name => 'selected_course[year]',:class => 'span1 other_year'} ) %>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- selected_course_category -->
|
|
<div class="control-group big-group">
|
|
<label class="control-label muted"><%= t("personal_selected_course.selected_course_category") %></label>
|
|
<div class="controls larger">
|
|
<% if @selected_course.course %>
|
|
<span class="course_category">
|
|
<%= @selected_course.course.course_category.title rescue "" %>
|
|
</span>
|
|
<% else %>
|
|
<span class="course_category">
|
|
</span>
|
|
<%= f.select :selected_course_category_id, SelectedCourseCategory.all.collect {|t| [ t.title, t.id ]},{},{:class=>"other_course_category"} %>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- selected_course_semester -->
|
|
<div class="control-group big-group">
|
|
<label class="control-label muted"><%= t("personal_selected_course.selected_course_semester") %></label>
|
|
<div class="controls larger">
|
|
<% if @selected_course.course %>
|
|
<span class="course_semester">
|
|
<%= @selected_course.course.course_semester.title rescue "" %>
|
|
</span>
|
|
<% else %>
|
|
<span class="course_semester">
|
|
</span>
|
|
<%= f.select :selected_course_category_id, SelectedCourseSemester.all.collect {|t| [ t.title, t.id ]},{},{:class=>"other_course_category"} %>
|
|
<% end %>
|
|
</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 @selected_course.is_hidden? %>">
|
|
<%= f.check_box :is_hidden %> <%= t(:hide) %>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</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();
|
|
}
|
|
});
|
|
$(".other_course_url").on("input",function(){
|
|
$(".other_course_url").val($(this).val());
|
|
})
|
|
</script>
|
|
<style>
|
|
.larger{
|
|
font-size: 1.3em;
|
|
}
|
|
</style> |