From 309ec851cc6f6a91158f60b2d4ac59efc24281d9 Mon Sep 17 00:00:00 2001 From: mahmudh Date: Wed, 7 Nov 2018 17:27:10 +0000 Subject: [PATCH] Add separate tracking data for home link on breadcrumb --- Gemfile.lock | 3 + .../components/_breadcrumbs.html.erb | 33 ++++------ .../components/_layout_header.html.erb | 2 +- .../app_helpers/taxon_breadcrumbs.rb | 2 +- .../presenters/breadcrumbs.rb | 63 +++++++++++++++++-- spec/components/breadcrumbs_spec.rb | 21 +++++++ 6 files changed, 95 insertions(+), 29 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index dd45c2abb6..0faac4e903 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -332,5 +332,8 @@ DEPENDENCIES webmock (~> 3.0.1) yard +RUBY VERSION + ruby 2.5.3p105 + BUNDLED WITH 1.17.1 diff --git a/app/views/govuk_publishing_components/components/_breadcrumbs.html.erb b/app/views/govuk_publishing_components/components/_breadcrumbs.html.erb index 343d07e97c..f5f271dcfc 100644 --- a/app/views/govuk_publishing_components/components/_breadcrumbs.html.erb +++ b/app/views/govuk_publishing_components/components/_breadcrumbs.html.erb @@ -4,44 +4,33 @@ inverse ||= false collapse_class = collapse_on_mobile && breadcrumbs.any? { |crumb| crumb[:is_page_parent] } ? "gem-c-breadcrumbs--collapse-on-mobile" : "" invert_class = inverse ? "gem-c-breadcrumbs--inverse" : "" - structured_data = GovukPublishingComponents::Presenters::Breadcrumbs.new(breadcrumbs, request.path).structured_data + breadcrumb_presenter = GovukPublishingComponents::Presenters::Breadcrumbs.new(breadcrumbs, request.path) %>
    <% breadcrumbs.each_with_index do |crumb, index| %> - <% - is_link = crumb[:url].present? || crumb[:is_current_page] - path = crumb[:is_current_page] ? '#content' : crumb[:url] - aria_current = crumb[:is_current_page] ? 'page' : 'false' - %> -
  1. - <% if is_link %> + <% breadcrumb = GovukPublishingComponents::Presenters::Breadcrumb.new(crumb, index) %> +
  2. + <% if breadcrumb.is_link? %> <%= link_to( - crumb[:title], - path, - data: { - track_category: 'breadcrumbClicked', - track_action: index + 1, - track_label: path, - track_options: { - dimension28: breadcrumbs.length.to_s, - dimension29: crumb[:title] - } - }, + breadcrumb[:title], + breadcrumb.path, + data: breadcrumb.tracking_data(breadcrumbs.length), class: "govuk-breadcrumbs__link", aria: { - current: aria_current, + current: breadcrumb.aria_current, } ) %> <% else %> - <%= crumb[:title] %> + <%= breadcrumb[:title] %> <% end %>
  3. <% end %>
+ diff --git a/app/views/govuk_publishing_components/components/_layout_header.html.erb b/app/views/govuk_publishing_components/components/_layout_header.html.erb index 5232bbb10a..2fcadd50a5 100644 --- a/app/views/govuk_publishing_components/components/_layout_header.html.erb +++ b/app/views/govuk_publishing_components/components/_layout_header.html.erb @@ -6,7 +6,7 @@