Skip to content

Commit

Permalink
Implemented CTI ticket create screen popup on answering call.
Browse files Browse the repository at this point in the history
  • Loading branch information
zammad-sync committed Jul 9, 2019
1 parent 9503ff2 commit 7faa4c3
Show file tree
Hide file tree
Showing 31 changed files with 1,839 additions and 462 deletions.
6 changes: 3 additions & 3 deletions LICENSE-3RD-PARTY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ License: MIT license
highlight.pack.js
Source: https://highlightjs.org
Copyright: 2006 Ivan Sagalaev (https://github.com/isagalaev)
License: BSD License
License: BSD License (BSD-3-Clause)
-----------------------------------------------------------------------------
jquery.flot.js
Source: https://github.com/dnschnur/flot
Expand All @@ -74,7 +74,7 @@ jquery.fineuploader-3.0.js
Source: http://github.com/Valums-File-Uploader/file-uploader
Copyright: 2010 Andrew Valums <andrew(at)valums.com>
2012 Ray Nicholus <fineuploader(at)garstasio.com>
License: MIT license, GNU GPL 2 or later, GNU LGPL 2 or later
License: GNU GPL 2 or later, GNU LGPL 2 or later
-----------------------------------------------------------------------------
jquery.noty.js
Source: https://github.com/needim/noty/
Expand Down Expand Up @@ -171,7 +171,7 @@ License: MIT license
Font Awesome icon font
Source: http://fontawesome.io/
Copyright: Font Awesome by Dave Gandy - http://fontawesome.io
License: SIL OFL 1.1
License: MIT License
-----------------------------------------------------------------------------
Simple line icons font
Source: https://github.com/thesabbir/simple-line-icons
Expand Down
83 changes: 83 additions & 0 deletions app/assets/javascripts/app/controllers/_integration/cti.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ class Form extends App.Controller
'submit form': 'update'
'click .js-inboundBlockCallerId .js-add': 'addInboundBlockCallerId'
'click .js-outboundRouting .js-add': 'addOutboundRouting'
'click .js-notifyMap .js-addMap': 'addNotifyMap'
'click .js-inboundBlockCallerId .js-remove': 'removeInboundBlockCallerId'
'click .js-outboundRouting .js-remove': 'removeOutboundRouting'
'click .js-notifyMap .js-removeMap': 'removeNotifyMap'

constructor: ->
super
Expand All @@ -43,6 +45,8 @@ class Form extends App.Controller
config.inbound = {}
if !config.inbound.block_caller_ids
config.inbound.block_caller_ids = []
if !config.notify_map
config.notify_map = []
config

setConfig: (value) ->
Expand All @@ -56,6 +60,32 @@ class Form extends App.Controller
cti_token: App.Setting.get('cti_token')
)

# placeholder
configure_attributes = [
{ name: 'user_ids', display: '', tag: 'column_select', multiple: true, null: true, relation: 'User', sortBy: 'firstname' },
]
new App.ControllerForm(
el: @$('.js-userSelectorBlank')
model:
configure_attributes: configure_attributes,
params:
user_ids: []
autofocus: false
)

for row in @config.notify_map
configure_attributes = [
{ name: 'user_ids', display: '', tag: 'column_select', multiple: true, null: true, relation: 'User', sortBy: 'firstname' },
]
new App.ControllerForm(
el: @$("[name=queue][value='#{row.queue}']").closest('tr').find('.js-userSelector')
model:
configure_attributes: configure_attributes,
params:
user_ids: row.user_ids
autofocus: false
)

updateCurrentConfig: =>
config = @config
cleanupInput = @cleanupInput
Expand Down Expand Up @@ -88,6 +118,17 @@ class Form extends App.Controller
}
)

# notify map
config.notify_map = []
@$('.js-notifyMap .js-row').each(->
queue = $(@).find('input[name="queue"]').val()
user_ids = $(@).find('select[name="user_ids"]').val()
config.notify_map.push {
queue: cleanupInput(queue)
user_ids: user_ids
}
)

@config = config

update: (e) =>
Expand Down Expand Up @@ -127,6 +168,41 @@ class Form extends App.Controller
}
@render()

addNotifyMap: (e) =>
e.preventDefault()
@updateCurrentConfig()
element = $(e.currentTarget).closest('tr')
queue = @cleanupInput(element.find('input[name="queue"]').val())
user_ids = element.find('select[name="user_ids"]').val()
if _.isEmpty(queue)
@notify(
type: 'error'
msg: App.i18n.translateContent('A queue is required!')
timeout: 6000
)
return
if _.isEmpty(user_ids)
@notify(
type: 'error'
msg: App.i18n.translateContent('A user is required!')
timeout: 6000
)
return

for row in @config.notify_map
if row.queue is queue
@notify(
type: 'error'
msg: App.i18n.translateContent('Queue already exists!')
timeout: 6000
)
return
@config.notify_map.push {
queue: queue
user_ids: user_ids
}
@render()

removeInboundBlockCallerId: (e) =>
e.preventDefault()
@updateCurrentConfig()
Expand All @@ -141,6 +217,13 @@ class Form extends App.Controller
element.remove()
@updateCurrentConfig()

removeNotifyMap: (e) =>
e.preventDefault()
@updateCurrentConfig()
element = $(e.currentTarget).closest('tr')
element.remove()
@updateCurrentConfig()

class State
@current: ->
App.Setting.get('cti_integration')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ class Form extends App.Controller
events:
'submit form': 'update'
'click .js-inboundBlockCallerId .js-add': 'addInboundBlockCallerId'
'click .js-outboundRouting .js-add': 'addOutboundRouting'
'click .js-inboundBlockCallerId .js-remove': 'removeInboundBlockCallerId'
'click .js-outboundRouting .js-add': 'addOutboundRouting'
'click .js-outboundRouting .js-remove': 'removeOutboundRouting'
'click .js-userDeviceMap .js-add': 'addUserDeviceMap'
'click .js-userDeviceMap .js-remove': 'removeUserDeviceMap'

constructor: ->
super
Expand All @@ -43,6 +45,8 @@ class Form extends App.Controller
config.inbound = {}
if !config.inbound.block_caller_ids
config.inbound.block_caller_ids = []
if !config.user_device_map
config.user_device_map = []
config

setConfig: (value) ->
Expand All @@ -60,7 +64,7 @@ class Form extends App.Controller
config = @config
cleanupInput = @cleanupInput

config.api_token = @$('input[name=api_token]').val()
config.api_token = cleanupInput(@$('input[name=api_token]').val())

# default caller_id
default_caller_id = @$('input[name=default_caller_id]').val()
Expand Down Expand Up @@ -90,6 +94,17 @@ class Form extends App.Controller
}
)

# user device map
config.user_device_map = []
@$('.js-userDeviceMap .js-row').each(->
device_id = $(@).find('input[name="device_id"]').val()
user_id = $(@).find('input[name="user_id"]').val()
config.user_device_map.push {
device_id: device_id
user_id: user_id
}
)

@config = config

update: (e) =>
Expand All @@ -114,6 +129,13 @@ class Form extends App.Controller
}
@render()

removeInboundBlockCallerId: (e) =>
e.preventDefault()
@updateCurrentConfig()
element = $(e.currentTarget).closest('tr')
element.remove()
@updateCurrentConfig()

addOutboundRouting: (e) =>
e.preventDefault()
@updateCurrentConfig()
Expand All @@ -129,14 +151,27 @@ class Form extends App.Controller
}
@render()

removeInboundBlockCallerId: (e) =>
removeOutboundRouting: (e) =>
e.preventDefault()
@updateCurrentConfig()
element = $(e.currentTarget).closest('tr')
element.remove()
@updateCurrentConfig()

removeOutboundRouting: (e) =>
addUserDeviceMap: (e) =>
e.preventDefault()
@updateCurrentConfig()
element = $(e.currentTarget).closest('tr')
user_id = @cleanupInput(element.find('input[name="user_id"]').val())
device_id = @cleanupInput(element.find('input[name="device_id"]').val())
return if _.isEmpty(user_id) || _.isEmpty(device_id)
@config.user_device_map.push {
user_id: user_id
device_id: device_id
}
@render()

removeUserDeviceMap: (e) =>
e.preventDefault()
@updateCurrentConfig()
element = $(e.currentTarget).closest('tr')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class Form extends App.Controller
'click .js-outboundRouting .js-add': 'addOutboundRouting'
'click .js-inboundBlockCallerId .js-remove': 'removeInboundBlockCallerId'
'click .js-outboundRouting .js-remove': 'removeOutboundRouting'
'click .js-userRemoteMap .js-add': 'addUserRemoteMap'
'click .js-userRemoteMap .js-remove': 'removeUserRemoteMap'

constructor: ->
super
Expand All @@ -43,6 +45,8 @@ class Form extends App.Controller
config.inbound = {}
if !config.inbound.block_caller_ids
config.inbound.block_caller_ids = []
if !config.user_remote_map
config.user_remote_map = []
config

setConfig: (value) ->
Expand All @@ -59,6 +63,9 @@ class Form extends App.Controller
config = @config
cleanupInput = @cleanupInput

config.api_user = cleanupInput(@$('input[name=api_user]').val())
config.api_password = cleanupInput(@$('input[name=api_password]').val())

# default caller_id
default_caller_id = @$('input[name=default_caller_id]').val()
config.outbound.default_caller_id = cleanupInput(default_caller_id)
Expand Down Expand Up @@ -87,6 +94,17 @@ class Form extends App.Controller
}
)

# user device map
config.user_remote_map = []
@$('.js-userRemoteMap .js-row').each(->
remote_user_id = $(@).find('input[name="remote_user_id"]').val()
user_id = $(@).find('input[name="user_id"]').val()
config.user_remote_map.push {
remote_user_id: remote_user_id
user_id: user_id
}
)

@config = config

update: (e) =>
Expand Down Expand Up @@ -140,6 +158,26 @@ class Form extends App.Controller
element.remove()
@updateCurrentConfig()

addUserRemoteMap: (e) =>
e.preventDefault()
@updateCurrentConfig()
element = $(e.currentTarget).closest('tr')
user_id = @cleanupInput(element.find('input[name="user_id"]').val())
remote_user_id = @cleanupInput(element.find('input[name="remote_user_id"]').val())
return if _.isEmpty(user_id) || _.isEmpty(remote_user_id)
@config.user_remote_map.push {
user_id: user_id
remote_user_id: remote_user_id
}
@render()

removeUserRemoteMap: (e) =>
e.preventDefault()
@updateCurrentConfig()
element = $(e.currentTarget).closest('tr')
element.remove()
@updateCurrentConfig()

class State
@current: ->
App.Setting.get('sipgate_integration')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class App.TicketCreate extends App.Controller

if _.isEmpty(params.ticket_id) && _.isEmpty(params.article_id)
if !_.isEmpty(params.customer_id)
@renderQueue(options: { customer_id: params.customer_id })
@renderQueue(options: params)
return
@renderQueue()
return
Expand Down
Loading

0 comments on commit 7faa4c3

Please sign in to comment.