From 480d97a728f4e85b7506ddc22ade0256950f604e Mon Sep 17 00:00:00 2001 From: senator Date: Mon, 15 Mar 2010 15:45:02 +0000 Subject: [PATCH] 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. git-svn-id: svn://svn.open-ils.org/ILS/trunk@15846 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../perlmods/OpenILS/Application/Acq/Lineitem.pm | 25 ++++++++++++------ .../perlmods/OpenILS/Application/Acq/Picklist.pm | 4 ++- Open-ILS/web/js/ui/default/acq/common/li_table.js | 30 ++++++++++++---------- Open-ILS/web/js/ui/default/acq/lineitem/related.js | 7 +++-- 4 files changed, 42 insertions(+), 24 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm index f3975707b5..92c00f22ce 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm @@ -309,23 +309,16 @@ __PACKAGE__->register_method ( ); 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 @@ sub lineitems_related_by_bib { "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}; } diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm index 7de39369e5..7c4eb9b15d 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm @@ -288,6 +288,7 @@ __PACKAGE__->register_method( "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 @@ sub retrieve_pl_lineitem { 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]); diff --git a/Open-ILS/web/js/ui/default/acq/common/li_table.js b/Open-ILS/web/js/ui/default/acq/common/li_table.js index 0b3275f432..63849f5297 100644 --- a/Open-ILS/web/js/ui/default/acq/common/li_table.js +++ b/Open-ILS/web/js/ui/default/acq/common/li_table.js @@ -296,19 +296,23 @@ function AcqLiTable() { 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": "" + li.cancel_reason().label() + - "
" + 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": "" + li.cancel_reason().label() + + "
" + 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 } diff --git a/Open-ILS/web/js/ui/default/acq/lineitem/related.js b/Open-ILS/web/js/ui/default/acq/lineitem/related.js index d46cd00dba..c6538feeb4 100644 --- a/Open-ILS/web/js/ui/default/acq/lineitem/related.js +++ b/Open-ILS/web/js/ui/default/acq/lineitem/related.js @@ -42,7 +42,8 @@ function fetchLi() { "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 @@ function fetchRelated() { ["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); -- 2.11.0