fix error
This commit is contained in:
parent
8a9c8fc17f
commit
e5c79ad013
|
@ -154,8 +154,7 @@ class Admin::AsksController < OrbitAdminController
|
|||
@categories = @module_app.categories.enabled.sort_by{|category| (((@module_app.asc rescue true) ? category.sort_number.to_i : -category.sort_number.to_i) rescue category.id)}
|
||||
@filter_fields = filter_fields(@categories)
|
||||
# 列表欄位
|
||||
@table_fields_default_fields = @ask_list_setting.default_fields.select{|f| @ask_setting.default_setting[f].nil? || @ask_setting.default_setting[f] }
|
||||
@table_fields = @table_fields_default_fields.map{|v| ['title'].include?(v) ? v : "ask.#{v}"}
|
||||
@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
|
||||
tmp = ask_setting.custom_fields
|
||||
|
|
|
@ -67,7 +67,7 @@ class AskSetting
|
|||
self.default_setting_required[k]
|
||||
end
|
||||
def default_field_name(k,locale=I18n.locale.to_s,use_checkbox_trans=false)
|
||||
I18n.with_locale(locale){ (use_checkbox_trans && ['agree_show','agree_usage'].include?(k.to_s)) ? I18n.t("ask.#{k}_checkbox") : I18n.t("mongoid.attributes.ask_question.#{k}")}
|
||||
I18n.with_locale(locale){ (use_checkbox_trans && ['agree_show','agree_usage'].include?(k.to_s)) ? I18n.t("ask.#{k}_checkbox") : ['serial_number','situation','ip'].include?(k) ? I18n.t("ask.#{k}") : I18n.t("mongoid.attributes.ask_question.#{k}")}
|
||||
end
|
||||
|
||||
def field_name_translations(k)
|
||||
|
|
|
@ -170,8 +170,7 @@
|
|||
<tr class="sort-header">
|
||||
<th style="width: 1em;"></th>
|
||||
<% @table_fields.each do |f| %>
|
||||
<% tmp = f.to_s.gsub(/ask\./,'') %>
|
||||
<%= thead(f) %>
|
||||
<%= ask_thead(f, @ask_setting.field_name(f)) %>
|
||||
<% end %>
|
||||
<% @table_ext_fields.each do |f, v| %>
|
||||
<%= ask_thead(f, v['field'][I18n.locale.to_s]) %>
|
||||
|
@ -189,53 +188,60 @@
|
|||
situation_trans = AskTicketStatus.all.map{|a| [a.key, a.title]}.to_h
|
||||
last_serial_number = @ask_setting.last_serial_number
|
||||
display_length = [last_serial_number.to_s.length + 1, 4].max
|
||||
edit_button_display_index = @table_fields.count > 3 ? 2 : @table_fields.count
|
||||
%>
|
||||
<% @askquestions.each do |b| %>
|
||||
<tr>
|
||||
<% is_editable = can_edit_or_delete?(b) %>
|
||||
<% is_editable = can_edit_or_delete?(b)
|
||||
ask_show_url = Page.where(:module=>'ask').first.url rescue nil
|
||||
edit_button_can_show = true
|
||||
%>
|
||||
<% content_for :edit_button do %>
|
||||
<div class="quick-edit">
|
||||
<ul class="nav nav-pills">
|
||||
<% if is_editable %>
|
||||
<li><a href="/<%= I18n.locale %>/admin/asks/<%=b.id.to_s%>/edit"><%= t(:edit) %></a></li>
|
||||
<li><a href="#" class="delete text-error" rel="/admin/asks/<%=b.id.to_s%>"><%= t(:delete_) %></a></li>
|
||||
<% end %>
|
||||
<li><a href="/<%= I18n.locale %>/admin/asks/<%=b.id.to_s%>/print" target="_blank"><%= t('ask.print') %></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
<td><% if is_editable %><input type="checkbox" class="batch_select" data-id="<%= b.id %>"><% end %></td>
|
||||
<% @table_fields_default_fields.each do |f| %>
|
||||
<% case f %>
|
||||
<% when 'serial_number' %>
|
||||
<td><%= b.get_serial_number(last_serial_number, display_length) %></td>
|
||||
<% when 'situation' %>
|
||||
<% @table_fields.each_with_index do |f,i| %>
|
||||
<td>
|
||||
<span class='label <%=situation_class_relation[b.situation]%>'><%= situation_trans[b.situation] %></span>
|
||||
</td>
|
||||
<% when 'ask_category_id' %>
|
||||
<td>
|
||||
<%= b.category.title rescue 'category not set' %>
|
||||
<div class="quick-edit">
|
||||
<ul class="nav nav-pills">
|
||||
<% if is_editable %>
|
||||
<li><a href="/<%= I18n.locale %>/admin/asks/<%=b.id.to_s%>/edit"><%= t(:edit) %></a></li>
|
||||
<li><a href="#" class="delete text-error" rel="/admin/asks/<%=b.id.to_s%>"><%= t(:delete_) %></a></li>
|
||||
<% end %>
|
||||
<li><a href="/<%= I18n.locale %>/admin/asks/<%=b.id.to_s%>/print" target="_blank"><%= t('ask.print') %></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
<% when 'title' %>
|
||||
<td>
|
||||
<% if b.situation == 'is_published' %>
|
||||
<%= link_to b.title,((Page.where(:module=>'ask').first.url+"?item=#{b.id}") rescue "javascript:alert('#{t('ask.no_index_page')}')") %>
|
||||
<% else %>
|
||||
<%= b.title %>
|
||||
<% case f %>
|
||||
<% when 'serial_number' %>
|
||||
<%= b.get_serial_number(last_serial_number, display_length) %>
|
||||
<% when 'situation' %>
|
||||
<span class='label <%=situation_class_relation[b.situation]%>'><%= situation_trans[b.situation] %></span>
|
||||
<% when 'ask_category_id' %>
|
||||
<%= b.category.title rescue 'category not set' %>
|
||||
<% when 'sex' %>
|
||||
<%= ['male','female'].include?(sex.to_s) ? t("mongoid.attributes.ask_question.#{sex}") : '' %>
|
||||
<% when 'mail' %>
|
||||
<%= b.mail %>
|
||||
<% when 'title' %>
|
||||
<% if b.situation == 'is_published' %>
|
||||
<%= link_to b.title, (ask_show_url ? (ask_show_url+"?item=#{b.id}") : "javascript:alert('#{t('ask.no_index_page')}')") %>
|
||||
<% else %>
|
||||
<%= b.title %>
|
||||
<% end %>
|
||||
<% when 'name' %>
|
||||
<%= b.name %>
|
||||
<% when 'phone' %>
|
||||
<%= b.phone %>
|
||||
<% when 'appointment' %>
|
||||
<%= b.appointment.strftime("%Y-%m-%d %H:%M") rescue nil %>
|
||||
<% when 'created_at' %>
|
||||
<%= b.created_at.strftime("%Y-%m-%d %H:%M") rescue nil %>
|
||||
<% when 'ip' %>
|
||||
<%= b.ip %>
|
||||
<% end %>
|
||||
<% if edit_button_display_index == i %>
|
||||
<%= yield :edit_button %>
|
||||
<% end %>
|
||||
</td>
|
||||
<% when 'name' %>
|
||||
<td>
|
||||
<%= b.name %>
|
||||
</td>
|
||||
<% when 'phone' %>
|
||||
<td><%= b.phone %></td>
|
||||
<% when 'appointment' %>
|
||||
<td><%= b.appointment.strftime("%Y-%m-%d %H:%M") rescue nil %></td>
|
||||
<% when 'created_at' %>
|
||||
<td><%= b.created_at.strftime("%Y-%m-%d %H:%M") rescue nil %></td>
|
||||
<% when 'ip' %>
|
||||
<td><%= b.ip %></td>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% @table_ext_fields.each do |f, v| %>
|
||||
<td>
|
||||
|
|
Loading…
Reference in New Issue