fix error
This commit is contained in:
parent
b05fc0f96f
commit
d4d45c6047
|
@ -155,13 +155,13 @@ class Admin::AsksController < OrbitAdminController
|
|||
@filter_fields = filter_fields(@categories)
|
||||
# 列表欄位
|
||||
@table_fields = @ask_list_setting.default_fields.select{|f| @ask_setting.default_setting[f].nil? || @ask_setting.default_setting[f] }
|
||||
if @category_id.present?
|
||||
if !category_id.nil?
|
||||
ask_setting = AskCategorySetting.where(:category_id=>@category_id, :use_default.ne=>true).first
|
||||
if ask_setting.nil?
|
||||
ask_setting = AskSetting.first
|
||||
tmp = ask_setting.custom_fields.map{|k,v| ["default@#{k}", v]}.to_h
|
||||
else
|
||||
tmp = ask_setting.custom_fields.map{|k,v| ["custom@#{k}", v]}.to_h
|
||||
tmp = ask_setting.custom_fields.map{|k,v| ["custom@#{category_id}@#{k}", v]}.to_h
|
||||
end
|
||||
list_setting_custom_fields = @ask_list_setting.custom_fields
|
||||
else
|
||||
|
@ -309,7 +309,7 @@ class Admin::AsksController < OrbitAdminController
|
|||
k = custom_fields.keys[i] rescue nil
|
||||
if !k.blank?
|
||||
v = custom_fields[k] rescue {}
|
||||
text_tp = Admin::AsksHelper.show_on_front(k,v,@ask_question.custom_values[k],true,true)
|
||||
text_tp = Admin::AsksHelper.show_on_front(k,v,@ask_question,true,true)
|
||||
text = text.gsub(format_text,text_tp.to_s)
|
||||
end
|
||||
when /custom\d+/
|
||||
|
@ -317,7 +317,7 @@ class Admin::AsksController < OrbitAdminController
|
|||
k = custom_fields.keys[i] rescue nil
|
||||
if !k.blank?
|
||||
v = custom_fields[k] rescue {}
|
||||
text_tp = Admin::AsksHelper.show_on_front(k,v,@ask_question.custom_values[k],true)
|
||||
text_tp = Admin::AsksHelper.show_on_front(k,v,@ask_question,true)
|
||||
text = text.gsub(format_text,text_tp.to_s)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -207,7 +207,21 @@ module Admin::AsksHelper
|
|||
end
|
||||
end.join(' ')
|
||||
end
|
||||
def show_on_front(k,v,value=nil,readonly=false,lock=false)
|
||||
def show_on_front(k,v,object=nil,readonly=false,lock=false)
|
||||
value = nil
|
||||
if !object.nil?
|
||||
value = object.custom_values[k]
|
||||
if value.nil?
|
||||
if k.start_with("default@")
|
||||
value = object.custom_values[k.sub(/.*@/,'')]
|
||||
elsif k.start_with("custom@")
|
||||
category_id, k = k.scan(/custom@((?:(?!@).)*)@\w+/)[0][0]
|
||||
if category_id==object.category_id.to_s
|
||||
value = object.custom_values[k]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
field_name = "#{get_input_name_for_ask}[custom_values][#{k}]"
|
||||
begin
|
||||
case v['type']
|
||||
|
|
|
@ -108,7 +108,7 @@
|
|||
"<div class=\"control-group\">
|
||||
<label class=\"control-label\">#{required_pattern}#{v['field'][I18n.locale]}</label>
|
||||
<div class=\"controls\">
|
||||
#{show_on_front(k,v,@ask_question.custom_values[k],true)}
|
||||
#{show_on_front(k,v,@ask_question,true)}
|
||||
</div>
|
||||
</div>"
|
||||
end.join.html_safe %>
|
||||
|
|
|
@ -234,7 +234,7 @@
|
|||
<% end %>
|
||||
<% @table_ext_fields.each do |f, v| %>
|
||||
<td>
|
||||
<%= show_on_front(f,v,b.custom_values[f],true) %>
|
||||
<%= show_on_front(f,v,b,true) %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
"<div class=\"control-group\">
|
||||
<label class=\"control-label\">#{required_pattern}#{v['field'][I18n.locale]}</label>
|
||||
<div class=\"controls\">
|
||||
#{show_on_front(k,v,ask.custom_values[k],true)}
|
||||
#{show_on_front(k,v,ask,true)}
|
||||
</div>
|
||||
</div>"
|
||||
end.join.html_safe %>
|
||||
|
|
Loading…
Reference in New Issue