diff --git a/app/controllers/admin/seminars_controller.rb b/app/controllers/admin/seminars_controller.rb index dbc4732..625a307 100644 --- a/app/controllers/admin/seminars_controller.rb +++ b/app/controllers/admin/seminars_controller.rb @@ -59,6 +59,11 @@ class Admin::SeminarsController < OrbitAdminController @fields_values << f.option_list end end + if @seminar.enable_summary_choice + @fields << "seminar_signup_contributes.description" + @fields_translations << I18n.t("seminar_signup.description") + @fields_values << @seminar.summary_chioices.map.with_index{|v,i| [i.to_s,{I18n.locale=>v}]}.to_h + end @fields_values = @fields_values.collect.with_index{|fields_values,i| [i, fields_values.values.map{|v| v[I18n.locale]} ] }.to_h end def update_reviewer_setting diff --git a/app/controllers/seminars_controller.rb b/app/controllers/seminars_controller.rb index e875a62..3143012 100644 --- a/app/controllers/seminars_controller.rb +++ b/app/controllers/seminars_controller.rb @@ -150,6 +150,15 @@ class SeminarsController < ApplicationController end seminar_reviews = SeminarReview.where(:seminar_main_id=>@seminar.id).to_a seminar_reviews.each{|sr| sr.save} + @seminar = @seminar_signup.seminar_main + unassigned_seminar_signup_ids = @seminar.seminar_signup_ids.map{|s| s.to_s} + unassigned_seminar_signup_ids.push(@seminar_signup.id.to_s) + seminar_reviews = SeminarReview.where(:seminar_main_id=>@seminar.id).to_a + seminar_reviews.each do |sr| + unassigned_seminar_signup_ids = unassigned_seminar_signup_ids - sr.all_seminar_signup_ids + end + @seminar.unassigned_seminar_signup_ids << @seminar_signup.id.to_s + @seminar.save else @seminar.unassigned_seminar_signup_ids << @seminar_signup.id.to_s @seminar.save diff --git a/app/helpers/admin/seminars_field_helper.rb b/app/helpers/admin/seminars_field_helper.rb index f3d385c..8e53536 100644 --- a/app/helpers/admin/seminars_field_helper.rb +++ b/app/helpers/admin/seminars_field_helper.rb @@ -52,7 +52,7 @@ module Admin::SeminarsFieldHelper @prefiled_value ||=[] control_group_wrapper do a = self.typeE[:option_list].collect do |key,value| - label_tag(key,check_box_tag(get_field_name_base+"[#{key}]", true , (@prefiled_value.include?(key) ? true : false), { :id=>"#{get_basic_field_name_org}_#{self.id}"})+value[I18n.locale.to_s],@markup_options.merge(:class=>"checkbox inline")) + label_tag("#{get_basic_field_name_org}_#{self.id}_#{key}",check_box_tag(get_field_name_base+"[#{key}]", true , (@prefiled_value.include?(key) ? true : false), { :id=>"#{get_basic_field_name_org}_#{self.id}_#{key}"})+value[I18n.locale.to_s],@markup_options.merge(:class=>"checkbox inline")) end.join.html_safe rescue "" end end @@ -138,7 +138,7 @@ module Admin::SeminarsFieldHelper @prefiled_value ||=[] control_group_wrapper do self.typeE[:option_list].collect do |key,value| - label_tag(key,radio_button_tag(get_field_name_base, key , (@prefiled_value.include?(key) ? true : false), {:required=>@require})+value[I18n.locale.to_s],@markup_options.merge(:class=>"radio inline")) + label_tag("#{get_basic_field_name_org}_#{self.id}_#{key}",radio_button_tag(get_field_name_base, key , (@prefiled_value.include?(key) ? true : false), {:required=>@require,:id=>"#{get_basic_field_name_org}_#{self.id}_#{key}"})+value[I18n.locale.to_s],@markup_options.merge(:class=>"radio inline")) end.join.html_safe end end diff --git a/app/models/seminar_main.rb b/app/models/seminar_main.rb index 49de8e0..fd1565f 100644 --- a/app/models/seminar_main.rb +++ b/app/models/seminar_main.rb @@ -6,13 +6,19 @@ class SeminarMain # encoding: utf-8 include OrbitCategory::Categorizable include Slug - + ChoiceTypes = ["checkbox","radio","select"] field :signup_note, localize: true field :title, as: :slug_title, type: String, localize: true field :speaker, localize: true field :content, localize: true field :act_place, localize: true - + field :enable_summary_choice, :type => Boolean, :default => false + field :summary_chioice_type, :type => String, :default => "checkbox" + field :summary_chioices, :type => Array, :default => ["A. Energy Conversion","B. Biocatalysis","C. Electrocatalysis", + " D. Photocatalysis","E. Catalytic and Porous Materials", + "F. Environmental and Reaction Engineering","G. Industrial Applications", + "H. Student Oral Presentation Contest (in English)","I. Student Poster Competition" + ] field :seminar_start_date, :type => Date, :default => Time.now field :seminar_end_date, :type => Date, :default => Time.now diff --git a/app/models/seminar_review.rb b/app/models/seminar_review.rb index fb407d6..5557d40 100644 --- a/app/models/seminar_review.rb +++ b/app/models/seminar_review.rb @@ -33,9 +33,11 @@ class SeminarReview next if fn.nil? if fn == "seminar_signup_fields" default_seminar_signup_ids += SeminarSignupValue.where(:seminar_signup_field_id=>id,:val.in=>self.default_topics_values[i].to_a).pluck(:seminar_signup_id) - elsif "seminar_submission_fields" + elsif fn == "seminar_submission_fields" seminar_signup_contribute_ids = SeminarSubmissionValue.where(:seminar_submission_field_id=>id,:val.in=>self.default_topics_values[i].to_a).pluck(:seminar_signup_contribute) default_seminar_signup_ids += SeminarSignupContribute.where(:id.in=>seminar_signup_contribute_ids).pluck(:seminar_signup_id) + elsif fn == "seminar_signup_contributes" + default_seminar_signup_ids += SeminarSignupContribute.where(:description.in=>self.default_topics_values[i].to_a).pluck(:seminar_signup_id) end end default_seminar_signup_ids.uniq! diff --git a/app/models/seminar_signup.rb b/app/models/seminar_signup.rb index cd08c32..baa912e 100644 --- a/app/models/seminar_signup.rb +++ b/app/models/seminar_signup.rb @@ -22,6 +22,10 @@ class SeminarSignup accepts_nested_attributes_for :seminar_signup_values, allow_destroy: true accepts_nested_attributes_for :seminar_signup_contributes, allow_destroy: true + before_create do + unit = self.unit_translations.values.select{|v| v.present?}.first + self.unit_translations = I18n.available_locales.map{|l| [l.to_s,unit]}.to_h + end after_destroy do seminar_main = self.seminar_main seminar_reviews = seminar_main.seminar_reviews diff --git a/app/views/admin/seminars/_form.html.erb b/app/views/admin/seminars/_form.html.erb index 27d3a1c..cb294d0 100644 --- a/app/views/admin/seminars/_form.html.erb +++ b/app/views/admin/seminars/_form.html.erb @@ -233,6 +233,27 @@ <% end %> +
+
<%=t('seminar_signup.enable_summary_choice')%>
+
<%= f.check_box :enable_summary_choice %>
+
+ <% hidden_style = (f.object.enable_summary_choice) ? "" : "style=display:none" %> +
> +
<%=t('seminar_signup.summary_choice_type')%>
+
<%= f.select :summary_chioice_type,f.object.class::ChoiceTypes.map{|c| [t("seminar_signup.#{c}"),c]} %>
+
+
> +
<%=t('seminar_signup.choices')%>
+
+ <% f.object.summary_chioices.each do |choice| %> +
+ X + <%= text_field_tag "seminar_main[summary_chioices][]",choice, {:id=>nil} %> +
+ <% end %> + +
+
@@ -494,7 +515,26 @@ $(this).parents('.start-line').hide(); } }); - + $(document).on('click','#add_summary_choice',function(){ + $(this).before("
X
") + }) + $(document).on('click','.remove_btn',function(){ + $(this).parent().remove(); + }) + $("input[name=\"seminar_main[enable_summary_choice]\"]").change(function(){ + if($(this).prop("checked")){ + $(".summary_choice_block").css("display",""); + }else{ + $(".summary_choice_block").css("display","none"); + } + }) }); -<% end %> \ No newline at end of file +<% end %> + \ No newline at end of file diff --git a/app/views/admin/seminars/_seminar_signup_render_table.html.erb b/app/views/admin/seminars/_seminar_signup_render_table.html.erb index 3034f37..7de0537 100644 --- a/app/views/admin/seminars/_seminar_signup_render_table.html.erb +++ b/app/views/admin/seminars/_seminar_signup_render_table.html.erb @@ -15,7 +15,9 @@ > + <% display_title = @seminar.nil? %> <% @seminar_signups.each do |seminar_signup| %> + <% @seminar = seminar_signup.seminar_main if display_title %> <% len = seminar_signup.seminar_signup_contributes.count %> <% rowspan = "rowspan=#{len==0? 1 : len}" %> <% vals = [] %> @@ -23,7 +25,7 @@ <% if @drag%> > <% end %> - <% vals << seminar_signup.seminar_main.title if @seminar.nil? %> + <% vals << seminar_signup.seminar_main.title if display_title %> <% @display_field.each_with_index do |fn,i|%> <% names = fn.split(".") %> <% val = "" %> @@ -67,7 +69,21 @@ <% if names[1] == "file" %> <% val = seminar_signup.seminar_signup_contributes.to_a %> <% else %> - <% val = seminar_signup.seminar_signup_contributes.collect{|s| s.send(names[1])} %> + <% if names[1] == "description" %> + <% descriptions = seminar_signup.seminar_signup_contributes.collect{|s| s.send(names[1])} %> + <% if @seminar.enable_summary_choice + descriptions = descriptions.map do |description| + if (description.to_s.to_i.to_s == description) + description = @seminar.summary_chioices[description.to_i] rescue description + else + description = description.map{|i| @seminar.summary_chioices[i.to_i] rescue "" }.join("
") rescue description + end + end + end %> + <% val = descriptions %> + <% else %> + <% val = seminar_signup.seminar_signup_contributes.collect{|s| s.send(names[1]).to_s} %> + <% end %> <% end %> <% elsif names[0] == "seminar_submission_fields" %> <% val = seminar_signup.seminar_signup_contributes.collect{|s| (s.seminar_submission_values.where(:key=>names[1]).first.get_value_by_locale(I18n.locale) rescue "")} %> @@ -83,7 +99,15 @@ <% if val[0].class == SeminarSignupContribute #File %> <% seminar_signup_contribute = val[0] %> - <%= link_to (seminar_signup_contribute.title.blank? ? File.basename(seminar_signup_contribute.file.path) : seminar_signup_contribute.title) , seminar_signup_contribute.file.url, {:target => '_blank', :title => Nokogiri::HTML(seminar_signup_contribute.description).text} if seminar_signup_contribute.file.file %> + <% description = seminar_signup_contribute.description.to_s %> + <% if @seminar.enable_summary_choice + if (seminar_signup_contribute.description.to_s.to_i.to_s == seminar_signup_contribute.description) + description = @seminar.summary_chioices[seminar_signup_contribute.description.to_i] rescue seminar_signup_contribute.description + else + description = seminar_signup_contribute.description.map{|i| @seminar.summary_chioices[i.to_i] rescue "" }.join("
") rescue seminar_signup_contribute.description + end + end %> + <%= link_to (seminar_signup_contribute.title.blank? ? File.basename(seminar_signup_contribute.file.path) : seminar_signup_contribute.title) , seminar_signup_contribute.file.url, {:target => '_blank', :title => Nokogiri::HTML(description.gsub("
"," , ")).text} if seminar_signup_contribute.file.file %> <% else %> <%= val[0].html_safe.to_s rescue "" %> <% end %> @@ -98,7 +122,15 @@ <% if vals[index][i].class == SeminarSignupContribute #File %> <% seminar_signup_contribute = vals[index][i] %> - <%= link_to (seminar_signup_contribute.title.blank? ? File.basename(seminar_signup_contribute.file.path) : seminar_signup_contribute.title) , seminar_signup_contribute.file.url, {:target => '_blank', :title => Nokogiri::HTML(seminar_signup_contribute.description).text} if seminar_signup_contribute.file.file %> + <% description = seminar_signup_contribute.description.to_s %> + <% if @seminar.enable_summary_choice + if (seminar_signup_contribute.description.to_s.to_i.to_s == seminar_signup_contribute.description) + description = @seminar.summary_chioices[seminar_signup_contribute.description.to_i] rescue seminar_signup_contribute.description + else + description = seminar_signup_contribute.description.map{|i| @seminar.summary_chioices[i.to_i] rescue "" }.join("
") rescue seminar_signup_contribute.description + end + end %> + <%= link_to (seminar_signup_contribute.title.blank? ? File.basename(seminar_signup_contribute.file.path) : seminar_signup_contribute.title) , seminar_signup_contribute.file.url, {:target => '_blank', :title => Nokogiri::HTML(description.gsub("
"," , ")).text} if seminar_signup_contribute.file.file %> <% else %> <%= vals[index][i].html_safe.to_s rescue "" %> <% end %> diff --git a/app/views/admin/seminars/get_hide_reviewer.html.erb b/app/views/admin/seminars/get_hide_reviewer.html.erb index ac43f9d..be878d8 100644 --- a/app/views/admin/seminars/get_hide_reviewer.html.erb +++ b/app/views/admin/seminars/get_hide_reviewer.html.erb @@ -4,7 +4,7 @@ <% member_id = member.id.to_s %> <% member_pic_url = ((member.avatar.file.present? rescue false) ? member.avatar.url : "/assets/member-pic.png") %>
  • -
  • @@ -50,4 +50,10 @@ 已截止 -<% end %> \ No newline at end of file +<% end %> + \ No newline at end of file diff --git a/app/views/seminars/con_upload.html.erb b/app/views/seminars/con_upload.html.erb index 1abe351..9470034 100644 --- a/app/views/seminars/con_upload.html.erb +++ b/app/views/seminars/con_upload.html.erb @@ -8,7 +8,7 @@ @time_now = data["time_now"] %> <% if @seminar.contribute_start_date <= @time_now and ( @seminar.contribute_end_date.nil? or @seminar.contribute_end_date+1 >= @time_now ) %> - + <% begin %> <% if !session[:seminar_signup_id].blank? %> <%= t('seminar_signup.logout') %> @@ -31,8 +31,16 @@ %> <%= seminar_signup_contribute.title %> - <%= seminar_signup_contribute.description.to_s.html_safe %> - <%= link_to File.basename(seminar_signup_contribute.file.path), seminar_signup_contribute.file.url, {:target => '_blank', :title => Nokogiri::HTML(seminar_signup_contribute.description).text} if seminar_signup_contribute.file.file %> + <% description = seminar_signup_contribute.description.to_s %> + <% if @seminar.enable_summary_choice + if (seminar_signup_contribute.description.to_s.to_i.to_s == seminar_signup_contribute.description) + description = @seminar.summary_chioices[seminar_signup_contribute.description.to_i] rescue seminar_signup_contribute.description + else + description = seminar_signup_contribute.description.map{|i| @seminar.summary_chioices[i.to_i] rescue "" }.join("
    ") rescue seminar_signup_contribute.description + end + end %> + <%= description.html_safe %> + <%= link_to File.basename(seminar_signup_contribute.file.path), seminar_signup_contribute.file.url, {:target => '_blank', :title => Nokogiri::HTML(description.gsub("
    "," , ")).text} if seminar_signup_contribute.file.file %> <%= link_to t(:edit), OrbitHelper.url_to_show(@seminar.to_param) + '?method=edit_file&con_no=' + seminar_signup_contribute.id, :class => 'btn btn-primary' %>
    @@ -49,7 +57,7 @@ <% if ( @seminar.contribute_file_count.blank? or @seminar_signup.seminar_signup_contributes.count < @seminar.contribute_file_count.to_i ) %> - <%= link_to content_tag(:i, nil, :class => 'icon-plus') +' '+ t('new_'), OrbitHelper.url_to_show(@seminar.to_param) + '?method=add_file', :class => 'btn btn-primary' %> + <%= link_to content_tag(:i, nil, :class => 'icon-plus') +' '+ t('seminar_signup.new_'), OrbitHelper.url_to_show(@seminar.to_param) + '?method=add_file', :class => 'btn btn-primary' %> <% end %>
    @@ -63,7 +71,10 @@ 回列表頁 <% end %> - + <% + rescue => e + puts e + end%> <% else %> 已截止 diff --git a/app/views/seminars/edit_file.html.erb b/app/views/seminars/edit_file.html.erb index 7a1bdbf..303b658 100644 --- a/app/views/seminars/edit_file.html.erb +++ b/app/views/seminars/edit_file.html.erb @@ -14,84 +14,11 @@ <% if !session[:seminar_signup_id].blank? %> <%= form_for @con, url: edit_file_proc_seminars_path, html: {class: "content form-horizontal" , :id=>"new-seminar-signup-contribute"} do |f| %> -
    - <% if @seminar.seminar_submission_field_sets.count != 0 - data1 = @seminar.seminar_submission_field_sets.select{|v| v.field_name=='title'}[0] - data2 = @seminar.seminar_submission_field_sets.select{|v| v.field_name=='description'}[0] - data3 = @seminar.seminar_submission_field_sets.select{|v| v.field_name=='file'}[0] - show1 = !(data1.disabled) - show2 = !(data2.disabled) - show3 = !(data3.disabled) - name1 = data1['name'][I18n.locale] - name2 = data2['name'][I18n.locale] - name3 = data3['name'][I18n.locale] - plc1 = data1['placeholder'][I18n.locale] - plc2 = data2['placeholder'][I18n.locale]==t('seminar_signup.description') ? '' : data2['placeholder'][I18n.locale] - plc3 = data3['placeholder'][I18n.locale]==t('seminar_signup.file') ? '' : data3['placeholder'][I18n.locale] - else - show1 = true - show2 = true - show3 = true - name1 = t('seminar_signup.title') - name2 = t('seminar_signup.description') - name3 = t('seminar_signup.file') - plc1 = t('seminar_signup.title') - plc2 = '' - plc3 = '' - end - %> - <% if show1 %> -
    - -
    - <%= f.text_field :title, :class=>"input-medium form-control", :id=>'name', :placeholder=> plc1, :required => true %> -
    -
    + <% begin %> + <%= render :partial => 'seminars/contribute_form',:locals=>{:f=>f} %> + <%rescue => e%> + <%= e %> <% end %> - <% if show2 %> -
    - - -
    - <%= "(#{plc2})" if !(plc2.to_s.blank?) %> -
    -
    - <%= f.text_area :description, rows: 5, :class=>"ckeditor input-medium form-control", :placeholder=> plc2 %> -
    -
    - <% end %> - <% if show3 %> -
    - - -
    - <%= "(#{plc3})" if !(plc3.to_s.blank?) %> -
    -
    - <%= f.file_field :file %> -
    -
    - <% end %> - <% @seminar.seminar_submission_fields.asc(:_id).each do |rf| %> -
    - <%= rf.block_helper(@seminar,@form_index,false,"seminar_signup_contribute",@con, rf.to_require,rf) %> -
    - <% @form_index = @form_index +1 %> - <% end %> -
    -
    - "> - - - <%= f.submit t('submit'), class: 'btn btn-primary', :id => 'button-mail' %> - <%= f.button t('cancel'), type: 'reset', class: 'btn' %> -
    -
    -
    <% end %> <% else %> diff --git a/app/views/seminars/show.html.erb b/app/views/seminars/show.html.erb index f74e5ac..2d5a83c 100644 --- a/app/views/seminars/show.html.erb +++ b/app/views/seminars/show.html.erb @@ -36,53 +36,37 @@ <% end %> +
    +
    *(<%= t('seminar.required') %>)
    +
    <% if @seminar.seminar_signup_field_sets.count != 0 %> <% @seminar.seminar_signup_field_sets.each do |signup_field| %> - <% if signup_field.field_name == 'name' %> -
    -
    *(<%= t('seminar.required') %>)
    -
    - <% end %> <% if !(signup_field.disabled) && signup_field.field_name != 'recaptcha' %>
    <% if signup_field.field_name == 'status' %> - + <% status_translations = ['G','C'].map{|c| [c, t("seminar.registration_status_#{c}")] }.to_h %> + <% status_translations = {'G'=>'No','C'=>'Yes'} if (signup_field.name.values.select{|v| v.include?('?') || v.include?('是否')}.count != 0 rescue false) %>
    <% if @seminar.registration_status.include?('G') %> <% end %> <% if @seminar.registration_status.include?('C') %> <% end %>
    <% elsif signup_field.field_name == 'unit' %>
    -
    -
    - <% @site_in_use_locales.each_with_index do |locale, i| %> -
    " id="unit_<%= locale %>"> - <%= f.fields_for "unit_translations".to_sym do |f| %> - <%= f.text_field locale, :class=>"input-medium form-control", :value => (@seminar_signup.send("unit_translations")[locale] rescue nil), :placeholder=> "#{signup_field.placeholder[I18n.locale]}", :required => true %> - <% end %> -
    - <% end %> -
    -
    - <% @site_in_use_locales.each_with_index do |locale, i| %> - " href="#unit_<%= locale %>" data-toggle="tab"><%= t(locale.to_s) %> - <% end %> -
    -
    + <%= f.text_field 'unit', :class=>"input-medium form-control", :value => (@seminar_signup.send("unit_translations")[locale] rescue nil), :placeholder=> "#{signup_field.placeholder[I18n.locale]}", :required => true %>
    <% elsif signup_field.field_name == 'address' %>
    @@ -150,10 +134,6 @@ <% end %>
    - -
    -
    *(<%= t('seminar.required') %>)
    -
    @@ -234,8 +214,8 @@
    "> - <%= f.submit t('submit'), class: 'btn btn-primary', :id => 'button-mail' %> - <%= f.button t('cancel'), type: 'reset', class: 'btn' %> + <%= f.submit "Submit", class: 'btn btn-primary', :id => 'button-mail' %> + <%= f.button "Delete", type: 'reset', class: 'btn' %>
    @@ -245,6 +225,7 @@