diff --git a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee
index 62262e123..03b5ff425 100644
--- a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee
+++ b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee
@@ -3,10 +3,10 @@ class App.TicketCreate extends App.Controller
'.tabsSidebar' : 'sidebar'
events:
- 'click .type-tabs .tab': 'changeFormType'
- 'submit form': 'submit'
- 'click .submit': 'submit'
- 'click .cancel': 'cancel'
+ 'click .type-tabs .tab': 'changeFormType'
+ 'submit form': 'submit'
+ 'click .submit': 'submit'
+ 'click .cancel': 'cancel'
constructor: (params) ->
super
@@ -87,6 +87,9 @@ class App.TicketCreate extends App.Controller
# update form
@el.find('[name="formSenderType"]').val(type)
+ # force changing signature
+ @el.find('[name="group_id"]').trigger('change')
+
meta: =>
text = ''
if @articleAttributes
@@ -167,10 +170,10 @@ class App.TicketCreate extends App.Controller
a = App.TicketArticle.find( params.article_id )
# reset owner
- t.owner_id = 0
- t.customer_id_autocompletion = a.from
- t.subject = a.subject || t.title
- t.body = a.body
+ t.owner_id = 0
+ t.customer_id_completion = a.from
+ t.subject = a.subject || t.title
+ t.body = a.body
# render page
@render( options: t )
@@ -191,10 +194,10 @@ class App.TicketCreate extends App.Controller
@form_id = App.ControllerForm.formId()
@html App.view('agent_ticket_create')(
- head: 'New Ticket'
- agent: @isRole('Agent')
- admin: @isRole('Admin')
- form_id: @form_id
+ head: 'New Ticket'
+ agent: @isRole('Agent')
+ admin: @isRole('Admin')
+ form_id: @form_id
)
formChanges = (params, attribute, attributes, classname, form, ui) =>
@@ -220,6 +223,35 @@ class App.TicketCreate extends App.Controller
# replace new option list
form.find('[name="' + fieldNameToChange + '"]').closest('.form-group').replaceWith( newElement )
+ 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.text2html(
+ App.Utils.replaceTags( signature.body, { user: App.Session.get() } )
+ )
+
+ # get current body
+ body = @$('[data-name="body"]').html() || ''
+ if App.Utils.signatureCheck( body, signatureFinished )
+ if !App.Utils.lastLineEmpty(body)
+ body = body + '
'
+ body = body + "