diff --git a/app/presenters/blacklight/rendering/link_to_facet.rb b/app/presenters/blacklight/rendering/link_to_facet.rb index 622a34641b..001ee384d5 100644 --- a/app/presenters/blacklight/rendering/link_to_facet.rb +++ b/app/presenters/blacklight/rendering/link_to_facet.rb @@ -23,13 +23,21 @@ def link_field end def link(field, v) - context.link_to v, search_path(field, v) + context.link_to search_path(field, v) do + context.tag.span(v) + + context.tag.span(search_description, class: 'visually-hidden') + end end def search_path(field, v) context.search_action_path(facet_params(field, v)) end + # Accessible description for the link, indicating it will do a faceted search + def search_description + context.t 'blacklight.search.facets.faceted_search', field_label: config.display_label + end + def facet_params(field, item) context.search_state.reset.filter(field).add(item).params end diff --git a/config/locales/blacklight.ar.yml b/config/locales/blacklight.ar.yml index 5694599b1b..2c647b9551 100644 --- a/config/locales/blacklight.ar.yml +++ b/config/locales/blacklight.ar.yml @@ -98,6 +98,7 @@ ar: all: الكل clear: إزالة معايير البحث count: "%{number}" + faceted_search: بحث %{field_label} group: close: إخفاء الأوجه open: عرض الأوجه diff --git a/config/locales/blacklight.de.yml b/config/locales/blacklight.de.yml index a804f40510..85842251af 100644 --- a/config/locales/blacklight.de.yml +++ b/config/locales/blacklight.de.yml @@ -88,6 +88,7 @@ de: all: Alle clear: Löschen count: "%{number}" + faceted_search: "%{field_label} Suche" group: close: Facetten ausblenden open: Facetten zeigen diff --git a/config/locales/blacklight.en.yml b/config/locales/blacklight.en.yml index 6bd7f10b3d..d45ca9fc1a 100644 --- a/config/locales/blacklight.en.yml +++ b/config/locales/blacklight.en.yml @@ -124,6 +124,7 @@ en: label: "Filter %{field_label}" placeholder: Filter... title: Limit your search + faceted_search: "%{field_label} search" filters: label: "%{label}:" remove: diff --git a/config/locales/blacklight.es.yml b/config/locales/blacklight.es.yml index 6d0ecb91ca..ef70fd3452 100644 --- a/config/locales/blacklight.es.yml +++ b/config/locales/blacklight.es.yml @@ -88,6 +88,7 @@ es: all: Todos clear: Borrar count: "%{number}" + faceted_search: Búsqueda %{field_label} group: close: Ocultar facetas open: Mostrar facetas diff --git a/config/locales/blacklight.fr.yml b/config/locales/blacklight.fr.yml index 268cf06c49..af2f04c7f9 100755 --- a/config/locales/blacklight.fr.yml +++ b/config/locales/blacklight.fr.yml @@ -88,6 +88,7 @@ fr: all: Tout clear: Effacer count: "%{number}" + faceted_search: Recherche %{field_label} group: close: Masquer les facettes open: Afficher les facettes diff --git a/config/locales/blacklight.hu.yml b/config/locales/blacklight.hu.yml index 72406fd27d..c67e043172 100644 --- a/config/locales/blacklight.hu.yml +++ b/config/locales/blacklight.hu.yml @@ -86,6 +86,7 @@ hu: all: Minden clear: Szűrőfeltétel eltávolítása count: "%{number}" + faceted_search: "%{field_label} keresés" group: close: Fazetek elrejtése open: Szempontok megjelenítése diff --git a/config/locales/blacklight.it.yml b/config/locales/blacklight.it.yml index 4d15c165dc..e0ad3f28ff 100644 --- a/config/locales/blacklight.it.yml +++ b/config/locales/blacklight.it.yml @@ -88,6 +88,7 @@ it: all: Ogni clear: Cancella count: "%{number}" + faceted_search: "%{field_label} ricerca" group: close: Nascondi sfaccettature open: Mostra sfaccettature diff --git a/config/locales/blacklight.nl.yml b/config/locales/blacklight.nl.yml index 2e9886a029..5352424268 100644 --- a/config/locales/blacklight.nl.yml +++ b/config/locales/blacklight.nl.yml @@ -86,6 +86,7 @@ nl: all: Al clear: Filters legen count: "%{number}" + faceted_search: "%{field_label} zoeken" group: close: Verberg facetten open: Toon facetten diff --git a/config/locales/blacklight.pt-BR.yml b/config/locales/blacklight.pt-BR.yml index 98b110351d..ec6b2082ed 100644 --- a/config/locales/blacklight.pt-BR.yml +++ b/config/locales/blacklight.pt-BR.yml @@ -86,6 +86,7 @@ pt-BR: all: Todo clear: Limpar count: "%{number}" + faceted_search: Pesquisa %{field_label} group: close: Ocultar facetas open: Mostrar facetas diff --git a/config/locales/blacklight.sq.yml b/config/locales/blacklight.sq.yml index 3eddf68b85..62573d3465 100644 --- a/config/locales/blacklight.sq.yml +++ b/config/locales/blacklight.sq.yml @@ -86,6 +86,7 @@ sq: all: Gjithë clear: Fshij filterin count: "%{number}" + faceted_search: "%{field_label} kërkim" group: close: Fshih aspektet open: Trego aspektet diff --git a/config/locales/blacklight.zh.yml b/config/locales/blacklight.zh.yml index d0d451bb6c..951da1f4a1 100644 --- a/config/locales/blacklight.zh.yml +++ b/config/locales/blacklight.zh.yml @@ -86,6 +86,7 @@ zh: all: 皆 clear: 清除搜索条件 count: "%{number}" + faceted_search: "%{field_label} 搜索" group: close: 隐藏方面 open: 显示方面 diff --git a/spec/presenters/blacklight/field_presenter_spec.rb b/spec/presenters/blacklight/field_presenter_spec.rb index 725e7f441a..be76c18f9f 100644 --- a/spec/presenters/blacklight/field_presenter_spec.rb +++ b/spec/presenters/blacklight/field_presenter_spec.rb @@ -83,7 +83,7 @@ def render context 'when field has link_to_facet with true' do before do allow(request_context).to receive(:search_action_path).with({ 'f' => { 'link_to_facet_true' => ['x'] } }).and_return('/foo') - allow(request_context).to receive(:link_to).with("x", '/foo').and_return('bar') + allow(request_context).to receive(:link_to).with('/foo').and_return('bar') end let(:field_name) { 'link_to_facet_true' } @@ -94,7 +94,7 @@ def render context 'when field has link_to_facet with a field name' do before do allow(request_context).to receive(:search_action_path).with({ 'f' => { 'some_field' => ['x'] } }).and_return('/foo') - allow(request_context).to receive(:link_to).with("x", '/foo').and_return('bar') + allow(request_context).to receive(:link_to).with('/foo').and_return('bar') end let(:field_name) { 'link_to_facet_named' } diff --git a/spec/presenters/blacklight/rendering/link_to_facet_spec.rb b/spec/presenters/blacklight/rendering/link_to_facet_spec.rb new file mode 100644 index 0000000000..28e391f40a --- /dev/null +++ b/spec/presenters/blacklight/rendering/link_to_facet_spec.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +RSpec.describe Blacklight::Rendering::LinkToFacet, type: :presenter do + include Capybara::RSpecMatchers + + let(:field_config) { Blacklight::Configuration::FacetField.new(link_to_facet: true, key: 'field', label: 'Field') } + let(:document) { instance_double(SolrDocument) } + let(:blacklight_config) { Blacklight::Configuration.new } + let(:view_context) { controller.view_context } + let(:value) { 'value' } + let(:pipeline) { Blacklight::Rendering::Pipeline.new([value], field_config, document, view_context, [described_class], {}) } + + describe '#render' do + subject { pipeline.render[0] } + + it 'renders the value' do + expect(subject).to have_css('span', text: 'value') + end + + it 'renders the accessible description as visually hidden' do + expect(subject).to have_css('span.visually-hidden', text: 'Field search') + end + end +end