From 1030eb1840fadb259a58cdf76e05c3c499ffa2a7 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 25 Mar 2016 08:45:21 +0100 Subject: [PATCH] Added current url support of clients for agents. --- .../javascripts/app/controllers/chat.coffee | 17 +++++++++ .../customer_chat/chat_notice_message.jst.eco | 1 + .../customer_chat/chat_window_info.jst.eco | 1 + lib/sessions/event/chat_session_init.rb | 1 + lib/sessions/event/chat_session_notice.rb | 22 ++++++++++++ lib/sessions/event/chat_status_customer.rb | 13 +++++++ public/assets/chat/chat.coffee | 12 +++++-- public/assets/chat/chat.js | 13 +++++-- public/assets/chat/chat.min.js | 4 +-- test/browser/chat_test.rb | 35 ++++++++++++++++--- 10 files changed, 108 insertions(+), 11 deletions(-) create mode 100644 app/assets/javascripts/app/views/customer_chat/chat_notice_message.jst.eco create mode 100644 lib/sessions/event/chat_session_notice.rb diff --git a/app/assets/javascripts/app/controllers/chat.coffee b/app/assets/javascripts/app/controllers/chat.coffee index ee665c6b0..b23fe5163 100644 --- a/app/assets/javascripts/app/controllers/chat.coffee +++ b/app/assets/javascripts/app/controllers/chat.coffee @@ -381,6 +381,11 @@ class ChatWindow extends App.Controller return if data.self_written @receiveMessage(data.message.content) ) + @bind('chat_session_notice', (data) => + return if data.session_id isnt @session.session_id + return if data.self_written + @addNoticeMessage(data.message) + ) @bind('chat_session_left', (data) => return if data.session_id isnt @session.session_id return if data.self_written @@ -410,6 +415,9 @@ class ChatWindow extends App.Controller # @addMessage 'Hello. My name is Roger, how can I help you?', 'agent' if @session + if @session && @session.preferences && @session.preferences.url + @addNoticeMessage(@session.preferences.url) + if @session.messages for message in @session.messages if message.created_by_id @@ -660,6 +668,15 @@ class ChatWindow extends App.Controller @scrollToBottom() + addNoticeMessage: (message, args) -> + @maybeAddTimestamp() + + @body.append App.view('customer_chat/chat_notice_message') + message: message + args: args + + @scrollToBottom() + scrollToBottom: -> @scrollHolder.scrollTop(@scrollHolder.prop('scrollHeight')) diff --git a/app/assets/javascripts/app/views/customer_chat/chat_notice_message.jst.eco b/app/assets/javascripts/app/views/customer_chat/chat_notice_message.jst.eco new file mode 100644 index 000000000..75d0994a9 --- /dev/null +++ b/app/assets/javascripts/app/views/customer_chat/chat_notice_message.jst.eco @@ -0,0 +1 @@ +
<%= @message %>
\ No newline at end of file diff --git a/app/assets/javascripts/app/views/customer_chat/chat_window_info.jst.eco b/app/assets/javascripts/app/views/customer_chat/chat_window_info.jst.eco index 6c90aa8a9..a7c3b1ff3 100644 --- a/app/assets/javascripts/app/views/customer_chat/chat_window_info.jst.eco +++ b/app/assets/javascripts/app/views/customer_chat/chat_window_info.jst.eco @@ -1,3 +1,4 @@ +