From 665c8af4df73817d4f4139fb6f71fcf86533177b Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 27 Jul 2017 22:31:47 +0000 Subject: [PATCH] LP#1638299: improve display of related headings in browse This patch adds a new global flag to control whether see alsos are displayed at all; it also allows better labels based on the heading purpose. Signed-off-by: Galen Charlton Signed-off-by: Kathy Lussier --- .../lib/OpenILS/WWW/EGCatLoader/Browse.pm | 19 ++++++++++++++++ Open-ILS/src/sql/Pg/950.data.seed-values.sql | 11 ++++++++++ Open-ILS/src/sql/Pg/upgrade/WWWW.cgf.sql | 14 ++++++++++++ Open-ILS/src/templates/opac/browse.tt2 | 22 +++++++++++++++---- 4 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/WWWW.cgf.sql diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Browse.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Browse.pm index 1d49aa5dae..4440b1563a 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Browse.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Browse.pm @@ -119,6 +119,21 @@ sub find_authority_headings_and_notes { $self->extract_public_general_notes($record, $row); + # extract headings from the main authority record along with their + # types + my $parsed_headings = $self->editor->json_query({ + from => [ "authority.extract_headings", $row->{marc} ] + }); + my %heading_type_map = (); + if ($parsed_headings) { + foreach my $h (@$parsed_headings) { + $heading_type_map{$h->{normalized_heading}} = + $h->{purpose} eq 'variant' ? 'variant' : + $h->{purpose} eq 'related' ? $h->{related_type} : + ''; + } + } + # By applying grep in this way, we get acsaf objects that *have* and # therefore *aren't* main entries, which is what we want. foreach my $acsaf (values(%$acsaf_table)) { @@ -130,6 +145,10 @@ sub find_authority_headings_and_notes { my $h = { main_entry => ( $acsaf->main_entry ? 0 : 1 ), heading => _get_authority_heading($field, \%sf_lookup), $acsaf->joiner }; + my $norm = search_normalize($h->{heading}); + if (exists $heading_type_map{$norm}) { + $h->{type} = $heading_type_map{$norm}; + } # XXX I was getting "target" from authority.authority_linking, but # that makes no sense: that table can only tell you that one # authority record as a whole points at another record. It does diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index a7cf4702a1..3ff267542e 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -16881,6 +16881,17 @@ INSERT INTO config.global_flag (name, label, value, enabled) VALUES ( TRUE ); +INSERT INTO config.global_flag (name, label, enabled) VALUES ( + 'opac.show_related_headings_in_browse', + oils_i18n_gettext( + 'opac.show_related_headings_in_browse', + 'Display related headings (see-also) in browse', + 'cgf', + 'label' + ), + TRUE +); + INSERT INTO config.settings_group (name, label) VALUES ('ebook_api', oils_i18n_gettext('ebook_api', 'Ebook API Integration', 'csg', 'label')); diff --git a/Open-ILS/src/sql/Pg/upgrade/WWWW.cgf.sql b/Open-ILS/src/sql/Pg/upgrade/WWWW.cgf.sql new file mode 100644 index 0000000000..f5f6049d68 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/WWWW.cgf.sql @@ -0,0 +1,14 @@ +BEGIN; + +INSERT INTO config.global_flag (name, label, enabled) VALUES ( + 'opac.show_related_headings_in_browse', + oils_i18n_gettext( + 'opac.show_related_headings_in_browse', + 'Display related headings (see-also) in browse', + 'cgf', + 'label' + ), + TRUE +); + +COMMIT; diff --git a/Open-ILS/src/templates/opac/browse.tt2 b/Open-ILS/src/templates/opac/browse.tt2 index 4e7424185e..b364655899 100644 --- a/Open-ILS/src/templates/opac/browse.tt2 +++ b/Open-ILS/src/templates/opac/browse.tt2 @@ -11,6 +11,20 @@ depart_list = ['blimit', 'bterm', 'bpivot']; ctx.metalinks.push(''); + MACRO heading_use_label BLOCK; + SWITCH use; + CASE 'variant'; + l('See'); + CASE 'broader'; + l('Broader term'); + CASE 'narrower'; + l('Broader term'); + CASE 'other'; + l('Related term'); + CASE; + l('See'); + END; + END; %]

[% l('Catalog Browse') %]

@@ -140,7 +154,7 @@ # that h.target_count is only # defined when h.target is. - IF h.target AND h.target_count AND result.list_authorities.grep('^' _ h.target _ '$').size == 0; + IF h.target AND h.target_count AND result.list_authorities.grep('^' _ h.target _ '$').size == 0 AND h.main_entry; id = h.target; NEXT IF seenit.$id; seenit.$id = 1; IF !auth_headings_ul_added; # only add a
    if we have at least one
  • (WCAG 2.0) @@ -148,7 +162,7 @@
      [% END %] -
    • [% field.name %] +
    • [% heading_use_label(use=h.type) %] [% h.heading | html %] ([% h.target_count %])
    • @@ -173,14 +187,14 @@ # that h.target_count is only # defined when h.target is. - IF h.target AND h.target_count AND result.list_sees.grep('^' _ h.target _ '$').size == 0 AND !h.main_entry; + IF h.target AND h.target_count AND result.list_sees.grep('^' _ h.target _ '$').size == 0 AND !h.main_entry AND ctx.get_cgf('opac.show_related_headings_in_browse').enabled == 't'; id = h.target; NEXT IF seenit.$id; seenit.$id = 1; IF !auth_headings_ul_added; # only add a
        if we have at least one
      • (WCAG 2.0) auth_headings_ul_added = 1; %]
          [% END %] -
        • [% field.name %] +
        • [% heading_use_label(use=h.type) %] [% h.heading | html %] ([% h.target_count %])
        • -- 2.43.2