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 render :json => data.to_json
end 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 def tickets_by_category
@table_fields = [:ticket_number, :site_name, :subject, :created_at, :tags, :status, :taken_by, :urgent] @table_fields = [:ticket_number, :site_name, :subject, :created_at, :tags, :status, :taken_by, :urgent]
statuses = params["type"] == "history" ? ["closed"] : ["open","commenced"] statuses = params["type"] == "history" ? ["closed"] : ["open","commenced"]

View File

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

View File

@ -104,52 +104,48 @@
</div> </div>
</div> </div>
<div class="ticket-meta-wrap clearfix"> <div class="ticket-meta-wrap clearfix">
<div class="ticket-meta"> <div class="ticket-meta">
<span class="ticket-author t-label t-label-primary"> <span class="ticket-author t-label t-label-primary">
<i class="icon-user"></i> <i class="icon-user"></i>
<%= !@ticket.ticket_creater_name.nil? ? @ticket.ticket_creater_name : @ticket.ticket_creater_id %> <%= !@ticket.ticket_creater_name.nil? ? @ticket.ticket_creater_name : @ticket.ticket_creater_id %>
</span> </span>
<span class="ticket-created-date t-label t-label-primary"> <span class="ticket-created-date t-label t-label-primary">
<i class="icon-time"></i> <i class="icon-time"></i>
<% dt = DateTime.parse(@ticket.created_at.to_s) %> <%= dt.strftime("%d %B %Y - %H:%M") %> <% dt = DateTime.parse(@ticket.created_at.to_s) %> <%= dt.strftime("%d %B %Y - %H:%M") %>
</span> </span>
</div> </div>
<div class="ticket-state"> <div class="ticket-state">
<% if @ticket.status != "closed" %> <% 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"> --> <div class="onoffswitch ticket-toggle-urgent" title="">
<!-- <i class="fa fa-fire"></i> <span class="ticket-tooltip-wrap"></span>
Urgent --> <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox <%= "active" if @ticket.is_urgent? %>" id="myonoffswitch" data-url="/admin/tickets/<%= @ticket.id.to_s %>/toggleurgent">
<div class="onoffswitch ticket-toggle-urgent" title=""> <label class="onoffswitch-label" for="myonoffswitch">
<span class="ticket-tooltip-wrap"></span> <span class="onoffswitch-inner"></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"> <span class="onoffswitch-switch"></span>
<label class="onoffswitch-label" for="myonoffswitch"> </label>
<span class="onoffswitch-inner"></span> </div>
<span class="onoffswitch-switch"></span> <% end %>
</label> <span class="ticket-status t-status <%= badge_class %>">
</div> <i class="fa fa-eye"></i>
<!-- </a> --> <%= @ticket.status %>
<% end %> </span>
<span class="ticket-status t-status <%= badge_class %>"> <span class="ticket-category t-category t-category-primary">
<i class="fa fa-eye"></i> <a class="ticket-category-dropdown" data-toggle="dropdown" href="#">
<%= @ticket.status %> <i class="fa fa-th-list"></i>
</span> <%= @ticket.category.title %>
<span class="ticket-category t-category t-category-primary"> <i class="fa fa-angle-down"></i>
<a class="ticket-category-dropdown" data-toggle="dropdown" href="#"> </a>
<i class="fa fa-th-list"></i> <ul class="ticket-category-select dropdown-menu" role="menu">
<%= @ticket.category.title %> <% @categories.each do |category| %>
<i class="fa fa-angle-down"></i> <li>
</a> <a class="ticket-start t-item ticket-category-select-option" href="#" data-category-id="<%= category.id.to_s %>">
<ul class="ticket-category-select dropdown-menu" role="menu"> <%= category.title %>
<% @categories.each do |category| %> </a>
<li> </li>
<a class="ticket-start t-item ticket-category-select-option" href="#" data-category-id="<%= category.id.to_s %>"> <% end %>
<%= category.title %> </ul>
</a> </span>
</li> </div>
<% end %>
</ul>
</span>
</div>
</div> </div>
</div> </div>
@ -319,6 +315,19 @@ $(document).ready(function(){
return false; 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> </script>

View File

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