fix error
This commit is contained in:
parent
3b2f8277a4
commit
b1d010d001
|
@ -156,7 +156,8 @@ class Admin::AsksController < OrbitAdminController
|
|||
# 列表欄位
|
||||
@table_fields = @ask_list_setting.default_fields.select{|f| @ask_setting.default_setting[f].nil? || @ask_setting.default_setting[f] }
|
||||
if @category_id.present?
|
||||
ask_setting = AskCategorySetting.where(:category_id=>@category_id).first
|
||||
ask_setting = AskCategorySetting.where(:category_id=>@category_id, :use_default.ne=>true).first
|
||||
ask_setting = AskSetting.first if ask_setting.nil?
|
||||
tmp = ask_setting.custom_fields
|
||||
list_setting_custom_fields = @ask_list_setting.custom_fields
|
||||
else
|
||||
|
@ -325,14 +326,14 @@ class Admin::AsksController < OrbitAdminController
|
|||
@print_setting = AskPrintSetting.first if @print_setting.nil?
|
||||
@save_name = @print_setting.save_name rescue ''
|
||||
@print_text = @print_setting.print_format rescue ''
|
||||
ask_setting = AskCategorySetting.where(category_id: @ask_question.category_id.to_s).first
|
||||
ask_setting = AskCategorySetting.where(category_id: @ask_question.category_id.to_s, :use_default.ne=>true).first
|
||||
ask_setting = AskSetting.first if ask_setting.nil?
|
||||
custom_fields = ask_setting.custom_fields
|
||||
@print_text = process_format_text(@print_text,custom_fields)
|
||||
@save_name = process_format_text(@save_name,custom_fields)
|
||||
end
|
||||
def edit
|
||||
@ask_setting = AskCategorySetting.where(category_id: @ask_question.category_id.to_s).first
|
||||
@ask_setting = AskCategorySetting.where(category_id: @ask_question.category_id.to_s, :use_default.ne=>true).first
|
||||
@ask_setting = AskSetting.first if @ask_setting.nil?
|
||||
@url = admin_ask_path(@ask_question)
|
||||
end
|
||||
|
|
|
@ -14,7 +14,8 @@ class AskListSetting
|
|||
def custom_fields_list
|
||||
locale = I18n.locale
|
||||
default_setting = AskSetting.first
|
||||
if self.category_id.blank?
|
||||
use_default = self.category_id.blank? || AskCategorySetting.where(:category_id=>self.category_id, :use_default.ne=>true).first.nil?
|
||||
if use_default
|
||||
fields = default_setting ? {I18n.t(:default) => default_setting.custom_fields.map{|k,v| ["default@#{k}",v['field'][locale]]}.to_h} : {}
|
||||
cat_ids_map = Category.where(:id.in=> AskCategorySetting.all.pluck(:category_id),:disabled.ne=>true).map{|c| [c.id.to_s, c.title]}.to_h
|
||||
fields = fields.merge(AskCategorySetting.where(:category_id.in => cat_ids_map.keys()).map{|c| [cat_ids_map[c.category_id] , c.custom_fields.select{|k,v| !(k.start_with?('default@'))}.map{|k,v| ["custom@#{c.id}@#{k}",v['field'][locale]]}]}.to_h)
|
||||
|
|
Loading…
Reference in New Issue