style changes and also added tagged tickets
This commit is contained in:
parent
87b382bf3a
commit
e11e82ad9f
|
@ -18,6 +18,10 @@ body {
|
|||
}
|
||||
}
|
||||
|
||||
#main-wrap .wrap-inner{
|
||||
padding : 20px;
|
||||
}
|
||||
|
||||
|
||||
.ticket-search-wrap {
|
||||
font-family: $main-font;
|
||||
|
|
|
@ -32,13 +32,47 @@ class Admin::TicketsController < OrbitAdminController
|
|||
|
||||
def my_tickets
|
||||
if params[:type] == "history"
|
||||
if params[:keywords].present?
|
||||
@tickets = search_tickets
|
||||
@tickets = @tickets.where(:taken_by => current_user.id).closed.group_by(&:category)
|
||||
else
|
||||
@tickets = Ticket.where(:taken_by => current_user.id).closed.group_by(&:category)
|
||||
end
|
||||
else
|
||||
if params[:keywords].present?
|
||||
@tickets = search_tickets
|
||||
@tickets = @tickets.where(:taken_by => current_user.id).commenced.desc(:urgent).group_by(&:category)
|
||||
else
|
||||
@tickets = Ticket.where(:taken_by => current_user.id).commenced.desc(:urgent).group_by(&:category)
|
||||
end
|
||||
end
|
||||
@categories = @tickets.keys
|
||||
end
|
||||
|
||||
def tagged_tickets
|
||||
tqrs = TicketQueryResponse.where(:user_tags.in => [current_user.id.to_s], :read_by.nin => [current_user.id.to_s])
|
||||
@unread_tickets = []
|
||||
@read_tickets = []
|
||||
tqrs.each do |tqr|
|
||||
@unread_tickets << tqr.ticket_query.ticket if !tqr.ticket_query.nil? && !tqr.ticket_query.ticket.nil?
|
||||
end
|
||||
tqrs = TicketQueryResponse.where(:user_tags.in => [current_user.id.to_s], :read_by.in => [current_user.id.to_s])
|
||||
tqrs.each do |tqr|
|
||||
@read_tickets << tqr.ticket_query.ticket if !tqr.ticket_query.nil? && !tqr.ticket_query.ticket.nil?
|
||||
end
|
||||
@read_tickets.uniq!
|
||||
@unread_tickets.uniq!
|
||||
if params[:keywords].present?
|
||||
tickets = search_tickets
|
||||
@read_tickets = @read_tickets & tickets
|
||||
@unread_tickets = @unread_tickets & tickets
|
||||
end
|
||||
@unread_tickets = @unread_tickets.group_by(&:category)
|
||||
@read_tickets = @read_tickets.group_by(&:category)
|
||||
@unread_tickets_categories = @unread_tickets.keys
|
||||
@read_tickets_categories = @read_tickets.keys
|
||||
end
|
||||
|
||||
def show
|
||||
@ticket = Ticket.find(params[:id]) rescue nil
|
||||
@categories = ModuleApp.find_by_key("ticket").categories
|
||||
|
@ -138,36 +172,7 @@ class Admin::TicketsController < OrbitAdminController
|
|||
end
|
||||
|
||||
def search
|
||||
statuses = ["open","commenced","closed"]
|
||||
if params[:keywords].present?
|
||||
keywords = params[:keywords]
|
||||
type = (keywords.is_i? ? (keywords.length == 8 ? "number" : "text") : "text")
|
||||
if type == "text"
|
||||
regex = Regexp.new(/[a-z]+:/)
|
||||
matches = keywords.scan(regex)
|
||||
if !matches.blank?
|
||||
smart_field = matches.first
|
||||
if @smart_search_fields.include?(smart_field)
|
||||
type = "smart"
|
||||
keywords = keywords.sub(smart_field,"")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
case type
|
||||
when "number"
|
||||
@tickets = Ticket.where(:status.in => statuses, :uid => keywords)
|
||||
when "text"
|
||||
@tickets = Ticket.where(:status.in => statuses)
|
||||
@tickets = search_data(@tickets,[:subject, :uid, :status, :site_type, :ticket_creater_id, :ticket_creater_name])
|
||||
regex = Regexp.new(".*"+keywords+".*", "i")
|
||||
sites = RegisteredSite.any_of({:title => regex},{:site_domain => regex})
|
||||
sites.each do |site|
|
||||
@tickets = (@tickets | site.tickets.where(:status.in => statuses))
|
||||
end
|
||||
when "smart"
|
||||
@tickets = smart_search(statuses,nil,smart_field,keywords)
|
||||
end
|
||||
@tickets = search_tickets
|
||||
if !@tickets.nil?
|
||||
@tickets = @tickets.group_by(&:category)
|
||||
@categories = @tickets.keys
|
||||
|
@ -220,7 +225,7 @@ class Admin::TicketsController < OrbitAdminController
|
|||
end
|
||||
|
||||
def tickets_by_category
|
||||
@table_fields = [:ticket_number, :site_name, :subject, :created_at, :tags, :status, :taken_by, :urgent]
|
||||
@table_fields = [:tagged, :ticket_number, :site_name, :subject, :created_at, :tags, :status, :taken_by, :urgent]
|
||||
statuses = params["type"] == "history" ? ["closed"] : ["open","commenced"]
|
||||
@category = Category.find(params[:category_id]) rescue nil
|
||||
if params[:keywords].present?
|
||||
|
@ -239,11 +244,11 @@ class Admin::TicketsController < OrbitAdminController
|
|||
end
|
||||
end
|
||||
if type.nil?
|
||||
@tickets = Ticket.where(:category_id => @category.id, :status.in => statuses).order_by(sort).page(params[:page]).per(15)
|
||||
@tickets = Ticket.where(:category_id => @category.id, :status.in => statuses).order_by(sort)
|
||||
else
|
||||
case type
|
||||
when "number"
|
||||
@tickets = Ticket.where(:category_id => @category.id, :status.in => statuses, :uid => keywords).order_by(sort).page(params[:page]).per(15)
|
||||
@tickets = Ticket.where(:category_id => @category.id, :status.in => statuses, :uid => keywords).order_by(sort)
|
||||
when "text"
|
||||
@tickets = Ticket.where(:category_id => @category.id, :status.in => statuses).order_by(sort)
|
||||
@tickets = search_data(@tickets,[:subject, :uid, :status, :site_type, :ticket_creater_id, :ticket_creater_name])
|
||||
|
@ -252,17 +257,51 @@ class Admin::TicketsController < OrbitAdminController
|
|||
sites.each do |site|
|
||||
@tickets = (@tickets | site.tickets.where(:category_id => @category.id, :status.in => statuses))
|
||||
end
|
||||
@tickets = Kaminari.paginate_array(@tickets).page(params[:page]).per(15)
|
||||
when "smart"
|
||||
@tickets = smart_search(statuses,@category,smart_field,keywords)
|
||||
@tickets = @tickets.order_by(sort) rescue @tickets
|
||||
@tickets = Kaminari.paginate_array(@tickets).page(params[:page]).per(15)
|
||||
end
|
||||
end if !@category.nil?
|
||||
@tickets = @tickets.where(:taken_by => current_user.id) if params[:takenby].present?
|
||||
@tickets = Kaminari.paginate_array(@tickets).page(params[:page]).per(15) if !@tickets.nil?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def search_tickets
|
||||
statuses = ["open","commenced","closed"]
|
||||
if params[:keywords].present?
|
||||
keywords = params[:keywords]
|
||||
type = (keywords.is_i? ? (keywords.length == 8 ? "number" : "text") : "text")
|
||||
if type == "text"
|
||||
regex = Regexp.new(/[a-z]+:/)
|
||||
matches = keywords.scan(regex)
|
||||
if !matches.blank?
|
||||
smart_field = matches.first
|
||||
if @smart_search_fields.include?(smart_field)
|
||||
type = "smart"
|
||||
keywords = keywords.sub(smart_field,"")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
case type
|
||||
when "number"
|
||||
tickets = Ticket.where(:status.in => statuses, :uid => keywords)
|
||||
when "text"
|
||||
tickets = Ticket.where(:status.in => statuses)
|
||||
tickets = search_data(tickets,[:subject, :uid, :status, :site_type, :ticket_creater_id, :ticket_creater_name])
|
||||
regex = Regexp.new(".*"+keywords+".*", "i")
|
||||
sites = RegisteredSite.any_of({:title => regex},{:site_domain => regex})
|
||||
sites.each do |site|
|
||||
tickets = (tickets | site.tickets.where(:status.in => statuses))
|
||||
end
|
||||
when "smart"
|
||||
tickets = smart_search(statuses,nil,smart_field,keywords)
|
||||
end
|
||||
tickets
|
||||
end
|
||||
|
||||
def can_mark_urgent?(ticket)
|
||||
tickets = Ticket.where(:category_id => ticket.category_id, :urgent => true).count
|
||||
return tickets < 5
|
||||
|
|
|
@ -45,4 +45,33 @@ class Ticket
|
|||
def registered_site_domain
|
||||
self.registered_site.site_domain
|
||||
end
|
||||
|
||||
def self.get_ticket_unread_count_for_user(user)
|
||||
tqrs = TicketQueryResponse.where(:user_tags.in => [user.id.to_s], :read_by.nin => [user.id.to_s])
|
||||
unread_tickets = []
|
||||
tqrs.each do |tqr|
|
||||
unread_tickets << tqr.ticket_query.ticket if !tqr.ticket_query.nil? && !tqr.ticket_query.ticket.nil?
|
||||
end
|
||||
unread_tickets.uniq!
|
||||
unread_tickets.count
|
||||
end
|
||||
|
||||
def tagged_status(user)
|
||||
queries = self.ticket_queries
|
||||
status = "not_tagged"
|
||||
queries.each do |query|
|
||||
tqrs = query.ticket_query_responses.where(:user_tags.in => [user.id.to_s])
|
||||
if tqrs.count > 0
|
||||
tqrs = query.ticket_query_responses.where(:user_tags.in => [user.id.to_s], :read_by.in => [user.id.to_s])
|
||||
if tqrs.count > 0
|
||||
status = "read"
|
||||
else
|
||||
status = "tagged"
|
||||
end
|
||||
else
|
||||
status = "not_tagged"
|
||||
end
|
||||
end
|
||||
status
|
||||
end
|
||||
end
|
|
@ -4,7 +4,7 @@
|
|||
Search tickets
|
||||
</h3>
|
||||
<span class="search-box">
|
||||
<form action="/admin/tickets/search" method="get" id="search-form">
|
||||
<form action="<%= !(defined? form_action).nil? ? form_action : "/admin/tickets/search" %>" method="get" id="search-form">
|
||||
<select id="smart-field-select" class="ticket-search-option">
|
||||
<option value="">General</option>
|
||||
<% @smart_search_fields.each do |ssf| %>
|
||||
|
@ -12,11 +12,20 @@
|
|||
<% end %>
|
||||
</select>
|
||||
<input class="ticket-search-field" type="text" placeholder="keyword" name="keywords">
|
||||
<% if params[:type] == "history" %>
|
||||
<input type="hidden" name="type" value="history" />
|
||||
<% end %>
|
||||
<% if params[:takenby].present? %>
|
||||
<input type="hidden" name="takenby" value="<%= params[:takenby] %>" />
|
||||
<% end %>
|
||||
<% if params[:tagged].present? %>
|
||||
<input type="hidden" name="takenby" value="<%= params[:tagged] %>" />
|
||||
<% end %>
|
||||
</form>
|
||||
</span>
|
||||
<% if params[:keywords].present? %>
|
||||
<div class="ticket-search-result">
|
||||
<a href="/admin/tickets"><i class="icons-cycle"></i></a>
|
||||
<a href="<%= !(defined? form_action).nil? ? form_action : "/admin/tickets" %>"><i class="icons-cycle"></i></a>
|
||||
Search result for <b><i>"<%= params[:keywords] %>"</i></b>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -6,8 +6,19 @@
|
|||
when "commenced"
|
||||
badge_class = "badge-success"
|
||||
end
|
||||
|
||||
case ticket_by_c.tagged_status(current_user)
|
||||
when "not_tagged"
|
||||
tagged_class = "fa-minus"
|
||||
when "tagged"
|
||||
tagged_class = "fa-eye-slash"
|
||||
when "read"
|
||||
tagged_class = "fa-eye"
|
||||
end
|
||||
|
||||
%>
|
||||
<tr>
|
||||
<td><i class="fa <%= tagged_class %>"></i></td>
|
||||
<td><%= ticket_by_c.uid %></td>
|
||||
<td>
|
||||
<% if !ticket_by_c.registered_site.nil? %>
|
||||
|
|
|
@ -1,22 +1,49 @@
|
|||
<% content_for :page_specific_css do %>
|
||||
<%= stylesheet_link_tag "https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" %>
|
||||
<%= stylesheet_link_tag "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" %>
|
||||
<%= stylesheet_link_tag "tickets/ticket_index" %>
|
||||
<style type="text/css">
|
||||
.past-link {
|
||||
font-size: 14px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.past-link a {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.past-link a:hover {
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
<% end %>
|
||||
<%= render :partial => "search_form" %>
|
||||
<div class="pull-right">
|
||||
<% if params[:type] == "history" %>
|
||||
<%= render :partial => "search_form", locals: {:form_action => "/admin/tickets/my_tickets"} %>
|
||||
<div class="ticket-container">
|
||||
<h3 class="ticket-section-heading type--normal">
|
||||
<i class="ticket-section-heading-icon fa fa-clock-o"></i>
|
||||
Tickets
|
||||
<div class="pull-right past-link">
|
||||
<% if params[:type] == "history" %>
|
||||
<a href="/admin/tickets/my_tickets">View my current tickets</a>
|
||||
<% else %>
|
||||
<% else %>
|
||||
<a href="/admin/tickets/my_tickets?type=history">View my past tickets</a>
|
||||
<% end %>
|
||||
</div>
|
||||
<div>
|
||||
<% @categories.each do |category| %>
|
||||
<div>
|
||||
<h3><%= category.title %></h3>
|
||||
<hr>
|
||||
<%= render :partial => "ticket", :collection => @tickets[category] %>
|
||||
<% end %>
|
||||
</div>
|
||||
</h3>
|
||||
<% @categories.each do |category| %>
|
||||
<div class="ticket-section-container t-strong-round">
|
||||
<h4 class="ticket-category-title">
|
||||
<i class="ticket-category-title-icon fa fa-tags"></i>
|
||||
<%= category.title %>
|
||||
</h4>
|
||||
<%= render :partial => "ticket", :collection => @tickets[category] %>
|
||||
<div class="ticket-section-view-all">
|
||||
<a class="ticket-section-view-all-btn" href="/admin/tickets/category/<%= category.id.to_s %>?takenby=<%= current_user.id.to_s %>">
|
||||
<i class="ticket-section-view-all-icon fa fa-share"></i>
|
||||
View all tickets from <%= category.title %>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pull-right"><a href="/admin/tickets/category/<%= category.id.to_s %>/?keywords=takenby: <%= current_user.name %>">View all tickets from <%= category.title %></a></div>
|
||||
<br>
|
||||
<% end %>
|
||||
</div>
|
||||
<script type="text/javascript" src="/assets/search.js"></script>
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
<% content_for :page_specific_css do %>
|
||||
<%= stylesheet_link_tag "https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" %>
|
||||
<%= stylesheet_link_tag "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" %>
|
||||
<%= stylesheet_link_tag "tickets/ticket_index" %>
|
||||
<% end %>
|
||||
<%= render :partial => "search_form", locals: {:form_action => "/admin/tickets/tagged_tickets"} %>
|
||||
<div class="ticket-container">
|
||||
<div class="ticket-section">
|
||||
<h3 class="ticket-section-heading type--ugrent">
|
||||
<i class="ticket-section-heading-icon fa fa-eye-slash"></i>
|
||||
Unread Tags
|
||||
</h3>
|
||||
<% @unread_tickets_categories.each do |category| %>
|
||||
<div class="ticket-section-container t-strong-round">
|
||||
<h4 class="ticket-category-title">
|
||||
<i class="ticket-category-title-icon fa fa-tags"></i>
|
||||
<%= category.title %>
|
||||
</h4>
|
||||
<%= render :partial => "ticket", :collection => @unread_tickets[category] %>
|
||||
<div class="ticket-section-view-all">
|
||||
<a class="ticket-section-view-all-btn" href="/admin/tickets/category/<%= category.id.to_s %>">
|
||||
<i class="ticket-section-view-all-icon fa fa-share"></i>
|
||||
View all tickets from <%= category.title %>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<h3 class="ticket-section-heading type--normal">
|
||||
<i class="ticket-section-heading-icon fa fa-eye"></i>
|
||||
Read Tags
|
||||
</h3>
|
||||
<% @read_tickets_categories.each do |category| %>
|
||||
<div class="ticket-section-container t-strong-round">
|
||||
<h4 class="ticket-category-title">
|
||||
<i class="ticket-category-title-icon fa fa-tags"></i>
|
||||
<%= category.title %>
|
||||
</h4>
|
||||
<%= render :partial => "ticket", :collection => @read_tickets[category] %>
|
||||
<div class="ticket-section-view-all">
|
||||
<a class="ticket-section-view-all-btn" href="/admin/tickets/category/<%= category.id.to_s %>">
|
||||
<i class="ticket-section-view-all-icon fa fa-share"></i>
|
||||
View all tickets from <%= category.title %>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<script type="text/javascript" src="/assets/search.js"></script>
|
|
@ -1,31 +1,14 @@
|
|||
<% content_for :page_specific_css do %>
|
||||
<%= stylesheet_link_tag "https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" %>
|
||||
<%= stylesheet_link_tag "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" %>
|
||||
<%= stylesheet_link_tag "tickets/ticket_index" %>
|
||||
<% end %>
|
||||
<div class="category_ticket_wrap">
|
||||
<% if !@category.nil? %>
|
||||
<div>
|
||||
<h3>
|
||||
<%= @category.title %><%= " - history" if params[:type] == "history" %>
|
||||
<div class="search-wrap">
|
||||
<a href="#" id="serach-btn" style="font-size:20px;"><i class="icons-search"></i></a>
|
||||
<% if params[:keywords].present? %>
|
||||
<a href="/admin/tickets/category/<%= @category.id.to_s %><%= "?type=history" if params[:type] == "history" %>" style="font-size:20px;"><i class="icons-cycle"></i></a>
|
||||
<span>Searched for <b><i><%= params[:keywords] %></i></b></span>
|
||||
<% end %>
|
||||
<span class="search-box" style="display:none;">
|
||||
<form action="<%= request.original_fullpath %>" method="get" id="search-form">
|
||||
<select id="smart-field-select" style="width:100px;">
|
||||
<option value="">general</option>
|
||||
<% @smart_search_fields.each do |ssf| %>
|
||||
<option value="<%= ssf %>"><%= ssf %></option>
|
||||
<% end %>
|
||||
</select>
|
||||
<input type="text" placeholder="Search" style="width:0;" name="keywords" />
|
||||
<% if params[:type] == "history" %>
|
||||
<input type="hidden" name="type" value="history" />
|
||||
<% end %>
|
||||
</form>
|
||||
</span>
|
||||
</div>
|
||||
<%= render :partial => "search_form", locals: {:form_action => "/admin/tickets/category/#{@category.id.to_s}"} %>
|
||||
</h3>
|
||||
<% h = request.original_fullpath.split("?")[1] %>
|
||||
<% if params[:type] == "history" %>
|
||||
|
@ -53,7 +36,7 @@
|
|||
<% if !@tickets.nil? && @tickets.count > 0 %>
|
||||
<%= render :partial => "ticket_by_c", :collection => @tickets %>
|
||||
<% else %>
|
||||
<tr><td colspan="7" style="text-align:center;">No tickets.</td></tr>
|
||||
<tr><td colspan="9" style="text-align:center;">No tickets.</td></tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
@ -2,4 +2,5 @@ en:
|
|||
tickets:
|
||||
tickets: Tickets
|
||||
my_tickets: My Tickets
|
||||
tickets_tagged: Tickets Tagged
|
||||
all: All
|
||||
|
|
|
@ -2,4 +2,5 @@ zh_tw:
|
|||
tickets:
|
||||
tickets: Tickets
|
||||
my_tickets: My Tickets
|
||||
tickets_tagged: Tickets Tagged
|
||||
all: All
|
||||
|
|
|
@ -16,6 +16,7 @@ Rails.application.routes.draw do
|
|||
delete "ticket/delete_response" => 'tickets#delete_response'
|
||||
get "tickets/category/:category_id" => 'tickets#tickets_by_category'
|
||||
get "tickets/my_tickets" => 'tickets#my_tickets'
|
||||
get "tickets/tagged_tickets" => 'tickets#tagged_tickets'
|
||||
post "comments/read" => 'tickets#mark_response_read'
|
||||
resources :tickets do
|
||||
get "start"
|
||||
|
|
|
@ -26,6 +26,12 @@ module Tickets
|
|||
:active_for_action=>{'admin/tickets'=>"my_tickets"},
|
||||
:available_for => 'users'
|
||||
|
||||
context_link 'tickets.tickets_tagged',
|
||||
:link_path=>"admin_tickets_tagged_tickets_path" ,
|
||||
:priority=>2,
|
||||
:active_for_action=>{'admin/tickets'=>"tagged_tickets"},
|
||||
:available_for => 'users'
|
||||
|
||||
context_link 'categories',
|
||||
:link_path=>"admin_module_app_categories_path" ,
|
||||
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'ticket').id}",
|
||||
|
|
Loading…
Reference in New Issue