Add email regex feature.
Edit defined_by_applicant feature.
Add agree and disagree record time and let admin can click in backend page.
Edit frontend select email feature.
Remove items and enquiry_for_applicants page.
This commit is contained in:
BoHung Chiu 2022-08-13 11:35:29 +08:00
parent d0062fed8f
commit 10cb149fc7
18 changed files with 563 additions and 105 deletions

View File

@ -18,16 +18,22 @@ class Admin::ApplicationFormSignupsController < OrbitAdminController
end
end
def edit
OrbitHelper.set_params(params,current_user)
params[:controller] = "admin/application_forms"
@application_form_signup = ApplicationFormSignup.find(params[:id])
@application_form = ApplicationFormMain.find(@application_form_signup.application_form_main_id)
@form_index = 0
@form_index = 0
end
def view
params[:controller] = "admin/application_forms"
@application_form_signup = ApplicationFormSignup.find(params[:id])
@application_form = ApplicationFormMain.find(@application_form_signup.application_form_main_id)
@form_index = 0
end
def update
@application_form_signup = ApplicationFormSignup.find(params[:id])

View File

@ -666,6 +666,7 @@ class Admin::ApplicationFormsController < OrbitAdminController
end
@application_form_signups = @application_form.application_form_signups.where(:id.in => unassigned_application_form_signup_ids, :name=>/#{params[:search]}/)
end
@application_form_signups = @application_form_signups.order(:id=>-1)
OrbitHelper.set_params(params,current_user)
@access_level = OrbitHelper.user_access_level?
@can_edit = true

View File

@ -406,9 +406,10 @@ class ApplicationFormsController < ApplicationController
extra_text = "<br>#{I18n.t('application_form_signup.serial_number')}: #{signup.display_serial_number}"
extra_text += render_to_string("application_forms/signup_email_contents",:locals=>{:application_form=>application_form,
:application_form_signup=>signup},:layout=>false)
signup.agree_reviewer_ids[stage_num.to_s] = params[:reviewer]
signup.agree_reviewer_times[stage_num.to_s] = Time.now
signup.save
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
@ -453,15 +454,37 @@ class ApplicationFormsController < ApplicationController
@signup = nil #ApplicationFormSignup.where(email: form_params_email, application_form_main_id: form_params_main_id ).first
@application_form = ApplicationFormMain.where(id: form_params_main_id).first
email_regex = @application_form.get_email_regex
@application_form_signup = ApplicationFormSignup.new(application_form_signup_params)
@application_form_signup.ip = request.remote_ip
@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
flag = false
end
verification_success = true
unless flag
if gotcha_valid?
flag = true
else
verification_success = false
end
end
email_valid = true
if email_regex
email_valid = !(::Regexp.new(email_regex).match(form_params_email.to_s).nil?)
unless email_valid
flag = false
end
end
referer_url = params[:referer_url].to_s
org_params = CGI.parse(referer_url.split('?')[1].to_s)
referer_url = referer_url.split("?")[0]
org_params.delete("notice")
notice = ''
begin
if gotcha_valid? || flag
if flag
if @signup.blank? && @application_form_signup.save
# if gotcha_valid? && @application_form_signup.save
@ -502,39 +525,21 @@ class ApplicationFormsController < ApplicationController
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}"
redirect_to "#{referer_url}/?method=signup_ok&serial_number=#{@application_form_signup.display_serial_number}" and return
else
if !@signup.blank?
redirect_to "#{params[:referer_url]}", :notice => 'mail已存在'
else
referer_url = params[:referer_url].to_s
if referer_url.split("/").last.include?("?")
uri_query = referer_url.split("?").last.gsub(/notice=[^&]*/,'')
if uri_query == ""
referer_url = referer_url.split("?")[0...-1].join("?") + "?notice=#{t('recaptcha.errors.verification_failed')}"
else
referer_url = referer_url.split("?")[0...-1].join("?") + "&notice=#{t('recaptcha.errors.verification_failed')}"
end
else
referer_url = referer_url + "?notice=#{t('recaptcha.errors.verification_failed')}"
end
redirect_to referer_url, :notice => t('recaptcha.errors.verification_failed')
notice = I18n.t('application_form.mail_exist')
end
end
else
referer_url = params[:referer_url].to_s
if referer_url.split("/").last.include?("?")
uri_query = referer_url.split("?").last.gsub(/notice=[^&]*/,'')
if uri_query == ""
referer_url = referer_url.split("?")[0...-1].join("?") + "?notice=#{t('recaptcha.errors.verification_failed')}"
else
referer_url = referer_url.split("?")[0...-1].join("?") + "&notice=#{t('recaptcha.errors.verification_failed')}"
end
else
referer_url = referer_url + "?notice=#{t('recaptcha.errors.verification_failed')}"
end
redirect_to referer_url, :notice => t('recaptcha.errors.verification_failed')
end
if !email_valid
notice = t('application_form.please_check_email_format')
elsif !verification_success
notice = t('recaptcha.errors.verification_failed')
end
org_params['notice'] = notice
referer_url += "?#{org_params.to_query}"
redirect_to referer_url, :notice => notice
rescue => e
render :html => [e.to_s, e.backtrace].to_s
end
@ -797,10 +802,6 @@ class ApplicationFormsController < ApplicationController
template_data:{'application_form_id'=>application_form_id,'locale'=>I18n.locale,'extra_text'=> extra_text}.merge(extra_data),
mail_lang: I18n.locale)
end
begin
mail.deliver
rescue => e
puts ["email can't deliver",e]
end
mail.save
end
end

View File

@ -7,6 +7,9 @@ class ApplicationFormMain
# encoding: utf-8
include OrbitCategory::Categorizable
include Slug
StaticSignupFields = ["application_form_signup.created_at", "application_form_signup.ip"]
DefaultSignupFields = ["created_at", "ip", "serial_number", "review_progress"]
ExceptFieldSetDisplays = ["password", "recaptcha"]
ChoiceTypes = ["checkbox","radio","select"]
# field :annc_count, :type => Integer, :default => 0
# field :album_count, :type => Integer, :default => 0
@ -63,6 +66,8 @@ class ApplicationFormMain
field :review_end_date, :type => Date
field :assign_mode, :type => Integer, :default => 0 # 0 => 用default signup ids來分配 ,1 => 用final_session來分配, 2 => 用final_session來分配(當有preffered session欄位時)
field :update_old_flag, :type => Boolean, :default => false
field :email_regex_enable, type: Boolean, default: false
field :email_regex, type: String, default: '\A[^@\s]+@([^@.\s]+\.)+[^@.\s]+\z'
belongs_to :application_form_item
belongs_to :organizer , :class_name=>"MemberProfile", :foreign_key => :organizer_id
has_many :application_form_sessions, :autosave => true, :dependent => :destroy
@ -195,6 +200,14 @@ class ApplicationFormMain
end
after_initialize do
end
def get_email_regex(frontend=false)
tmp = self.email_regex
if frontend && tmp
tmp = tmp.gsub("\\A","^").gsub("\\z","$").gsub("\\","\\\\\\\\")
end
tmp = nil if !(self.email_regex_enable) || (self.application_form_signup_field_sets.where(:field_name=>'email').pluck(:disabled)[0] rescue false)
tmp
end
def get_max_stage
self.reviewer_enables.rindex(true) || 0
end

View File

@ -3,8 +3,9 @@ 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", "agree_reviewer_ids"]
HiddenFields = ['ip', '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", "agree_reviewer_times"]
DefaultEnableFields = ['name','tel','phone','email', 'recaptcha']
field :ip, type: String
field :sort_number , type: Integer, default: 10000
field :process_stage, type: Integer, default: 1
field :review_status, type: Integer, default: 0 # 0 => 審核中, 1 => 不通過, 2=> 申請通過
@ -12,7 +13,7 @@ class ApplicationFormSignup
field :status
field :name # become Last Name for TICC
field :tel, type: String # become First Name for TICC
field :unit, localize: true
field :unit, localize: true #Only localize for preserving old record
field :phone, type: String
field :fax, type: String
field :email, type: String
@ -25,6 +26,7 @@ class ApplicationFormSignup
field :preferred_sessions, type: Array, default: []
field :reviewer_ids_list, type: Array, default: []
field :agree_reviewer_ids, type: Hash, default: {}
field :agree_reviewer_times, type: Hash, default: {}
def reviewer_ids_list
main = self.application_form_main
main.reviewer_enables.each_with_index.collect do |e,k|
@ -51,7 +53,12 @@ class ApplicationFormSignup
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
tmp_unit_translations = self.unit_translations
self.unit_translations = I18n.available_locales.map do |l|
l = l.to_s
tmp = tmp_unit_translations[l]
[l, (tmp ? tmp : unit)]
end.to_h
self.random_cipher(false)
if self.application_form_main
enable_idx = self.application_form_main.reviewer_enables.index(true)
@ -107,7 +114,41 @@ class ApplicationFormSignup
self.process_stage = new_stage
self.save
end
def review_progress(with_details=true)
def procedure(agree_link=nil)
stage_trans = I18n.t('application_form.stage')
text = ""
main = self.application_form_main
tmp_process_idx = self.process_stage - 1
if main
main.reviewer_enables.each_with_index do |t, i|
if t
text += "<span>#{I18n.t("application_form.num.#{i + 1}")}#{stage_trans}: "
if main.reviewer_type_list[i]=='fixed'
member_ids = main.reviewer_ids_list[i]
is_fixed = true
else
member_ids = self[:reviewer_ids_list][i] rescue []
is_fixed = false
end
if member_ids.present?
text += member_ids.map{|id| MemberProfile.find(id).name rescue nil}.compact.join(', ')
if is_fixed
text += " (#{I18n.t('application_form.fixed')})"
else
text += " (#{I18n.t('application_form.defined_by_applicant')})"
end
end
if i == tmp_process_idx && self.review_status == 0 && agree_link
text += "<a style=\"margin-left: 0.5em;\" class=\"btn btn-success agree_link\" href=\"#{agree_link}&type=agree\">#{I18n.t('application_form.link_choice.agree')}</a>"
text += "<a style=\"margin-left: 0.5em;\" class=\"btn btn-danger disagree_link\" href=\"#{agree_link}&type=disagree\">#{I18n.t('application_form.link_choice.disagree')}</a>"
end
text += "</span><br>"
end
end
end
text
end
def review_progress(with_details=true, include_time=false)
stage_trans = I18n.t('application_form.stage')
max_stage = @max_stage
if max_stage.nil?
@ -117,17 +158,29 @@ class ApplicationFormSignup
text = "#{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)}"
if with_details
text += "<br>"
text += review_details
text += review_details(include_time)
end
text
end
def review_details
def review_details(include_time=true)
text = ""
stage_trans = I18n.t('application_form.stage')
last_is_disagree = (self.review_status == 1)
last_idx = (self.process_stage - 1).to_s
self.agree_reviewer_ids.each do |i, member_id|
m = MemberProfile.find(member_id) rescue nil
t = agree_reviewer_times[i]
if m
text += "#{I18n.t('application_form.num.'+(i.to_i+1).to_s)}#{stage_trans}: #{m.tmp_name}<br>"
text += "#{I18n.t('application_form.num.'+(i.to_i+1).to_s)}#{stage_trans}: #{m.tmp_name} "
if i == last_idx && last_is_disagree
text += I18n.t('application_form.link_choice.disagree')
else
text += I18n.t('application_form.link_choice.agree')
end
if include_time && t
text += " (#{t.to_time.strftime("%Y/%m/%d %H:%M")})"
end
text += "<br>"
end
end
text
@ -173,10 +226,11 @@ class ApplicationFormSignup
field_name = set.field_name
next if set.disabled || except_fields.include?(field_name)
value = self.send(field_name) rescue nil
next if value.nil?
localize = self.fields[field_name].options[:localize]
next if value.nil? && !localize
if field_name == "status"
value = I18n.t("application_form.registration_status_#{value}")
elsif self.fields[field_name].options[:localize]
elsif localize && field_name != "unit"
values = self.send("#{field_name}_translations").select{|k,v| v.present?}
value = ""
if values.count == 0

View File

@ -0,0 +1,37 @@
<div class="control-group">
<div class="control-label muted"><%= t('application_form_signup.procedure') %></div>
<div class="controls" id="procedure_block">
<% host_url = Site.first.root_url
if host_url == "http://"
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=>@application_form_signup.id.to_s, :cipher=>@application_form_signup.get_cipher_stage(@application_form_signup.process_stage))
agree_link += "&reviewer=#{current_user.member_profile_id}"
agree_link = nil unless OrbitHelper.user_can_edit?(@application_form_signup) || @application_form.organizer_id == current_user.member_profile_id
%>
<%= @application_form_signup.procedure(agree_link).html_safe %>
<script>
$('.agree_link, .disagree_link').click(function(event){
event.preventDefault();
var href = $(this).attr('href');
$.get(href).done(function(html){
var text = $(html).find('.agree_text, .disagree_text, .finish_text, .error_text').text().trim();
alert(text);
$.get(window.location.href).done(function(html){
$(html).find('#procedure_block, #review_progress_block').each(function(i, v){
var id = $(v).attr('id');
$('#' + id).replaceWith(v);
});
})
})
return false;
})
</script>
</div>
</div>
<div class="control-group">
<div class="control-label muted"><%= t('application_form_signup.records') %></div>
<div class="controls" id="review_progress_block">
<%= @application_form_signup.review_progress(true, true).html_safe %>
</div>
</div>

View File

@ -0,0 +1,57 @@
<fieldset class="form-horizontal main-forms">
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/fileupload" %>
<%= stylesheet_link_tag "lib/main-list" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
<%= javascript_include_tag "lib/datetimepicker/date.time.picker.js" %>
<%= javascript_include_tag "lib/file-type" %>
<%= javascript_include_tag "lib/module-area" %>
<% end %>
<style type="text/css">
.form-horizontal .control-label{
padding-top: 0;
}
</style>
<!-- Input Area -->
<div class="input-area">
<!-- Language -->
<div class="tab-content">
<!-- Title -->
<div class="control-group">
<div class="control-label muted"><%= t('application_form.title') %></div>
<div class="controls">
<%= @application_form.title %>
</div>
</div>
<div class="control-group">
<div class="control-label muted"><%= t('application_form_signup.created_at') %></div>
<div class="controls">
<%= @application_form_signup.created_at.strftime("%Y/%m/%d %H:%M") %><%= @application_form_signup.ip.present? ? " (#{@application_form_signup.ip})" : "" %>
</div>
</div>
<%= render :partial => 'view' %>
<% fields_info = @application_form_signup.get_display_fields %>
<% fields_info.each do |info| %>
<div class="control-group">
<div class="control-label muted"><%= info['title'] %></div>
<div class="controls">
<%= info['value'] %>
</div>
</div>
<% end %>
</div>
</div>
<div class="form-actions">
<%= link_to t('application_form.go_back'), "/admin/application_forms/#{@application_form.id}/application_form_signup", :class=>"btn" %>
</div>
</fieldset>

View File

@ -51,7 +51,7 @@
val += "<div class=\"quick-edit\">
<ul class=\"nav nav-pills\">"
if @can_edit
val += "<li><a href=\"/admin/application_form_signups/#{application_form_signup.id}/edit\">#{t(:edit)}</a></li>
val += "<li><a href=\"/admin/application_form_signups/#{application_form_signup.id}/view\">#{t('application_form.view')}</a></li>
<li><a href=\"#{print_admin_application_form_path(application_form_signup.id)}\" target=\"_blank\">#{t('application_form.print')}</a></li>
<li><a href=\"#{admin_application_form_signup_path(application_form_signup.id)}\" class=\"delete text-error\" rel=\"nofollow\" data-method=\"delete\" data-confirm=\"Are you sure?\">#{t(:delete_)}</a></li>"
end
@ -69,7 +69,7 @@
val += "<div class=\"quick-edit\">
<ul class=\"nav nav-pills\">"
if @can_edit
val += "<li><a href=\"/admin/application_form_signups/#{application_form_signup.id}/edit\">#{t(:edit)}</a></li>
val += "<li><a href=\"/admin/application_form_signups/#{application_form_signup.id}/view\">#{t('application_form.view')}</a></li>
<li><a href=\"#{admin_application_form_signup_path(application_form_signup.id)}\" class=\"delete text-error\" rel=\"nofollow\" data-method=\"delete\" data-confirm=\"Are you sure?\">#{t(:delete_)}</a></li>"
end
val += "</ul>
@ -115,6 +115,7 @@
end %>
<% elsif names[0] == "application_form_signup" %>
<% val = (application_form_signup.send("display_"+names[1]) rescue application_form_signup.send(names[1])) rescue nil %>
<% val = val.strftime('%Y/%m/%d %H:%M') if names[1] == 'created_at' %>
<% elsif names[0] == "application_form_review_result" %>
<% if names[1] == "review" %>
<% val = contribute_ids.map{|contribute_id| "<a href=\"#{edit_admin_application_form_review_result_path(contribute_id)}\" class=\"btn\">#{t("application_form.review")}</a>"} %>

View File

@ -107,6 +107,7 @@
<th><%= t('application_form.name') %></th>
<th><%= t('application_form.placeholder') %></th>
<th><%= t('application_form.disable') %></th>
<th></th>
<!-- <th><%= t('application_form.hidden') %></th> -->
</thead>
<tbody>
@ -126,8 +127,23 @@
<input type="hidden" class="field_set" name='<%= "application_form_main[application_form_signup_field_sets][#{signup_index}][disabled]" %>' value="false">
<%= check_box_tag("application_form_main[application_form_signup_field_sets][#{signup_index}][disabled]", true ,attr_signup.disabled) %>
</td>
<td>
<% if attr_signup.field_name != 'recaptcha' %>
<td style="padding-left: 1em;">
<% if attr_signup.field_name == 'email' %>
<label for="application_form_email_regex" style="float: left;margin-right: 0.3em;"><%= t("application_form.email_regex") %>:</label>
<%= f.check_box :email_regex_enable, {:id=>"email_regex_enable", :style=>"float: left;"} %><%= t("ask.enable") %>
<div style="clear: both;"></div>
<%= f.text_field :email_regex, {:id=>"application_form_email_regex", :style => "width: 30em;"}.merge(f.object.email_regex_enable ? {} : {:disabled=>"disabled"}) %>
<script>
$("#email_regex_enable").click(function(){
if($(this).prop("checked")){
$("#application_form_email_regex").removeAttr("disabled");
}else{
$("#application_form_email_regex").attr("disabled","disabled");
}
})
</script>
<% end %>
<% if false #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"> -->
<%= 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) %>
@ -370,13 +386,13 @@
<% content_for :page_specific_javascript do %>
<script>
function check_members_button(){
$('.controls>.members').each(function(){
if ($(this).parent().find('select[name="application_form_main[reviewer_type_list][]"]').val()=='fixed'){
$(this).removeClass('hide');
}else{
$(this).addClass('hide');
}
})
// $('.controls>.members').each(function(){
// if ($(this).parent().find('select[name="application_form_main[reviewer_type_list][]"]').val()=='fixed'){
// $(this).removeClass('hide');
// }else{
// $(this).addClass('hide');
// }
// })
}
$(function() {
$("#main-wrap").after("");

View File

@ -2,19 +2,27 @@
<% @field_name_translations = [] %>
<% default_hidden = [] %>
<%
default_application_form_signup_fields = ["serial_number", "review_progress"]
default_show = []
default_application_form_signup_fields = ApplicationFormMain::DefaultSignupFields
default_application_form_signup_fields.each do |f|
@field_names << "application_form_signup.#{f}"
@field_name_translations << t("application_form_signup.#{f}")
default_show << "application_form_signup.#{f}"
end
%>
<% if @application_form.present? %>
<% @max_stage = @application_form.get_max_stage %>
<% if @application_form.application_form_signup_field_sets.count != 0 %>
<% @application_form.application_form_signup_field_sets.each do |field_set| %>
<% next if field_set.field_name == "password" %>
<% default_hidden << "application_form_signup_field_set.#{field_set.field_name}" if (field_set.hidden) %>
<% @field_names << "application_form_signup_field_set.#{field_set.field_name}" %>
<%
field_name = field_set.field_name
if ApplicationFormMain::ExceptFieldSetDisplays.include?(field_name)
default_hidden << "application_form_signup_field_set.#{field_name}"
next
end
%>
<% default_hidden << "application_form_signup_field_set.#{field_name}" if (field_set.hidden) %>
<% @field_names << "application_form_signup_field_set.#{field_name}" %>
<% @field_name_translations << field_set.name[I18n.locale] %>
<% end %>
<% else %>
@ -28,17 +36,6 @@
<% @field_names << "application_form_signup_fields.#{s.key}" %>
<% @field_name_translations << s.title %>
<% end %>
<% if @application_form.application_form_submission_field_sets.count != 0 %>
<% show1 = !(@application_form.application_form_submission_field_sets.select{|v| v.field_name=='title'}[0].hidden)
show2 = !(@application_form.application_form_submission_field_sets.select{|v| v.field_name=='file'}[0].hidden)
show3 = !(@application_form.application_form_submission_field_sets.select{|v| v.field_name=='description'}[0].hidden)
%>
<% else %>
<% show1 = true
show2 = true
show3 = true
%>
<% end %>
<% @application_form.application_form_submission_fields.each do |s| %>
<% @field_names << "application_form_submission_fields.#{s.key}" %>
<% if s.markup != "application_form_preferred_session"
@ -48,8 +45,12 @@
end %>
<% end %>
<% @display_field = @application_form_signup_admin_setting.display_field rescue [] %>
<% if @display_field.blank?
<%
if @display_field.blank?
@display_field = @field_names - default_hidden
else
@display_field = @display_field - ApplicationFormMain::ExceptFieldSetDisplays.map{|f| "application_form_signup_field_set.#{f}"}
@display_field = (ApplicationFormMain::StaticSignupFields + @display_field).uniq
end %>
<% if @enable_review_result
@field_names.insert(1,"application_form_review_result.review")
@ -65,13 +66,10 @@
@display_field << "application_form_review_result.presentation_type"
end%>
<% else %>
<% @field_names = [] %>
<% @field_name_translations = [] %>
<% default_show = [] %>
<% application_form_signup_field_sets = ApplicationFormSignupFieldSet.all.uniq{|s| s.field_name} %>
<% if application_form_signup_field_sets.count != 0 %>
<% application_form_signup_field_sets.each do |field_set| %>
<% next if field_set.field_name == "password" %>
<% next if ApplicationFormMain::ExceptFieldSetDisplays.include?(field_set) %>
<% default_show << "application_form_signup_field_set.#{field_set.field_name}" if !(field_set.hidden) %>
<% @field_names << "application_form_signup_field_set.#{field_set.field_name}" %>
<% @field_name_translations << field_set.name[I18n.locale] %>
@ -87,19 +85,17 @@
<% @field_names << "application_form_signup_fields.#{s.key}" %>
<% @field_name_translations << s.title %>
<% end %>
<% show1 = true
show2 = true
show3 = true
%>
<% application_form_submission_fields = ApplicationFormSignupField.all.uniq{|s| s.key} %>
<% application_form_submission_fields.each do |s| %>
<% @field_names << "application_form_submission_fields.#{s.key}" %>
<% @field_name_translations << s.title %>
<% end %>
<% @display_field = @application_form_signup_admin_setting.display_field %>
<% @display_field.delete("application_form_signup_field_set.password") %>
<% @display_field.delete("application_form_signup_field_set.recaptcha") %>
<% if @display_field.blank?
@display_field = default_show
<%
if @display_field.blank?
@display_field = default_show
else
@display_field = @display_field - ApplicationFormMain::ExceptFieldSetDisplays.map{|f| "application_form_signup_field_set.#{f}"}
@display_field = (ApplicationFormMain::StaticSignupFields + @display_field).uniq
end %>
<% end %>

View File

@ -38,7 +38,7 @@
</thead>
<tbody>
<% @field_names[((i/max_length) *max_length) ..i].each do |fn|%>
<td><%= check_box_tag "#{f.object_name}[display_field][]",fn , @display_field.include?(fn) %></td>
<td><%= check_box_tag "#{f.object_name}[display_field][]",fn , @display_field.include?(fn), (ApplicationFormMain::StaticSignupFields.include?(fn) ? {disabled: 'disabled'} : {}) %></td>
<% end %>
</tbody>
</table>

View File

@ -0,0 +1,131 @@
<% unless @include_js_css_flag %>
<%= javascript_include_tag "lib/checkbox.card.js" %>
<%= stylesheet_link_tag 'basic/global' %>
<%= stylesheet_link_tag 'member_select' %>
<style>
.modal-backdrop, .modal-backdrop.fade.in {
opacity: 0.8;
filter: alpha(opacity=80);
}
.modal-header {
padding: 9px 15px;
border-bottom: 1px solid #eee;
}
.modal-header h3 {
margin: 0;
line-height: 30px;
font-weight: bold;
color: inherit;
text-rendering: optimizelegibility;
}
.modal-body input, .modal-body label {
font-size: 14px;
font-weight: normal;
line-height: 20px;
}
.modal {
position: fixed;
top: 10%;
left: 50%;
z-index: 1050;
width: 560px;
margin-left: -280px;
background-color: #ffffff;
border: 1px solid #999;
border: 1px solid rgba(0, 0, 0, 0.3);
*border: 1px solid #999;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
outline: none;
-webkit-box-shadow: 0 3px 7px rgb(0 0 0 / 30%);
-moz-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
box-shadow: 0 3px 7px rgb(0 0 0 / 30%);
-webkit-background-clip: padding-box;
-moz-background-clip: padding-box;
background-clip: padding-box;
}
.modal-body input[type="checkbox"] {
cursor: pointer;
}
</style>
<% @include_js_css_flag = true %>
<% end %>
<% index = '' unless defined?(index) %>
<div id="selected_<%=select_name rescue 'email_users'%>" class="selected_users <%=extra_class rescue ''%>">
<% email_members.each do |email_member| %>
<span class="alert alert-info selected_user" id="<%= email_member.id %>">
<span class='close remove_user' onclick='removeUser<%=index%>($(this))'>x</span>
<%= email_member.name %>
<%= hidden_field_tag field, email_member.id %>
</span>
<% end %>
</div>
<a class="btn btn-primary btn-small select_user_modal<%=index%>"><%= t('application_form.select') %></a>
<script type="text/javascript">
mail_users<%=index%> = Array();
$(function(){
$.each($("#selected_<%=select_name rescue'email_users'%> .selected_user"),function(i){
mail_users<%=index%>.push($(this).attr("id"));
});
$(".select_user_modal<%=index%>").click(function(){
if($("#select_user<%=index%>").length==0) {
$("body").append("<span id='select_user<%=index%>'><%=escape_javascript(render(:partial=>'application_forms/select_emails', :locals=>{:member_profiles=>member_profiles,:@index=>(index)})) %></span>");
$('.checkbox-card').cardCheck();
}
$("#member-filter").modal('show');
});
});
var removeUser<%=index%> = function(user){
var id = $(user).parent().attr('id');
$("#select_user<%=index%> input[type='checkbox'][value=\""+id+"\"]").prop('checked', false).parent('.check-item').removeClass('active').css('display','');
mail_users<%=index%> = $.grep(mail_users<%=index%>, function(value) {return value != id;});
$(user).parent().remove();
}
Array.prototype.unique = function(){
const distinct = (value, index, self) =>{
return self.indexOf(value) === index;
}
return this.filter(distinct);
}
var updateUsers<%=index%> = function(){
$("#select_user<%=index%> .check-item input[type='checkbox']:checked").each(function(i, v){
mail_users<%=index%>.push($(v).val());
});
$("#selected_<%=select_name rescue'email_users'%>").html("");
mail_users<%=index%> = mail_users<%=index%>.unique();
$.each(mail_users<%=index%>, function(i, user_id){
var username = $("input[value='"+user_id+"']").parent().find(".user-name").html();
$("#selected_<%=select_name rescue'email_users'%>").append(
" <span class='alert alert-info selected_user' id='"+user_id+"'>"+
"<span class='close remove_user' onclick='removeUser<%=index%>($(this))'>x</span>"+
username+
"<input type='hidden' name='<%= field %>' value='"+user_id+"' >"+
"</span>"
);
});
}
var updateModal<%=index%> = function(){
$.each($("#selected_<%=select_name rescue'email_users'%> .selected_user"),function(){
var user_id = $(this).attr('id');
$("input[value='"+user_id+"']").parent("li").hide();
});
$('.check-item').click(function(){
var user_id = $(this).find("input[type='checkbox']").val();
$(this).toggleClass("active");
if($(this).hasClass("active")){
mail_users<%=index%>.push(user_id);
}else{
mail_users<%=index%> = $.grep(mail_users<%=index%>, function(value) {return value != user_id;});
}
});
}
</script>

View File

@ -0,0 +1,50 @@
<div id="member-filter" class="modal fade">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3><%= t('list.user') %></h3>
</div>
<div class="modal-body">
<div class="tabbable tabs-left">
<fieldset class="clearfix">
<div class="member-filter-result nano">
<div class="content">
<i class="icon-search"></i>
<input class="search_names" placeholder="<%=t('users.name')%>" style="margin: 1em;">
<div style="margin-bottom: 1em;"></div>
<ul class="checkbox-card clearfix">
<% member_profiles.each do |profile| %>
<% next if profile.email.nil? %>
<li class="check-item">
<label>
<%= image_tag profile.get_avatar, class: "user-pic" %>
<span class="user-name"><%= profile.name %></span>
</label>
<%= check_box_tag 'email_user_ids[]', profile.id , false , :id => "email_user_ids_#{(profile.id rescue '')}" %>
</li>
<% end %>
</ul>
</div>
</div>
</fieldset>
<div class="form-actions condition">
<button type="button" class="btn" data-dismiss="modal"><%= t(:cancel) %></button>
<button type="button" class="btn btn-primary" data-dismiss="modal" onclick="updateUsers<%=@index rescue ''%>()"><%= t(:submit) %></button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
$('.search_names').off('input').on('input',function(){
var name = $(this).val();
var $check_items = $(this).parent().find('.check-item');
$check_items.each(function(i,item){
if( $(item).find('.user-name').text().search(name) == -1){
$(item).css('display','none');
}else{
$(item).css('display','');
}
})
})
})
</script>

View File

@ -4,6 +4,7 @@
@application_form_signup = data["application_form_signup"]
@time_now = data["time_now"]
@form_index = 0
email_regex = @application_form.get_email_regex(true)
if data["prefix_url"]
prefix_url = data["prefix_url"]
else
@ -107,6 +108,39 @@
<div class="col-sm-10">
<%= f.email_field :email, :class=>"input-medium form-control availibility", :placeholder=> signup_field.placeholder[I18n.locale], :required => true %>
</div>
<script type="text/javascript">
$(document).ready(function(){
function scrollIntoView(selector, offset = 0) {
window.scroll(0, document.querySelector(selector).offsetTop - offset);
}
var email_regex = "<%=email_regex%>";
if(email_regex.length != 0){
email_regex = new RegExp(email_regex);
var submit_flag = false;
var $form = $("#new-application_form-signup");
var email_field = $('#application_form_signup_email');
if($form.length != 0 && email_field.length != 0){
$form.submit(function(){
if(!submit_flag){
submit_flag = true;
if(email_regex.test(email_field.val())){
submit_flag = false;
}else{
email_field.css("border", "2px solid red");
scrollIntoView('#application_form_signup_email');
alert("<%=t('application_form.please_check_email_format')%>");
email_field.one("input",function(){
email_field.css("border", "");
})
submit_flag = false;
return false;
}
}
})
}
}
})
</script>
<% elsif signup_field.field_name == 'note' %>
<div class="col-sm-10">
<div class="input-append">
@ -173,6 +207,39 @@
<div class="col-sm-10">
<%= f.email_field :email, :class=>"input-medium form-control availibility", :placeholder=> t(:email), :required => true %>
</div>
<script type="text/javascript">
$(document).ready(function(){
function scrollIntoView(selector, offset = 0) {
window.scroll(0, document.querySelector(selector).offsetTop - offset);
}
var email_regex = "<%=email_regex%>";
if(email_regex.length != 0){
email_regex = new RegExp(email_regex);
var submit_flag = false;
var $form = $("#new-application_form-signup");
var email_field = $('#application_form_signup_email');
if($form.length != 0 && email_field.length != 0){
$form.submit(function(){
if(!submit_flag){
submit_flag = true;
if(email_regex.test(email_field.val())){
submit_flag = false;
}else{
email_field.css("border", "2px solid red");
scrollIntoView('#application_form_signup_email');
alert("<%=t('application_form.please_check_email_format')%>");
email_field.one("input",function(){
email_field.css("border", "");
})
submit_flag = false;
return false;
}
}
})
}
}
})
</script>
</div>
<% end %>
@ -180,11 +247,12 @@
<% if flag %>
<div class="form-group">
<label for="status" class="col-sm-2 control-label"><%= t("application_form.reviewers.#{k+1}") %></label>
<div class="col-sm-10">
<div class="col-sm-10">
<% tmp = Array(@application_form.reviewer_ids_list[k]) %>
<% if @application_form.reviewer_type_list[k]=='fixed' %>
<%= MemberProfile.where(:id.in=>Array(@application_form.reviewer_ids_list[k])).collect{|m| m.name}.join(', ') %>
<%= MemberProfile.where(:id.in=>tmp).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: 'application_forms/email_selection_box', locals: {field: "#{f.object_name}[reviewer_ids_list][#{k}][]", email_members: [], member_profiles: (tmp.count == 0 ? MemberProfile.all : MemberProfile.where(:id.in=>tmp)), index: "#{k+1}", select_name: "reviewer_ids_list_#{k}"} %>
<% end %>
</div>
</div>
@ -306,11 +374,7 @@
type : "get",
success : function(data){
if( data.success == true ){
alert("1tttt");
}else{
alert("1ssss2");
}
}
})
@ -338,3 +402,8 @@ alert("1ssss2");
<%= t('application_form.sign_up_overdue') %>
<% end %>
<script type="text/javascript">
var email_regex = "<%=email_regex%>";
if(email_regex.length != 0)
email_regex = new RegExp(email_regex);
</script>

View File

@ -27,6 +27,13 @@ en:
abstract_number: Abstract number
presentation_type: Presentation
application_form:
mail_exist: "mail exist!"
select: Select
go_back: "Go back"
view: View
please_check_email_format: "Please check email format!"
enable: Enable
email_regex: Email validation regex
version: Version
confidentiality: Confidentiality
this_link_has_expired: "This Link has been clicked and expired!"
@ -226,6 +233,10 @@ en:
content: Content #內容
application_form_signup:
procedure: Procedure
records: Records
created_at: "Processing Time"
ip: "IP"
review_progress: Review progress
reviewer_ids_list: Reviewer Stages
serial_number: Application No.

View File

@ -28,6 +28,13 @@ zh_tw:
abstract_number: 摘要編號
presentation_type: 發表方式
application_form:
mail_exist: "mail已存在!"
select: 選擇
go_back: "回上一頁"
view: 查看
please_check_email_format: "請檢察email是否正確!"
enable: 啟用
email_regex: Email驗證regex
version: 表單版本
confidentiality: 機密等級
this_link_has_expired: "此連結已經點選並已失效!"
@ -227,6 +234,10 @@ zh_tw:
content: 內容
application_form_signup:
procedure: 審查程序
records: 審查紀錄
created_at: "申請時間"
ip: "IP"
review_progress: 審核進度
reviewer_ids_list: 審查階段
serial_number: 申請序號

View File

@ -50,7 +50,11 @@ Rails.application.routes.draw do
end
end
resources :application_form_agreements
resources :application_form_signups
resources :application_form_signups, except: [:edit, :update] do
member do
get 'view'
end
end
resources :application_form_submission_values
resources :application_form_review_results
resources :application_form_item_contents

View File

@ -39,21 +39,21 @@ module ApplicationForm
:active_for_action=>{'admin/application_forms'=>'categories'},
:active_for_category => 'ApplicationForm',
:available_for => 'managers'
context_link 'application_form.set_application_form_items',
:link_path=>"admin_application_form_items_path" ,
:priority=>4,
:active_for_action=>{'admin/application_forms'=>'application_form_items'},
:available_for => 'managers'
# context_link 'application_form.set_application_form_items',
# :link_path=>"admin_application_form_items_path" ,
# :priority=>4,
# :active_for_action=>{'admin/application_forms'=>'application_form_items'},
# :available_for => 'managers'
context_link 'application_form.set_application_form_agreements',
:link_path=>"admin_application_form_agreements_path" ,
:priority=>5,
:active_for_action=>{'admin/application_forms'=>'application_form_agreements'},
:available_for => 'managers'
context_link 'application_form.enquiry_for_applicants',
:link_path=>"admin_application_form_enquiry_for_applicants_path" ,
:priority=>6,
:active_for_action=>{'admin/application_forms'=>'enquiry_for_applicants'},
:available_for => 'users'
# context_link 'application_form.enquiry_for_applicants',
# :link_path=>"admin_application_form_enquiry_for_applicants_path" ,
# :priority=>6,
# :active_for_action=>{'admin/application_forms'=>'enquiry_for_applicants'},
# :available_for => 'users'
context_link 'application_form.setting',
:link_path=>"setting_admin_application_forms_path" ,
:priority=>7,