From 84e2235ed2ee0875a29a606c307974902d5a2579 Mon Sep 17 00:00:00 2001 From: Ruben Arakelyan Date: Mon, 23 Jul 2018 12:03:46 +0100 Subject: [PATCH] Get webchat info from content item This commit replaces the existing hardcoded webchat info for one page with the relevant content item field, to allow editors to specify this text using contacts-admin. --- app/presenters/contact_presenter.rb | 4 ++ app/views/content_items/contact.html.erb | 2 +- app/views/shared/_webchat.html.erb | 50 ++++++++++++------------ 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/app/presenters/contact_presenter.rb b/app/presenters/contact_presenter.rb index 4907a8d97..d21f6a13c 100644 --- a/app/presenters/contact_presenter.rb +++ b/app/presenters/contact_presenter.rb @@ -8,6 +8,10 @@ def title_and_context end end + def webchat_body + content_item.dig("details", "more_info_webchat").try(:html_safe) + end + def online_form_links contact_form_links = content_item["details"]["contact_form_links"] || [] contact_form_links.map do |link| diff --git a/app/views/content_items/contact.html.erb b/app/views/content_items/contact.html.erb index e4b607549..fe96c0977 100644 --- a/app/views/content_items/contact.html.erb +++ b/app/views/content_items/contact.html.erb @@ -46,7 +46,7 @@ <% if @content_item.show_webchat? %>

Webchat

-

<%= render 'shared/webchat' %>

+ <%= render 'shared/webchat' %> <% end %> <% if @content_item.phone.any? %> diff --git a/app/views/shared/_webchat.html.erb b/app/views/shared/_webchat.html.erb index 2e9a4cf14..d2fb72863 100644 --- a/app/views/shared/_webchat.html.erb +++ b/app/views/shared/_webchat.html.erb @@ -1,29 +1,27 @@ - - <% if webchat_unavailable? %> - <%= unavailability_message %> - <% else %> - <% if @content_item.base_path == '/government/organisations/hm-revenue-customs/contact/tax-credits-enquiries' %> - Advisers can only talk to you about Child Tax Credit and Working Tax Credit. - They won't be able to transfer you to another webchat team. -
-
+<%= @content_item.webchat_body %> + +

+ + <% if webchat_unavailable? %> + <%= unavailability_message %> + <% else %> + + Webchat is unavailable at the moment because of technical problems. + + + + <% end %> - - Webchat is unavailable at the moment because of technical problems. - - - - - <% end %> - + +

<% # This is inline in the source however slimmer will optimize this. %> <%= javascript_include_tag "webchat", integrity: true, crossorigin: 'anonymous' %>