fix error

This commit is contained in:
邱博亞 2022-12-31 16:05:26 +08:00
parent 5b7cac3970
commit 636a7aa71d
3 changed files with 7 additions and 3 deletions

View File

@ -439,7 +439,7 @@ class Admin::AsksController < OrbitAdminController
def get_fields_with_key(s)
fields_with_key = {}
fields_with_key['default_values'] = s.default_setting.collect{|k,v| [k, process_trans(s.field_name_translations(k))] if v && !['ask_category_id','recaptcha'].include?(k)}.compact
fields_with_key['default_values'] = [['ask_category_id', process_trans(s.field_name_translations('ask_category_id'))]] + fields_with_key['default_values']
fields_with_key['default_values'] = [['ask_category_id', process_trans(s.field_name_translations('ask_category_id'))]] + [['situation', process_trans(I18n.available_locales.map{|v| [v.to_s, I18n.with_locale(v){I18n.t('ask.situation')}]}.to_h)]] + fields_with_key['default_values']
fields_with_key['default_values'] = fields_with_key['default_values'].to_h
fields_with_key['custom_values'] = s.custom_fields.collect{|k, field_setting| [k, process_trans(field_setting['field'])]}.to_h
fields_with_key
@ -460,6 +460,7 @@ class Admin::AsksController < OrbitAdminController
end
ask_category_settings[nil] = ask_default_setting
fields_with_key_group[nil] = get_fields_with_key(ask_default_setting)
situations = AskTicketStatus.all.collect{|situation| [situation.key, situation.get_title_translations]}
render xlsx: 'do_export.xlsx',
handlers: ['axlsx'],
filename: "Questions-#{date_start}-#{date_end}.xlsx",
@ -467,7 +468,8 @@ class Admin::AsksController < OrbitAdminController
:ask_category_settings => ask_category_settings,
:fields_with_key_group => fields_with_key_group,
:categories => categories.collect{|c| [c.id, c]}.to_h,
:ask_questions => ask_questions
:ask_questions => ask_questions,
:situations => situations
}
end

View File

@ -329,7 +329,7 @@ module Admin::AsksHelper
file_value = value[0] rescue nil
file_path = value[1] rescue nil
file_required = v['required']=='true' ? 'required="required"' : ''
readonly ? "<img src=\"#{file_path}\" alt=\"#{file_value}\">" : "<div class=\"file-selector\"><label class=\"ui-button\">
readonly ? (file_value ? "<img src=\"#{file_path}\" alt=\"#{file_value}\">" : "") : "<div class=\"file-selector\"><label class=\"ui-button\">
<input data-image-src=\"#{file_path}\" style=\"position: absolute;width:0.1em;padding: 0;border: 0;opacity: 0;left: 50%;top: 0;\" accept=\"image/*\" class=\"upload\" name=\"#{field_name}\" #{file_required} type=\"file\" value=\"#{file_value}\"/>
<i class=\"fa fa-photo\"></i> #{t('ask.upload_image')}
</label><div class=\"filename\"></div></div>"

View File

@ -41,6 +41,8 @@ wb.add_worksheet(name: "Ask Question") do |sheet|
else
text = I18n.t('ask.no')
end
when 'situation'
text = situations[ask_question.situation].join('/') rescue ''
end
row_group[field] = text
end