From: senator Date: Wed, 21 Apr 2010 21:01:55 +0000 (+0000) Subject: Acq: added UI controls to attach a claim policy to one or many lineitems X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=62ef9a76a4999df7c957cc6b023ce998d216ee49;p=evergreen%2Fmasslnc.git Acq: added UI controls to attach a claim policy to one or many lineitems Incidentally, two bugs were fixed: 1) Incorrect permacrud action entries in the IDL that stopped open-ils.pcrud from generating methods for the jub and acqlih classes. 2) A widely used acq subroutine, retrieve_lineitem_impl, incorrectly cleared the purchase_order and picklist fields of its result if fleshing for those fields was not specifically requested. The correct behavior is to set those fields back to their integer foreign key values. This was causing several subtle problems. git-svn-id: svn://svn.open-ils.org/ILS/trunk@16284 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 8066397b2d..9afdd90bbe 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -5464,10 +5464,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - - - - + + + + + + @@ -5508,10 +5510,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - - - - + + + + + + diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm index 28bf41e85c..fe5e8b95df 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm @@ -141,8 +141,14 @@ sub retrieve_lineitem_impl { $li->picklist->org_unit, $li->picklist) ); - $li->clear_purchase_order unless $$options{flesh_po}; - $li->clear_picklist unless $$options{flesh_pl}; + unless ($$options{flesh_po}) { + $li->purchase_order( + $li->purchase_order ? $li->purchase_order->id : undef + ); + } + unless ($$options{flesh_pl}) { + $li->picklist($li->picklist ? $li->picklist->id : undef); + } return $li; } @@ -200,7 +206,7 @@ __PACKAGE__->register_method( method => 'update_lineitem', api_name => 'open-ils.acq.lineitem.update', signature => { - desc => 'Update a lineitem', + desc => 'Update one or many lineitems', params => [ {desc => 'Authentication token', type => 'string'}, {desc => 'lineitem object update', type => 'object'} @@ -213,8 +219,13 @@ sub update_lineitem { my($self, $conn, $auth, $li) = @_; my $e = new_editor(xact=>1, authtoken=>$auth); return $e->die_event unless $e->checkauth; - my $evt = update_lineitem_impl($e, $li); - return $evt if $evt; + + $li = [$li] unless ref $li eq "ARRAY"; + foreach (@$li) { + my $evt = update_lineitem_impl($e, $_); + return $evt if $evt; + } + $e->commit; return 1; } @@ -230,8 +241,7 @@ sub update_lineitem_impl { ]) or return $e->die_event; # the marc may have been cleared on retrieval... - $li->marc($e->retrieve_acq_lineitem($li->id)->marc) - unless $li->marc; + $li->marc($orig_li->marc) unless $li->marc; $li->editor($e->requestor->id); $li->edit_time('now'); diff --git a/Open-ILS/web/js/dojo/openils/acq/nls/acq.js b/Open-ILS/web/js/dojo/openils/acq/nls/acq.js index d8bebc6e68..6918435087 100644 --- a/Open-ILS/web/js/dojo/openils/acq/nls/acq.js +++ b/Open-ILS/web/js/dojo/openils/acq/nls/acq.js @@ -71,5 +71,7 @@ 'NO_FIND_INVOICE': "Could not find that invoice.\nNote that the Invoice # field is case-sensitive.", 'NO_LI_TO_CLAIM': "You have not selected any lineitems to claim.", 'CLAIM_VOUCHERS': "Claim Vouchers", - 'PRINT': "Print" + 'PRINT': "Print", + 'ATTACH_CLAIM_POLICY': "Attach claim policy", + 'CHANGE_CLAIM_POLICY': "Change claim policy" } 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 7a9288ea5b..57160bb209 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 @@ -188,6 +188,42 @@ function AcqLiTable() { td.appendChild(document.createTextNode(val)); }; + this.setClaimPolicyControl = function(li, row) { + if (!self.claimPolicyPicker) { + self.claimPolicyPicker = true; /* prevents a race condition */ + new openils.widget.AutoFieldWidget({ + "parentNode": "acq-lit-li-claim-policy", + "fmClass": "acqclp", + "selfReference": true, + "dijitArgs": {"required": true} + }).build(function(w) { self.claimPolicyPicker = w; }); + } + + if (typeof(row) == "undefined") + row = dojo.query('tr[li="' + li.id() + '"]', "acq-lit-tbody")[0]; + + var actViewPolicy = nodeByName("action_view_claim_policy", row); + if (li.claim_policy()) + actViewPolicy.innerHTML = localeStrings.CHANGE_CLAIM_POLICY; + + if (!actViewPolicy.onclick) { + actViewPolicy.onclick = function() { + if (li.claim_policy()) + self.claimPolicyPicker.attr("value", li.claim_policy()); + liClaimPolicyDialog.show(); + liClaimPolicySave.onClick = function() { + self.changeClaimPolicy( + [li], self.claimPolicyPicker.attr("value"), + function() { + self.setClaimPolicyControl(li, row); + liClaimPolicyDialog.hide(); + } + ); + } + }; + } + }; + /** * Inserts a single lineitem into the growing table of lineitems * @param {Object} li The lineitem object to insert @@ -220,14 +256,7 @@ function AcqLiTable() { this.updateLiNotesCount(li, row); - if (li.claim_policy()) { - var actViewInvoice = nodeByName("action_view_claim_policy", row); - actViewInvoice.disabled = false; - actViewInvoice.onclick = function() { - location.href = oilsBasePath + "/conify/global/acq/claim_policy/" + - li.claim_policy(); - }; - } + this.setClaimPolicyControl(li, row); // show which PO this lineitem is a member of if(li.purchase_order() && !this.isPO) { @@ -1745,9 +1774,43 @@ function AcqLiTable() { case "cancel_lineitems": this.maybeCancelLineitems(); break; + + case "change_claim_policy": + var li_list = this.getSelected(); + this.claimPolicyPicker.attr("value", null); + liClaimPolicyDialog.show(); + liClaimPolicySave.onClick = function() { + self.changeClaimPolicy( + li_list, + self.claimPolicyPicker.attr("value"), + function() { + li_list.forEach( + function(li) { self.setClaimPolicyControl(li); } + ); + liClaimPolicyDialog.hide(); + } + ) + }; + break; } } + this.changeClaimPolicy = function(li_list, value, callback) { + li_list.forEach( + function(li) { li.claim_policy(value); } + ); + fieldmapper.standardRequest( + ["open-ils.acq", "open-ils.acq.lineitem.update"], { + "params": [openils.User.authtoken, li_list], + "async": true, + "oncomplete": function(r) { + r = openils.Util.readResponse(r); + if (callback) callback(r); + } + } + ); + }; + this.createAssets = function() { if(!this.isPO) return; if(!confirm(localeStrings.CREATE_PO_ASSETS_CONFIRM)) return; diff --git a/Open-ILS/web/templates/default/acq/common/li_table.tt2 b/Open-ILS/web/templates/default/acq/common/li_table.tt2 index a1e969472e..de3d0c8c1d 100644 --- a/Open-ILS/web/templates/default/acq/common/li_table.tt2 +++ b/Open-ILS/web/templates/default/acq/common/li_table.tt2 @@ -24,6 +24,7 @@ + @@ -77,7 +78,6 @@ () - @@ -112,7 +112,7 @@ - + @@ -379,6 +379,12 @@ Cancel Copy +
+ +   + Save +