[open-ils-commits] r15846 - in trunk/Open-ILS: src/perlmods/OpenILS/Application/Acq web/js/ui/default/acq/common web/js/ui/default/acq/lineitem (senator)

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Mar 15 11:45:05 EDT 2010


Author: senator
Date: 2010-03-15 11:45:02 -0400 (Mon, 15 Mar 2010)
New Revision: 15846

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm
   trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
   trunk/Open-ILS/web/js/ui/default/acq/lineitem/related.js
Log:
Acq: for showing related lineitems, do the right thing w/ null bib rec

Also, flesh_cancel_reason employed in more of the cases where we're retrieving
lineitems to build an li_table, and li_table doesn't fail so hard when it
doesn't have a fleshed cancel_reason.


Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm	2010-03-15 09:52:49 UTC (rev 15845)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm	2010-03-15 15:45:02 UTC (rev 15846)
@@ -309,23 +309,16 @@
 );
 
 sub lineitems_related_by_bib {
-    my($self, $conn, $auth, $id_value, $options) = @_;
+    my($self, $conn, $auth, $test_value, $options) = @_;
     my $e = new_editor(authtoken => $auth);
     return $e->event unless $e->checkauth;
 
     my $perm_orgs = $U->user_has_work_perm_at($e, 'VIEW_PURCHASE_ORDER', {descendants =>1}, $e->requestor->id);
 
-    if ($self->api_name =~ /by_lineitem_id/) {
-        my $orig = retrieve_lineitem($self, $conn, $auth, $id_value) or
-            return $e->die_event;
-        $id_value = $orig->eg_bib_id;
-    }
-
     my $query = {
         "select"=>{"jub"=>["id"]},
         "from"=>{"jub"=>"acqpo"}, 
         "where"=>{
-            "eg_bib_id"=>$id_value,
             "+acqpo"=>{
                 "ordering_agency"=>{
                     "in"=>$perm_orgs
@@ -335,6 +328,22 @@
         "order_by"=>[{"class"=>"jub", "field"=>"create_time", "direction"=>"desc"}]
     };
 
+    # Be sure we just return the original LI if no related bibs
+    if ($self->api_name =~ /by_lineitem_id/) {
+        my $orig = retrieve_lineitem($self, $conn, $auth, $test_value) or
+            return $e->die_event;
+        if ($test_value = $orig->eg_bib_id) {
+            $query->{"where"}->{"eg_bib_id"} = $test_value;
+        } else {
+            $query->{"where"}->{"id"} = $orig->id;
+        }
+    } elsif ($test_value) {
+        $query->{"where"}->{"eg_bib_id"} = $test_value;
+    } else {
+        $e->disconnect;
+        return new OpenILS::Event("BAD_PARAMS", "Null bib id");
+    }
+
     if ($options && defined $options->{lineitem_state}) {
         $query->{'where'}{'jub'}{'state'} = $options->{lineitem_state};
     }

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm	2010-03-15 09:52:49 UTC (rev 15845)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm	2010-03-15 15:45:02 UTC (rev 15846)
@@ -288,6 +288,7 @@
                 "flesh_attrs", additionaly return the list of flattened attributes
                 "clear_marc", discards the raw MARC data to reduce data size
                 "flesh_notes", flesh lineitem notes
+                "flesh_cancel_reason", flesh cancel_reason
                 /, 
                 type => 'hash'}
         ],
@@ -349,13 +350,14 @@
 
         my $entry;
         my $flesh = {};
-        if($$options{flesh_attrs} or $$options{flesh_notes}) {
+        if($$options{flesh_attrs} or $$options{flesh_notes} or $$options{flesh_cancel_reason}) {
             $flesh = {flesh => 2, flesh_fields => {jub => []}};
             if($$options{flesh_notes}) {
                 push(@{$flesh->{flesh_fields}->{jub}}, 'lineitem_notes');
                 $flesh->{flesh_fields}->{acqlin} = ['alert_text'];
             }
             push(@{$flesh->{flesh_fields}->{jub}}, 'attributes') if $$options{flesh_attrs};
+            push @{$flesh->{flesh_fields}->{jub}}, 'cancel_reason' if $$options{flesh_cancel_reason};
         }
 
         $entry = $e->retrieve_acq_lineitem([$id, $flesh]);

Modified: trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js	2010-03-15 09:52:49 UTC (rev 15845)
+++ trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js	2010-03-15 15:45:02 UTC (rev 15846)
@@ -296,19 +296,23 @@
         var state_cell = nodeByName("li_state", row);
 
         if (li.state() == "cancelled") {
-            var holds_state = dojo.create(
-                "span", {
-                    "style": "border-bottom: 1px dashed #000;",
-                    "innerHTML": li.state()
-                }, state_cell, "only"
-            );
-            new dijit.Tooltip(
-                {
-                    "label": "<em>" + li.cancel_reason().label() +
-                        "</em><br />" + li.cancel_reason().description(),
-                    "connectId": [holds_state]
-                }, dojo.create("span", null, state_cell, "last")
-            );
+            if (typeof li.cancel_reason() == "object") {
+                var holds_state = dojo.create(
+                    "span", {
+                        "style": "border-bottom: 1px dashed #000;",
+                        "innerHTML": li.state()
+                    }, state_cell, "only"
+                );
+                new dijit.Tooltip(
+                    {
+                        "label": "<em>" + li.cancel_reason().label() +
+                            "</em><br />" + li.cancel_reason().description(),
+                        "connectId": [holds_state]
+                    }, dojo.create("span", null, state_cell, "last")
+                );
+            } else {
+                state_cell.innerHTML = li.state(); // TODO i18n state labels
+            }
         } else {
             state_cell.innerHTML = li.state(); // TODO i18n state labels
         }

Modified: trunk/Open-ILS/web/js/ui/default/acq/lineitem/related.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/lineitem/related.js	2010-03-15 09:52:49 UTC (rev 15845)
+++ trunk/Open-ILS/web/js/ui/default/acq/lineitem/related.js	2010-03-15 15:45:02 UTC (rev 15846)
@@ -42,7 +42,8 @@
             "params": [openils.User.authtoken, liId, {
                 "flesh_attrs": true,
                 "flesh_li_details": true,
-                "flesh_fund_debit": true
+                "flesh_fund_debit": true,
+                "flesh_cancel_reason": true
             }],
             "oncomplete": function(r) {
                 drawLiInfo(openils.Util.readResponse(r));
@@ -66,7 +67,9 @@
         ["open-ils.acq", "open-ils.acq.lineitems_for_bib.by_lineitem_id"], {
             "async": true,
             "params": [openils.User.authtoken, liId, {
-                "flesh_attrs": true, "flesh_notes": true
+                "flesh_attrs": true,
+                "flesh_notes": true,
+                "flesh_cancel_reason": true
             }],
             "onresponse": function(r) {
                 var resp = openils.Util.readResponse(r);



More information about the open-ils-commits mailing list