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=a6819ff8bbe942c6e39737e7ed1887831a20d44b;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 2b4752f45c..9572552c60 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm @@ -3490,9 +3490,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 5e8efd0d31..06e5b4aac1 100644 --- a/Open-ILS/src/templates/acq/common/li_table.tt2 +++ b/Open-ILS/src/templates/acq/common/li_table.tt2 @@ -327,6 +327,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 c905f5e40e..d9113cb4a0 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 @@ -2135,6 +2135,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);