fleshing prefix/suffix/class for call numbers, for Item Status and Holdings Maintenan...
authorJason Etheridge <jason@esilibrary.com>
Thu, 10 Mar 2011 10:07:28 +0000 (05:07 -0500)
committerJason Etheridge <jason@esilibrary.com>
Thu, 10 Mar 2011 10:07:28 +0000 (05:07 -0500)
Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm
Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm
Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm
Open-ILS/xul/staff_client/chrome/content/main/constants.js
Open-ILS/xul/staff_client/chrome/content/util/list.js
Open-ILS/xul/staff_client/server/cat/copy_browser.js
Open-ILS/xul/staff_client/server/circ/util.js
Open-ILS/xul/staff_client/server/locale/en-US/circ.properties
Open-ILS/xul/staff_client/server/patron/util.js

index ec5c56f..8b29701 100644 (file)
@@ -713,7 +713,7 @@ sub fetch_copy_location_by_name {
 }
 
 sub fetch_callnumber {
-       my( $self, $id ) = @_;
+       my( $self, $id, $flesh ) = @_;
        my $evt = undef;
 
        my $e = OpenILS::Event->new( 'ASSET_CALL_NUMBER_NOT_FOUND', id => $id );
@@ -726,6 +726,27 @@ sub fetch_callnumber {
                'open-ils.cstore.direct.asset.call_number.retrieve', $id );
        $evt = $e  unless $cn;
 
+    if ($flesh && $cn) {
+        $cn->prefix(
+            $self->simplereq(
+                'open-ils.cstore',
+                'open-ils.cstore.direct.asset.call_number_prefix.retrieve', $cn->prefix
+            )
+        );
+        $cn->suffix(
+            $self->simplereq(
+                'open-ils.cstore',
+                'open-ils.cstore.direct.asset.call_number_suffix.retrieve', $cn->suffix
+            )
+        );
+        $cn->label_class(
+            $self->simplereq(
+                'open-ils.cstore',
+                'open-ils.cstore.direct.asset.call_number_class.retrieve', $cn->label_class
+            )
+        );
+    }
+
        return ( $cn, $evt );
 }
 
index 7cd1b5e..c5e5b83 100644 (file)
@@ -660,9 +660,14 @@ sub _build_volume_list {
     $search_hash->{deleted} = 'f';
     my $e = new_editor();
 
-    my $vols = $e->search_asset_call_number([$search_hash, { 'order_by' => {
-        'acn' => 'oils_text_as_bytea(label_sortkey), oils_text_as_bytea(label), id, owning_lib'
-    } } ] );
+    my $vols = $e->search_asset_call_number([
+        $search_hash,
+        {
+            flesh => 1,
+            flesh_fields => { acn => ['prefix','suffix','label_class'] },
+            'order_by' => { 'acn' => 'oils_text_as_bytea(label_sortkey), oils_text_as_bytea(label), id, owning_lib' }
+        }
+    ]);
 
     my @volumes;
 
index 67b2dc1..7040592 100644 (file)
@@ -974,7 +974,7 @@ sub copy_details {
                                flesh => 2,
                                flesh_fields => {
                                        acp => ['call_number'],
-                                       acn => ['record']
+                                       acn => ['record','prefix','suffix','label_class']
                                }
                        }
                ]) or return $e->event;
index 6243219..f277385 100644 (file)
@@ -2227,6 +2227,21 @@ sub fetch_cn {
 }
 
 __PACKAGE__->register_method(
+    method        => "fetch_fleshed_cn",
+    api_name      => "open-ils.search.callnumber.fleshed.retrieve",
+    authoritative => 1,
+    notes         => "retrieves a callnumber based on ID, fleshing prefix, suffix, and label_class",
+);
+
+sub fetch_fleshed_cn {
+       my( $self, $client, $id ) = @_;
+       my( $cn, $evt ) = $apputils->fetch_callnumber( $id, 1 );
+       return $evt if $evt;
+       return $cn;
+}
+
+
+__PACKAGE__->register_method(
     method    => "fetch_copy_by_cn",
     api_name  => 'open-ils.search.copies_by_call_number.retrieve',
     signature => q/
index c28b5f2..cb0235b 100644 (file)
@@ -81,8 +81,8 @@ var api = {
     'CHECKOUT_RENEW' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.renew' },
     'CIRC_MODIFIER_LIST' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.circ_modifier.retrieve.all' },
     'CLEAR_HOLD_SHELF' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.clear_shelf.process', 'secure' : false },
-    'FM_ACN_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.callnumber.retrieve', 'secure' : false },
-    'FM_ACN_RETRIEVE.authoritative' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.callnumber.retrieve.authoritative', 'secure' : false },
+    'FM_ACN_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.callnumber.fleshed.retrieve', 'secure' : false },
+    'FM_ACN_RETRIEVE.authoritative' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.callnumber.fleshed.retrieve.authoritative', 'secure' : false },
     'FM_ACN_TREE_UPDATE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.asset.volume.fleshed.batch.update' },
     'FM_ACN_TREE_LIST_RETRIEVE_VIA_RECORD_ID_AND_ORG_IDS' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.asset.copy_tree.retrieve', 'secure' : false },
     'FM_ACN_TREE_LIST_RETRIEVE_VIA_RECORD_ID_AND_ORG_IDS.authoritative' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.asset.copy_tree.retrieve.authoritative', 'secure' : false },
index dc1570a..fb46564 100644 (file)
@@ -30,6 +30,7 @@ util.list.prototype = {
     'init' : function (params) {
 
         var obj = this;
+        obj.scratch_data = {};
 
         JSAN.use('util.widgets');
 
@@ -1016,11 +1017,11 @@ util.list.prototype = {
     
                 if (typeof params.map_row_to_column == 'function')  {
     
-                    label = params.map_row_to_column(params.row,this.columns[i]);
+                    label = params.map_row_to_column(params.row,this.columns[i],this.scratch_data);
     
                 } else if (typeof this.map_row_to_column == 'function') {
     
-                    label = this.map_row_to_column(params.row,this.columns[i]);
+                    label = this.map_row_to_column(params.row,this.columns[i],this.scratch_data);
     
                 }
                 if (this.columns[i].type == 'checkbox') { treecell.setAttribute('value',label); } else { treecell.setAttribute('label',label ? label : ''); }
@@ -1032,11 +1033,11 @@ util.list.prototype = {
 
             if (typeof params.map_row_to_columns == 'function') {
 
-                labels = params.map_row_to_columns(params.row,this.columns);
+                labels = params.map_row_to_columns(params.row,this.columns,this.scratch_data);
 
             } else if (typeof this.map_row_to_columns == 'function') {
 
-                labels = this.map_row_to_columns(params.row,this.columns);
+                labels = this.map_row_to_columns(params.row,this.columns,this.scratch_data);
 
             }
             for (var i = 0; i < labels.length; i++) {
@@ -1070,13 +1071,13 @@ util.list.prototype = {
             var value = '';
             if (typeof params.map_row_to_column == 'function')  {
 
-                value = params.map_row_to_column(params.row,this.columns[i]);
+                value = params.map_row_to_column(params.row,this.columns[i],this.scratch_data);
 
             } else {
 
                 if (typeof this.map_row_to_column == 'function') {
 
-                    value = this.map_row_to_column(params.row,this.columns[i]);
+                    value = this.map_row_to_column(params.row,this.columns[i],this.scratch_data);
                 }
             }
             if (typeof value == 'string' || typeof value == 'number') {
@@ -1817,9 +1818,11 @@ util.list.prototype = {
     },
     // Default for the map_row_to_columns function for .init
     'std_map_row_to_columns' : function(error_value) {
-        return function(row,cols) {
+        return function(row,cols,scratch) {
             // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
             // cols contains all of the objects listed above in columns
+            // scratch is a temporary space shared by all cells/rows (or just per row if not explicitly passed in)
+            if (!scratch) { scratch = {}; }
 
             var obj = {};
             JSAN.use('util.error'); obj.error = new util.error();
@@ -1833,7 +1836,7 @@ util.list.prototype = {
             try {
                 for (var i = 0; i < cols.length; i++) {
                     switch (typeof cols[i].render) {
-                        case 'function': try { values[i] = cols[i].render(my); } catch(E) { values[i] = error_value; obj.error.sdump('D_COLUMN_RENDER_ERROR',E); } break;
+                        case 'function': try { values[i] = cols[i].render(my,scratch); } catch(E) { values[i] = error_value; obj.error.sdump('D_COLUMN_RENDER_ERROR',E); } break;
                         case 'string' : cmd += 'try { ' + cols[i].render + '; values['+i+'] = v; } catch(E) { values['+i+'] = error_value; }'; break;
                         default: cmd += 'values['+i+'] = "??? '+(typeof cols[i].render)+'"; ';
                     }
index a66c9c4..dce4862 100644 (file)
@@ -1525,7 +1525,10 @@ cat.copy_browser.prototype = {
                             'due_date',
                             'owning_lib',
                             'circ_lib',
+                            'label_class',
+                            'prefix',
                             'call_number',
+                            'suffix',
                             'copy_number',
                             'location',
                             'barcode',
index e8a7086..42ae218 100644 (file)
@@ -571,22 +571,45 @@ circ.util.columns = function(modify,params) {
             'flex' : 1,
             'primary' : false,
             'hidden' : true,
-            'editable' : false, 'render' : function(my) {
-                if (my.acp && my.acp.call_number() == -1) {
+            'editable' : false, 'render' : function(my,scratch_data) {
+                var acn_id;
+                if (my.acn) {
+                    if (typeof my.acn == 'object') {
+                        acn_id = my.acn.id();
+                    } else {
+                        acn_id = my.acn;
+                    }
+                } else if (my.acp) {
+                    if (typeof my.acp.call_number() == 'object') {
+                        acn_id = my.acp.call_number().id();
+                    } else {
+                        acn_id = my.acp.call_number();
+                    }
+                }
+                if (!acn_id && acn_id != 0) {
+                    return '';
+                } else if (acn_id == -1) {
                     return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged');
-                } else if (my.acp && my.acp.call_number() == -2) {
+                } else if (acn_id == -2) {
                     return document.getElementById('circStrings').getString('staff.circ.utils.retrieving');
                 } else {
                     if (!my.acn) {
-                        var x = network.simple_request("FM_ACN_RETRIEVE.authoritative",[ my.acp.call_number() ]);
-                        if (x.ilsevent) {
-                            return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged');
+                        if (typeof scratch_data['acn_map'] == 'undefined') {
+                            scratch_data['acn_map'] = {};
+                        }
+                        if (typeof scratch_data['acn_map'][ acn_id ] == 'undefined') {
+                            var x = network.simple_request("FM_ACN_RETRIEVE.authoritative",[ acn_id ]);
+                            if (x.ilsevent) {
+                                return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged');
+                            } else {
+                                my.acn = x;
+                                scratch_data['acn_map'][ acn_id ] = my.acn;
+                            }
                         } else {
-                            my.acn = x; return x.label();
+                            my.acn = scratch_data['acn_map'][ acn_id ];
                         }
-                    } else {
-                        return my.acn.label();
                     }
+                    return my.acn.label();
                 }
             },
             'persist' : 'hidden width ordinal'
@@ -608,6 +631,46 @@ circ.util.columns = function(modify,params) {
             'persist' : 'hidden width ordinal'
         },
         {
+            'id' : 'prefix',
+            'fm_class' : 'acn',
+            'label' : document.getElementById('circStrings').getString('staff.circ.utils.prefix'),
+            'flex' : 1,
+            'primary' : false,
+            'hidden' : true,
+            'editable' : false, 'render' : function(my) {
+                if (typeof my.acn == 'undefined') return '';
+                return (typeof my.acn.prefix() == 'object') ? my.acn.prefix().label() : my.acn.prefix();
+            },
+            'persist' : 'hidden width ordinal'
+        },
+        {
+            'id' : 'suffix',
+            'fm_class' : 'acn',
+            'label' : document.getElementById('circStrings').getString('staff.circ.utils.suffix'),
+            'flex' : 1,
+            'primary' : false,
+            'hidden' : true,
+            'editable' : false, 'render' : function(my) {
+                if (typeof my.acn == 'undefined') return '';
+                return (typeof my.acn.suffix() == 'object') ? my.acn.suffix().label() : my.acn.suffix();
+            },
+            'persist' : 'hidden width ordinal'
+        },
+        {
+            'id' : 'label_class',
+            'fm_class' : 'acn',
+            'label' : document.getElementById('circStrings').getString('staff.circ.utils.label_class'),
+            'flex' : 1,
+            'primary' : false,
+            'hidden' : true,
+            'editable' : false, 'render' : function(my) {
+                if (typeof my.acn == 'undefined') return '';
+                return (typeof my.acn.label_class() == 'object') ? my.acn.label_class().name() : my.acn.label_class();
+            },
+            'persist' : 'hidden width ordinal'
+        },
+
+        {
             'id' : 'copy_number',
             'fm_class' : 'acp',
             'label' : document.getElementById('commonStrings').getString('staff.acp_label_copy_number'),
@@ -2233,9 +2296,11 @@ circ.util.std_map_row_to_column = function(error_value) {
 };
 */
 circ.util.std_map_row_to_columns = function(error_value) {
-    return function(row,cols) {
+    return function(row,cols,scratch) {
         // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
         // cols contains all of the objects listed above in columns
+        // scratch is a temporary space shared by all cells/rows (or just per row if not explicitly passed in)
+        if (!scratch) { scratch = {}; }
 
         var obj = {};
         JSAN.use('util.error'); obj.error = new util.error();
@@ -2249,7 +2314,7 @@ circ.util.std_map_row_to_columns = function(error_value) {
         try {
             for (var i = 0; i < cols.length; i++) {
                 switch (typeof cols[i].render) {
-                    case 'function': try { values[i] = cols[i].render(my); } catch(E) { values[i] = error_value; obj.error.sdump('D_COLUMN_RENDER_ERROR',E); } break;
+                    case 'function': try { values[i] = cols[i].render(my,scratch); } catch(E) { values[i] = error_value; obj.error.sdump('D_COLUMN_RENDER_ERROR',E); } break;
                     case 'string' : cmd += 'try { ' + cols[i].render + '; values['+i+'] = v; } catch(E) { values['+i+'] = error_value; }'; break;
                     default: cmd += 'values['+i+'] = "??? '+(typeof cols[i].render)+'"; ';
                 }
index c6f718d..508e404 100644 (file)
@@ -238,6 +238,9 @@ staff.circ.utils.offline.use_time=Use Time
 staff.circ.utils.not_cataloged=Not Cataloged
 staff.circ.utils.retrieving=Retrieving...
 staff.circ.utils.owning_lib=Owning Library
+staff.circ.utils.prefix=Prefix
+staff.circ.utils.suffix=Suffix
+staff.circ.utils.label_class=Classification
 staff.circ.utils.loan_duration.short=Short
 staff.circ.utils.loan_duration.normal=Normal
 staff.circ.utils.loan_duration.long=Long
index 0f235ef..742b6b4 100644 (file)
@@ -540,9 +540,10 @@ patron.util.columns = function(modify,params) {
 }
 
 patron.util.std_map_row_to_columns = function(error_value) {
-    return function(row,cols) {
+    return function(row,cols,scratch) {
         // row contains { 'my' : { 'au' : {} } }
         // cols contains all of the objects listed above in columns
+        // scratch is a temporary space shared by all cells/rows (or just per row if not explicitly passed in)
         
         var obj = {}; obj.OpenILS = {}; 
         JSAN.use('util.error'); obj.error = new util.error();