From 08a98efca4eab36bd74bfd851b79aad8ecdfcc45 Mon Sep 17 00:00:00 2001 From: Denny Bresch Date: Sat, 17 Aug 2019 00:24:50 +0200 Subject: [PATCH] Fixes #2647 - Enhance CTI-Caller-Log to "mark as seen" all unread entries at once --- .../javascripts/app/controllers/cti.coffee | 22 +++++++++-- .../app/views/cti/caller_log.jst.eco | 10 ++++- app/controllers/cti_controller.rb | 15 ++++++++ config/routes/cti.rb | 6 ++- spec/factories/cti/log.rb | 1 + spec/requests/integration/cti_spec.rb | 37 +++++++++++++++++++ 6 files changed, 83 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/app/controllers/cti.coffee b/app/assets/javascripts/app/controllers/cti.coffee index 9244701b9..ea65e59dc 100644 --- a/app/assets/javascripts/app/controllers/cti.coffee +++ b/app/assets/javascripts/app/controllers/cti.coffee @@ -5,8 +5,9 @@ class App.CTI extends App.Controller elements: '.js-callerLog': 'callerLog' events: - 'click .js-check': 'done' - 'click .js-newUser': 'newUser' + 'click .js-check': 'done' + 'click .js-checkAll': 'doneAll' + 'click .js-newUser': 'newUser' list: [] backends: [] meta: @@ -191,10 +192,23 @@ class App.CTI extends App.Controller @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) => element = $(e.currentTarget) - id = element.closest('tr').data('id') - done = element.prop('checked') + id = element.closest('tr').data('id') + done = element.prop('checked') @ajax( type: 'POST' url: "#{@apiPath}/cti/done/#{id}" diff --git a/app/assets/javascripts/app/views/cti/caller_log.jst.eco b/app/assets/javascripts/app/views/cti/caller_log.jst.eco index b3551483f..ea3d40ffd 100644 --- a/app/assets/javascripts/app/views/cti/caller_log.jst.eco +++ b/app/assets/javascripts/app/views/cti/caller_log.jst.eco @@ -1,7 +1,13 @@ - + @@ -13,7 +19,7 @@ <% for item in @list: %> - +
+ + <%- @T('From') %> <%- @T('To') %>