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>
<div class="ticket-response-delete-wrap">
<a class="ticket-response-delete" href="#">
<i class="ticket-response-delete-icon fa fa-trash"></i>
Delete
</a>
</div>
<% if user.id.to_s == current_user.id.to_s %>
<div class="ticket-response-delete-wrap">
<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

@ -104,52 +104,48 @@
</div>
</div>
<div class="ticket-meta-wrap clearfix">
<div class="ticket-meta">
<span class="ticket-author t-label t-label-primary">
<i class="icon-user"></i>
<%= !@ticket.ticket_creater_name.nil? ? @ticket.ticket_creater_name : @ticket.ticket_creater_id %>
</span>
<span class="ticket-created-date t-label t-label-primary">
<i class="icon-time"></i>
<% dt = DateTime.parse(@ticket.created_at.to_s) %> <%= dt.strftime("%d %B %Y - %H:%M") %>
</span>
</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">
<label class="onoffswitch-label" for="myonoffswitch">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>
<!-- </a> -->
<% end %>
<span class="ticket-status t-status <%= badge_class %>">
<i class="fa fa-eye"></i>
<%= @ticket.status %>
</span>
<span class="ticket-category t-category t-category-primary">
<a class="ticket-category-dropdown" data-toggle="dropdown" href="#">
<i class="fa fa-th-list"></i>
<%= @ticket.category.title %>
<i class="fa fa-angle-down"></i>
</a>
<ul class="ticket-category-select dropdown-menu" role="menu">
<% @categories.each do |category| %>
<li>
<a class="ticket-start t-item ticket-category-select-option" href="#" data-category-id="<%= category.id.to_s %>">
<%= category.title %>
</a>
</li>
<% end %>
</ul>
</span>
</div>
<div class="ticket-meta">
<span class="ticket-author t-label t-label-primary">
<i class="icon-user"></i>
<%= !@ticket.ticket_creater_name.nil? ? @ticket.ticket_creater_name : @ticket.ticket_creater_id %>
</span>
<span class="ticket-created-date t-label t-label-primary">
<i class="icon-time"></i>
<% dt = DateTime.parse(@ticket.created_at.to_s) %> <%= dt.strftime("%d %B %Y - %H:%M") %>
</span>
</div>
<div class="ticket-state">
<% if @ticket.status != "closed" %>
<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">
<label class="onoffswitch-label" for="myonoffswitch">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>
<% end %>
<span class="ticket-status t-status <%= badge_class %>">
<i class="fa fa-eye"></i>
<%= @ticket.status %>
</span>
<span class="ticket-category t-category t-category-primary">
<a class="ticket-category-dropdown" data-toggle="dropdown" href="#">
<i class="fa fa-th-list"></i>
<%= @ticket.category.title %>
<i class="fa fa-angle-down"></i>
</a>
<ul class="ticket-category-select dropdown-menu" role="menu">
<% @categories.each do |category| %>
<li>
<a class="ticket-start t-item ticket-category-select-option" href="#" data-category-id="<%= category.id.to_s %>">
<%= category.title %>
</a>
</li>
<% end %>
</ul>
</span>
</div>
</div>
</div>
@ -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'