<% # 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" %> <% 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 %>
<% @site_in_use_locales.each_with_index do |locale, i| %>
">
<% if @selected_course.course.nil? %> <% 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 %> <%= 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 %>
<% protocol = ("#{URI(request.referer).scheme}://" rescue request.protocol) %> <% host_url = protocol+(request.host_with_port) %> <% course_url = @selected_course.course_url %> <% if course_url != "#" %> <% course_url = host_url+course_url %> <%=course_url%> <% elsif @selected_course.course.nil? %> <%=f.text_field :other_course_url ,:class=>"other_course_url #{locale}" %> <% end %>
<%= 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 %>
<% end %>
<% if !@member.nil? %>
<%= @member.name rescue ''%> <%= f.hidden_field :member_profile_id, :value => @member.id %>
<% else %>
<% 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'} %>
<% end %>
<% if @selected_course.course %> <%= @selected_course.year %> <% else %> <%= 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 %>
<% if @selected_course.course %> <%= @selected_course.course.course_category.title rescue "" %> <% else %> <%= f.select :selected_course_category_id, SelectedCourseCategory.all.collect {|t| [ t.title, t.id ]},{},{:class=>"other_course_category"} %> <% end %>
<% if @selected_course.course %> <%= @selected_course.course.course_semester.title rescue "" %> <% else %> <%= f.select :selected_course_category_id, SelectedCourseSemester.all.collect {|t| [ t.title, t.id ]},{},{:class=>"other_course_category"} %> <% end %>
<%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %> <%= f.submit t('submit'), class: 'btn btn-primary' %> <%= link_to t('cancel'), request.referer, :class=>"btn" %>