From 96b601074bebb4088dca0ee49fe5a12587de5979 Mon Sep 17 00:00:00 2001 From: chiu Date: Mon, 27 Jul 2020 10:11:58 +0800 Subject: [PATCH] fix category setiing new problem and add ask time for admin index --- app/controllers/admin/asks_controller.rb | 2 +- app/views/admin/asks/_ask_setting.html.erb | 4 +- app/views/admin/asks/_form.html.erb | 175 +++++++++++---------- app/views/admin/asks/_index.html.erb | 1 + config/locales/en.yml | 1 + 5 files changed, 96 insertions(+), 87 deletions(-) diff --git a/app/controllers/admin/asks_controller.rb b/app/controllers/admin/asks_controller.rb index 4b2a932..5e95ee5 100644 --- a/app/controllers/admin/asks_controller.rb +++ b/app/controllers/admin/asks_controller.rb @@ -92,7 +92,7 @@ class Admin::AsksController < OrbitAdminController @categories = @module_app.categories @filter_fields = filter_fields(@categories, @tags) # 列表欄位 - @table_fields = [:situation, :category, 'title' , 'ask.name', 'ask.phone', 'ask.appointment'] + @table_fields = [:situation, :category, 'title' , 'ask.name', 'ask.phone', 'ask.appointment','ask.created_at'] # 列表排序 # debugger if filter2("situation").blank? and filter2("identity").blank? diff --git a/app/views/admin/asks/_ask_setting.html.erb b/app/views/admin/asks/_ask_setting.html.erb index 68b1da5..9c65fc4 100644 --- a/app/views/admin/asks/_ask_setting.html.erb +++ b/app/views/admin/asks/_ask_setting.html.erb @@ -133,7 +133,9 @@ <%= hidden_field_tag :delete_field, nil,{'class'=> 'delete_field' } %> - <%= f.hidden_field :id, value: ask_setting.id %> + <% if !ask_setting.new_record? %> + <%= f.hidden_field :id, value: ask_setting.id %> + <% end %> diff --git a/app/views/admin/asks/_form.html.erb b/app/views/admin/asks/_form.html.erb index bcf6a1e..ddbebc3 100644 --- a/app/views/admin/asks/_form.html.erb +++ b/app/views/admin/asks/_form.html.erb @@ -1,6 +1,6 @@ <% - ask_setting = @ask_setting - set_input_name('ask_question') + ask_setting = @ask_setting + set_input_name('ask_question') %> <% content_for :page_specific_css do %> <%= stylesheet_link_tag "lib/main-forms" %> @@ -14,104 +14,109 @@ <%# javascript_include_tag "jquery.ui.datepicker.monthyearpicker" %> <%# javascript_include_tag "lib/bootstrap-datetimepicker" %>
-
- - - - - - - - - - - - - - - - - - +
+
<%= AskQuestion.human_attribute_name(:name) %>:<%= @ask_question.name %><%= AskQuestion.human_attribute_name(:mail) %>:<%= @ask_question.mail %><%= AskQuestion.human_attribute_name(:phone) %>:<%= @ask_question.phone %>
<%= t('title') %>:<%= f.text_field :title %>
<%= AskQuestion.human_attribute_name(:appointment) %>:<%= @ask_question.appointment.strftime("%Y-%m-%d %H:%M") rescue nil %>
+ + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - -
<%= AskQuestion.human_attribute_name(:name) %>:<%= @ask_question.name %><%= AskQuestion.human_attribute_name(:mail) %>:<%= @ask_question.mail %><%= AskQuestion.human_attribute_name(:phone) %>:<%= @ask_question.phone %>
<%= t('title') %>:<%= @ask_question.title %>
<%= AskQuestion.human_attribute_name(:appointment) %>:<%= @ask_question.appointment.strftime("%Y-%m-%d %H:%M") rescue nil %>
- <%= f.label :reply %> -
<%= f.text_area :reply, rows: 10, style: 'width: 500px' %> -
- <%= f.label :comment %> -
<%= f.text_field :comment, style: 'width: 500px' %>
<%= f.label :agree_show %><%= f.select :agree_show,[[t('ask.no'),false],[t('ask.yes'),true]] %>
<%= f.label t('situation') %> <%= f.select :situation, [ - [t('ask.is_waiting'), 'is_waiting'], - [t('ask.is_processed'), 'is_processed'], - [t('ask.is_referral'), 'is_referral'], - [t('ask.is_published'),'is_published'] - ] %>
+ <%= f.label :reply %> +
<%= f.text_area :reply, rows: 10, style: 'width: 500px' %> +
+ <%= f.label :comment %> +
<%= @ask_question.comment %>
<%= f.label :agree_show %><%= @ask_question.agree_show ? t('ask.yes') : t('ask.no') %> +
<%= f.label t('situation') %> + <% tmp = {'is_waiting'=>t('ask.is_waiting'), + 'is_processed'=>t('ask.is_processed'), + 'is_referral'=>t('ask.is_referral'), + 'is_published'=>t('ask.is_published')} %> + <%= tmp[@ask_question.situation] %> +
- <%= f.label :send_email %><%= f.radio_button :send_email, 1, checked: @ask_question.send_email? %><%= t('ask.yes') %> -      - <%= f.radio_button :send_email, 0, checked: !@ask_question.send_email? %><%= t('ask.no') %> -
- <%= ask_setting.custom_fields.collect do |k,v| - required_pattern = v['required']=='true' ? '*' : '' - "
- -
- #{show_on_front(k,v,@ask_question.custom_values[k])} -
-
" - end.join.html_safe %> -
+ + + <%= f.label :send_email %><%= f.radio_button :send_email, 1, checked: @ask_question.send_email? %><%= t('ask.yes') %> +      + <%= f.radio_button :send_email, 0, checked: !@ask_question.send_email? %><%= t('ask.no') %> + + + + <%= ask_setting.custom_fields.collect do |k,v| + required_pattern = v['required']=='true' ? '*' : '' + "
+ +
+ #{show_on_front(k,v,@ask_question.custom_values[k],true)} +
+
" + end.join.html_safe %> +
<% - cancel_href = url_for(:back) - if cancel_href == 'javascript:history.back()' - now_ask_page = AskQuestion.order_by(:id).map(&:id).map.with_index.select{|v,i| v==@ask_question.id}[0][1] rescue nil - now_ask_page = now_ask_page.nil? ? 1 : ((now_ask_page+1).to_f/10).ceil - cancel_href = "/#{I18n.locale}/admin/asks?page=#{now_ask_page}" - end + cancel_href = url_for(:back) + if cancel_href == 'javascript:history.back()' + now_ask_page = AskQuestion.order_by(:id).map(&:id).map.with_index.select{|v,i| v==@ask_question.id}[0][1] rescue nil + now_ask_page = now_ask_page.nil? ? 1 : ((now_ask_page+1).to_f/10).ceil + cancel_href = "/#{I18n.locale}/admin/asks?page=#{now_ask_page}" + end %>
<%= f.submit t('submit'), class: 'btn btn-primary' %> diff --git a/app/views/admin/asks/_index.html.erb b/app/views/admin/asks/_index.html.erb index de7c428..ba4edcd 100644 --- a/app/views/admin/asks/_index.html.erb +++ b/app/views/admin/asks/_index.html.erb @@ -51,6 +51,7 @@ <% if @ask_setting.default_setting['appointment'] %> <%= b.appointment.strftime("%Y-%m-%d %H:%M") rescue nil %> <% end %> + <%= b.created_at.strftime("%Y-%m-%d %H:%M") rescue nil %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 3f69a58..eccd60e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -13,6 +13,7 @@ en: select_category: '-----Select a category-----' save_data: Save as pdf print: Print + created_at: Ask Time ask_time: Ask Time custom_format_explain: use checkbox format to show custom-field's value output_result: Output result