better display of labels
authorGalen Charlton <gmc@equinoxinitiative.org>
Fri, 18 Aug 2017 21:36:57 +0000 (21:36 +0000)
committerGalen Charlton <gmc@equinoxinitiative.org>
Fri, 18 Aug 2017 21:36:57 +0000 (21:36 +0000)
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Browse.pm
Open-ILS/src/templates/opac/browse.tt2

index 1d49aa5..4440b15 100644 (file)
@@ -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
index 36f528b..679ceac 100644 (file)
 
     depart_list = ['blimit', 'bterm', 'bpivot'];
     ctx.metalinks.push('<meta name="robots" content="noindex,follow">');
+    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;
 %]
 
     <h2 class="sr-only">[% l('Catalog Browse') %]</h2>
                                             # 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 <ul> if we have at least one <li> (WCAG 2.0)
                                                 <ul class="browse-result-authority-headings"> 
                                                 [% END %]
 
-                                                <li><span class="browse-result-authority-field-name">[% l('See') %]</span>
+                                                <li><span class="browse-result-authority-field-name">[% heading_use_label(use=h.type) %]</span>
                                                 <a href="[% mkurl(ctx.opac_root _ '/browse', {bterm => h.heading}, ['bpivot']) %]">[% h.heading | html %]</a>
                                                 <span class="browse-result-authority-bib-links">([% h.target_count %])</span>
                                                 </li>
                                                     auth_headings_ul_added = 1; %]
                                                 <ul class="browse-result-authority-headings"> 
                                                 [% END %]
-                                                <li><span class="browse-result-authority-field-name">[% l('See') %]</span>
+                                                <li><span class="browse-result-authority-field-name">[% heading_use_label(use=h.type) %]</span>
                                                 <a href="[% mkurl(ctx.opac_root _ '/results', {query => 'identifier|authority_id[' _ h.target _ ']'}) %]">[% h.heading | html %]</a>
                                                 <span class="browse-result-authority-bib-links">([% h.target_count %])</span>
                                                 </li>