diff --git a/app/assets/javascripts/app/controllers/chat.coffee b/app/assets/javascripts/app/controllers/chat.coffee index af460d8ea..2357bb72d 100644 --- a/app/assets/javascripts/app/controllers/chat.coffee +++ b/app/assets/javascripts/app/controllers/chat.coffee @@ -332,10 +332,13 @@ class ChatWindow extends App.Controller 'click': 'clearUnread' 'click .js-send': 'sendMessage' 'click .js-close': 'close' + 'click .js-disconnect': 'disconnect' elements: '.js-customerChatInput': 'input' '.js-status': 'status' + '.js-close': 'closeButton' + '.js-disconnect': 'disconnectButton' '.js-body': 'body' '.js-scrollHolder': 'scrollHolder' @@ -376,13 +379,13 @@ class ChatWindow extends App.Controller @bind('chat_session_left', (data) => return if data.session_id isnt @session.session_id return if data.self_written - @addStatusMessage("#{data.realname} has left the conversation") + @addStatusMessage("#{data.realname} left the conversation") @goOffline() ) @bind('chat_session_closed', (data) => return if data.session_id isnt @session.session_id return if data.self_written - @addStatusMessage("#{data.realname} has closed the conversation") + @addStatusMessage("#{data.realname} closed the conversation") @goOffline() ) @bind('chat_focus', (data) => @@ -438,14 +441,18 @@ class ChatWindow extends App.Controller maxlength: 40000 }) - close: => - @el.one 'transitionend', { callback: @release }, @onTransitionend - @el.removeClass('is-open') + disconnect: => + @addStatusMessage("You left the conversation") App.WebSocket.send( event:'chat_session_close' data: session_id: @session.session_id ) + @goOffline() + + close: => + @el.one 'transitionend', { callback: @release }, @onTransitionend + @el.removeClass('is-open') if @removeCallback @removeCallback(@session.session_id) @@ -588,8 +595,9 @@ class ChatWindow extends App.Controller @$('.js-loader').remove() goOffline: => - #@addStatusMessage("#{ @options.name }'s connection got closed") @status.attr('data-status', 'offline') + @disconnectButton.addClass 'is-hidden' + @closeButton.removeClass 'is-hidden' @el.addClass('is-offline') @input.attr('disabled', true) @@ -622,6 +630,8 @@ class ChatWindow extends App.Controller time: time addStatusMessage: (message, args) -> + @maybeAddTimestamp() + @body.append App.view('customer_chat/chat_status_message') message: message args: args diff --git a/app/assets/javascripts/app/views/customer_chat/chat_window.jst.eco b/app/assets/javascripts/app/views/customer_chat/chat_window.jst.eco index c9ca6b9d6..7cd95126e 100644 --- a/app/assets/javascripts/app/views/customer_chat/chat_window.jst.eco +++ b/app/assets/javascripts/app/views/customer_chat/chat_window.jst.eco @@ -7,8 +7,11 @@