Added counter support for sidebar tab (per default show open tickets of customer).
This commit is contained in:
parent
cc1d38f506
commit
a324553072
7 changed files with 127 additions and 15 deletions
|
@ -2,10 +2,16 @@ class SidebarCustomer extends App.Controller
|
|||
sidebarItem: =>
|
||||
return if !@permissionCheck('ticket.agent')
|
||||
return if _.isEmpty(@params.customer_id)
|
||||
counter = ''
|
||||
if App.User.exists(@params.customer_id)
|
||||
user = App.User.find(@params.customer_id)
|
||||
counter = @sidebarItemCounter(user)
|
||||
{
|
||||
head: 'Customer'
|
||||
name: 'customer'
|
||||
icon: 'person'
|
||||
counter: counter
|
||||
counterPossible: true
|
||||
actions: [
|
||||
{
|
||||
title: 'Edit Customer'
|
||||
|
@ -16,12 +22,28 @@ class SidebarCustomer extends App.Controller
|
|||
callback: @showCustomer
|
||||
}
|
||||
|
||||
sidebarItemCounter: (user) ->
|
||||
counter = ''
|
||||
if user && user.preferences && user.preferences.tickets_open
|
||||
counter = user.preferences.tickets_open
|
||||
counter
|
||||
|
||||
sidebarItemUpdate: (user) =>
|
||||
counter = @sidebarItemCounter(user)
|
||||
element = @el.closest('.tabsSidebar-holder').find('.tabsSidebar .tabsSidebar-tabs .tabsSidebar-tab[data-tab=customer] .js-tabCounter')
|
||||
if !counter || counter is 0
|
||||
element.addClass('hide')
|
||||
else
|
||||
element.removeClass('hide')
|
||||
element.text(counter)
|
||||
|
||||
showCustomer: (el) =>
|
||||
@el = el
|
||||
return if _.isEmpty(@params.customer_id)
|
||||
new App.WidgetUser(
|
||||
el: @el
|
||||
user_id: @params.customer_id
|
||||
callback: @sidebarItemUpdate
|
||||
)
|
||||
|
||||
editCustomer: =>
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
class SidebarCustomer extends App.Controller
|
||||
sidebarItem: =>
|
||||
return if !@permissionCheck('ticket.agent')
|
||||
counter = ''
|
||||
if App.User.exists(@ticket.customer_id)
|
||||
user = App.User.find(@ticket.customer_id)
|
||||
counter = @sidebarItemCounter(user)
|
||||
items = {
|
||||
head: 'Customer'
|
||||
name: 'customer'
|
||||
icon: 'person'
|
||||
counter: counter
|
||||
counterPossible: true
|
||||
actions: [
|
||||
{
|
||||
title: 'Change Customer'
|
||||
|
@ -22,11 +28,27 @@ class SidebarCustomer extends App.Controller
|
|||
}
|
||||
items
|
||||
|
||||
sidebarItemCounter: (user) ->
|
||||
counter = ''
|
||||
if user && user.preferences && user.preferences.tickets_open
|
||||
counter = user.preferences.tickets_open
|
||||
counter
|
||||
|
||||
sidebarItemUpdate: (user) =>
|
||||
counter = @sidebarItemCounter(user)
|
||||
element = @el.closest('.tabsSidebar-holder').find('.tabsSidebar .tabsSidebar-tabs .tabsSidebar-tab[data-tab=customer] .js-tabCounter')
|
||||
if !counter || counter is 0
|
||||
element.addClass('hide')
|
||||
else
|
||||
element.removeClass('hide')
|
||||
element.text(counter)
|
||||
|
||||
showCustomer: (el) =>
|
||||
@el = el
|
||||
new App.WidgetUser(
|
||||
el: @el
|
||||
user_id: @ticket.customer_id
|
||||
callback: @sidebarItemUpdate
|
||||
)
|
||||
|
||||
editCustomer: =>
|
||||
|
|
|
@ -251,7 +251,7 @@ class App.Ticket extends App.Model
|
|||
group_ids = App.Session.get('group_ids')
|
||||
if _.isEmpty(group_ids[@group_id])
|
||||
return false
|
||||
else if group_ids[@group_id] && !_.include(group_ids[@group_id], 'edit') && !_.include(group_ids[@group_id], 'full')
|
||||
else if group_ids[@group_id] && !_.include(group_ids[@group_id], 'change') && !_.include(group_ids[@group_id], 'full')
|
||||
return false
|
||||
true
|
||||
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
<div class="tabsSidebar-tabs" style="<%- if @dir is 'rtl' then 'margin-right' else 'margin-left' %>: -<%- @scrollbarWidth %>px">
|
||||
<% for item in @items: %>
|
||||
<div class="tabsSidebar-tab" data-tab="<%= item.name %>">
|
||||
<% if item.counterPossible is true: %>
|
||||
<div class="tabsSidebar-tab-count js-tabCounter <% if !item.counter || item.counter is 0: %>hide<% end %>"><%= item.counter %></div>
|
||||
<% end %>
|
||||
<%- @Icon(item.icon) %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -5556,8 +5556,53 @@ footer {
|
|||
fill: hsl(197,19%,78%);
|
||||
}
|
||||
|
||||
.tabsSidebar-tab.active .icon {
|
||||
fill: hsl(206,7%,37%);
|
||||
.tabsSidebar-tab.active {
|
||||
.tabsSidebar-tab-count {
|
||||
background: hsl(206,7%,37%);
|
||||
|
||||
&:after {
|
||||
border-right-color: hsl(206,7%,37%);
|
||||
}
|
||||
}
|
||||
|
||||
.icon {
|
||||
fill: hsl(206,7%,37%);
|
||||
}
|
||||
}
|
||||
|
||||
.tabsSidebar-tab-count {
|
||||
position: absolute;
|
||||
left: 9px;
|
||||
top: 5px;
|
||||
background: hsl(197,19%,78%);
|
||||
width: 16px;
|
||||
height: 13px;
|
||||
text-align: center;
|
||||
border-radius: 2px;
|
||||
font-size: 9px;
|
||||
line-height: 14px;
|
||||
color: hsl(197,20%,93%);
|
||||
|
||||
[data-tab="organization"] & {
|
||||
left: 7px;
|
||||
|
||||
+ .icon {
|
||||
margin-left: 3px;
|
||||
}
|
||||
}
|
||||
|
||||
+ .icon {
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
&:after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
right: 20%;
|
||||
border-bottom: 3px solid transparent;
|
||||
border-right: 5px solid hsl(197,19%,78%);
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar .text-muted {
|
||||
|
|
|
@ -86,7 +86,7 @@ returns
|
|||
types.push 'email'
|
||||
end
|
||||
types.each do |type_name|
|
||||
type = Ticket::Article::Type.lookup( name: type_name )
|
||||
type = Ticket::Article::Type.lookup(name: type_name)
|
||||
next if type.blank?
|
||||
type_ids.push type.id
|
||||
end
|
||||
|
@ -99,7 +99,7 @@ returns
|
|||
filter[:group_id] = []
|
||||
groups = if params[:current_user].permissions?('ticket.agent')
|
||||
if params[:ticket].present?
|
||||
params[:current_user].groups_access(%w[edit])
|
||||
params[:current_user].groups_access(%w[change])
|
||||
else
|
||||
params[:current_user].groups_access(%w[create])
|
||||
end
|
||||
|
|
|
@ -313,10 +313,10 @@ class TicketScreenOptionsTest < ActiveSupport::TestCase
|
|||
Ticket::Article::Type.lookup(name: 'note').id,
|
||||
], result[:form_meta][:filter][:type_id].sort)
|
||||
assert(result[:form_meta][:filter][:group_id])
|
||||
assert_equal([group1.id, group3.id], result[:form_meta][:filter][:group_id].sort)
|
||||
assert_equal([group1.id, group2.id, group3.id], result[:form_meta][:filter][:group_id].sort)
|
||||
assert(result[:form_meta][:dependencies])
|
||||
assert(result[:form_meta][:dependencies][:group_id])
|
||||
assert_equal(3, result[:form_meta][:dependencies][:group_id].count)
|
||||
assert_equal(4, result[:form_meta][:dependencies][:group_id].count)
|
||||
assert(result[:form_meta][:dependencies][:group_id][''])
|
||||
assert(result[:form_meta][:dependencies][:group_id][''][:owner_id])
|
||||
assert_equal([], result[:form_meta][:dependencies][:group_id][''][:owner_id])
|
||||
|
@ -327,6 +327,10 @@ class TicketScreenOptionsTest < ActiveSupport::TestCase
|
|||
assert(result[:form_meta][:dependencies][:group_id][group1.id][:owner_id].include?(agent2.id))
|
||||
assert(result[:form_meta][:dependencies][:group_id][group1.id][:owner_id].include?(agent3.id))
|
||||
assert(result[:form_meta][:dependencies][:group_id][group1.id][:owner_id].include?(agent4.id))
|
||||
assert(result[:form_meta][:dependencies][:group_id][group2.id])
|
||||
assert(result[:form_meta][:dependencies][:group_id][group2.id][:owner_id])
|
||||
assert_equal(1, result[:form_meta][:dependencies][:group_id][group2.id][:owner_id].count)
|
||||
assert(result[:form_meta][:dependencies][:group_id][group2.id][:owner_id].include?(agent3.id))
|
||||
assert(result[:form_meta][:dependencies][:group_id][group3.id])
|
||||
assert(result[:form_meta][:dependencies][:group_id][group3.id][:owner_id])
|
||||
assert_equal(2, result[:form_meta][:dependencies][:group_id][group3.id][:owner_id].count)
|
||||
|
@ -360,10 +364,10 @@ class TicketScreenOptionsTest < ActiveSupport::TestCase
|
|||
Ticket::Article::Type.lookup(name: 'note').id,
|
||||
], result[:form_meta][:filter][:type_id].sort)
|
||||
assert(result[:form_meta][:filter][:group_id])
|
||||
assert_equal([group1.id, group3.id], result[:form_meta][:filter][:group_id].sort)
|
||||
assert_equal([group1.id, group2.id, group3.id], result[:form_meta][:filter][:group_id].sort)
|
||||
assert(result[:form_meta][:dependencies])
|
||||
assert(result[:form_meta][:dependencies][:group_id])
|
||||
assert_equal(3, result[:form_meta][:dependencies][:group_id].count)
|
||||
assert_equal(4, result[:form_meta][:dependencies][:group_id].count)
|
||||
assert(result[:form_meta][:dependencies][:group_id][''])
|
||||
assert(result[:form_meta][:dependencies][:group_id][''][:owner_id])
|
||||
assert_equal([], result[:form_meta][:dependencies][:group_id][''][:owner_id])
|
||||
|
@ -374,6 +378,10 @@ class TicketScreenOptionsTest < ActiveSupport::TestCase
|
|||
assert(result[:form_meta][:dependencies][:group_id][group1.id][:owner_id].include?(agent2.id))
|
||||
assert(result[:form_meta][:dependencies][:group_id][group1.id][:owner_id].include?(agent3.id))
|
||||
assert(result[:form_meta][:dependencies][:group_id][group1.id][:owner_id].include?(agent4.id))
|
||||
assert(result[:form_meta][:dependencies][:group_id][group2.id])
|
||||
assert(result[:form_meta][:dependencies][:group_id][group2.id][:owner_id])
|
||||
assert_equal(1, result[:form_meta][:dependencies][:group_id][group2.id][:owner_id].count)
|
||||
assert(result[:form_meta][:dependencies][:group_id][group2.id][:owner_id].include?(agent3.id))
|
||||
assert(result[:form_meta][:dependencies][:group_id][group3.id])
|
||||
assert(result[:form_meta][:dependencies][:group_id][group3.id][:owner_id])
|
||||
assert_equal(2, result[:form_meta][:dependencies][:group_id][group3.id][:owner_id].count)
|
||||
|
@ -407,10 +415,10 @@ class TicketScreenOptionsTest < ActiveSupport::TestCase
|
|||
Ticket::Article::Type.lookup(name: 'note').id,
|
||||
], result[:form_meta][:filter][:type_id].sort)
|
||||
assert(result[:form_meta][:filter][:group_id])
|
||||
assert_equal([group1.id, group3.id], result[:form_meta][:filter][:group_id].sort)
|
||||
assert_equal([group1.id, group2.id, group3.id], result[:form_meta][:filter][:group_id].sort)
|
||||
assert(result[:form_meta][:dependencies])
|
||||
assert(result[:form_meta][:dependencies][:group_id])
|
||||
assert_equal(3, result[:form_meta][:dependencies][:group_id].count)
|
||||
assert_equal(4, result[:form_meta][:dependencies][:group_id].count)
|
||||
assert(result[:form_meta][:dependencies][:group_id][''])
|
||||
assert(result[:form_meta][:dependencies][:group_id][''][:owner_id])
|
||||
assert_equal([], result[:form_meta][:dependencies][:group_id][''][:owner_id])
|
||||
|
@ -421,6 +429,10 @@ class TicketScreenOptionsTest < ActiveSupport::TestCase
|
|||
assert(result[:form_meta][:dependencies][:group_id][group1.id][:owner_id].include?(agent2.id))
|
||||
assert(result[:form_meta][:dependencies][:group_id][group1.id][:owner_id].include?(agent3.id))
|
||||
assert(result[:form_meta][:dependencies][:group_id][group1.id][:owner_id].include?(agent4.id))
|
||||
assert(result[:form_meta][:dependencies][:group_id][group2.id])
|
||||
assert(result[:form_meta][:dependencies][:group_id][group2.id][:owner_id])
|
||||
assert_equal(1, result[:form_meta][:dependencies][:group_id][group2.id][:owner_id].count)
|
||||
assert(result[:form_meta][:dependencies][:group_id][group2.id][:owner_id].include?(agent3.id))
|
||||
assert(result[:form_meta][:dependencies][:group_id][group3.id])
|
||||
assert(result[:form_meta][:dependencies][:group_id][group3.id][:owner_id])
|
||||
assert_equal(2, result[:form_meta][:dependencies][:group_id][group3.id][:owner_id].count)
|
||||
|
@ -455,10 +467,10 @@ class TicketScreenOptionsTest < ActiveSupport::TestCase
|
|||
Ticket::Article::Type.lookup(name: 'note').id,
|
||||
], result[:form_meta][:filter][:type_id].sort)
|
||||
assert(result[:form_meta][:filter][:group_id])
|
||||
assert_equal([group1.id], result[:form_meta][:filter][:group_id].sort)
|
||||
assert_equal([group1.id, group2.id], result[:form_meta][:filter][:group_id].sort)
|
||||
assert(result[:form_meta][:dependencies])
|
||||
assert(result[:form_meta][:dependencies][:group_id])
|
||||
assert_equal(2, result[:form_meta][:dependencies][:group_id].count)
|
||||
assert_equal(3, result[:form_meta][:dependencies][:group_id].count)
|
||||
assert(result[:form_meta][:dependencies][:group_id][''])
|
||||
assert(result[:form_meta][:dependencies][:group_id][''][:owner_id])
|
||||
assert_equal([], result[:form_meta][:dependencies][:group_id][''][:owner_id])
|
||||
|
@ -469,6 +481,10 @@ class TicketScreenOptionsTest < ActiveSupport::TestCase
|
|||
assert(result[:form_meta][:dependencies][:group_id][group1.id][:owner_id].include?(agent2.id))
|
||||
assert(result[:form_meta][:dependencies][:group_id][group1.id][:owner_id].include?(agent3.id))
|
||||
assert(result[:form_meta][:dependencies][:group_id][group1.id][:owner_id].include?(agent4.id))
|
||||
assert(result[:form_meta][:dependencies][:group_id][group2.id])
|
||||
assert(result[:form_meta][:dependencies][:group_id][group2.id][:owner_id])
|
||||
assert_equal(1, result[:form_meta][:dependencies][:group_id][group2.id][:owner_id].count)
|
||||
assert(result[:form_meta][:dependencies][:group_id][group2.id][:owner_id].include?(agent3.id))
|
||||
|
||||
result = Ticket::ScreenOptions.attributes_to_change(
|
||||
ticket_id: ticket2.id,
|
||||
|
@ -497,10 +513,10 @@ class TicketScreenOptionsTest < ActiveSupport::TestCase
|
|||
Ticket::Article::Type.lookup(name: 'note').id,
|
||||
], result[:form_meta][:filter][:type_id].sort)
|
||||
assert(result[:form_meta][:filter][:group_id])
|
||||
assert_equal([group1.id], result[:form_meta][:filter][:group_id].sort)
|
||||
assert_equal([group1.id, group2.id], result[:form_meta][:filter][:group_id].sort)
|
||||
assert(result[:form_meta][:dependencies])
|
||||
assert(result[:form_meta][:dependencies][:group_id])
|
||||
assert_equal(2, result[:form_meta][:dependencies][:group_id].count)
|
||||
assert_equal(3, result[:form_meta][:dependencies][:group_id].count)
|
||||
assert(result[:form_meta][:dependencies][:group_id][''])
|
||||
assert(result[:form_meta][:dependencies][:group_id][''][:owner_id])
|
||||
assert_equal([], result[:form_meta][:dependencies][:group_id][''][:owner_id])
|
||||
|
@ -511,6 +527,10 @@ class TicketScreenOptionsTest < ActiveSupport::TestCase
|
|||
assert(result[:form_meta][:dependencies][:group_id][group1.id][:owner_id].include?(agent2.id))
|
||||
assert(result[:form_meta][:dependencies][:group_id][group1.id][:owner_id].include?(agent3.id))
|
||||
assert(result[:form_meta][:dependencies][:group_id][group1.id][:owner_id].include?(agent4.id))
|
||||
assert(result[:form_meta][:dependencies][:group_id][group2.id])
|
||||
assert(result[:form_meta][:dependencies][:group_id][group2.id][:owner_id])
|
||||
assert_equal(1, result[:form_meta][:dependencies][:group_id][group2.id][:owner_id].count)
|
||||
assert(result[:form_meta][:dependencies][:group_id][group2.id][:owner_id].include?(agent3.id))
|
||||
|
||||
result = Ticket::ScreenOptions.attributes_to_change(
|
||||
ticket_id: ticket1.id,
|
||||
|
|
Loading…
Reference in a new issue