acq - add to po option work on li_table MAYBE
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Tue, 5 Mar 2013 23:11:41 +0000 (18:11 -0500)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Thu, 7 Mar 2013 23:06:11 +0000 (18:06 -0500)
should be almost there, but not yet tested completely

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm
Open-ILS/src/templates/acq/common/add_to_po.tt2
Open-ILS/src/templates/acq/common/li_table.tt2
Open-ILS/web/js/ui/default/acq/common/li_table.js
Open-ILS/web/js/ui/default/acq/lineitem/related.js

index 2b4752f..9572552 100644 (file)
@@ -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) {
index 354bf87..370bd28 100644 (file)
@@ -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 +
             <table class='dijitTooltipTable'>
                 <tr>
                     <td><label>[% l('Enter the PO Name: ') %]</label></td>
-                    <td><input jsId='addToPoInput' name='addToPoInput' dojoType="dijit.form.TextBox" /></td>
+                    <td>
+                        <input jsId="addToPoInput" dojoType="openils.widget.PCrudAutocompleteBox" fmclass="acqpo" searchAttr="name" name="target_po" />
+
+                        </td>
                 </tr>
                 <tr>
                     <td colspan='2' align='center'>
index 5e8efd0..06e5b4a 100644 (file)
         <div jsId="acqLitLinkInvoiceDialog" dojoType="dijit.Dialog">
             [% INCLUDE "acq/common/inv_dialog.tt2" which = "li" %]
         </div>
+        [% INCLUDE "acq/common/add_to_po.tt2" %]
     </div>
 
 
index c905f5e..d9113cb 100644 (file)
@@ -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();
index ba6dbdc..9ae3c5f 100644 (file)
@@ -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);