Skip to content

Commit

Permalink
Fixes #5082 - [CTI] The ticket title is not automatically filled when…
Browse files Browse the repository at this point in the history
… opening the "new ticket screen" if the caller is unknown

Co-authored-by: Rolf Schmidt rolf.schmidt@zammad.com
  • Loading branch information
zammad-sync committed Mar 15, 2024
1 parent de803f1 commit 144f4e9
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
Expand Up @@ -302,9 +302,15 @@ class App.TicketCreate extends App.Controller
buildScreen: (params) =>

if _.isEmpty(params.ticket_id) && _.isEmpty(params.article_id)
if !_.isEmpty(params.customer_id)
@renderQueue(options: _.omit(params, 'id'))

# remove not form relevant options
localOptions = _.omit(params, 'id', 'query', 'shown', 'taskKey', 'ticket_id', 'article_id', 'appEl', 'el', 'type')
localOptions = _.omit(localOptions, _.isUndefined)

if !_.isEmpty(localOptions)
@renderQueue(options: localOptions)
return

@renderQueue()
return

Expand Down
4 changes: 3 additions & 1 deletion app/models/cti/driver/base.rb
Expand Up @@ -157,12 +157,14 @@ def push_open_ticket_screen(log)
end

id = SecureRandom.uuid
title = Translation.translate(user.locale, __('Call from %s'), @params[:from])

PushMessages.send_to(user.id, {
event: 'remote_task',
data: {
key: "TicketCreateScreen-#{id}",
controller: 'TicketCreate',
params: { customer_id: customer_id.to_s, title: 'Call', id: id },
params: { customer_id: customer_id.to_s, title: title, id: id },
show: true,
url: "ticket/create/id/#{id}"
},
Expand Down
4 changes: 4 additions & 0 deletions i18n/zammad.pot
Expand Up @@ -2053,6 +2053,10 @@ msgstr ""
msgid "Call Settings"
msgstr ""

#: app/models/cti/driver/base.rb
msgid "Call from %s"
msgstr ""

#: app/assets/javascripts/app/controllers/cti.coffee
msgid "Call from %s for %s"
msgstr ""
Expand Down
24 changes: 22 additions & 2 deletions spec/system/cti_spec.rb
Expand Up @@ -96,7 +96,7 @@ def authenticate
context 'when a customer call is answered' do
let(:second_params) { params.merge(event: 'answer', answeringNumber: agent_phone) }

context 'without active tickets' do
context 'with known customer and without active tickets' do
before do
travel(-2.months)
create(:ticket, customer: customer)
Expand All @@ -109,11 +109,31 @@ def authenticate
it 'opens a new ticket after phone call inbound' do
within(:active_content) do
expect(page).to have_text('New Ticket')
expect(page).to have_css('input[name="title"][value="Call from 0190333"]', visible: :all)
expect(page).to have_css('.tabsSidebar-tab[data-tab="customer"]', visible: :all)
end
end
end

context 'with active tickets' do
context 'without known customer and without active tickets' do
let(:first_params) { params.merge(event: 'newCall', direction: 'out', from: '001', to: '002') }
let(:second_params) { params.merge(event: 'answer', answeringNumber: agent_phone) }

before do
visit_cti
place_call
end

it 'opens a new ticket after phone call inbound' do
within(:active_content) do
expect(page).to have_text('New Ticket')
expect(page).to have_css("input[name='title'][value='Call from 0190333']", visible: :all)
expect(page).to have_no_css('.tabsSidebar-tab[data-tab="customer"]')
end
end
end

context 'with known customer and with active tickets' do
before do
create(:ticket, customer: customer)
visit_cti
Expand Down

0 comments on commit 144f4e9

Please sign in to comment.