Display 'title of unit' $o in serial holdings
authorDan Wells <dbw2@calvin.edu>
Tue, 17 Sep 2013 20:21:56 +0000 (16:21 -0400)
committerDan Wells <dbw2@calvin.edu>
Tue, 17 Sep 2013 20:25:27 +0000 (16:25 -0400)
If a holding has a subfield 'o' value, tack it onto the display
string for that enumeration.

Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/Holding.pm

index 37f985a..c9dc00b 100644 (file)
@@ -56,13 +56,13 @@ sub new {
             }
             if ($key =~ /[a-h]/) {
                 # Enumeration specific details of holdings
-                $self->{_mfhdh_FIELDS}->{$key}{UNIT} = undef;
+                $self->{_mfhdh_FIELDS}->{$key}{UNIT_TITLE} = undef;
                 $last_enum = $key;
             }
         } elsif ($key eq 'o') {
             warn '$o specified prior to first enumeration'
               unless defined($last_enum);
-            $self->{_mfhdh_FIELDS}->{$last_enum}->{UNIT} = $val;
+            $self->{_mfhdh_FIELDS}->{$last_enum}->{UNIT_TITLE} = $val;
             $last_enum = undef;
         } elsif ($key =~ /[npq]/) {
             $self->{_mfhdh_DESCR}->{$key} = $val;
@@ -131,6 +131,20 @@ sub field_values {
     }
 }
 
+#
+# Given a field key, returns a unit title (if there is one), or undef
+# if there isn't
+#
+sub unit_title {
+    my ($self, $key) = @_;
+
+    if (exists $self->fields->{$key}) {
+        return $self->fields->{$key}{UNIT_TITLE};
+    } else {
+        return;
+    }
+}
+
 sub seqno {
     my $self = shift;
 
@@ -361,7 +375,8 @@ sub format_single_enum {
 
 
     $skip_sep ||= ($key eq 'a');
-    return ($skip_sep ? '' : $sep) . $capstr . $holding_values->{$key};
+    return ($skip_sep ? '' : $sep) . $capstr . $holding_values->{$key} .
+        ($self->unit_title($key) ? ' ' . $self->unit_title($key) : '');
 }
 
 #