This commit is contained in:
邱博亞 2024-01-18 23:46:47 +08:00
parent 8768186242
commit 61fa9d03f8
4 changed files with 71 additions and 22 deletions

View File

@ -501,7 +501,20 @@ class Admin::ApplicationFormsController < OrbitAdminController
application_form.application_form_email_sets.create(value)
end
end
redirect_to params['referer_url']
if params['referer_url'].blank?
fallback_location = admin_application_forms_path
if Is_Rails5
redirect_back(fallback_location: fallback_location) and return
else
begin
redirect_to :back and return
rescue
redirect_to fallback_location and return
end
end
else
redirect_to params['referer_url'] and return
end
end
@ -929,7 +942,31 @@ class Admin::ApplicationFormsController < OrbitAdminController
(ApplicationFormSignup.attribute_names + ['recaptcha']).each do |attr_signup|
next if except_attributes.include?(attr_signup)
signup_set = @application_form.application_form_signup_field_sets.select{|v| v.field_name==attr_signup }
if signup_set.length==0
fix_trans = false
if signup_set.length > 0 && signup_set[0].name[I18n.locale.to_s].include?("Translation missing")
fix_trans = true
end
if signup_set.length==0 || fix_trans
name1 = Hash.new
now_locale = I18n.locale
I18n.available_locales.each do |locale|
I18n.with_locale(locale) do
tmp = t("application_form_signup.#{attr_signup}", :default=>nil)
if tmp.nil?
tmp = t("application_form.#{attr_signup}", :default=>nil)
end
if tmp
name1[locale] = tmp
end
end
end
I18n.locale = now_locale
if fix_trans
signup_set.each do |s|
s.update(name:name1,placeholder:name1)
end
next
end
if ApplicationFormSignup::DefaultEnableFields.include? attr_signup
disabled = false
else
@ -940,17 +977,10 @@ class Admin::ApplicationFormsController < OrbitAdminController
else
hidden = true
end
name1 = Hash.new
now_locale = I18n.locale
I18n.available_locales.each do |locale|
I18n.locale = locale
name1[locale] = t("application_form_signup.#{attr_signup}")
end
I18n.locale = now_locale
if save_flag
@application_form.application_form_signup_field_sets.create(field_name:attr_signup,disabled:disabled,hidden:hidden,name:name1,placeholder:name1)
@application_form.application_form_signup_field_sets.create(field_name:attr_signup,disabled:disabled,hidden:hidden,name:name1,placeholder:name1)
else
@application_form.application_form_signup_field_sets.new(field_name:attr_signup,disabled:disabled,hidden:hidden,name:name1,placeholder:name1)
@application_form.application_form_signup_field_sets.new(field_name:attr_signup,disabled:disabled,hidden:hidden,name:name1,placeholder:name1)
end
end
end
@ -958,18 +988,35 @@ class Admin::ApplicationFormsController < OrbitAdminController
ApplicationFormSignupContribute.attribute_names.each do |attr_submission|
next if except_attributes.include?(attr_submission)
signup_set = @application_form.application_form_submission_field_sets.select{|v| v.field_name==attr_submission }
if signup_set.length==0
fix_trans = false
if signup_set.length > 0 && signup_set[0].name[I18n.locale.to_s].include?("Translation missing")
fix_trans = true
end
if signup_set.length==0 || fix_trans
name1 = Hash.new
now_locale = I18n.locale
I18n.available_locales.each do |locale|
I18n.locale = locale
name1[locale] = t("application_form_signup.#{attr_submission}")
I18n.with_locale(locale) do
tmp = t("application_form_signup.#{attr_submission}", :default=>nil)
if tmp.nil?
tmp = t("application_form.#{attr_submission}", :default=>nil)
end
if tmp
name1[locale] = tmp
end
end
end
I18n.locale = now_locale
if fix_trans
signup_set.each do |s|
s.update(name:name1,placeholder:name1)
end
next
end
if save_flag
@application_form.application_form_submission_field_sets.create(field_name:attr_submission,name:name1,placeholder:name1)
@application_form.application_form_submission_field_sets.create(field_name:attr_submission,name:name1,placeholder:name1)
else
@application_form.application_form_submission_field_sets.new(field_name:attr_submission,name:name1,placeholder:name1)
@application_form.application_form_submission_field_sets.new(field_name:attr_submission,name:name1,placeholder:name1)
end
end
end

View File

@ -1,8 +1,8 @@
<%
data = action_data
@application_form = data["application_form"]
@application_form_signup = data["application_form_signup"]
@time_now = data["time_now"]
data = action_data
@application_form = data["application_form"]
@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"]
@ -11,7 +11,7 @@
prefix_url = OrbitHelper.url_to_show(@application_form.to_param)
end
%>
<% if @application_form.application_form_start_date < @time_now and ( @application_form.application_form_end_date.nil? or @application_form.application_form_end_date+1.days > @time_now ) %>
<% if @application_form.application_form_start_date && @application_form.application_form_start_date < @time_now && ( @application_form.application_form_end_date.nil? || @application_form.application_form_end_date+1.days > @time_now ) %>
<%#= stylesheet_link_tag "lib/main-forms" %>
<% notice = flash["notice"] || params[:notice] %>
@ -389,7 +389,7 @@
})();
</script>
<% elsif @application_form.application_form_start_date > @time_now %>
<% elsif @application_form.application_form_start_date && @application_form.application_form_start_date > @time_now %>
<%= t('application_form.sign_up_not_yet') %>

View File

@ -27,6 +27,7 @@ en:
abstract_number: Abstract number
presentation_type: Presentation
application_form:
save_success: "Save Successfully!"
mail_exist: "mail exist!"
select: Select
go_back: "Go back"

View File

@ -28,6 +28,7 @@ zh_tw:
abstract_number: 摘要編號
presentation_type: 發表方式
application_form:
save_success: "儲存成功!"
mail_exist: "mail已存在!"
select: 選擇
go_back: "回上一頁"