[open-ils-commits] r12998 - 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 14:21:21 EDT 2009


Author: erickson
Date: 2009-04-27 14:21:18 -0400 (Mon, 27 Apr 2009)
New Revision: 12998

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:
plug in real copy 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 16:41:46 UTC (rev 12997)
+++ trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js	2009-04-27 18:21:18 UTC (rev 12998)
@@ -41,7 +41,6 @@
     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() { 
@@ -187,12 +186,6 @@
         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);
@@ -200,6 +193,14 @@
             }
         }
 
+        if(li.eg_bib_id()) {
+            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);
+            }
+        }
+
         self.tbody.appendChild(row);
         self.selectors.push(dojo.query('[name=selectbox]', row)[0]);
     };
@@ -963,11 +964,20 @@
 
     // grab the li-details for this lineitem, grab the linked copies and volumes, add them to the table
     this.showRealCopies = function(li) {
+        while(this.realCopiesTbody.childNodes[0])
+            this.realCopiesTbody.removeChild(this.realCopiesTbody.childNodes[0]);
         this.show('real-copies');
+
         var pcrud = new openils.PermaCrud({authtoken : this.authtoken});
-
+        this.realCopyList = [];
+        this.volCache = {};
         var tabIndex = 1000;
         var self = this;
+
+        acqLitSaveRealCopies.onClick = function() {
+            self.saveRealCopies();
+        }
+
         this._fetchLineitem(li.id(), 
             function(fullLi) {
                 li = self.liCache[li.id()] = fullLi;
@@ -997,22 +1007,25 @@
 
     this.addRealCopy = function(volume, copy, tabIndex) {
         var row = this.realCopiesRow.cloneNode(true);
+        this.realCopyList.push(copy);
 
         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')
+                    readOnly : (field != 'barcode'),
                 });
 
                 var widgetDrawn = null;
 
                 if(field == 'barcode') {
+
                     widgetDrawn = function(w, ww) {
                         var node = w.domNode;
                         node.setAttribute('tabindex', ''+tabIndex);
@@ -1028,6 +1041,15 @@
                             }
                         );
 
+                        dojo.connect(w, 'onChange', 
+                            function(val) { 
+                                if(!val || val == copy.barcode()) return;
+                                copy.ischanged(true);
+                                copy.barcode(val);
+                            }
+                        );
+
+
                         if(self.realCopiesTbody.getElementsByTagName('TR').length == 0)
                             selectNode = node;
                     }
@@ -1040,6 +1062,16 @@
         this.realCopiesTbody.appendChild(row);
         if(selectNode) selectNode.select();
     };
+
+    this.saveRealCopies = function() {
+        var pcrud = new openils.PermaCrud({authtoken : this.authtoken});
+        progressDialog.show(true);
+        var list = this.realCopyList.filter(function(copy) { return copy.ischanged(); });
+        pcrud.update(list, {oncomplete: function() { 
+            progressDialog.hide();
+            self.show('list');
+        }});
+    }
 }
 
 

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 16:41:46 UTC (rev 12997)
+++ trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2	2009-04-27 18:21:18 UTC (rev 12998)
@@ -48,9 +48,10 @@
                     <td><span><a id='acq-lit-select-toggle' href='javascript:void(0);'>&#x2713</a></span></td>
                     <td>Line Items</td>
                     <td></td>
-                    <td>Price</td>
+                    <td></td>
                     <td>Items</td>
                     <td>Notes</td>
+                    <td>Price</td>
                 </tr>
             </tbody>
             <tbody id='acq-lit-tbody'>
@@ -79,16 +80,14 @@
                             </tbody>
                         </table>
                     </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 class='hidden' name='real_copies_link' href='javascript:void(0);'>Update&nbsp;Barcodes</a></td>
+                    <td><a name='receive_link' href='javascript:void(0);'>Mark&nbsp;Received</a></td>
                     <td><a name='copieslink' href='javascript:void(0);'>Copies(<span name='count'>0</span>)</a></td>
                     <td>
                         <a name='noteslink' href='javascript:void(0);' 
                             style='margin-right:15px;'>Notes(<span name='notes_count'>0</span>)</a>
                     </td>
+                    <td><input type='text' size='8' name='price'/></td>
                 </tr>
             </tbody>
         </table>



More information about the open-ils-commits mailing list