Added plugin mechanism to configure plugins if a form field in ticket create or ticket zoom has changed (ported group based signature and form dependencies to plugins).

This commit is contained in:
Martin Edenhofer 2018-02-27 09:54:50 +01:00
parent 1e311034a0
commit 8005d3aee5
21 changed files with 278 additions and 231 deletions

View file

@ -227,7 +227,7 @@ class App.Controller extends Spine.Controller
App.Config.set('requested_url', location) App.Config.set('requested_url', location)
if closeTab if closeTab
App.TaskManager.remove(@task_key) App.TaskManager.remove(@taskKey)
# redirect to login # redirect to login
@navigate '#login' @navigate '#login'
@ -547,32 +547,6 @@ class App.Controller extends Spine.Controller
item.created_by = App.User.findNative(item.created_by_id) item.created_by = App.User.findNative(item.created_by_id)
item item
# central method, is getting called on every ticket form change
ticketFormChanges: (params, attribute, attributes, classname, form, ui) =>
if @formMeta.dependencies && @formMeta.dependencies[attribute.name]
dependency = @formMeta.dependencies[attribute.name][ parseInt(params[attribute.name]) ]
if !dependency
dependency = @formMeta.dependencies[attribute.name][ params[attribute.name] ]
if dependency
for fieldNameToChange of dependency
filter = []
if dependency[fieldNameToChange]
filter = dependency[fieldNameToChange]
# find element to replace
for item in attributes
if item.name is fieldNameToChange
item['filter'] = {}
item['filter'][ fieldNameToChange ] = filter
item.default = params[item.name]
#if !item.default
# delete item['default']
newElement = ui.formGenItem(item, classname, form)
# replace new option list
if newElement
form.find('[name="' + fieldNameToChange + '"]').closest('.form-group').replaceWith(newElement)
stopPropagation: (e) -> stopPropagation: (e) ->
e.stopPropagation() e.stopPropagation()
@ -592,19 +566,19 @@ class App.Controller extends Spine.Controller
@clearDelay(@initLoadingDoneDelay) @clearDelay(@initLoadingDoneDelay)
renderScreenSuccess: (data) -> renderScreenSuccess: (data) ->
App.TaskManager.touch(@task_key) if @task_key App.TaskManager.touch(@taskKey) if @taskKey
(data.el || @).html App.view('generic/error/success')(data) (data.el || @).html App.view('generic/error/success')(data)
renderScreenError: (data) -> renderScreenError: (data) ->
App.TaskManager.touch(@task_key) if @task_key App.TaskManager.touch(@taskKey) if @taskKey
(data.el || @).html App.view('generic/error/generic')(data) (data.el || @).html App.view('generic/error/generic')(data)
renderScreenNotFound: (data) -> renderScreenNotFound: (data) ->
App.TaskManager.touch(@task_key) if @task_key App.TaskManager.touch(@taskKey) if @taskKey
(data.el || @).html App.view('generic/error/not_found')(data) (data.el || @).html App.view('generic/error/not_found')(data)
renderScreenUnauthorized: (data) -> renderScreenUnauthorized: (data) ->
App.TaskManager.touch(@task_key) if @task_key App.TaskManager.touch(@taskKey) if @taskKey
(data.el || @).html App.view('generic/error/unauthorized')(data) (data.el || @).html App.view('generic/error/unauthorized')(data)
locationVerify: (e) => locationVerify: (e) =>
@ -901,7 +875,7 @@ class App.UpdateTastbar extends App.Controller
update: (genericObject) => update: (genericObject) =>
# update taskbar with new meta data # update taskbar with new meta data
App.TaskManager.touch(@task_key) App.TaskManager.touch(@taskKey)
class App.ControllerWidgetPermanent extends App.Controller class App.ControllerWidgetPermanent extends App.Controller
constructor: (params) -> constructor: (params) ->

View file

@ -6,6 +6,12 @@ class App.ControllerForm extends App.Controller
if !@handlers if !@handlers
@handlers = [] @handlers = []
if @handlersConfig
for key, value of @handlersConfig
if value && value.run
@handlers.push value.run
@handlers.push @showHideToggle @handlers.push @showHideToggle
@handlers.push @requiredMandantoryToggle @handlers.push @requiredMandantoryToggle

View file

@ -28,9 +28,17 @@ class App.TicketCreate extends App.Controller
@bindId = App.TicketCreateCollection.one(load) @bindId = App.TicketCreateCollection.one(load)
# rerender view, e. g. on langauge change # rerender view, e. g. on langauge change
@bind 'ui:rerender', => @bind('ui:rerender', =>
return if !@authenticateCheck() return if !@authenticateCheck()
@render() @render()
)
# listen to rerender sidebars
@bind('ui::ticket::sidebarRerender', (data) =>
return if data.taskKey isnt @taskKey
return if !@sidebarWidget
@sidebarWidget.render(@params())
)
release: => release: =>
App.TicketCreateCollection.unbindById(@bindId) App.TicketCreateCollection.unbindById(@bindId)
@ -98,7 +106,7 @@ class App.TicketCreate extends App.Controller
@$('.js-note').addClass('hide') @$('.js-note').addClass('hide')
@$(".js-note[data-type='#{type}']").removeClass('hide') @$(".js-note[data-type='#{type}']").removeClass('hide')
App.TaskManager.touch(@task_key) App.TaskManager.touch(@taskKey)
meta: => meta: =>
text = '' text = ''
@ -138,7 +146,7 @@ class App.TicketCreate extends App.Controller
autosaveStart: => autosaveStart: =>
if !@autosaveLast if !@autosaveLast
task = App.TaskManager.get(@task_key) task = App.TaskManager.get(@taskKey)
if task && !task.state if task && !task.state
task.state = {} task.state = {}
@autosaveLast = task.state || {} @autosaveLast = task.state || {}
@ -149,12 +157,12 @@ class App.TicketCreate extends App.Controller
if _.isEmpty(@autosaveLast) || !_.isEmpty(diff) if _.isEmpty(@autosaveLast) || !_.isEmpty(diff)
@autosaveLast = data @autosaveLast = data
@log 'debug', 'form hash changed', diff, data @log 'debug', 'form hash changed', diff, data
App.TaskManager.update(@task_key, { 'state': data }) App.TaskManager.update(@taskKey, { 'state': data })
# check it task title in task need to be updated # check it task title in task need to be updated
if @latestTitle isnt data.title if @latestTitle isnt data.title
@latestTitle = data.title @latestTitle = data.title
App.TaskManager.touch(@task_key) App.TaskManager.touch(@taskKey)
@el.on('change.local blur.local keyup.local paste.local input.local', 'form, .js-textarea', (e) => @el.on('change.local blur.local keyup.local paste.local input.local', 'form, .js-textarea', (e) =>
@delay(update, 250, 'ticket-create-form-update') @delay(update, 250, 'ticket-create-form-update')
@ -173,7 +181,7 @@ class App.TicketCreate extends App.Controller
# fetch split ticket data # fetch split ticket data
@ajax( @ajax(
id: "ticket_split#{@task_key}" id: "ticket_split#{@taskKey}"
type: 'GET' type: 'GET'
url: "#{@apiPath}/ticket_split" url: "#{@apiPath}/ticket_split"
data: data:
@ -214,8 +222,8 @@ class App.TicketCreate extends App.Controller
params = @prefilledParams || {} params = @prefilledParams || {}
if template && !_.isEmpty(template.options) if template && !_.isEmpty(template.options)
params = template.options params = template.options
else if App.TaskManager.get(@task_key) && !_.isEmpty(App.TaskManager.get(@task_key).state) else if App.TaskManager.get(@taskKey) && !_.isEmpty(App.TaskManager.get(@taskKey).state)
params = App.TaskManager.get(@task_key).state params = App.TaskManager.get(@taskKey).state
if !_.isEmpty(params['form_id']) if !_.isEmpty(params['form_id'])
@formId = params['form_id'] @formId = params['form_id']
@ -226,40 +234,6 @@ class App.TicketCreate extends App.Controller
form_id: @formId form_id: @formId
)) ))
signatureChanges = (params, attribute, attributes, classname, form, ui) =>
if attribute && attribute.name is 'group_id'
signature = undefined
if params['group_id']
group = App.Group.find(params['group_id'])
if group && group.signature_id
signature = App.Signature.find(group.signature_id)
# check if signature need to be added
type = @$('[name="formSenderType"]').val()
if signature isnt undefined && signature.body && type is 'email-out'
signatureFinished = App.Utils.replaceTags(signature.body, { user: App.Session.get(), config: App.Config.all() })
body = @$('[data-name=body]')
if App.Utils.signatureCheck(body.html() || '', signatureFinished)
# if signature has changed, in case remove old signature
signature_id = @$('[data-signature=true]').data('signature-id')
if signature_id && signature_id.toString() isnt signature.id.toString()
@$('[data-signature="true"]').remove()
if !App.Utils.htmlLastLineEmpty(body)
body.append('<br><br>')
signature = $("<div data-signature=\"true\" data-signature-id=\"#{signature.id}\">#{signatureFinished}</div>")
App.Utils.htmlStrip(signature)
body.append(signature)
@$('[data-name=body]').replaceWith(body)
# remove old signature
else
@$('[data-name="body"]').find('[data-signature=true]').remove()
App.Ticket.configure_attributes.push { App.Ticket.configure_attributes.push {
name: 'cc' name: 'cc'
display: 'Cc' display: 'Cc'
@ -277,6 +251,9 @@ class App.TicketCreate extends App.Controller
edit: {} edit: {}
} }
} }
handlers = @Config.get('TicketCreateFormHandler')
new App.ControllerForm( new App.ControllerForm(
el: @$('.ticket-form-top') el: @$('.ticket-form-top')
form_id: @formId form_id: @formId
@ -284,13 +261,12 @@ class App.TicketCreate extends App.Controller
screen: 'create_top' screen: 'create_top'
events: events:
'change [name=customer_id]': @localUserInfo 'change [name=customer_id]': @localUserInfo
handlers: [ handlersConfig: handlers
@ticketFormChanges,
signatureChanges,
]
filter: @formMeta.filter filter: @formMeta.filter
formMeta: @formMeta
autofocus: true autofocus: true
params: params params: params
taskKey: @taskKey
) )
new App.ControllerForm( new App.ControllerForm(
@ -299,6 +275,7 @@ class App.TicketCreate extends App.Controller
model: App.TicketArticle model: App.TicketArticle
screen: 'create_top' screen: 'create_top'
params: params params: params
taskKey: @taskKey
) )
new App.ControllerForm( new App.ControllerForm(
el: @$('.ticket-form-middle') el: @$('.ticket-form-middle')
@ -307,13 +284,12 @@ class App.TicketCreate extends App.Controller
screen: 'create_middle' screen: 'create_middle'
events: events:
'change [name=customer_id]': @localUserInfo 'change [name=customer_id]': @localUserInfo
handlers: [ handlersConfig: handlers
@ticketFormChanges,
signatureChanges,
]
filter: @formMeta.filter filter: @formMeta.filter
formMeta: @formMeta
params: params params: params
noFieldset: true noFieldset: true
taskKey: @taskKey
) )
new App.ControllerForm( new App.ControllerForm(
el: @$('.ticket-form-bottom') el: @$('.ticket-form-bottom')
@ -322,12 +298,11 @@ class App.TicketCreate extends App.Controller
screen: 'create_bottom' screen: 'create_bottom'
events: events:
'change [name=customer_id]': @localUserInfo 'change [name=customer_id]': @localUserInfo
handlers: [ handlersConfig: handlers
@ticketFormChanges,
signatureChanges,
]
filter: @formMeta.filter filter: @formMeta.filter
formMeta: @formMeta
params: params params: params
taskKey: @taskKey
) )
App.Ticket.configure_attributes.pop() App.Ticket.configure_attributes.pop()
@ -351,7 +326,7 @@ class App.TicketCreate extends App.Controller
el: @sidebar el: @sidebar
params: @formDefault params: @formDefault
sidebarState: @sidebarState sidebarState: @sidebarState
task_key: @task_key taskKey: @taskKey
query: @query query: @query
) )
@ -361,7 +336,7 @@ class App.TicketCreate extends App.Controller
App.User.full(@formDefault.customer_id, callback) App.User.full(@formDefault.customer_id, callback)
# update taskbar with new meta data # update taskbar with new meta data
App.TaskManager.touch(@task_key) App.TaskManager.touch(@taskKey)
localUserInfo: (e) => localUserInfo: (e) =>
return if !@sidebarWidget return if !@sidebarWidget
@ -387,11 +362,14 @@ class App.TicketCreate extends App.Controller
e.preventDefault() e.preventDefault()
@navigate '#' @navigate '#'
params: =>
params = @formParam(@$('.main form'))
submit: (e) => submit: (e) =>
e.preventDefault() e.preventDefault()
# get params # get params
params = @formParam(e.target) params = @params()
# fillup params # fillup params
if !params.title if !params.title
@ -500,7 +478,7 @@ class App.TicketCreate extends App.Controller
timeout: 4000 timeout: 4000
# close ticket create task # close ticket create task
App.TaskManager.remove(ui.task_key) App.TaskManager.remove(ui.taskKey)
# scroll to top # scroll to top
ui.scrollTo() ui.scrollTo()

View file

@ -0,0 +1,38 @@
class TicketCreateFormHanderSignature
@run: (params, attribute, attributes, classname, form, ui) ->
return if !attribute
return if attribute.name isnt 'group_id'
signature = undefined
if params['group_id']
group = App.Group.find(params['group_id'])
if group && group.signature_id
signature = App.Signature.find(group.signature_id)
# check if signature need to be added
type = ui.el.closest('.content').find('[name="formSenderType"]').val()
if signature && signature.body && type is 'email-out'
signatureFinished = App.Utils.replaceTags(signature.body, { user: App.Session.get(), config: App.Config.all() })
currentBody = ui.el.closest('.content').find('[data-name=body]')
if !_.isEmpty(currentBody)
if App.Utils.signatureCheck(currentBody.html() || '', signatureFinished)
# if signature has changed, in case remove old signature
signature_id = ui.el.closest('.content').find('[data-signature=true]').data('signature-id')
if signature_id && signature_id.toString() isnt signature.id.toString()
ui.el.closest('.content').find('[data-signature="true"]').remove()
if !App.Utils.htmlLastLineEmpty(currentBody)
currentBody.append('<br><br>')
signature = $("<div data-signature=\"true\" data-signature-id=\"#{signature.id}\">#{signatureFinished}</div>")
App.Utils.htmlStrip(signature)
currentBody.append(signature)
ui.el.closest('.content').find('[data-name=body]').replaceWith(currentBody)
# remove old signature
else
ui.el.closest('.content').find('[data-name="body"]').find('[data-signature=true]').remove()
App.Config.set('200-ticketFormSignature', TicketCreateFormHanderSignature, 'TicketCreateFormHandler')

View file

@ -26,6 +26,7 @@ class App.TicketCreateSidebar extends App.Controller
params: @params params: @params
query: @query query: @query
taskGet: @taskGet taskGet: @taskGet
taskKey: @taskKey
) )
else else
@sidebarBackends[key].reload( @sidebarBackends[key].reload(

View file

@ -24,6 +24,7 @@ class Index extends App.ControllerContent
# set defaults # set defaults
defaults = template['options'] || {} defaults = template['options'] || {}
handlers = @Config.get('TicketCreateFormHandler')
groupFilter = App.Config.get('customer_ticket_create_group_ids') groupFilter = App.Config.get('customer_ticket_create_group_ids')
if groupFilter if groupFilter
@ -41,10 +42,9 @@ class Index extends App.ControllerContent
form_id: @form_id form_id: @form_id
model: App.Ticket model: App.Ticket
screen: 'create_top' screen: 'create_top'
handlers: [ handlersConfig: handlers
@ticketFormChanges
]
filter: @formMeta.filter filter: @formMeta.filter
formMeta: @formMeta
autofocus: true autofocus: true
params: defaults params: defaults
) )
@ -54,19 +54,21 @@ class Index extends App.ControllerContent
form_id: @form_id form_id: @form_id
model: App.TicketArticle model: App.TicketArticle
screen: 'create_top' screen: 'create_top'
filter: @formMeta.filter
formMeta: @formMeta
params: defaults params: defaults
handlersConfig: handlers
) )
new App.ControllerForm( new App.ControllerForm(
el: @el.find('.ticket-form-middle') el: @el.find('.ticket-form-middle')
form_id: @form_id form_id: @form_id
model: App.Ticket model: App.Ticket
screen: 'create_middle' screen: 'create_middle'
handlers: [
@ticketFormChanges
]
filter: @formMeta.filter filter: @formMeta.filter
formMeta: @formMeta
params: defaults params: defaults
noFieldset: true noFieldset: true
handlersConfig: handlers
) )
if !_.isEmpty(App.Ticket.attributesGet('create_bottom', false, true)) if !_.isEmpty(App.Ticket.attributesGet('create_bottom', false, true))
new App.ControllerForm( new App.ControllerForm(
@ -74,10 +76,9 @@ class Index extends App.ControllerContent
form_id: @form_id form_id: @form_id
model: App.Ticket model: App.Ticket
screen: 'create_bottom' screen: 'create_bottom'
handlers: [ handlersConfig: handlers
@ticketFormChanges
]
filter: @formMeta.filter filter: @formMeta.filter
formMeta: @formMeta
params: defaults params: defaults
) )

View file

@ -48,7 +48,7 @@ class App.OrganizationProfile extends App.Controller
new Object( new Object(
el: elLocal.find('.js-object-container') el: elLocal.find('.js-object-container')
object_id: organization.id object_id: organization.id
task_key: @task_key taskKey: @taskKey
) )
new ActionRow( new ActionRow(
@ -135,7 +135,7 @@ class Object extends App.ObserverController
render: (organization) => render: (organization) =>
# update taskbar with new meta data # update taskbar with new meta data
App.TaskManager.touch(@task_key) App.TaskManager.touch(@taskKey)
# get display data # get display data
organizationData = [] organizationData = []

View file

@ -15,12 +15,12 @@ class App.Search extends App.Controller
# check authentication # check authentication
@authenticateCheckRedirect() @authenticateCheckRedirect()
current = App.TaskManager.get(@task_key).state current = App.TaskManager.get(@taskKey).state
if current && current.query if current && current.query
@query = current.query @query = current.query
# update taskbar with new meta data # update taskbar with new meta data
App.TaskManager.touch(@task_key) App.TaskManager.touch(@taskKey)
@throttledSearch = _.throttle @search, 200 @throttledSearch = _.throttle @search, 200
@ -66,7 +66,7 @@ class App.Search extends App.Controller
# nothing # nothing
render: -> render: ->
currentState = App.TaskManager.get(@task_key).state currentState = App.TaskManager.get(@taskKey).state
if !@query if !@query
if currentState && currentState.query if currentState && currentState.query
@query = currentState.query @query = currentState.query
@ -179,12 +179,12 @@ class App.Search extends App.Controller
) )
updateTask: => updateTask: =>
current = App.TaskManager.get(@task_key).state current = App.TaskManager.get(@taskKey).state
return if !current return if !current
current.query = @query current.query = @query
current.model = @model current.model = @model
App.TaskManager.update(@task_key, { state: current }) App.TaskManager.update(@taskKey, { state: current })
App.TaskManager.touch(@task_key) App.TaskManager.touch(@taskKey)
updateFilledClass: -> updateFilledClass: ->
@searchInput.toggleClass 'is-empty', !@searchInput.val() @searchInput.toggleClass 'is-empty', !@searchInput.val()

View file

@ -45,8 +45,8 @@ class App.TaskbarWidget extends App.CollectionController
@queue.push ['destroy', tasks] @queue.push ['destroy', tasks]
@uIRunner() @uIRunner()
) )
@bind('taskCollectionOrderSet', (task_keys) => @bind('taskCollectionOrderSet', (taskKeys) =>
@collectionOrderSet(task_keys) @collectionOrderSet(taskKeys)
) )
itemGet: (key) -> itemGet: (key) ->

View file

@ -1249,15 +1249,15 @@ class BulkForm extends App.Controller
@html App.view('agent_ticket_view/bulk')() @html App.view('agent_ticket_view/bulk')()
handlers = @Config.get('TicketZoomFormHandler')
new App.ControllerForm( new App.ControllerForm(
el: @$('#form-ticket-bulk') el: @$('#form-ticket-bulk')
model: model:
configure_attributes: @configure_attributes_ticket configure_attributes: @configure_attributes_ticket
className: 'create' className: 'create'
labelClass: 'input-group-addon' labelClass: 'input-group-addon'
handlers: [ handlersConfig: handlers
@ticketFormChanges
]
params: {} params: {}
filter: @formMeta.filter filter: @formMeta.filter
noFieldset: true noFieldset: true

View file

@ -59,6 +59,13 @@ class App.TicketZoom extends App.Controller
@initSpoolSent = true @initSpoolSent = true
) )
# listen to rerender sidebars
@bind('ui::ticket::sidebarRerender', (data) =>
return if data.taskKey isnt @taskKey
return if !@sidebarWidget
@sidebarWidget.render(@formCurrent())
)
fetchMayBe: (data) => fetchMayBe: (data) =>
if @ticketUpdatedAtLastCall if @ticketUpdatedAtLastCall
if new Date(data.updated_at).getTime() is new Date(@ticketUpdatedAtLastCall).getTime() if new Date(data.updated_at).getTime() is new Date(@ticketUpdatedAtLastCall).getTime()
@ -155,7 +162,7 @@ class App.TicketZoom extends App.Controller
# notify if ticket changed not by my self # notify if ticket changed not by my self
if @initFetched if @initFetched
if newTicketRaw.updated_by_id isnt @Session.get('id') if newTicketRaw.updated_by_id isnt @Session.get('id')
App.TaskManager.notify(@task_key) App.TaskManager.notify(@taskKey)
@initFetched = true @initFetched = true
if !@doNotLog if !@doNotLog
@ -304,7 +311,7 @@ class App.TicketZoom extends App.Controller
@positionPageHeaderStop() @positionPageHeaderStop()
muteTask: => muteTask: =>
App.TaskManager.mute(@task_key) App.TaskManager.mute(@taskKey)
shortcutNavigationStart: => shortcutNavigationStart: =>
@articlePager = @articlePager =
@ -391,7 +398,7 @@ class App.TicketZoom extends App.Controller
render: (local) => render: (local) =>
# update taskbar with new meta data # update taskbar with new meta data
App.TaskManager.touch(@task_key) App.TaskManager.touch(@taskKey)
if !@renderDone if !@renderDone
@renderDone = true @renderDone = true
@ -414,7 +421,7 @@ class App.TicketZoom extends App.Controller
object_id: @ticket_id object_id: @ticket_id
overview_id: @overview_id overview_id: @overview_id
el: elLocal.find('.js-ticketTitleContainer') el: elLocal.find('.js-ticketTitleContainer')
task_key: @task_key taskKey: @taskKey
) )
new App.TicketZoomMeta( new App.TicketZoomMeta(
@ -427,7 +434,7 @@ class App.TicketZoom extends App.Controller
el: elLocal.find('.js-attributeBar') el: elLocal.find('.js-attributeBar')
overview_id: @overview_id overview_id: @overview_id
callback: @submit callback: @submit
task_key: @task_key taskKey: @taskKey
) )
#if @shown #if @shown
# @attributeBar.start() # @attributeBar.start()
@ -441,7 +448,7 @@ class App.TicketZoom extends App.Controller
formMeta: @formMeta formMeta: @formMeta
form_id: @form_id form_id: @form_id
defaults: @taskGet('article') defaults: @taskGet('article')
task_key: @task_key taskKey: @taskKey
ui: @ ui: @
) )
@ -469,14 +476,14 @@ class App.TicketZoom extends App.Controller
el: elLocal.find('.ticketZoom-header') el: elLocal.find('.ticketZoom-header')
) )
@sidebar = new App.TicketZoomSidebar( @sidebarWidget = new App.TicketZoomSidebar(
el: elLocal el: elLocal
sidebarState: @sidebarState sidebarState: @sidebarState
object_id: @ticket_id object_id: @ticket_id
model: 'Ticket' model: 'Ticket'
query: @query query: @query
taskGet: @taskGet taskGet: @taskGet
task_key: @task_key taskKey: @taskKey
formMeta: @formMeta formMeta: @formMeta
markForm: @markForm markForm: @markForm
tags: @tags tags: @tags
@ -486,6 +493,14 @@ class App.TicketZoom extends App.Controller
# check if autolock is needed # check if autolock is needed
if @Config.get('ticket_auto_assignment') is true if @Config.get('ticket_auto_assignment') is true
if @ticket.owner_id is 1 && @permissionCheck('ticket.agent') && @ticket.editable('full') if @ticket.owner_id is 1 && @permissionCheck('ticket.agent') && @ticket.editable('full')
userIdsIgnore = @Config.get('ticket_auto_assignment_user_ids_ignore') || []
userIgnored = false
currentUserId = App.Session.get('id')
for userIdIgnore in userIdsIgnore
if userIdIgnore.toString() is currentUserId.toString()
userIgnored = true
break
if userIgnored is false
ticket_auto_assignment_selector = @Config.get('ticket_auto_assignment_selector') ticket_auto_assignment_selector = @Config.get('ticket_auto_assignment_selector')
if App.Ticket.selector(@ticket, ticket_auto_assignment_selector['condition']) if App.Ticket.selector(@ticket, ticket_auto_assignment_selector['condition'])
assign = => assign = =>
@ -503,8 +518,8 @@ class App.TicketZoom extends App.Controller
ticket_article_ids: @ticket_article_ids ticket_article_ids: @ticket_article_ids
) )
if @sidebar if @sidebarWidget
@sidebar.reload( @sidebarWidget.reload(
tags: @tags tags: @tags
links: @links links: @links
) )
@ -747,13 +762,13 @@ class App.TicketZoom extends App.Controller
ticket: ticket ticket: ticket
callback: callback:
tagAdd: (tag) => tagAdd: (tag) =>
return if !@sidebar return if !@sidebarWidget
return if !@sidebar.reload return if !@sidebarWidget.reload
@sidebar.reload(tagAdd: tag, source: 'macro') @sidebarWidget.reload(tagAdd: tag, source: 'macro')
tagRemove: (tag) => tagRemove: (tag) =>
return if !@sidebar return if !@sidebarWidget
return if !@sidebar.reload return if !@sidebarWidget.reload
@sidebar.reload(tagRemove: tag) @sidebarWidget.reload(tagRemove: tag)
) )
# set defaults # set defaults
@ -854,8 +869,8 @@ class App.TicketZoom extends App.Controller
# reset form after save # reset form after save
@reset() @reset()
if @sidebar if @sidebarWidget
@sidebar.commit() @sidebarWidget.commit()
if taskAction is 'closeNextInOverview' if taskAction is 'closeNextInOverview'
if @overview_id if @overview_id
@ -868,7 +883,7 @@ class App.TicketZoom extends App.Controller
next = list.tickets[current_position] next = list.tickets[current_position]
if next if next
# close task # close task
App.TaskManager.remove(@task_key) App.TaskManager.remove(@taskKey)
# open task via task manager to get overview information # open task via task manager to get overview information
App.TaskManager.execute( App.TaskManager.execute(
@ -886,7 +901,7 @@ class App.TicketZoom extends App.Controller
taskAction = 'closeTab' taskAction = 'closeTab'
if taskAction is 'closeTab' if taskAction is 'closeTab'
App.TaskManager.remove(@task_key) App.TaskManager.remove(@taskKey)
nextTaskUrl = App.TaskManager.nextTaskUrl() nextTaskUrl = App.TaskManager.nextTaskUrl()
if nextTaskUrl if nextTaskUrl
@navigate nextTaskUrl @navigate nextTaskUrl
@ -943,8 +958,8 @@ class App.TicketZoom extends App.Controller
@$('.tabsSidebar-tab[data-tab="ticket"]').removeClass('is-changed') @$('.tabsSidebar-tab[data-tab="ticket"]').removeClass('is-changed')
taskGet: (area) => taskGet: (area) =>
return {} if !App.TaskManager.get(@task_key) return {} if !App.TaskManager.get(@taskKey)
@localTaskData = App.TaskManager.get(@task_key).state || {} @localTaskData = App.TaskManager.get(@taskKey).state || {}
if area if area
if !@localTaskData[area] if !@localTaskData[area]
@localTaskData[area] = {} @localTaskData[area] = {}
@ -955,18 +970,18 @@ class App.TicketZoom extends App.Controller
taskUpdate: (area, data) => taskUpdate: (area, data) =>
@localTaskData[area] = data @localTaskData[area] = data
App.TaskManager.update(@task_key, { 'state': @localTaskData }) App.TaskManager.update(@taskKey, { 'state': @localTaskData })
taskUpdateAll: (data) => taskUpdateAll: (data) =>
@localTaskData = data @localTaskData = data
App.TaskManager.update(@task_key, { 'state': @localTaskData }) App.TaskManager.update(@taskKey, { 'state': @localTaskData })
# reset task state # reset task state
taskReset: => taskReset: =>
@localTaskData = @localTaskData =
ticket: {} ticket: {}
article: {} article: {}
App.TaskManager.update(@task_key, { 'state': @localTaskData }) App.TaskManager.update(@taskKey, { 'state': @localTaskData })
class TicketZoomRouter extends App.ControllerPermanent class TicketZoomRouter extends App.ControllerPermanent
requiredPermission: ['ticket.agent', 'ticket.customer'] requiredPermission: ['ticket.agent', 'ticket.customer']

View file

@ -519,7 +519,7 @@ class App.TicketZoomArticleNew extends App.Controller
# detect current signature (use current group_id, if not set, use ticket.group_id) # detect current signature (use current group_id, if not set, use ticket.group_id)
ticketCurrent = App.Ticket.fullLocal(@ticket_id) ticketCurrent = App.Ticket.fullLocal(@ticket_id)
group_id = ticketCurrent.group_id group_id = ticketCurrent.group_id
task = App.TaskManager.get(@task_key) task = App.TaskManager.get(@taskKey)
if task && task.state && task.state.ticket && task.state.ticket.group_id if task && task.state && task.state.ticket && task.state.ticket.group_id
group_id = task.state.ticket.group_id group_id = task.state.ticket.group_id
group = App.Group.find(group_id) group = App.Group.find(group_id)

View file

@ -50,7 +50,7 @@ class App.TicketZoomAttributeBar extends App.Controller
if @permissionCheck('ticket.agent') if @permissionCheck('ticket.agent')
@taskbarWatcher = new App.TaskbarWatcher( @taskbarWatcher = new App.TaskbarWatcher(
task_key: @task_key taskKey: @taskKey
el: localeEl.filter('.js-avatars') el: localeEl.filter('.js-avatars')
) )

View file

@ -0,0 +1,32 @@
class TicketZoomFormHanderDependencies
# central method, is getting called on every ticket form change
@run: (params, attribute, attributes, classname, form, ui) ->
return if !ui.formMeta
return if !ui.formMeta.dependencies
return if !ui.formMeta.dependencies[attribute.name]
dependency = ui.formMeta.dependencies[attribute.name][ parseInt(params[attribute.name]) ]
if !dependency
dependency = ui.formMeta.dependencies[attribute.name][ params[attribute.name] ]
if dependency
for fieldNameToChange of dependency
filter = []
if dependency[fieldNameToChange]
filter = dependency[fieldNameToChange]
# find element to replace
for item in attributes
if item.name is fieldNameToChange
item['filter'] = {}
item['filter'][ fieldNameToChange ] = filter
item.default = params[item.name]
#if !item.default
# delete item['default']
newElement = ui.formGenItem(item, classname, form)
# replace new option list
if newElement
form.find('[name="' + fieldNameToChange + '"]').closest('.form-group').replaceWith(newElement)
App.Config.set('100-ticketFormChanges', TicketZoomFormHanderDependencies, 'TicketZoomFormHandler')
App.Config.set('100-ticketFormChanges', TicketZoomFormHanderDependencies, 'TicketCreateFormHandler')

View file

@ -25,6 +25,7 @@ class App.TicketZoomSidebar extends App.ObserverController
ticket: ticket ticket: ticket
query: @query query: @query
taskGet: @taskGet taskGet: @taskGet
taskKey: @taskKey
formMeta: @formMeta formMeta: @formMeta
markForm: @markForm markForm: @markForm
tags: @tags tags: @tags

View file

@ -18,7 +18,7 @@ class SidebarIdoit extends App.Controller
changeObjects: => changeObjects: =>
new App.IdoitObjectSelector( new App.IdoitObjectSelector(
task_key: @task_key taskKey: @taskKey
container: @el.closest('.content') container: @el.closest('.content')
callback: (objectIds, objectSelectorUi) => callback: (objectIds, objectSelectorUi) =>
if @ticket && @ticket.id if @ticket && @ticket.id
@ -54,7 +54,7 @@ class SidebarIdoit extends App.Controller
# ajax call to show items # ajax call to show items
@ajax( @ajax(
id: "idoit-#{@task_key}" id: "idoit-#{@taskKey}"
type: 'POST' type: 'POST'
url: "#{@apiPath}/integration/idoit" url: "#{@apiPath}/integration/idoit"
data: JSON.stringify(method: 'cmdb.objects', filter: ids: @objectIds) data: JSON.stringify(method: 'cmdb.objects', filter: ids: @objectIds)

View file

@ -12,6 +12,7 @@ class Edit extends App.ObserverController
ticketState = App.TicketState.find(defaults.state_id).name ticketState = App.TicketState.find(defaults.state_id).name
taskState = @taskGet('ticket') taskState = @taskGet('ticket')
handlers = @Config.get('TicketZoomFormHandler')
if !_.isEmpty(taskState) if !_.isEmpty(taskState)
defaults = _.extend(defaults, taskState) defaults = _.extend(defaults, taskState)
@ -23,10 +24,9 @@ class Edit extends App.ObserverController
elReplace: @el elReplace: @el
model: App.Ticket model: App.Ticket
screen: 'edit' screen: 'edit'
handlers: [ handlersConfig: handlers
@ticketFormChanges
]
filter: @formMeta.filter filter: @formMeta.filter
formMeta: @formMeta
params: defaults params: defaults
isDisabled: !ticket.editable() isDisabled: !ticket.editable()
#bookmarkable: true #bookmarkable: true
@ -36,10 +36,9 @@ class Edit extends App.ObserverController
elReplace: @el elReplace: @el
model: App.Ticket model: App.Ticket
screen: 'edit' screen: 'edit'
handlers: [ handlersConfig: handlers
@ticketFormChanges
]
filter: @formMeta.filter filter: @formMeta.filter
formMeta: @formMeta
params: defaults params: defaults
isDisabled: ticket.editable() isDisabled: ticket.editable()
#bookmarkable: true #bookmarkable: true
@ -137,7 +136,7 @@ class SidebarTicket extends App.Controller
showTicketMerge: => showTicketMerge: =>
new App.TicketMerge( new App.TicketMerge(
ticket: @ticket ticket: @ticket
task_key: @task_key taskKey: @taskKey
container: @el.closest('.content') container: @el.closest('.content')
) )

View file

@ -1,8 +1,8 @@
class App.TaskbarWatcher extends App.Controller class App.TaskbarWatcher extends App.Controller
constructor: -> constructor: ->
super super
@subscribeId = App.TaskManager.preferencesSubscribe(@task_key, @render) @subscribeId = App.TaskManager.preferencesSubscribe(@taskKey, @render)
App.TaskManager.preferencesTrigger(@task_key) App.TaskManager.preferencesTrigger(@taskKey)
release: => release: =>
return if !@subscribeId return if !@subscribeId
@ -53,7 +53,7 @@ class App.TaskbarWatcher extends App.Controller
start: => start: =>
@intervalId = @interval( @intervalId = @interval(
=> =>
App.TaskManager.preferencesTrigger(@task_key) App.TaskManager.preferencesTrigger(@taskKey)
5 * 60000 5 * 60000
'ticket-watcher-interval' 'ticket-watcher-interval'
) )

View file

@ -28,9 +28,9 @@ class App.TicketZoomTitle extends App.ObserverController
ticket.save() ticket.save()
App.TaskManager.mute(@task_key) App.TaskManager.mute(@taskKey)
# update taskbar with new meta data # update taskbar with new meta data
App.TaskManager.touch(@task_key) App.TaskManager.touch(@taskKey)
App.Event.trigger('overview:fetch') App.Event.trigger('overview:fetch')

View file

@ -55,7 +55,7 @@ class App.UserProfile extends App.Controller
new Object( new Object(
el: elLocal.find('.js-object-container') el: elLocal.find('.js-object-container')
object_id: user.id object_id: user.id
task_key: @task_key taskKey: @taskKey
) )
new ActionRow( new ActionRow(
@ -153,7 +153,7 @@ class Object extends App.ObserverController
render: (user) => render: (user) =>
# update taskbar with new meta data # update taskbar with new meta data
App.TaskManager.touch(@task_key) App.TaskManager.touch(@taskKey)
# get display data # get display data
userData = [] userData = []

View file

@ -281,6 +281,7 @@ class _taskManagerSingleton extends App.Controller
@domStore[domKey] = { el: el } @domStore[domKey] = { el: el }
params_app['el'] = el params_app['el'] = el
params_app['task_key'] = params.key params_app['task_key'] = params.key
params_app['taskKey'] = params.key
if !params.show if !params.show
params_app['doNotLog'] = 1 params_app['doNotLog'] = 1
@ -555,7 +556,8 @@ class _taskManagerSingleton extends App.Controller
@tasksToUpdate[task.key] = 'inProgress' @tasksToUpdate[task.key] = 'inProgress'
taskUpdate = App.Taskbar.findByAttribute('key', task.key) taskUpdate = App.Taskbar.findByAttribute('key', task.key)
if !taskUpdate if !taskUpdate
taskUpdate = new App.Taskbar delete ui.tasksToUpdate[@key]
continue
taskUpdate.load(task) taskUpdate.load(task)
if taskUpdate.isOnline() if taskUpdate.isOnline()
ui = @ ui = @
@ -584,13 +586,13 @@ class _taskManagerSingleton extends App.Controller
# destroy task in backend # destroy task in backend
delete @tasksToUpdate[task.key] delete @tasksToUpdate[task.key]
delete @tasksPreferences[task.key]
# if task isnt already stored on backend # if task isnt already stored on backend
return if !task.id return if !task.id
return if !App.Taskbar.exists(task.id)
App.Taskbar.destroy(task.id) App.Taskbar.destroy(task.id)
delete @tasksPreferences[task.key]
tasksAutoCleanupDelay: => tasksAutoCleanupDelay: =>
delay = => delay = =>
@tasksAutoCleanup() @tasksAutoCleanup()