Fixes #563, Closes #3273 - Sidebar - Customer - Open tickets should be clickable and open advanced search.

This commit is contained in:
Rolf Schmidt 2021-05-17 14:39:33 +00:00 committed by Thorsten Eckel
parent cacfb4b909
commit 992aa6d837
3 changed files with 90 additions and 3 deletions

View file

@ -14,6 +14,15 @@ class App.WidgetUser extends App.Controller
release: => release: =>
App.User.unsubscribe(@subscribeId) App.User.unsubscribe(@subscribeId)
getAdvancedSearchUrl: (customer_id, states) ->
states_string = ''
if states.length > 1
states_string = ' AND state.name:("' + states.join('" OR "') + '")'
else
states_string = " AND state.name:\"#{states[0]}\""
return "/#search/customer_id:#{customer_id}#{states_string}"
render: (user) => render: (user) =>
# execute callback on render/rerender # execute callback on render/rerender
@ -48,8 +57,9 @@ class App.WidgetUser extends App.Controller
if user.preferences if user.preferences
items = [] items = []
if user.preferences.tickets_open > 0 if user.preferences.tickets_open > 0
states_open = App.TicketState.byCategory('open').map((state) -> state.name)
item = item =
url: '' url: @getAdvancedSearchUrl(@user_id, states_open)
name: 'open' name: 'open'
count: user.preferences.tickets_open count: user.preferences.tickets_open
title: 'Open Tickets' title: 'Open Tickets'
@ -57,8 +67,9 @@ class App.WidgetUser extends App.Controller
data: 'open' data: 'open'
items.push item items.push item
if user.preferences.tickets_closed > 0 if user.preferences.tickets_closed > 0
states_closed = App.TicketState.byCategory('closed').map((state) -> state.name)
item = item =
url: '' url: @getAdvancedSearchUrl(@user_id, states_closed)
name: 'closed' name: 'closed'
count: user.preferences.tickets_closed count: user.preferences.tickets_closed
title: 'Closed Tickets' title: 'Closed Tickets'

View file

@ -12,3 +12,53 @@ class App.TicketState extends App.Model
@configure_overview = [ @configure_overview = [
'name', 'name',
] ]
@byCategory: (category) ->
switch category
when 'open'
state_types = ['new', 'open', 'pending reminder', 'pending action']
break
when 'pending_reminder'
state_types = ['pending reminder']
break
when 'pending_action'
state_types = ['pending action']
break
when 'pending'
state_types = ['pending reminder', 'pending action']
break
when 'work_on'
state_types = ['new', 'open']
break
when 'work_on_all'
state_types = ['new', 'open', 'pending reminder']
break
when 'viewable'
state_types = ['new', 'open', 'pending reminder', 'pending action', 'closed', 'removed']
break
when 'viewable_agent_new'
state_types = ['new', 'open', 'pending reminder', 'pending action', 'closed']
break
when 'viewable_agent_edit'
state_types = ['open', 'pending reminder', 'pending action', 'closed']
break
when 'viewable_customer_new'
state_types = ['new', 'closed']
break
when 'viewable_customer_edit'
state_types = ['open', 'closed']
break
when 'closed'
state_types = ['closed']
break
when 'merged'
state_types = ['merged']
break
else
state_types = []
result = []
for state in App.TicketState.all()
continue if !_.contains(state_types, App.TicketStateType.find(state.state_type_id).name)
result.push(state)
result

View file

@ -1652,4 +1652,30 @@ RSpec.describe 'Ticket zoom', type: :system do
end end
end end
end end
context 'Sidebar - Open & Closed Tickets', searchindex: true, authenticated_as: :authenticate do
let(:customer) { create(:customer, :with_org) }
let(:ticket_open) { create(:ticket, group: Group.find_by(name: 'Users'), customer: customer, title: SecureRandom.uuid) }
let(:ticket_closed) { create(:ticket, group: Group.find_by(name: 'Users'), customer: customer, state: Ticket::State.find_by(name: 'closed'), title: SecureRandom.uuid) }
def authenticate
ticket_open
ticket_closed
configure_elasticsearch(required: true, rebuild: true)
Scheduler.worker(true)
true
end
it 'does show open and closed tickets in advanced search url' do
visit "#ticket/zoom/#{ticket_open.id}"
click '.tabsSidebar-tab[data-tab=customer]'
click '.user-tickets[data-type=open]'
expect(page).to have_text(ticket_open.title, wait: 20)
visit "#ticket/zoom/#{ticket_open.id}"
click '.tabsSidebar-tab[data-tab=customer]'
click '.user-tickets[data-type=closed]'
expect(page).to have_text(ticket_closed.title, wait: 20)
end
end
end end