diff --git a/app/controllers/admin/application_forms_controller.rb b/app/controllers/admin/application_forms_controller.rb index 2d23956..a933d9b 100644 --- a/app/controllers/admin/application_forms_controller.rb +++ b/app/controllers/admin/application_forms_controller.rb @@ -711,6 +711,7 @@ class Admin::ApplicationFormsController < OrbitAdminController page = params[:type] || params[:page] if params[:action] == "application_form_signup" page = params[:type] + page = 'table' if page.blank? end page = nil if page.blank? @application_form_signup_admin_setting = ApplicationFormSignupAdminSetting.where(:application_form_main_id=>params[:id],:page=>page).first @@ -821,14 +822,14 @@ class Admin::ApplicationFormsController < OrbitAdminController i = format_text.scan(/\d+/)[0].to_i - 1 k = custom_fields.keys[i] rescue nil if !k.blank? - text_tp = @application_form_signup.application_form_signup_values.select{|v| v.application_form_signup_field_id==k}[0].get_value_by_locale + text_tp = @application_form_signup.application_form_signup_values.select{|v| v.application_form_signup_field_id==k}[0].get_value_by_locale(I18n.locale) text = text.gsub(format_text,text_tp.to_s) end when /custom\d+/ i = format_text.scan(/\d+/)[0].to_i - 1 k = custom_fields.keys[i] rescue nil if !k.blank? - text_tp = @application_form_signup.application_form_signup_values.select{|v| v.application_form_signup_field_id==k}[0].get_value_by_locale + text_tp = @application_form_signup.application_form_signup_values.select{|v| v.application_form_signup_field_id==k}[0].get_value_by_locale(I18n.locale) text = text.gsub(format_text,text_tp.to_s) end end diff --git a/app/controllers/application_forms_controller.rb b/app/controllers/application_forms_controller.rb index 7c67ec9..496c8e2 100644 --- a/app/controllers/application_forms_controller.rb +++ b/app/controllers/application_forms_controller.rb @@ -407,6 +407,8 @@ class ApplicationFormsController < ApplicationController extra_text += render_to_string("application_forms/signup_email_contents",:locals=>{:application_form=>application_form, :application_form_signup=>signup},:layout=>false) if params[:type] == 'agree' + signup.agree_reviewer_ids[stage_num.to_s] = params[:reviewer] + signup.save if stage_num == application_form.get_max_stage signup.update(:review_status => 2) signup.clean_cipher @@ -427,7 +429,10 @@ class ApplicationFormsController < ApplicationController host_url = request.protocol + request.host_with_port end agree_link = host_url + Rails.application.routes.url_helpers.xhr_application_forms_agree_link_path(:locale=>I18n.locale, :id=>signup.id.to_s, :cipher=>signup.get_cipher_stage(signup.process_stage)) - send_mail('submission', signup.get_reviewer_email, form_params_main_id,extra_text, {'agree_link'=>agree_link}) + id_with_email = signup.get_reviewer_email + id_with_email.each do |id, email| + send_mail('submission', email, form_params_main_id,extra_text, {'agree_link'=>agree_link + "&reviewer=#{id}"}) + end end else mail_to = [signup.email] @@ -449,6 +454,7 @@ class ApplicationFormsController < ApplicationController @application_form = ApplicationFormMain.where(id: form_params_main_id).first @application_form_signup = ApplicationFormSignup.new(application_form_signup_params) + @application_form_signup.application_form_main = @application_form if @application_form.application_form_signup_field_sets.count!=0 flag = @application_form.application_form_signup_field_sets.select{|v| v.field_name=='recaptcha'}[0].disabled else @@ -492,7 +498,10 @@ class ApplicationFormsController < ApplicationController host_url = request.referer.match(/http(s|):\/\/[^\/]+/)[0] end agree_link = host_url + Rails.application.routes.url_helpers.xhr_application_forms_agree_link_path(:locale=>I18n.locale, :id=>@application_form_signup.id.to_s, :cipher=>@application_form_signup.get_cipher_stage(1)) - send_mail('submission', @application_form_signup.get_reviewer_email, form_params_main_id,extra_text, {'agree_link'=>agree_link}) + id_with_email = @application_form_signup.get_reviewer_email + id_with_email.each do |id, email| + send_mail('submission', email , form_params_main_id,extra_text, {'agree_link'=>agree_link + "&reviewer=#{id}"}) + end redirect_to "#{params[:referer_url]}/?method=signup_ok&serial_number=#{@application_form_signup.display_serial_number}" else if !@signup.blank? @@ -756,7 +765,7 @@ class ApplicationFormsController < ApplicationController def application_form_signup_params tmp = params.require(:application_form_signup).permit! - tmp['reviewer_ids_list'] = (0...@application_form.reviewer_enables.length).map{|k| Array((tmp['reviewer_ids_list'][k.to_s] rescue []))} + tmp['reviewer_ids_list'] = (0..@application_form.reviewer_enables.rindex(true)).map{|k| Array((tmp['reviewer_ids_list'][k.to_s] rescue []))} tmp end diff --git a/app/models/application_form_main.rb b/app/models/application_form_main.rb index 2809c32..416c6cf 100644 --- a/app/models/application_form_main.rb +++ b/app/models/application_form_main.rb @@ -17,6 +17,8 @@ class ApplicationFormMain field :speaker, localize: true field :content, localize: true field :act_place, localize: true + field :version + field :confidentiality 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", diff --git a/app/models/application_form_signup.rb b/app/models/application_form_signup.rb index 45e2dde..bdde74d 100644 --- a/app/models/application_form_signup.rb +++ b/app/models/application_form_signup.rb @@ -3,7 +3,7 @@ class ApplicationFormSignup require 'openssl/cipher' include Mongoid::Document include Mongoid::Timestamps - HiddenFields = ['application_form_signup_id', 'password', 'status', 'reviewer_ids_list','_id', 'created_at', 'updated_at','application_form_main_id',"serial_number","final_session","final_sessions","preferred_sessions",'application_form_session_id',"application_form_session_ids","preferred_session","sort_number","abstract_number","presentation_type", "cipher_stage_num", "process_stage", "review_status"] + HiddenFields = ['application_form_signup_id', 'password', 'status', 'reviewer_ids_list','_id', 'created_at', 'updated_at','application_form_main_id',"serial_number","final_session","final_sessions","preferred_sessions",'application_form_session_id',"application_form_session_ids","preferred_session","sort_number","abstract_number","presentation_type", "cipher_stage_num", "process_stage", "review_status", "agree_reviewer_ids"] DefaultEnableFields = ['name','tel','phone','email', 'recaptcha'] field :sort_number , type: Integer, default: 10000 field :process_stage, type: Integer, default: 1 @@ -24,6 +24,7 @@ class ApplicationFormSignup field :final_sessions field :preferred_sessions, type: Array, default: [] field :reviewer_ids_list, type: Array, default: [] + field :agree_reviewer_ids, type: Hash, default: {} def reviewer_ids_list main = self.application_form_main main.reviewer_enables.each_with_index.collect do |e,k| @@ -52,6 +53,10 @@ class ApplicationFormSignup unit = self.unit_translations.values.select{|v| v.present?}.first self.unit_translations = I18n.available_locales.map{|l| [l.to_s,unit]}.to_h self.random_cipher(false) + if self.application_form_main + enable_idx = self.application_form_main.reviewer_enables.index(true) + self.process_stage = enable_idx.nil? ? 0 : (enable_idx + 1) + end if self.serial_number.nil? s = ApplicationFormSetting.first s.last_serial_number += 1 @@ -111,13 +116,17 @@ class ApplicationFormSignup max_stage += 1 " #{I18n.t('application_form.num.'+self.process_stage.to_s)}#{stage_trans} / #{I18n.t('application_form.num.'+max_stage.to_s)}#{stage_trans} : #{I18n.t('application_form.status.'+review_status.to_s)}" end - def get_reviewer_email(stage=self.process_stage, override_reviewer_ids_list=nil) + def get_reviewer_email(stage=self.process_stage, override_reviewer_ids_list=nil, only_email=false) stage = stage - 1 if override_reviewer_ids_list.nil? override_reviewer_ids_list = self.reviewer_ids_list end member_ids = override_reviewer_ids_list[stage] - return MemberProfile.where(:id.in=>member_ids).pluck(:email).select{|s| s.present?}.uniq + if(only_email) + return MemberProfile.where(:id.in=>member_ids).pluck(:email).select{|s| s.present?}.uniq + else + return MemberProfile.where(:id.in=>member_ids).pluck(:id,:email).select{|id,s| s.present?}.uniq{|id,s| s} + end end def get_cipher_stage(stage) self.cipher_stage_num[stage - 1] diff --git a/app/views/admin/application_forms/_form.html.erb b/app/views/admin/application_forms/_form.html.erb index 4c7035c..ebfa705 100644 --- a/app/views/admin/application_forms/_form.html.erb +++ b/app/views/admin/application_forms/_form.html.erb @@ -31,7 +31,7 @@
  • <%= t(:basic) %>
  • <%= t('application_form.review') %>
  • <%= t('application_form.signup_set') %>
  • -
  • <%= t('application_form.custom_set') %>
  • +
  • <%= t('application_form.auto_send_email_set') %>
  • @@ -90,11 +90,10 @@
    <%= select_tag "#{f.object_name}[reviewer_type_list][]",options_for_select(['defined_by_applicant','fixed'].map{|v| [t("application_form.#{v}"),v]},f.object.reviewer_type_list[k]) %>
    - <% if !@members[k].nil? %> - <%= render partial: 'admin/member_selects/email_selection_box', locals: {field: "#{f.object_name}[reviewer_ids_list][#{k}]", email_members:@members[k], index: "#{k+2}", select_name: "reviewer_ids_list_#{k}"} %> - <% else %> - <%= render partial: 'admin/member_selects/email_selection_box', locals: {field: "#{f.object_name}[reviewer_ids_list][#{k}]", email_members:[], index: "#{k+2}", select_name: "reviewer_ids_list_#{k}"} %> - <% end %> + <% email_members = @members[k] + email_members = [] if email_members.nil? + %> + <%= render partial: 'admin/member_selects/email_selection_box', locals: {field: "#{f.object_name}[reviewer_ids_list][#{k}][]", email_members: email_members, index: "#{k+2}", select_name: "reviewer_ids_list_#{k}"} %>
    @@ -108,7 +107,7 @@ <%= t('application_form.name') %> <%= t('application_form.placeholder') %> <%= t('application_form.disable') %> - <%= t('application_form.hidden') %> + <% @signup_sets.each_with_index do |attr_signup,signup_index| %> @@ -129,8 +128,9 @@ <% if attr_signup.field_name != 'recaptcha' %> - - <%= check_box_tag("application_form_main[application_form_signup_field_sets][#{signup_index}][hidden]", true ,attr_signup.hidden) %> + + <%= hidden_field_tag("application_form_main[application_form_signup_field_sets][#{signup_index}][hidden]",attr_signup.hidden) %> + <%#= check_box_tag("application_form_main[application_form_signup_field_sets][#{signup_index}][hidden]", true ,attr_signup.hidden) %> <% end %> @@ -140,7 +140,7 @@ -
    +
    - + +
    + +
    + <%= f.text_field :version, :class => "form_version_input" %> +
    +
    + +
    + +
    + <%= f.text_field :confidentiality, :class => "form_confidentiality_input" %> +
    +
    @@ -411,6 +424,12 @@ $(document).on('click','.remove_btn',function(){ $(this).parent().remove(); }) + $(".form_version_input").on("input",function(){ + $(".form_version_input").not(this).val($(this).val()); + }) + $(".form_confidentiality_input").on("input",function(){ + $(".form_confidentiality_input").not(this).val($(this).val()); + }) $("input[name=\"application_form_main[enable_summary_choice]\"]").change(function(){ if($(this).prop("checked")){ $(".summary_choice_block").css("display",""); diff --git a/app/views/application_forms/show.html.erb b/app/views/application_forms/show.html.erb index d59ed58..ecc015d 100644 --- a/app/views/application_forms/show.html.erb +++ b/app/views/application_forms/show.html.erb @@ -184,7 +184,7 @@ <% if @application_form.reviewer_type_list[k]=='fixed' %> <%= MemberProfile.where(:id.in=>Array(@application_form.reviewer_ids_list[k])).collect{|m| m.name}.join(', ') %> <% else %> - <%= render partial: 'admin/member_selects/email_selection_box', locals: {field: "#{f.object_name}[reviewer_ids_list][#{k}]", email_members: [], index: "#{k+1}", select_name: "reviewer_ids_list_#{k}"} %> + <%= render partial: 'admin/member_selects/email_selection_box', locals: {field: "#{f.object_name}[reviewer_ids_list][#{k}][]", email_members: [], index: "#{k+1}", select_name: "reviewer_ids_list_#{k}"} %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index bdb9310..e4a12ab 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -27,7 +27,9 @@ en: abstract_number: Abstract number presentation_type: Presentation application_form: - this_link_has_expired: "This link has expired!" + version: Version + confidentiality: Confidentiality + this_link_has_expired: "This Link has been clicked and expired!" close: "Close" send_email_to_next_stage_reviewer: "Email has been sent to reviewer of next stage!" denied_stage: "Denied Stage" diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index e41c327..1f2fc52 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -28,7 +28,9 @@ zh_tw: abstract_number: 摘要編號 presentation_type: 發表方式 application_form: - this_link_has_expired: "此連結已失效!" + version: 表單版本 + confidentiality: 機密等級 + this_link_has_expired: "此連結已經點選並已失效!" close: "關閉" send_email_to_next_stage_reviewer: "已寄送email給下個階段審核者!" denied_stage: "未通過階段"