Apply new signature in ticket zoom on group change.
This commit is contained in:
parent
0cb2cb0c4f
commit
ecadd6e777
5 changed files with 52 additions and 27 deletions
|
@ -31,7 +31,7 @@ class App.TicketCreate extends App.Controller
|
|||
|
||||
@fetch(params)
|
||||
|
||||
# lisen if view need to be rerendert
|
||||
# lisen if view need to be rerendered
|
||||
@bind 'ticket_create_rerender', (defaults) =>
|
||||
@log 'notice', 'error', defaults
|
||||
@render(defaults)
|
||||
|
@ -41,6 +41,10 @@ class App.TicketCreate extends App.Controller
|
|||
return if !@authenticate(true)
|
||||
@render()
|
||||
|
||||
# bind on new ticket_create_attributes updates
|
||||
@bind 'ticket_create_attributes', (data) =>
|
||||
App.SessionStorage.set('ticket_create_attributes', data)
|
||||
|
||||
changeFormType: (e) =>
|
||||
type = $(e.target).data('type')
|
||||
if !type
|
||||
|
|
|
@ -329,10 +329,12 @@ class App.TicketZoom extends App.Controller
|
|||
|
||||
new App.TicketZoomArticleNew(
|
||||
ticket: @ticket
|
||||
ticket_id: @ticket.id
|
||||
el: @$('.article-new')
|
||||
form_meta: @form_meta
|
||||
form_id: @form_id
|
||||
defaults: @taskGet('article')
|
||||
task_key: @task_key
|
||||
ui: @
|
||||
)
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ class App.TicketZoomArticleNew extends App.Controller
|
|||
@bind(
|
||||
'ui::ticket::setArticleType'
|
||||
(data) =>
|
||||
return if data.ticket.id isnt @ticket.id
|
||||
return if data.ticket.id isnt @ticket_id
|
||||
#@setArticleType(data.type.name)
|
||||
|
||||
@openTextarea(null, true)
|
||||
|
@ -113,7 +113,7 @@ class App.TicketZoomArticleNew extends App.Controller
|
|||
@bind(
|
||||
'ui::ticket::taskReset'
|
||||
(data) =>
|
||||
return if data.ticket_id isnt @ticket.id
|
||||
return if data.ticket_id isnt @ticket_id
|
||||
@type = 'note'
|
||||
@defaults = {}
|
||||
@render()
|
||||
|
@ -131,7 +131,7 @@ class App.TicketZoomArticleNew extends App.Controller
|
|||
|
||||
render: ->
|
||||
|
||||
ticket = App.Ticket.fullLocal( @ticket.id )
|
||||
ticket = App.Ticket.fullLocal( @ticket_id )
|
||||
|
||||
@html App.view('ticket_zoom/article_new')(
|
||||
ticket: ticket
|
||||
|
@ -343,15 +343,30 @@ class App.TicketZoomArticleNew extends App.Controller
|
|||
for name in articleType.attributes
|
||||
@$("[name=#{name}]").closest('.form-group').removeClass('hide')
|
||||
|
||||
# check if signature need to be added
|
||||
body = @$('[data-name=body]').html() || ''
|
||||
# detect current signature (use current group_id, if not set, use ticket.group_id)
|
||||
ticketCurrent = App.Ticket.find(@ticket_id)
|
||||
group_id = ticketCurrent.group_id
|
||||
task = App.TaskManager.get(@task_key)
|
||||
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)
|
||||
signature = undefined
|
||||
if @ticket.group.signature_id
|
||||
signature = App.Signature.find( @ticket.group.signature_id )
|
||||
if group && group.signature_id
|
||||
signature = App.Signature.find(group.signature_id)
|
||||
|
||||
# add/replace signature
|
||||
if signature && signature.body && @type is 'email'
|
||||
|
||||
# if signature has changed, remove it
|
||||
signature_id = @$('[data-signature=true]').data('signature-id')
|
||||
if signature_id && signature_id.toString() isnt signature.id.toString()
|
||||
@$('[data-name=body] [data-signature="true"]').remove()
|
||||
|
||||
# apply new signature
|
||||
signatureFinished = App.Utils.text2html(
|
||||
App.Utils.replaceTags( signature.body, { user: App.Session.get(), ticket: @ticket } )
|
||||
App.Utils.replaceTags( signature.body, { user: App.Session.get(), ticket: ticketCurrent } )
|
||||
)
|
||||
body = @$('[data-name=body]').html() || ''
|
||||
if App.Utils.signatureCheck(body, signatureFinished)
|
||||
if !App.Utils.lastLineEmpty(body)
|
||||
body = body + '<br>'
|
||||
|
@ -360,7 +375,7 @@ class App.TicketZoomArticleNew extends App.Controller
|
|||
|
||||
# remove old signature
|
||||
else
|
||||
@$('[data-name=body]').find('[data-signature=true]').remove()
|
||||
@$('[data-name=body] [data-signature=true]').remove()
|
||||
|
||||
detectEmptyTextarea: =>
|
||||
if !@textarea.text().trim()
|
||||
|
|
|
@ -53,14 +53,14 @@ class Sessions::Backend::TicketCreate
|
|||
|
||||
if !@client
|
||||
return {
|
||||
collection: 'ticket_create_attributes',
|
||||
event: 'ticket_create_attributes',
|
||||
data: data,
|
||||
}
|
||||
end
|
||||
|
||||
@client.log "push ticket_create for user #{@user.id}"
|
||||
@client.send(
|
||||
collection: 'ticket_create_attributes',
|
||||
event: 'ticket_create_attributes',
|
||||
data: data,
|
||||
)
|
||||
end
|
||||
|
|
|
@ -258,25 +258,29 @@ class AgentTicketActionLevel5Test < TestCase
|
|||
no_quote: true,
|
||||
)
|
||||
|
||||
=begin
|
||||
# update group2
|
||||
select(
|
||||
:css => '.active [name="group_id"]',
|
||||
:value => group_name2,
|
||||
css: '.active [name="group_id"]',
|
||||
value: group_name2,
|
||||
)
|
||||
|
||||
# execute reply
|
||||
sleep 5 # time to recognice form changes
|
||||
click(
|
||||
css: '.active [data-type="reply"]',
|
||||
)
|
||||
|
||||
# check if signature exists
|
||||
match_not(
|
||||
:css => '.active [data-name="body"]',
|
||||
:value => signature_body1,
|
||||
:no_quote => true,
|
||||
css: '.active [data-name="body"]',
|
||||
value: signature_body1,
|
||||
no_quote: true,
|
||||
)
|
||||
match(
|
||||
:css => '.active [data-name="body"]',
|
||||
:value => signature_body2,
|
||||
:no_quote => true,
|
||||
css: '.active [data-name="body"]',
|
||||
value: signature_body2,
|
||||
no_quote: true,
|
||||
)
|
||||
=end
|
||||
|
||||
# discard changes
|
||||
sleep 2
|
||||
|
|
Loading…
Reference in a new issue