Broke price information out into estimated and actual price columns. Not entirely...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 23 Jul 2008 19:19:28 +0000 (19:19 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 23 Jul 2008 19:19:28 +0000 (19:19 +0000)
these to be broken out, but it's trivial to pull them back into a single column if not.

I have an editor in place for setting the prices, but I'm trying to understand how one
captures the edited data when you are editing a column that is not part of the grid's
data model.  Bueller?

git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@10101 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/common/jubgrid.js
Open-ILS/web/oilsweb/oilsweb/templates/oils/default/common/jubgrid.html

index 7895839..9ca3389 100644 (file)
@@ -45,8 +45,21 @@ var JUBGrid = {
     getJUBIsbn : function(rowIndex) {
         return JUBGrid._getMARCAttr(rowIndex, 'isbn');
     },
-    getJUBPrice : function(rowIndex) {
-        return JUBGrid._getMARCAttr(rowIndex, 'price');
+    getJUBActualPrice : function(rowIndex) {
+        var data = JUBGrid.jubGrid.model.getRow(rowIndex);
+        if (!data) return '';
+        var price = new openils.acq.Lineitems(
+            {lineitem:JUBGrid.getLi(data.id)}).getActualPrice();
+        if(price) return price.price;
+        return ''
+    },
+    getJUBEstimatedPrice : function(rowIndex) {
+        var data = JUBGrid.jubGrid.model.getRow(rowIndex);
+        if (!data) return '';
+           var price = new openils.acq.Lineitems(
+            {lineitem:JUBGrid.getLi(data.id)}).getEstimatedPrice();
+        if(price) return price.price;
+        return ''
     },
     getJUBPubdate : function(rowIndex) {
         return JUBGrid._getMARCAttr(rowIndex, 'pubdate');
@@ -85,10 +98,16 @@ var JUBGrid = {
         return fieldmapper.aou.findOrgUnit(data.owning_lib).shortname();
     },
 
+    gridDataChanged : function(newVal, rowIdx, cellIdx) {
+        // cellIdx == -1 if you are editing a column that
+        // is not represented in the data model. Khaaaaaaan!!! 
+    },
+
     populate : function(gridWidget, model, lineitems) {
-       for (var i in lineitems) {
-           JUBGrid.lineitems[lineitems[i].id()] = lineitems[i];
-       }
+        for (var i in lineitems) {
+            JUBGrid.lineitems[lineitems[i].id()] = lineitems[i];
+        }
+        dojo.connect (gridWidget, "onApplyCellEdit", JUBGrid.gridDataChanged);
         JUBGrid.jubGrid = gridWidget;
         JUBGrid.jubGrid.setModel(model);
         if(JUBGrid.showDetails) {
index c0b46d6..c8dc4d7 100644 (file)
@@ -58,9 +58,20 @@ pointing to the JUB model (and store) that you have created.
             {name: '${_("Author")}', get:JUBGrid.getJUBAuthor},
             {name: '${_("ISBN")}', get:JUBGrid.getJUBIsbn},
             {name: '${_("Pubdate")}', get:JUBGrid.getJUBPubdate},
-            {name: '${_("Price")}', get:JUBGrid.getJUBPrice},
+            {name: '${_("Actual Price")}', 
+                field:'actual_price',
+                get:JUBGrid.getJUBActualPrice,
+                editor:dojox.grid.editors.Dijit, 
+                editorClass: "dijit.form.CurrencyTextBox" 
+            },
+            {name: '${_("Estimated Price")}', 
+                field:'estimated_price',
+                get:JUBGrid.getJUBEstimatedPrice,
+                editor:dojox.grid.editors.Dijit, 
+                editorClass: "dijit.form.CurrencyTextBox" 
+            },
             {name: '${_("Vendor")}',
-            field: 'provider', width:'auto', get:JUBGrid.getProvider,
+            field: 'provider', get:JUBGrid.getProvider,
             editor:openils.editors.ProviderSelectEditor,
            },
             {name: '${_("No. Copies")}', field: 'item_count'},