Skip to content

Commit

Permalink
Get webchat info from content item
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Ruben Arakelyan committed Jul 23, 2018
1 parent d8a3794 commit 84e2235
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 27 deletions.
4 changes: 4 additions & 0 deletions app/presenters/contact_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/contact.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

<% if @content_item.show_webchat? %>
<h2 id="webchat-title">Webchat</h2>
<p><%= render 'shared/webchat' %></p>
<%= render 'shared/webchat' %>
<% end %>

<% if @content_item.phone.any? %>
Expand Down
50 changes: 24 additions & 26 deletions app/views/shared/_webchat.html.erb
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
<span class="js-webchat"
data-availability-url="<%= @content_item.webchat_availability_url %>"
data-open-url="<%= @content_item.webchat_open_url %>">
<% 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.
<br/>
<br/>
<%= @content_item.webchat_body %>

<p>
<span class="js-webchat"
data-availability-url="<%= @content_item.webchat_availability_url %>"
data-open-url="<%= @content_item.webchat_open_url %>">
<% if webchat_unavailable? %>
<%= unavailability_message %>
<% else %>
<span class="js-webchat-advisers-error">
Webchat is unavailable at the moment because of technical problems.
</span>
<span class="js-webchat-advisers-unavailable hidden">
Webchat is closed at the moment.
</span>
<span class="js-webchat-advisers-busy hidden">
All webchat advisers are busy at the moment.
</span>
<span class="js-webchat-advisers-available hidden">
Advisers are available to chat.
<a href="#" rel="external" class="js-webchat-open-button">Speak to an adviser now</a>.
</span>
<% end %>
<span class="js-webchat-advisers-error">
Webchat is unavailable at the moment because of technical problems.
</span>
<span class="js-webchat-advisers-unavailable hidden">
Webchat is closed at the moment.
</span>
<span class="js-webchat-advisers-busy hidden">
All webchat advisers are busy at the moment.
</span>
<span class="js-webchat-advisers-available hidden">
Advisers are available to chat.
<a href="#" rel="external" class="js-webchat-open-button">Speak to an adviser now</a>.
</span>
<% end %>
</span>
</span>
</p>
<% # This is inline in the source however slimmer will optimize this. %>
<%= javascript_include_tag "webchat", integrity: true, crossorigin: 'anonymous' %>

0 comments on commit 84e2235

Please sign in to comment.