From 4a9a2d8d1038addfa6a508df67b63689a1716d38 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 13 Jan 2015 08:26:45 +0100 Subject: [PATCH] Improved replacing signature. --- .../app/controllers/agent_ticket_create.js.coffee | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 03b5ff425..5347ddd79 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee @@ -242,6 +242,15 @@ class App.TicketCreate extends App.Controller # get current body body = @$('[data-name="body"]').html() || '' if App.Utils.signatureCheck( body, signatureFinished ) + + # if signature has changed, replace it + signature_id = @$('[data-signature=true]').data('signature-id') + if signature_id && signature_id.toString() isnt signature.id.toString() + + # remove old signature + @$('[data-signature="true"]').remove() + body = @$('[data-name="body"]').html() || '' + if !App.Utils.lastLineEmpty(body) body = body + '
' body = body + "
#{signatureFinished}
" @@ -250,7 +259,7 @@ class App.TicketCreate extends App.Controller # remove old signature else - @$('[data-name="body"]').find("[data-signature=true]").remove() + @$('[data-name="body"]').find('[data-signature=true]').remove() new App.ControllerForm( el: @el.find('.ticket-form-top')