for now, update the price when it's changed. will probably make this more interactiv...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 6 Apr 2009 20:34:59 +0000 (20:34 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 6 Apr 2009 20:34:59 +0000 (20:34 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@12804 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/ui/default/acq/common/li_table.js
Open-ILS/web/templates/default/acq/common/li_table.tt2

index e04faad..e99e0e2 100644 (file)
@@ -139,13 +139,32 @@ function AcqLiTable() {
         dojo.query('[attr=title]', row)[0].onclick = function() {self.drawInfo(li.id())};
         dojo.query('[name=copieslink]', row)[0].onclick = function() {self.drawCopies(li.id())};
         dojo.query('[name=count]', row)[0].appendChild(document.createTextNode(li.item_count()));
-        dojo.query('[name=estimated_price]', row)[0].value =  
-            liWrapper.findAttr('estimated_price', 'lineitem_local_attr_definition');
+
+        var priceInput = dojo.query('[name=estimated_price]', row)[0];
+        priceInput.value = liWrapper.findAttr('estimated_price', 'lineitem_local_attr_definition') || '';
+        priceInput.onchange = function() { self.updateLiPrice(priceInput, li) };
 
         self.tbody.appendChild(row);
         self.selectors.push(dojo.query('[name=selectbox]', row)[0]);
     };
 
+    self.updateLiPrice = function(input, li) {
+        var price = input.value;
+        var liWrapper = new openils.acq.Lineitem({lineitem:li});
+        var oldPrice = liWrapper.findAttr('estimated_price', 'lineitem_local_attr_definition') || null;
+        if(price == oldPrice) return;
+        console.log("setting price " + price + " for " + li.id());
+        fieldmapper.standardRequest(
+            ['open-ils.acq', 'open-ils.acq.lineitem_local_attr.set'],
+            {   async : true,
+                params : [this.authtoken, li.id(), 'estimated_price', price],
+                oncomplete : function(r) {
+                    openils.Util.readResponse(r);
+                }
+            }
+        );
+    }
+
     this.removeLineitem = function(liId) {
         this.tbody.removeChild(dojo.query('[li='+liId+']', this.tbody)[0]);
         delete this.liCache[liId];
index 5bad449..220e61b 100644 (file)
@@ -6,7 +6,7 @@
         <table id='acq-lit-table' class='oils-generic-table'>
             <thead>
                 <tr>
-                    <th style='border:1px solid #aaa;' colspan='0'>
+                    <th colspan='0'>
                         <table style='width:100%;'>
                             <tr>
                                 <td>