added get history on the frontend
This commit is contained in:
parent
7c9ec914b1
commit
0ca1da5018
|
@ -101,7 +101,7 @@ class AsksController < ApplicationController
|
|||
end
|
||||
end
|
||||
end
|
||||
[category_id,
|
||||
[category_id,
|
||||
{
|
||||
setting: ask_setting,
|
||||
custom_fields: custom_fields.to_h
|
||||
|
@ -285,6 +285,7 @@ class AsksController < ApplicationController
|
|||
'switch_form' => switch_form,
|
||||
'ask_setting' => ask_setting,
|
||||
'default_ask_setting' => @default_ask_setting,
|
||||
'question_status' => @params['type'],
|
||||
'email_regex' => email_regex
|
||||
}
|
||||
elsif @layout_type == 'published_index'
|
||||
|
@ -335,7 +336,7 @@ class AsksController < ApplicationController
|
|||
end
|
||||
end
|
||||
end
|
||||
[category_id,
|
||||
[category_id,
|
||||
{
|
||||
setting: ask_setting,
|
||||
custom_fields: custom_fields.to_h
|
||||
|
@ -444,7 +445,7 @@ class AsksController < ApplicationController
|
|||
if !file.blank?
|
||||
if v['type']=='image'
|
||||
all_to_save += [[k,AskImage.new(file: file,ask_question_id: @ask_question.id)]]
|
||||
else
|
||||
else
|
||||
all_to_save += [[k,AskFile.new(file: file,ask_question_id: @ask_question.id)]]
|
||||
end
|
||||
end
|
||||
|
@ -594,6 +595,7 @@ class AsksController < ApplicationController
|
|||
"identity" => email_er[:identity],
|
||||
"mail" => email_er.mail,
|
||||
"phone" => email_er.phone,
|
||||
"serial_number" => email_er.get_serial_number,
|
||||
# "fax" => email_er.fax,
|
||||
# "content" => email_er.content
|
||||
"appointment" => email_er.appointment,
|
||||
|
@ -619,6 +621,7 @@ class AsksController < ApplicationController
|
|||
"identity" => email_er[:identity],
|
||||
"mail" => email_er.mail,
|
||||
"phone" => email_er.phone,
|
||||
"serial_number" => email_er.get_serial_number,
|
||||
# "fax" => email_er.fax,
|
||||
# "content" => email_er.content
|
||||
"appointment" => email_er.appointment,
|
||||
|
@ -633,6 +636,17 @@ class AsksController < ApplicationController
|
|||
# email_er.email.deliver
|
||||
end
|
||||
|
||||
def get_history
|
||||
question = AskQuestion.where(:serial_number => params["ticket_id"].to_i, :mail => params["email"]).first
|
||||
if !question.nil?
|
||||
@histories = question.ask_status_histories
|
||||
@status_mapping = AskTicketStatus.default_sorting.map{|a| [a.key, a.title]}.to_h
|
||||
else
|
||||
@histories = []
|
||||
end
|
||||
render :partial => "history"
|
||||
end
|
||||
|
||||
def create_params
|
||||
params.require(:ask_question).permit!
|
||||
end
|
||||
|
@ -896,4 +910,4 @@ class AsksController < ApplicationController
|
|||
end.join
|
||||
switch_form
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
<% if @histories.count > 0 %>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= t('status') %></th>
|
||||
<th><%= t('ask.modified_by') %></th>
|
||||
<th><%= t('ask.remark') %></th>
|
||||
<th><%= t('ask.attachment') %></th>
|
||||
<th><%= t('ask.updated_at') %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @histories.each do |ask_status_history| %>
|
||||
<tr>
|
||||
<td>
|
||||
<%= @status_mapping[ask_status_history.status] %>
|
||||
</td>
|
||||
<td>
|
||||
<%= ask_status_history.modified_by_name %>
|
||||
</td>
|
||||
<td>
|
||||
<%= ask_status_history.comment %>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to(ask_status_history[:file], ask_status_history.file.url) if ask_status_history.file.present? %>
|
||||
</td>
|
||||
<td>
|
||||
<%= ask_status_history.created_at.strftime("%Y-%m-%d %H:%M:%S") %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% else %>
|
||||
<p><%= t('no_history_records') %></p
|
||||
<% end %>
|
|
@ -9,6 +9,10 @@
|
|||
<%= link_to t("edit"), @data['edit_url'] %>
|
||||
<% end %>
|
||||
<table>
|
||||
<tr>
|
||||
<th><%= t("ask.serial_number") %>:</th>
|
||||
<td><%= @data['serial_number'] %></td>
|
||||
</tr>
|
||||
<% question = AskQuestion.find(@data['ask_question_id']) rescue nil %>
|
||||
<% if question %>
|
||||
<%
|
||||
|
@ -95,6 +99,10 @@
|
|||
</tr>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<tr>
|
||||
<th><%= t("ask.serial_number") %>:</th>
|
||||
<td><%= @data['serial_number'] %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><%= AskQuestion.human_attribute_name(:name) %>:</th>
|
||||
<td><%= @data['name'] %></td>
|
||||
|
|
|
@ -119,11 +119,49 @@
|
|||
<%# javascript_include_tag "jquery.ui.datepicker.monthyearpicker" %>
|
||||
<%= javascript_include_tag 'validator' %>
|
||||
<link href="/assets/ask/ask.css" media="screen" rel="stylesheet">
|
||||
<div id="new-ask-question" class="ask-question">
|
||||
<%= @switch_form.html_safe %>
|
||||
</div>
|
||||
|
||||
<% if data['question_status'] == 'status' %>
|
||||
<div id="ticket-status-form">
|
||||
<form id="check_history_form" action="/xhr/asks/get_history" method="post">
|
||||
<div>
|
||||
<label for="history_email_id"><%= t("ask.email_id") %></label>
|
||||
<input id="history_email_id" type="text">
|
||||
</div>
|
||||
<div>
|
||||
<label for="history_ticket_number"><%= t("ask.ticket_number") %></label>
|
||||
<input id="history_ticket_number" type="text">
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="<%= t("ask.check_history") %>" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div id="history_area">
|
||||
</div>
|
||||
<% else %>
|
||||
<div><a href="?type=status" class="btn"><%= t("ask.check_status") %></a>
|
||||
<div id="new-ask-question" class="ask-question">
|
||||
<%= @switch_form.html_safe %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<script type='text/javascript'>
|
||||
$("#check_history_form").on("submit", function name() {
|
||||
var form = $(this);
|
||||
console.log(form);
|
||||
var data = {
|
||||
"email" : $("#history_email_id").val(),
|
||||
"ticket_id" : $("#history_ticket_number").val()
|
||||
}
|
||||
$.ajax({
|
||||
url : form.attr("action"),
|
||||
data : data,
|
||||
method : "post"
|
||||
}).done(function(data){
|
||||
$("#history_area").html(data);
|
||||
})
|
||||
return false;
|
||||
})
|
||||
// $(function(){
|
||||
// $("#button-mail").click(function(){
|
||||
// if( $("#ask_question_name").val()!='' ) $("#ask_question_name").css('border','');
|
||||
|
|
|
@ -140,6 +140,8 @@ en:
|
|||
must_verify_email: The form can only be filled in after email verification.
|
||||
go_to_form: Go to Form
|
||||
see_email: "Please check your email, so you can fill out the form."
|
||||
check_status: Check Status
|
||||
check_history: Check History
|
||||
|
||||
mongoid:
|
||||
attributes:
|
||||
|
|
|
@ -150,6 +150,8 @@ zh_tw:
|
|||
must_verify_email: Email驗證後才可開始填寫
|
||||
go_to_form: 前往表單
|
||||
see_email: "請確認email驗證信,以開始填寫表單。"
|
||||
check_status: Check Status
|
||||
check_history: Check History
|
||||
|
||||
mongoid:
|
||||
attributes:
|
||||
|
|
|
@ -63,7 +63,7 @@ Rails.application.routes.draw do
|
|||
collection do
|
||||
delete 'delete'
|
||||
post 'batch_modify_status'
|
||||
get ':id/print', to: 'asks#print'
|
||||
get ':id/print', to: 'asks#print'
|
||||
get 'export'
|
||||
get 'setting'
|
||||
get 'backend_table_setting'
|
||||
|
@ -97,6 +97,6 @@ Rails.application.routes.draw do
|
|||
end
|
||||
resources :asks #fronted
|
||||
get "/xhr/asks/verify_email/:id" => "asks#verify_email"
|
||||
post "/xhr/asks/get_history" => "asks#get_history"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue