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)
if closeTab
App.TaskManager.remove(@task_key)
App.TaskManager.remove(@taskKey)
# redirect to login
@navigate '#login'
@ -547,32 +547,6 @@ class App.Controller extends Spine.Controller
item.created_by = App.User.findNative(item.created_by_id)
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) ->
e.stopPropagation()
@ -592,19 +566,19 @@ class App.Controller extends Spine.Controller
@clearDelay(@initLoadingDoneDelay)
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)
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)
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)
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)
locationVerify: (e) =>
@ -901,7 +875,7 @@ class App.UpdateTastbar extends App.Controller
update: (genericObject) =>
# update taskbar with new meta data
App.TaskManager.touch(@task_key)
App.TaskManager.touch(@taskKey)
class App.ControllerWidgetPermanent extends App.Controller
constructor: (params) ->

View file

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

View file

@ -28,9 +28,17 @@ class App.TicketCreate extends App.Controller
@bindId = App.TicketCreateCollection.one(load)
# rerender view, e. g. on langauge change
@bind 'ui:rerender', =>
@bind('ui:rerender', =>
return if !@authenticateCheck()
@render()
)
# listen to rerender sidebars
@bind('ui::ticket::sidebarRerender', (data) =>
return if data.taskKey isnt @taskKey
return if !@sidebarWidget
@sidebarWidget.render(@params())
)
release: =>
App.TicketCreateCollection.unbindById(@bindId)
@ -98,7 +106,7 @@ class App.TicketCreate extends App.Controller
@$('.js-note').addClass('hide')
@$(".js-note[data-type='#{type}']").removeClass('hide')
App.TaskManager.touch(@task_key)
App.TaskManager.touch(@taskKey)
meta: =>
text = ''
@ -138,7 +146,7 @@ class App.TicketCreate extends App.Controller
autosaveStart: =>
if !@autosaveLast
task = App.TaskManager.get(@task_key)
task = App.TaskManager.get(@taskKey)
if task && !task.state
task.state = {}
@autosaveLast = task.state || {}
@ -149,12 +157,12 @@ class App.TicketCreate extends App.Controller
if _.isEmpty(@autosaveLast) || !_.isEmpty(diff)
@autosaveLast = 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
if @latestTitle isnt 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) =>
@delay(update, 250, 'ticket-create-form-update')
@ -173,7 +181,7 @@ class App.TicketCreate extends App.Controller
# fetch split ticket data
@ajax(
id: "ticket_split#{@task_key}"
id: "ticket_split#{@taskKey}"
type: 'GET'
url: "#{@apiPath}/ticket_split"
data:
@ -214,8 +222,8 @@ class App.TicketCreate extends App.Controller
params = @prefilledParams || {}
if template && !_.isEmpty(template.options)
params = template.options
else if App.TaskManager.get(@task_key) && !_.isEmpty(App.TaskManager.get(@task_key).state)
params = App.TaskManager.get(@task_key).state
else if App.TaskManager.get(@taskKey) && !_.isEmpty(App.TaskManager.get(@taskKey).state)
params = App.TaskManager.get(@taskKey).state
if !_.isEmpty(params['form_id'])
@formId = params['form_id']
@ -226,40 +234,6 @@ class App.TicketCreate extends App.Controller
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 {
name: 'cc'
display: 'Cc'
@ -277,20 +251,22 @@ class App.TicketCreate extends App.Controller
edit: {}
}
}
handlers = @Config.get('TicketCreateFormHandler')
new App.ControllerForm(
el: @$('.ticket-form-top')
form_id: @formId
model: App.Ticket
screen: 'create_top'
el: @$('.ticket-form-top')
form_id: @formId
model: App.Ticket
screen: 'create_top'
events:
'change [name=customer_id]': @localUserInfo
handlers: [
@ticketFormChanges,
signatureChanges,
]
filter: @formMeta.filter
autofocus: true
params: params
handlersConfig: handlers
filter: @formMeta.filter
formMeta: @formMeta
autofocus: true
params: params
taskKey: @taskKey
)
new App.ControllerForm(
@ -299,35 +275,34 @@ class App.TicketCreate extends App.Controller
model: App.TicketArticle
screen: 'create_top'
params: params
taskKey: @taskKey
)
new App.ControllerForm(
el: @$('.ticket-form-middle')
form_id: @formId
model: App.Ticket
screen: 'create_middle'
el: @$('.ticket-form-middle')
form_id: @formId
model: App.Ticket
screen: 'create_middle'
events:
'change [name=customer_id]': @localUserInfo
handlers: [
@ticketFormChanges,
signatureChanges,
]
filter: @formMeta.filter
params: params
noFieldset: true
handlersConfig: handlers
filter: @formMeta.filter
formMeta: @formMeta
params: params
noFieldset: true
taskKey: @taskKey
)
new App.ControllerForm(
el: @$('.ticket-form-bottom')
form_id: @formId
model: App.Ticket
screen: 'create_bottom'
el: @$('.ticket-form-bottom')
form_id: @formId
model: App.Ticket
screen: 'create_bottom'
events:
'change [name=customer_id]': @localUserInfo
handlers: [
@ticketFormChanges,
signatureChanges,
]
filter: @formMeta.filter
params: params
handlersConfig: handlers
filter: @formMeta.filter
formMeta: @formMeta
params: params
taskKey: @taskKey
)
App.Ticket.configure_attributes.pop()
@ -351,7 +326,7 @@ class App.TicketCreate extends App.Controller
el: @sidebar
params: @formDefault
sidebarState: @sidebarState
task_key: @task_key
taskKey: @taskKey
query: @query
)
@ -361,7 +336,7 @@ class App.TicketCreate extends App.Controller
App.User.full(@formDefault.customer_id, callback)
# update taskbar with new meta data
App.TaskManager.touch(@task_key)
App.TaskManager.touch(@taskKey)
localUserInfo: (e) =>
return if !@sidebarWidget
@ -387,11 +362,14 @@ class App.TicketCreate extends App.Controller
e.preventDefault()
@navigate '#'
params: =>
params = @formParam(@$('.main form'))
submit: (e) =>
e.preventDefault()
# get params
params = @formParam(e.target)
params = @params()
# fillup params
if !params.title
@ -500,7 +478,7 @@ class App.TicketCreate extends App.Controller
timeout: 4000
# close ticket create task
App.TaskManager.remove(ui.task_key)
App.TaskManager.remove(ui.taskKey)
# scroll to top
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

@ -23,9 +23,10 @@ class App.TicketCreateSidebar extends App.Controller
for key in keys
if !@sidebarBackends[key] || !@sidebarBackends[key].reload
@sidebarBackends[key] = new sidebarBackends[key](
params: @params
query: @query
taskGet: @taskGet
params: @params
query: @query
taskGet: @taskGet
taskKey: @taskKey
)
else
@sidebarBackends[key].reload(

View file

@ -24,6 +24,7 @@ class Index extends App.ControllerContent
# set defaults
defaults = template['options'] || {}
handlers = @Config.get('TicketCreateFormHandler')
groupFilter = App.Config.get('customer_ticket_create_group_ids')
if groupFilter
@ -37,48 +38,48 @@ class Index extends App.ControllerContent
)
new App.ControllerForm(
el: @el.find('.ticket-form-top')
form_id: @form_id
model: App.Ticket
screen: 'create_top'
handlers: [
@ticketFormChanges
]
filter: @formMeta.filter
autofocus: true
params: defaults
el: @el.find('.ticket-form-top')
form_id: @form_id
model: App.Ticket
screen: 'create_top'
handlersConfig: handlers
filter: @formMeta.filter
formMeta: @formMeta
autofocus: true
params: defaults
)
new App.ControllerForm(
el: @el.find('.article-form-top')
form_id: @form_id
model: App.TicketArticle
screen: 'create_top'
params: defaults
el: @el.find('.article-form-top')
form_id: @form_id
model: App.TicketArticle
screen: 'create_top'
filter: @formMeta.filter
formMeta: @formMeta
params: defaults
handlersConfig: handlers
)
new App.ControllerForm(
el: @el.find('.ticket-form-middle')
form_id: @form_id
model: App.Ticket
screen: 'create_middle'
handlers: [
@ticketFormChanges
]
filter: @formMeta.filter
params: defaults
noFieldset: true
el: @el.find('.ticket-form-middle')
form_id: @form_id
model: App.Ticket
screen: 'create_middle'
filter: @formMeta.filter
formMeta: @formMeta
params: defaults
noFieldset: true
handlersConfig: handlers
)
if !_.isEmpty(App.Ticket.attributesGet('create_bottom', false, true))
new App.ControllerForm(
el: @el.find('.ticket-form-bottom')
form_id: @form_id
model: App.Ticket
screen: 'create_bottom'
handlers: [
@ticketFormChanges
]
filter: @formMeta.filter
params: defaults
el: @el.find('.ticket-form-bottom')
form_id: @form_id
model: App.Ticket
screen: 'create_bottom'
handlersConfig: handlers
filter: @formMeta.filter
formMeta: @formMeta
params: defaults
)
new App.ControllerDrox(

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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
query: @query
taskGet: @taskGet
taskKey: @taskKey
formMeta: @formMeta
markForm: @markForm
tags: @tags

View file

@ -18,7 +18,7 @@ class SidebarIdoit extends App.Controller
changeObjects: =>
new App.IdoitObjectSelector(
task_key: @task_key
taskKey: @taskKey
container: @el.closest('.content')
callback: (objectIds, objectSelectorUi) =>
if @ticket && @ticket.id
@ -54,7 +54,7 @@ class SidebarIdoit extends App.Controller
# ajax call to show items
@ajax(
id: "idoit-#{@task_key}"
id: "idoit-#{@taskKey}"
type: 'POST'
url: "#{@apiPath}/integration/idoit"
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
taskState = @taskGet('ticket')
handlers = @Config.get('TicketZoomFormHandler')
if !_.isEmpty(taskState)
defaults = _.extend(defaults, taskState)
@ -20,29 +21,27 @@ class Edit extends App.ObserverController
followUpPossible != 'new_ticket' ||
@permissionCheck('admin') || @permissionCheck('ticket.agent')
new App.ControllerForm(
elReplace: @el
model: App.Ticket
screen: 'edit'
handlers: [
@ticketFormChanges
]
filter: @formMeta.filter
params: defaults
isDisabled: !ticket.editable()
#bookmarkable: true
elReplace: @el
model: App.Ticket
screen: 'edit'
handlersConfig: handlers
filter: @formMeta.filter
formMeta: @formMeta
params: defaults
isDisabled: !ticket.editable()
#bookmarkable: true
)
else
new App.ControllerForm(
elReplace: @el
model: App.Ticket
screen: 'edit'
handlers: [
@ticketFormChanges
]
filter: @formMeta.filter
params: defaults
isDisabled: ticket.editable()
#bookmarkable: true
elReplace: @el
model: App.Ticket
screen: 'edit'
handlersConfig: handlers
filter: @formMeta.filter
formMeta: @formMeta
params: defaults
isDisabled: ticket.editable()
#bookmarkable: true
)
@markForm(true)
@ -137,7 +136,7 @@ class SidebarTicket extends App.Controller
showTicketMerge: =>
new App.TicketMerge(
ticket: @ticket
task_key: @task_key
taskKey: @taskKey
container: @el.closest('.content')
)

View file

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

View file

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

View file

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

View file

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