Bug 36750: Fix aria-label for show more/less links

Didn't manage to keep the more_less_labels because of the space in the
key names

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Jonathan Druart 2024-05-06 11:55:28 +02:00 committed by Katrin Fischer
parent 4ffaa07a40
commit a654faf72e
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834
2 changed files with 59 additions and 25 deletions

View file

@ -39,18 +39,6 @@
[% IF ( related ) %] <li>(related searches: [% FOREACH relate IN related %][% relate.related_search | html %][% END %])</li>[% END %]
</li>
[% SET more_less_labels = {} %]
[% more_less_labels.Authors = { more = t("Show more authors"), less = t("Show fewer authors") } %]
[% more_less_labels.Titles = { more = t("Show more titles"), less = t("Show fewer titles") } %]
[% more_less_labels.Topics = { more = t("Show more topics"), less = t("Show fewer topics") } %]
[% more_less_labels.Places = { more = t("Show more places"), less = t("Show fewer places") } %]
[% more_less_labels.Series = { more = t("Show more series"), less = t("Show fewer series") } %]
[% more_less_labels.ItemTypes = { more = t("Show more item types"), less = t("Show fewer item types") } %]
[% more_less_labels.CollectionCodes = { more = t("Show more collections"), less = t("Show fewer collections") } %]
[% more_less_labels.Language = { more = t("Show more languages"), less = t("Show fewer languages") } %]
[% more_less_labels.HomeLibrary = { more = t("Show more home libraries"), less = t("Show fewer home libraries") } %]
[% more_less_labels.HoldingLibrary = { more = t("Show more holding libraries"), less = t("Show fewer holding libraries") } %]
[% more_less_labels.Location = { more = t("Show more locations"), less = t("Show fewer locations") } %]
[% FOREACH facets_loo IN facets_loop %]
[% IF facets_loo.facets.size > 0 %]
<li id="[% facets_loo.type_id | html %]">
@ -114,17 +102,63 @@
[% END %]
[% IF facets_loo.facets.size > 5 %]
<li class="moretoggle">
[% FOR label IN more_less_labels.keys %]
[% IF facets_loo.item('type_label_' _ label) %]
<a href="#" aria-label="[% more_less_labels.item(label).more || t('Show more') | html | trim %]"><strong>Show more</strong></a>
[% END %]
[% SET aria_label = t("Show more") %]
[% SWITCH facets_loo.label %]
[% CASE 'Authors' %]
[% aria_label = t("Show more authors") %]
[% CASE 'Titles' %]
[% aria_label = t("Show more titles") %]
[% CASE 'Topics' %]
[% aria_label = t("Show more topics") %]
[% CASE 'Places' %]
[% aria_label = t("Show more places") %]
[% CASE 'Series' %]
[% aria_label = t("Show more series") %]
[% CASE 'ItemTypes' %]
[% aria_label = t("Show more item types") %]
[% CASE 'Home libraries' %]
[% aria_label = t("Show more home libraries") %]
[% CASE 'Holding libraries' %]
[% aria_label = t("Show more holding libraries") %]
[% CASE 'Location' %]
[% aria_label = t("Show more home locations") %]
[% CASE 'Collections' %]
[% aria_label = t("Show more home collections") %]
[% CASE 'Languages' %]
[% aria_label = t("Show more home languages") %]
[% END %]
<a href="#" aria-label="[% aria_label | html | trim %]"><strong>Show more</strong></a>
</li>
<li class="moretoggle" style="display:none">
[% FOR label IN more_less_labels.keys %]
[% IF facets_loo.item('type_label_' _ label) %]
<a href="#" aria-label="[% more_less_labels.item(label).less || t('Show less') | html | trim %]"><strong>Show less</strong></a>
[% END %]
[% SET aria_label = t("Show more") %]
[% SWITCH facets_loo.label %]
[% CASE 'Authors' %]
[% aria_label = t("Show fewer authors") %]
[% CASE 'Titles' %]
[% aria_label = t("Show fewer titles") %]
[% CASE 'Topics' %]
[% aria_label = t("Show fewer topics") %]
[% CASE 'Places' %]
[% aria_label = t("Show fewer places") %]
[% CASE 'Series' %]
[% aria_label = t("Show fewer series") %]
[% CASE 'ItemTypes' %]
[% aria_label = t("Show fewer item types") %]
[% CASE 'Home libraries' %]
[% aria_label = t("Show fewer home libraries") %]
[% CASE 'Holding libraries' %]
[% aria_label = t("Show fewer holding libraries") %]
[% CASE 'Location' %]
[% aria_label = t("Show fewer home locations") %]
[% CASE 'Collections' %]
[% aria_label = t("Show fewer home collections") %]
[% CASE 'Languages' %]
[% aria_label = t("Show fewer home languages") %]
[% END %]
[% IF aria_label %]
<a href="#" aria-label="[% aria_label | html | trim %]"><strong>Show less</strong></a>
[% END %]
</li>
[% END %]

View file

@ -825,9 +825,9 @@ ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'
my $facets_info = C4::Search::_get_facets_info( $facets );
my $expected_facets_info_marc21 = {
'au' => { 'label_value' => "Authors" },
'ccode' => { 'label_value' => "CollectionCodes" },
'holdingbranch' => { 'label_value' => "HoldingLibrary" },
'itype' => { 'label_value' => "ItemTypes" },
'ccode' => { 'label_value' => "Collections" },
'holdingbranch' => { 'label_value' => "Holding libraries" },
'itype' => { 'label_value' => "Item types" },
'location' => { 'label_value' => "Location" },
'se' => { 'label_value' => "Series" },
'su-geo' => { 'label_value' => "Places" },
@ -925,8 +925,8 @@ sub run_unimarc_search_tests {
my $facets_info = C4::Search::_get_facets_info( $facets );
my $expected_facets_info_unimarc = {
'au' => { 'label_value' => "Authors" },
'ccode' => { 'label_value' => "CollectionCodes" },
'holdingbranch' => { 'label_value' => "HoldingLibrary" },
'ccode' => { 'label_value' => "Collections" },
'holdingbranch' => { 'label_value' => "Holding libraries" },
'location' => { 'label_value' => "Location" },
'se' => { 'label_value' => "Series" },
'su-geo' => { 'label_value' => "Places" },