From d1266dcfa11209be9e6f5a722cb346f88c5582e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E5=8D=9A=E4=BA=9E?= Date: Mon, 5 Jun 2023 22:55:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=BE=A9=E5=AF=84=E4=BF=A1=E5=95=8F?= =?UTF-8?q?=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/asks/email.html.erb | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/app/views/asks/email.html.erb b/app/views/asks/email.html.erb index 6d053ea..ba25546 100644 --- a/app/views/asks/email.html.erb +++ b/app/views/asks/email.html.erb @@ -15,6 +15,10 @@ yes_trans = t('ask.yes') no_trans = t('ask.no') locale = I18n.locale.to_s + ask_setting = AskCategorySetting.enabled.where(category_id: question.category_id.to_s).first + ask_setting = AskSetting.first if ask_setting.nil? + is_cat_record = (ask_setting.class == AskCategorySetting) + tmp_ask_cat_id = (is_cat_record ? ask_setting.id.to_s : '') %> <% @data['disp_fields_infos'].each do |f, field_info| %> <% next if f == 'recaptcha' %> @@ -24,8 +28,25 @@ is_cat = false is_custom = false if f.include?("@") - f = field_info["key"] + field = f is_custom = true + is_field_enable = false + if field.start_with?("default@") + f = is_cat_record ? field : field[8..-1] + v = ask_setting.custom_fields[f] + if v + is_field_enable = true + end + elsif field.start_with?("custom@") && is_cat_record + if field.include?(tmp_ask_cat_id) + f = field[8+tmp_ask_cat_id.length..-1] + v = ask_setting.custom_fields[f] + if v + is_field_enable = true + end + end + end + next if !is_field_enable elsif f == 'ask_category_id' f = 'category_id' is_cat = true @@ -50,9 +71,9 @@ elsif type == "date" val = val["datetime"].values[0].values rescue [] if val.count == 2 - val = val[0].gsub('-', '/') + " ~ " + val[1].gsub('-', '/') + val = val[0].to_s.gsub('-', '/') + " ~ " + val[1].to_s.gsub('-', '/') else - val = val[0].gsub('-', '/') + val = val[0].to_s.gsub('-', '/') end elsif type == "instructions" val = field_info["instructions"][locale].to_s.html_safe rescue ""