From: Lebbeous Fogle-Weekley Date: Tue, 5 Mar 2013 23:11:41 +0000 (-0500) Subject: acq - add to po option work on li_table MAYBE X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=29ebd7ca7daf69764362f6e2b7fecbdf12a55b8d;p=evergreen%2Fequinox.git acq - add to po option work on li_table MAYBE should be almost there, but not yet tested completely Signed-off-by: Lebbeous Fogle-Weekley --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm index c4828c78a7..62909f675d 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm @@ -3547,9 +3547,9 @@ sub add_li_to_po { $lis = $e->search_acq_lineitem({id => $li_id}) or return $e->die_event; } else { - $lis = []; - push @$lis, $e->retrieve_acq_lineitem(int($li_id)) + my $li = $e->retrieve_acq_lineitem(int($li_id)) or return $e->die_event; + $lis = [$li]; } foreach my $li (@$lis) { diff --git a/Open-ILS/src/templates/acq/common/add_to_po.tt2 b/Open-ILS/src/templates/acq/common/add_to_po.tt2 index 354bf879d6..370bd2893d 100644 --- a/Open-ILS/src/templates/acq/common/add_to_po.tt2 +++ b/Open-ILS/src/templates/acq/common/add_to_po.tt2 @@ -4,16 +4,15 @@ var poId = addToPoInput.attr('value'); if (!poId) return false; - /* XXX we rely on a global liTable singleton. Ugh. */ - var liId = liTable.getSelected()[0].id(); + var liId = dia._get_li(); console.log("adding li " + liId + " to PO " + poId); fieldmapper.standardRequest( ['open-ils.acq', 'open-ils.acq.purchase_order.add_lineitem'], - { async : true, - params : [openils.User.authtoken, poId, liId], - oncomplete : function(r) { + { async: true, + params: [openils.User.authtoken, poId, liId], + oncomplete: function(r) { if ((r = openils.Util.readResponse(r))) { if (r.success) { location.href = oilsBasePath + @@ -44,7 +43,10 @@ - +
+ + +
diff --git a/Open-ILS/src/templates/acq/common/li_table.tt2 b/Open-ILS/src/templates/acq/common/li_table.tt2 index e8c4b0952e..03dd567289 100644 --- a/Open-ILS/src/templates/acq/common/li_table.tt2 +++ b/Open-ILS/src/templates/acq/common/li_table.tt2 @@ -382,6 +382,7 @@
[% INCLUDE "acq/common/inv_dialog.tt2" which = "li" %]
+ [% INCLUDE "acq/common/add_to_po.tt2" %] 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 ccbc6ddc82..28caf997fb 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 @@ -2511,6 +2511,14 @@ function AcqLiTable() { this._deleteLiList(self.getSelected()); break; + case 'add_to_order': + addToPoDialog._get_li = dojo.hitch( + this, + function() { return this.getSelected(false, null, true); } + ); + addToPoDialog.show(); + break; + case 'create_order': this._loadPOSelect(); acqLitPoCreateDialog.show(); 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 ba6dbdce8b..9ae3c5f350 100644 --- a/Open-ILS/web/js/ui/default/acq/lineitem/related.js +++ b/Open-ILS/web/js/ui/default/acq/lineitem/related.js @@ -4,6 +4,7 @@ dojo.require("openils.XUL"); dojo.require("openils.CGI"); dojo.require("openils.PermaCrud"); dojo.require('openils.BibTemplate'); +dojo.require('openils.widget.PCrudAutocompleteBox'); dojo.require('fieldmapper.OrgUtils'); dojo.requireLocalization('openils.acq', 'acq'); @@ -148,6 +149,13 @@ function load() { prepareButtons(); fetchRelated(); + + /* addToPoDialog now requires this function be defined to tell it what + * lineitem IDs to add to the PO. Part of making it reusable in more + * places. */ + addToPoDialog._get_li = function() { + return liTable.getSelected()[0].id(); + }; } openils.Util.addOnLoad(load);