added delete option.. person making the comment can delete

This commit is contained in:
Harry Bomrah 2015-09-03 19:29:43 +08:00
parent 6906b186ad
commit 2fe61680e3
4 changed files with 71 additions and 53 deletions

View File

@ -209,6 +209,12 @@ class Admin::TicketsController < OrbitAdminController
render :json => data.to_json
end
def delete_response
response = TicketQueryResponse.find(params[:response_id]) rescue nil
response.destroy if !response.nil?
render :json => {"success" => true}.to_json
end
def tickets_by_category
@table_fields = [:ticket_number, :site_name, :subject, :created_at, :tags, :status, :taken_by, :urgent]
statuses = params["type"] == "history" ? ["closed"] : ["open","commenced"]

View File

@ -14,12 +14,14 @@
<div class="ticket-response-created-date">
<% dt = DateTime.parse(response.created_at.to_s) %> <%= dt.strftime("%d %B %Y - %H:%M") %>
</div>
<% if user.id.to_s == current_user.id.to_s %>
<div class="ticket-response-delete-wrap">
<a class="ticket-response-delete" href="#">
<a class="ticket-response-delete" href="/admin/ticket/delete_response" data-response-id="<%= response.id.to_s %>">
<i class="ticket-response-delete-icon fa fa-trash"></i>
Delete
</a>
</div>
<% end %>
<div class="ticket-internal-comment-wrap">
<div class="ticket-internal-wrap">

View File

@ -116,9 +116,6 @@
</div>
<div class="ticket-state">
<% if @ticket.status != "closed" %>
<!-- <a href="/admin/tickets/<%= @ticket.id.to_s %>/toggleurgent" class="ticket-urgent-btn t-btn t-btn-danger t-uppercase <%= "active" if @ticket.is_urgent? %>" id="toggle-urgent"> -->
<!-- <i class="fa fa-fire"></i>
Urgent -->
<div class="onoffswitch ticket-toggle-urgent" title="">
<span class="ticket-tooltip-wrap"></span>
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox <%= "active" if @ticket.is_urgent? %>" id="myonoffswitch" data-url="/admin/tickets/<%= @ticket.id.to_s %>/toggleurgent">
@ -127,7 +124,6 @@
<span class="onoffswitch-switch"></span>
</label>
</div>
<!-- </a> -->
<% end %>
<span class="ticket-status t-status <%= badge_class %>">
<i class="fa fa-eye"></i>
@ -319,6 +315,19 @@ $(document).ready(function(){
return false;
})
$("body").on("click",".ticket-response-delete",function(){
var el = $(this);
$.ajax({
url : el.attr("href"),
data : {"response_id" : el.data("response-id")},
type : "delete",
dataType : "json"
}).done(function(){
$("div[data-scroll-id=response_" + el.data("response-id") + "]").slideUp(function(){
$(this).remove();
})
})
return false;
})
</script>

View File

@ -13,6 +13,7 @@ Rails.application.routes.draw do
namespace :admin do
get "tickets/search" => 'tickets#search'
post "ticket/submit_response" => 'tickets#submit_response'
delete "ticket/delete_response" => 'tickets#delete_response'
get "tickets/category/:category_id" => 'tickets#tickets_by_category'
get "tickets/my_tickets" => 'tickets#my_tickets'
post "comments/read" => 'tickets#mark_response_read'