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 34132eda5..ccfe2e6ba 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee @@ -64,7 +64,10 @@ class App.TicketCreate extends App.Controller @title @article_attributes['title'] changed: => - true + formCurrent = @formParam( '.ticket-create' ) + diff = difference( @formDefault, formCurrent ) + return false if !diff || _.isEmpty( diff ) + return true release: => # @clearInterval( @key, 'ticket_zoom' ) @@ -193,6 +196,8 @@ class App.TicketCreate extends App.Controller el: @el.find('[data-id="text_module"]'), ) + @formDefault = @formParam( '.ticket-create' ) + localUserInfo: (params) => @userInfo( user_id: params.customer_id ) diff --git a/app/assets/javascripts/app/controllers/agent_ticket_zoom.js.coffee b/app/assets/javascripts/app/controllers/agent_ticket_zoom.js.coffee index 20bc766ae..61380ef3b 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_zoom.js.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_zoom.js.coffee @@ -51,7 +51,13 @@ class App.TicketZoom extends App.Controller @title 'Ticket Zoom ' + @ticket.number # else # @title 'Loading...' - + + changed: => + formCurrent = @formParam( '.ticket-update' ) + diff = difference( @formDefault, formCurrent ) + return false if !diff || _.isEmpty( diff ) + return true + release: => @clearInterval( @key, 'ticket_zoom' ) @el.remove() @@ -202,6 +208,8 @@ class App.TicketZoom extends App.Controller # show frontend times @frontendTimeUpdate() + @formDefault = @formParam( '.ticket-update' ) + # scroll to article if given if @article_id && document.getElementById( 'article-' + @article_id ) offset = document.getElementById( 'article-' + @article_id ).offsetTop diff --git a/app/assets/javascripts/app/controllers/task_widget.js.coffee b/app/assets/javascripts/app/controllers/task_widget.js.coffee index 83dc5d651..de52791b8 100644 --- a/app/assets/javascripts/app/controllers/task_widget.js.coffee +++ b/app/assets/javascripts/app/controllers/task_widget.js.coffee @@ -56,6 +56,12 @@ class App.TaskWidget extends App.Controller e.preventDefault() key = $(e.target).parent().data('id') + # check if input has changed + task = App.TaskManager.get( key ) + if task.worker && task.worker.changed + if task.worker.changed() + return if !window.confirm( App.i18n.translateInline('Tab has changed, you really want to close it?') ) + # check if active task is closed task_last = undefined tasks_all = App.TaskManager.all() diff --git a/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee b/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee index f90a4cc27..c2ff041e0 100644 --- a/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee +++ b/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee @@ -14,6 +14,11 @@ class App.TaskManager _instance ?= new _Singleton _instance.add( type, type_id, callback, params, to_not_show ) + @get: ( key ) -> + if _instance == undefined + _instance ?= new _Singleton + _instance.get( key ) + @remove: ( key ) -> if _instance == undefined _instance ?= new _Singleton @@ -118,6 +123,9 @@ class _Singleton extends App.Controller @task_count + get: ( key ) => + return @tasks[key] + remove: ( key, to_not_show = false ) => if @tasks[key] @tasks[key].worker.release() diff --git a/app/assets/javascripts/app/views/agent_ticket_create.jst.eco b/app/assets/javascripts/app/views/agent_ticket_create.jst.eco index 84f034e91..9a237bc61 100644 --- a/app/assets/javascripts/app/views/agent_ticket_create.jst.eco +++ b/app/assets/javascripts/app/views/agent_ticket_create.jst.eco @@ -5,7 +5,7 @@ -
+
diff --git a/app/assets/javascripts/app/views/agent_ticket_zoom.jst.eco b/app/assets/javascripts/app/views/agent_ticket_zoom.jst.eco index ced5a0d4e..b7b5db8bb 100644 --- a/app/assets/javascripts/app/views/agent_ticket_zoom.jst.eco +++ b/app/assets/javascripts/app/views/agent_ticket_zoom.jst.eco @@ -82,7 +82,7 @@
- +