Add fields: version and confidentiality.
Update link expired translations.
Record agree reviewers.(Reviewer in every stage change to multiple.)
This commit is contained in:
BoHung Chiu 2022-06-26 16:16:18 +08:00
parent 350127fdf1
commit 92cf65bfaa
8 changed files with 67 additions and 23 deletions

View File

@ -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

View File

@ -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

View File

@ -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",

View File

@ -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]
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]

View File

@ -31,7 +31,7 @@
<li class="active"><a href="#basic" data-toggle="tab"><%= t(:basic) %></a></li>
<li><a href="#review" data-toggle="tab"><%= t('application_form.review') %></a></li>
<li><a href="#signup_set" data-toggle="tab"><%= t('application_form.signup_set') %></a></li>
<li><a href="#custom_set" data-toggle="tab"><%= t('application_form.custom_set') %></a></li>
<!-- <li><a href="#custom_set" data-toggle="tab"><%= t('application_form.custom_set') %></a></li> -->
<li><a href="#auto_send_email_set" data-toggle="tab"><%= t('application_form.auto_send_email_set') %></a></li>
</ul>
@ -90,11 +90,10 @@
<div class="controls">
<%= 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]) %>
<div class="members">
<% 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}"} %>
</div>
</div>
</div>
@ -108,7 +107,7 @@
<th><%= t('application_form.name') %></th>
<th><%= t('application_form.placeholder') %></th>
<th><%= t('application_form.disable') %></th>
<th><%= t('application_form.hidden') %></th>
<!-- <th><%= t('application_form.hidden') %></th> -->
</thead>
<tbody>
<% @signup_sets.each_with_index do |attr_signup,signup_index| %>
@ -129,8 +128,9 @@
</td>
<td>
<% if attr_signup.field_name != 'recaptcha' %>
<input type="hidden" class="field_set" name='<%= "application_form_main[application_form_signup_field_sets][#{signup_index}][hidden]" %>' value="false">
<%= check_box_tag("application_form_main[application_form_signup_field_sets][#{signup_index}][hidden]", true ,attr_signup.hidden) %>
<!-- <input type="hidden" class="field_set" name='<%= "application_form_main[application_form_signup_field_sets][#{signup_index}][hidden]" %>' value="false"> -->
<%= 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 %>
</td>
</tr>
@ -140,7 +140,7 @@
</div>
<!-- Custom Set Module -->
<div class="tab-pane fade in " id="custom_set" style="padding: 1.2em;">
<!-- <div class="tab-pane fade in " id="custom_set" style="padding: 1.2em;">
<table>
<thead>
<th style="padding-right: 2em;"><%= t('application_form.field_name') %></th>
@ -165,7 +165,7 @@
<% end %>
</tbody>
</table>
</div>
</div> -->
<!-- Email Set Module -->
<div class="tab-pane fade in " id="auto_send_email_set" style="padding: 1.2em;">
<ul class="nav nav-pills module-nav">
@ -280,7 +280,20 @@
<% end %>
</div>
</div>
<!-- Version-->
<div class="control-group input-title">
<label class="control-label muted"><%= t('application_form.version') %></label>
<div class="controls">
<%= f.text_field :version, :class => "form_version_input" %>
</div>
</div>
<!-- Confidentiality-->
<div class="control-group input-title">
<label class="control-label muted"><%= t('application_form.confidentiality') %></label>
<div class="controls">
<%= f.text_field :confidentiality, :class => "form_confidentiality_input" %>
</div>
</div>
</div>
@ -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","");

View File

@ -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 %>
</div>
</div>

View File

@ -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"

View File

@ -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: "未通過階段"