Fixes #2647 - Enhance CTI-Caller-Log to "mark as seen" all unread entries at once
This commit is contained in:
parent
ebe053efca
commit
08a98efca4
6 changed files with 83 additions and 8 deletions
|
@ -5,8 +5,9 @@ class App.CTI extends App.Controller
|
||||||
elements:
|
elements:
|
||||||
'.js-callerLog': 'callerLog'
|
'.js-callerLog': 'callerLog'
|
||||||
events:
|
events:
|
||||||
'click .js-check': 'done'
|
'click .js-check': 'done'
|
||||||
'click .js-newUser': 'newUser'
|
'click .js-checkAll': 'doneAll'
|
||||||
|
'click .js-newUser': 'newUser'
|
||||||
list: []
|
list: []
|
||||||
backends: []
|
backends: []
|
||||||
meta:
|
meta:
|
||||||
|
@ -191,10 +192,23 @@ class App.CTI extends App.Controller
|
||||||
|
|
||||||
@updateNavMenu()
|
@updateNavMenu()
|
||||||
|
|
||||||
|
doneAll: =>
|
||||||
|
|
||||||
|
# get id's of all unchecked caller logs
|
||||||
|
@logIds = $('.js-callerLog').map(->
|
||||||
|
return $(@).data('id') if !$(@).find('.js-check').prop('checked')
|
||||||
|
).get()
|
||||||
|
|
||||||
|
@ajax(
|
||||||
|
type: 'POST'
|
||||||
|
url: "#{@apiPath}/cti/done/bulk"
|
||||||
|
data: JSON.stringify({ids: @logIds})
|
||||||
|
)
|
||||||
|
|
||||||
done: (e) =>
|
done: (e) =>
|
||||||
element = $(e.currentTarget)
|
element = $(e.currentTarget)
|
||||||
id = element.closest('tr').data('id')
|
id = element.closest('tr').data('id')
|
||||||
done = element.prop('checked')
|
done = element.prop('checked')
|
||||||
@ajax(
|
@ajax(
|
||||||
type: 'POST'
|
type: 'POST'
|
||||||
url: "#{@apiPath}/cti/done/#{id}"
|
url: "#{@apiPath}/cti/done/#{id}"
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
<table class="table table-striped table-hover">
|
<table class="table table-striped table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th style="width: 40px;"></th>
|
<th style="width: 40px;">
|
||||||
|
<label class="checkbox-replacement checkbox-replacement--fullscreen">
|
||||||
|
<input type="checkbox" class="js-checkAll">
|
||||||
|
<%- @Icon('checkbox', 'icon-unchecked') %>
|
||||||
|
<%- @Icon('checkbox-checked', 'icon-checked') %>
|
||||||
|
</label>
|
||||||
|
</th>
|
||||||
<th><%- @T('From') %></th>
|
<th><%- @T('From') %></th>
|
||||||
<th><%- @T('To') %></th>
|
<th><%- @T('To') %></th>
|
||||||
<!--<th style="width: 100px;"><%- @T('Queue') %></th>-->
|
<!--<th style="width: 100px;"><%- @T('Queue') %></th>-->
|
||||||
|
@ -13,7 +19,7 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<% for item in @list: %>
|
<% for item in @list: %>
|
||||||
<tr class="u-center<% if item.done: %> is-grayed-out<% end %>" data-id="<%- item.id %>">
|
<tr class="u-center js-callerLog <% if item.done: %> is-grayed-out<% end %>" data-id="<%- item.id %>">
|
||||||
<td class="table-checkbox u-positionOrigin">
|
<td class="table-checkbox u-positionOrigin">
|
||||||
<label class="checkbox-replacement checkbox-replacement--fullscreen<% if item.disabled is true: %> is-disabled<% end %>">
|
<label class="checkbox-replacement checkbox-replacement--fullscreen<% if item.disabled is true: %> is-disabled<% end %>">
|
||||||
<input type="checkbox" class="js-check"<% if item.done: %> checked<% end %><% if item.disabled is true: %> disabled<% end %>>
|
<input type="checkbox" class="js-check"<% if item.done: %> checked<% end %><% if item.disabled is true: %> disabled<% end %>>
|
||||||
|
|
|
@ -4,6 +4,7 @@ class CtiController < ApplicationController
|
||||||
prepend_before_action { authentication_check(permission: 'cti.agent') }
|
prepend_before_action { authentication_check(permission: 'cti.agent') }
|
||||||
|
|
||||||
# list current caller log
|
# list current caller log
|
||||||
|
# GET /api/v1/cti/log
|
||||||
def index
|
def index
|
||||||
backends = [
|
backends = [
|
||||||
{
|
{
|
||||||
|
@ -29,6 +30,7 @@ class CtiController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# set caller log to done
|
# set caller log to done
|
||||||
|
# POST /api/v1/cti/done/:id
|
||||||
def done
|
def done
|
||||||
log = Cti::Log.find(params['id'])
|
log = Cti::Log.find(params['id'])
|
||||||
log.done = params['done']
|
log.done = params['done']
|
||||||
|
@ -36,4 +38,17 @@ class CtiController < ApplicationController
|
||||||
render json: {}
|
render json: {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# sets for all given ids the caller log to done
|
||||||
|
# POST /api/v1/cti/done/bulk
|
||||||
|
def done_bulk
|
||||||
|
|
||||||
|
log_ids = params['ids'] || []
|
||||||
|
log_ids.each do |log_id|
|
||||||
|
log = Cti::Log.find(log_id)
|
||||||
|
log.done = true
|
||||||
|
log.save!
|
||||||
|
end
|
||||||
|
render json: {}
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
Zammad::Application.routes.draw do
|
Zammad::Application.routes.draw do
|
||||||
|
api_path = Rails.configuration.api_path
|
||||||
|
|
||||||
match '/api/v1/cti/log', to: 'cti#index', via: :get
|
match api_path + '/cti/log', to: 'cti#index', via: :get
|
||||||
match '/api/v1/cti/done/:id', to: 'cti#done', via: :post
|
match api_path + '/cti/done/bulk', to: 'cti#done_bulk', via: :post
|
||||||
|
match api_path + '/cti/done/:id', to: 'cti#done', via: :post
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,6 +5,7 @@ FactoryBot.define do
|
||||||
from { '4930609854180' }
|
from { '4930609854180' }
|
||||||
to { '4930609811111' }
|
to { '4930609811111' }
|
||||||
call_id { (Cti::Log.pluck(:call_id).map(&:to_i).max || 0).next } # has SQL UNIQUE constraint
|
call_id { (Cti::Log.pluck(:call_id).map(&:to_i).max || 0).next } # has SQL UNIQUE constraint
|
||||||
|
done { false }
|
||||||
|
|
||||||
trait :with_preferences do
|
trait :with_preferences do
|
||||||
preferences { Cti::CallerId.get_comment_preferences(from, 'from')&.last }
|
preferences { Cti::CallerId.get_comment_preferences(from, 'from')&.last }
|
||||||
|
|
|
@ -795,5 +795,42 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
expect(log.duration_talking_time).to be_nil
|
expect(log.duration_talking_time).to be_nil
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'flags caller_log as done' do
|
||||||
|
|
||||||
|
cti_log1 = create(:cti_log)
|
||||||
|
log = Cti::Log.find(cti_log1.id)
|
||||||
|
expect(log.done).to eq(false)
|
||||||
|
|
||||||
|
authenticated_as(agent_user)
|
||||||
|
post "/api/v1/cti/done/#{cti_log1.id}", params: {
|
||||||
|
done: true
|
||||||
|
}
|
||||||
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
|
log = Cti::Log.find(cti_log1.id)
|
||||||
|
expect(log.done).to eq(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'flags all caller_logs as done via done_bulk' do
|
||||||
|
|
||||||
|
cti_log1 = create(:cti_log)
|
||||||
|
cti_log2 = create(:cti_log)
|
||||||
|
|
||||||
|
log = Cti::Log.find(cti_log1.id)
|
||||||
|
expect(log.done).to eq(false)
|
||||||
|
|
||||||
|
authenticated_as(agent_user)
|
||||||
|
post '/api/v1/cti/done/bulk', params: {
|
||||||
|
ids: [cti_log1.id, cti_log2.id]
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(response).to have_http_status(:ok)
|
||||||
|
log1 = Cti::Log.find(cti_log1.id)
|
||||||
|
expect(log1.done).to eq(true)
|
||||||
|
|
||||||
|
log2 = Cti::Log.find(cti_log2.id)
|
||||||
|
expect(log2.done).to eq(true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue