Teach the spine label editor to use the label prefixes and suffixes
authordbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 27 Aug 2010 21:58:24 +0000 (21:58 +0000)
committerdbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 27 Aug 2010 21:58:24 +0000 (21:58 +0000)
If label_prefix or label_suffix are defined in asset.copy_location, the
spine label editor will now prefix or suffix them to the call number
label respectively.

git-svn-id: svn://svn.open-ils.org/ILS/trunk@17365 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/cat/spine_labels.js

index 720348b..f742a38 100644 (file)
                 for (var i = 0; i < g.barcodes.length; i++) {
                     var copy = g.network.simple_request( 'FM_ACP_RETRIEVE_VIA_BARCODE.authoritative', [ g.barcodes[i] ] );
                     if (typeof copy.ilsevent != 'undefined') throw(copy);
+                    var label_prefix = copy.location().label_prefix() || '';
+                    var label_suffix = copy.location().label_suffix() || '';
                     if (!g.volumes[ copy.call_number() ]) {
                         var volume = g.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ copy.call_number() ] );
                         if (typeof volume.ilsevent != 'undefined') throw(volume);
                         var record = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative', [ volume.record() ]);
                         volume.record( record );
+
+                        /* Jam the prefixes and suffixes into the volume object */
+                        volume.prefix = label_prefix;
+                        volume.suffix = label_suffix;
+
                         g.volumes[ volume.id() ] = volume;
                     }
                     if (g.volumes[ copy.call_number() ].copies()) {
             }
 
             /* for LC, split between Cutter numbers */
-            var lc_cutter_re = /^(.*?)(\.[A-Z]{1}[0-9]+.*?)$/ig;
+            var lc_cutter_re = /^(.*)(\.[A-Z]{1}[0-9]+.*?)$/ig;
             var lc_cutter_match = lc_cutter_re.exec(callnum);
             if (lc_cutter_match && lc_cutter_match.length > 1) {
                 callnum = '';
                 }
             }
 
+            /* Only add the prefixes and suffixes once */
+            if (!override || volume.id() != override.acn) {
+                if (volume.prefix) {
+                    callnum = volume.prefix + ' ' + callnum;
+                }
+                if (volume.suffix) {
+                    callnum += ' ' + volume.suffix;
+                }
+            }
+
             names = callnum.split(/\s+/);
             var j = 0;
             while (j < label_cfg.spine_length || j < label_cfg.pocket_length) {