[open-ils-commits] r12997 - in trunk/Open-ILS/web: js/ui/default/acq/common templates/default/acq/common (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Apr 27 12:41:48 EDT 2009


Author: erickson
Date: 2009-04-27 12:41:46 -0400 (Mon, 27 Apr 2009)
New Revision: 12997

Modified:
   trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
   trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2
Log:
started a per-lineitem, batch-barcode updater ui.  just need to plug in the save

Modified: trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js	2009-04-27 14:23:44 UTC (rev 12996)
+++ trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js	2009-04-27 16:41:46 UTC (rev 12997)
@@ -20,6 +20,10 @@
 var localeStrings = dojo.i18n.getLocalization('openils.acq', 'acq');
 const XUL_OPAC_WRAPPER = 'chrome://open_ils_staff_client/content/cat/opac.xul';
 
+function nodeByName(name, context) {
+    return dojo.query('[name='+name+']', context)[0];
+}
+
 function AcqLiTable() {
 
     var self = this;
@@ -35,6 +39,9 @@
     this.copyBatchWidgets = {};
     this.liNotesTbody = dojo.byId('acq-lit-notes-tbody');
     this.liNotesRow = this.liNotesTbody.removeChild(dojo.byId('acq-lit-notes-row'));
+    this.realCopiesTbody = dojo.byId('acq-lit-real-copies-tbody');
+    this.realCopiesRow = this.realCopiesTbody.removeChild(dojo.byId('acq-lit-real-copies-row'));
+    this.volCache = {};
 
     dojo.connect(acqLitLiActionsSelector, 'onChange', 
         function() { 
@@ -52,12 +59,14 @@
         self._savePl(acqLitSavePlDialog.getValues());
     }
 
+
     //dojo.byId('acq-lit-notes-new-button').onclick = function(){acqLitCreateLiNoteDialog.show();}
 
     dojo.byId('acq-lit-select-toggle').onclick = function(){self.toggleSelect()};
     dojo.byId('acq-lit-info-back-button').onclick = function(){self.show('list')};
     dojo.byId('acq-lit-copies-back-button').onclick = function(){self.show('list')};
     dojo.byId('acq-lit-notes-back-button').onclick = function(){self.show('list')};
+    dojo.byId('acq-lit-real-copies-back-button').onclick = function(){self.show('list')};
 
     this.reset = function() {
         while(self.tbody.childNodes[0])
@@ -90,6 +99,7 @@
         openils.Util.hide('acq-lit-info-div');
         openils.Util.hide('acq-lit-li-details');
         openils.Util.hide('acq-lit-notes-div');
+        openils.Util.hide('acq-lit-real-copies-div');
         switch(div) {
             case 'list':
                 openils.Util.show('acq-lit-table-div');
@@ -100,6 +110,9 @@
             case 'copies':
                 openils.Util.show('acq-lit-li-details');
                 break;
+            case 'real-copies':
+                openils.Util.show('acq-lit-real-copies-div');
+                break;
             case 'notes':
                 openils.Util.show('acq-lit-notes-div');
                 break;
@@ -170,8 +183,16 @@
         priceInput.onchange = function() { self.updateLiPrice(priceInput, li) };
 
         var recv_link = dojo.query('[name=receive_link]', row)[0];
+
         if(li.state() == 'received') {
+            // if the LI is received, hide the receive link and show the 'update barcodes' link
             openils.Util.hide(recv_link)
+            var real_copies_link = dojo.query('[name=real_copies_link]', row)[0];
+            openils.Util.show(real_copies_link);
+            real_copies_link.onclick = function() {
+                self.showRealCopies(li);
+            }
+
         } else {
             recv_link.onclick = function() {
                 self.receiveLi(li);
@@ -939,6 +960,86 @@
             }
         );
     }
+
+    // grab the li-details for this lineitem, grab the linked copies and volumes, add them to the table
+    this.showRealCopies = function(li) {
+        this.show('real-copies');
+        var pcrud = new openils.PermaCrud({authtoken : this.authtoken});
+
+        var tabIndex = 1000;
+        var self = this;
+        this._fetchLineitem(li.id(), 
+            function(fullLi) {
+                li = self.liCache[li.id()] = fullLi;
+
+                pcrud.search(
+                    'acp', {
+                        id : li.lineitem_details().map(
+                            function(item) { return item.eg_copy_id() }
+                        )
+                    }, {
+                        async : true,
+                        streaming : true,
+                        onresponse : function(r) {
+                            var copy = openils.Util.readResponse(r);
+                            var volId = copy.call_number();
+                            var volume = self.volCache[volId];
+                            if(!volume) {
+                                volume = self.volCache[volId] = pcrud.retrieve('acn', volId);
+                            }
+                            self.addRealCopy(volume, copy, tabIndex++);
+                        }
+                    }
+                );
+            }
+        );
+    }
+
+    this.addRealCopy = function(volume, copy, tabIndex) {
+        var row = this.realCopiesRow.cloneNode(true);
+
+        var selectNode;
+        dojo.forEach(
+            ['owning_lib', 'location', 'circ_modifier', 'label', 'barcode'],
+            function(field) {
+                var isvol = (field == 'owning_lib' || field == 'label');
+                var widget = new openils.widget.AutoFieldWidget({
+                    fmField : field,
+                    fmObject : isvol ? volume : copy,
+                    parentNode : nodeByName(field, row),
+                    readOnly : (field != 'barcode')
+                });
+
+                var widgetDrawn = null;
+
+                if(field == 'barcode') {
+                    widgetDrawn = function(w, ww) {
+                        var node = w.domNode;
+                        node.setAttribute('tabindex', ''+tabIndex);
+
+                        // on enter, select the next barcode input
+                        dojo.connect(w, 'onKeyDown',
+                            function(e) {
+                                if(e.keyCode == dojo.keys.ENTER) {
+                                    var ti = node.getAttribute('tabindex');
+                                    var nextNode = dojo.query('[tabindex=' + String(Number(ti) + 1) + ']', self.realCopiesTbody)[0];
+                                    if(nextNode) nextNode.select();
+                                }
+                            }
+                        );
+
+                        if(self.realCopiesTbody.getElementsByTagName('TR').length == 0)
+                            selectNode = node;
+                    }
+                }
+
+                widget.build(widgetDrawn);
+            }
+        );
+
+        this.realCopiesTbody.appendChild(row);
+        if(selectNode) selectNode.select();
+    };
 }
 
 

Modified: trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2	2009-04-27 14:23:44 UTC (rev 12996)
+++ trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2	2009-04-27 16:41:46 UTC (rev 12997)
@@ -79,7 +79,10 @@
                             </tbody>
                         </table>
                     </td>
-                    <td><a name='receive_link' href='javascript:void(0);'>Mark&nbsp;Received</a></td>
+                    <td>
+                        <a name='receive_link' href='javascript:void(0);'>Mark&nbsp;Received</a>
+                        <a class='hidden' name='real_copies_link' href='javascript:void(0);'>Update&nbsp;Barcodes</a>
+                    </td>
                     <td><input type='text' size='8' name='price'/></td>
                     <td><a name='copieslink' href='javascript:void(0);'>Copies(<span name='count'>0</span>)</a></td>
                     <td>
@@ -239,6 +242,49 @@
         </table>
     </div>
 
+
+    <!-- Copies table -->
+    <div id='acq-lit-real-copies-div' class='hidden'>
+        <h2>Copies</h2>
+
+        <div class='acq-lit-li-menu-bar'>
+            <table style='width:100%'>
+                <tr>
+                    <td style='text-align:left;'>
+                        <div dojoType='dijit.form.Button' id='acq-lit-real-copies-back-button'>&#x2196; Return</div>
+                    </td>
+                    <td style='text-align:right;'>
+                        <span>
+                            <div dojoType='dijit.form.Button' jsId='acqLitSaveRealCopies'>Save Changes</div>
+                        </span>
+                    </td>
+                </tr>
+            </table>
+        </div>
+
+        <table id='acq-lit-real-copies-table'>
+            <tbody style='font-weight:bold;'>
+                <tr>
+                    <td style='margin-top:30px;'>Owning Branch</td>
+                    <td>Shelving Location</td>
+                    <td>Circ Modifier</td>
+                    <td>Callnumber</td>
+                    <td>Barcode</td>
+                    <td colspan='0'>
+                </tr>
+            </tbody>
+            <tbody id='acq-lit-real-copies-tbody' class='oils-generic-table'>
+                <tr id='acq-lit-real-copies-row'>
+                    <td><div name='owning_lib'/></td>
+                    <td><div name='location'/></td>
+                    <td><div name='circ_modifier'/></td>
+                    <td><div name='label'/></td>
+                    <td><div name='barcode'/></td>
+                </tr>
+            </tbody>
+        </table>
+    </div>
+
     <div class='hidden' id='acq-lit-progress-numbers'>
         <table class='oils-generic-table'>
             <tbody>



More information about the open-ils-commits mailing list