diff --git a/app/assets/javascripts/modules/list-filter.js b/app/assets/javascripts/modules/list-filter.js index 449496e38..9eebf6bf3 100644 --- a/app/assets/javascripts/modules/list-filter.js +++ b/app/assets/javascripts/modules/list-filter.js @@ -77,9 +77,16 @@ window.GOVUK.Modules = window.GOVUK.Modules || {}; var matchingItems = block.querySelectorAll('[data-filter="item"]') var matchingItemCount = 0 + var innerBlocks = block.querySelectorAll('[data-filter="inner-block"]') + for (var r = 0; r < innerBlocks.length; r++) { + innerBlocks[r].classList.add('js-hidden') + } + for (var j = 0; j < matchingItems.length; j++) { if (!matchingItems[j].classList.contains('js-hidden')) { matchingItemCount++ + + if (matchingItems[j].closest('[data-filter="inner-block"]') !== null) { matchingItems[j].closest('[data-filter="inner-block"]').classList.remove('js-hidden') } } } diff --git a/app/assets/stylesheets/views/_world_index.scss b/app/assets/stylesheets/views/_world_index.scss index 942df6778..b00c30369 100644 --- a/app/assets/stylesheets/views/_world_index.scss +++ b/app/assets/stylesheets/views/_world_index.scss @@ -30,4 +30,20 @@ padding: govuk-spacing(1) 0; @include govuk-font(19); } + + .filter-list__form { + display: none; + } + + .filter-list__form--active { + display: block; + } + + .js-hidden { + display: none; + } + + .filter-list__results { + padding-left: $govuk-gutter-half; + } } diff --git a/app/presenters/world_index_presenter.rb b/app/presenters/world_index_presenter.rb index f2577226f..f4cecc910 100644 --- a/app/presenters/world_index_presenter.rb +++ b/app/presenters/world_index_presenter.rb @@ -29,6 +29,13 @@ def world_location_link(world_location) link_to world_location["name"], path, class: "govuk-link" end + def filter_terms(world_location) + slug = world_location["slug"] + name = world_location["name"] + + [slug, name].compact.join(" ") + end + private def location_group(location) diff --git a/app/views/world/index.html.erb b/app/views/world/index.html.erb index f4759562a..0647c7bc7 100644 --- a/app/views/world/index.html.erb +++ b/app/views/world/index.html.erb @@ -2,81 +2,100 @@ <% page_class "world-locations" %> <% add_view_stylesheet("world_index") %> -
<%= t('world_locations.content.find_out') %>
-<%= t('world_locations.content.find_out') %>
-<%= t('world_locations.count_prefix') %> - <%= @presented_index.world_locations_count %> <%= I18n.t("world_locations.type.world_location", count: 2) %> -
- <%= render "govuk_publishing_components/components/big_number", { - number: @presented_index.world_locations_count, - aria: { - hidden: true, - } +<%= t('world_locations.count_prefix') %> + <%= @presented_index.world_locations_count %> <%= I18n.t("world_locations.type.world_location", count: 2) %> +
+ <%= render "govuk_publishing_components/components/big_number", { + number: @presented_index.world_locations_count, + aria: { + hidden: true, + }, + data_attributes: { + item_count: "true", + }, + } %> +<%= t('world_locations.count_prefix') %> + <%= @presented_index.international_delegations_count %> <%= I18n.t("world_locations.type.international_delegation", count: 2) %> +
+ <%= render "govuk_publishing_components/components/big_number", { + number: @presented_index.international_delegations_count, + aria: { + hidden: true, + }, + data_attributes: { + item_count: "true", + }, + } %> +<%= t('world_locations.count_prefix') %> - <%= @presented_index.international_delegations_count %> <%= I18n.t("world_locations.type.international_delegation", count: 2) %> -
- <%= render "govuk_publishing_components/components/big_number", { - number: @presented_index.international_delegations_count, - aria: { - hidden: true, - }, - } %> -<%= t('world_locations.content.complete_list', href: link_to(t('world_locations.content.list_link'), "/government/publications/list-of-foreign-office-posts", class: "govuk-link")).html_safe %>
<%= t('world_locations.content.complete_list', href: link_to(t('world_locations.content.list_link'), "/government/publications/list-of-foreign-office-posts", class: "govuk-link")).html_safe %>
diff --git a/spec/javascripts/modules/list-filter_spec.js b/spec/javascripts/modules/list-filter_spec.js index 045e5bc5d..670bd40f9 100644 --- a/spec/javascripts/modules/list-filter_spec.js +++ b/spec/javascripts/modules/list-filter_spec.js @@ -41,6 +41,13 @@ describe('list-filter.js', function () { // Double space and line break added on purpose: '