[open-ils-commits] r11759 - in trunk/Open-ILS/web: js/ui/default/conify/global/config templates/default/conify/global/config

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Jan 7 15:59:33 EST 2009


Author: erickson
Date: 2009-01-07 15:59:29 -0500 (Wed, 07 Jan 2009)
New Revision: 11759

Modified:
   trunk/Open-ILS/web/js/ui/default/conify/global/config/billing_type.js
   trunk/Open-ILS/web/templates/default/conify/global/config/billing_type.tt2
Log:
added an edit dialog

Modified: trunk/Open-ILS/web/js/ui/default/conify/global/config/billing_type.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/conify/global/config/billing_type.js	2009-01-07 20:16:13 UTC (rev 11758)
+++ trunk/Open-ILS/web/js/ui/default/conify/global/config/billing_type.js	2009-01-07 20:59:29 UTC (rev 11759)
@@ -2,6 +2,7 @@
 dojo.require('dojox.grid.cells.dijit');
 dojo.require('dojo.data.ItemFileWriteStore');
 dojo.require('dijit.form.CurrencyTextBox');
+dojo.require('dijit.Dialog');
 dojo.require('dojox.widget.PlaceholderMenuItem');
 dojo.require('fieldmapper.OrgUtils');
 dojo.require('openils.widget.OrgUnitFilteringSelect');
@@ -55,7 +56,7 @@
 }
 
 function btCreate(args) {
-    if(!args.name || args.owner == null) 
+    if(!args.name || args.owner == null)
         return;
     if(args.default_price == '' || isNaN(args.default_price))
         args.default_price = null;
@@ -77,6 +78,68 @@
     );
 }
 
+function btDrawEditDialog() {
+    btEditDialog.show();
+    var item =  btGrid.selection.getSelected()[0];
+    if(!item) {
+        btEditDialog.hide();
+        return;
+    }
+    var id = btGrid.store.getValue(item, 'id');
+    var name = btGrid.store.getValue(item, 'name');
+    var owner = btGrid.store.getValue(item, 'owner');
+    var price = btGrid.store.getValue(item, 'default_price');
+
+    dojo.byId('btId').innerHTML = id;
+    btName.setValue(name);
+    btOwnerLocation.setValue(owner);
+    btDefaultPrice.setValue(price);
+    new openils.User().buildPermOrgSelector('ADMIN_BILLING_TYPE', btOwnerLocation, owner);
+
+    if (id >= 100){
+        btOwnerLocation.setDisabled(false);
+        btDefaultPrice.setDisabled(false);
+
+    } else {
+        btOwnerLocation.setDisabled(true);
+        btDefaultPrice.setDisabled(true);
+    }
+    
+    // add an onclick for the save button that knows which object we are editing
+    editSave.domNode.onclick = function() {
+        var map = openils.Util.mapList(btList, 'id', true);
+        var bt = map[id]; // id comes from the getValue() call above
+        saveChanges(bt, item);
+    }
+}
+
+
+function saveChanges(bt, item){
+    bt.name(btName.getValue());
+    bt.owner(btOwnerLocation.getValue());
+    bt.default_price(btDefaultPrice.getValue());
+
+    fieldmapper.standardRequest(
+        ['open-ils.permacrud', 'open-ils.permacrud.update.cbt'],
+        {   async: true,
+            params: [openils.User.authtoken, bt],
+            oncomplete: function(r) {
+
+                if(openils.Util.readResponse(r)) {
+                    // update succeeded.  put the new values into the grid
+                    btGrid.store.setValue(item, 'name', bt.name());
+                    btGrid.store.setValue(item, 'default_price', (bt.default_price()));
+                    btGrid.store.setValue(item, 'owner', bt.owner());
+                    btEditDialog.hide();
+
+                } else {
+                    // update failed.  indicate this to the user somehow
+                    alert('Update Failed. Reason: ');
+                }
+            }
+        }
+    );
+}
 openils.Util.addOnLoad(btInit);
 
 

Modified: trunk/Open-ILS/web/templates/default/conify/global/config/billing_type.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/conify/global/config/billing_type.tt2	2009-01-07 20:16:13 UTC (rev 11758)
+++ trunk/Open-ILS/web/templates/default/conify/global/config/billing_type.tt2	2009-01-07 20:59:29 UTC (rev 11759)
@@ -33,7 +33,7 @@
         </table>
     </div>
 </div> 
-
+<button dojoType='dijit.form.Button' onclick='btDrawEditDialog();'>Edit Current Row</button>
 <span>Context Org Unit</span>
 <select dojoType="openils.widget.OrgUnitFilteringSelect" jsId='btContextOrgSelect' 
     searchAttr='shortname' labelAttr='shortname'> </select>
@@ -48,18 +48,47 @@
 <div dojoType="dijit.layout.ContentPane" layoutAlign="top">
     <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:600px;'>
         <table jsId="btGrid" dojoType="dojox.grid.DataGrid" query="{id: '*'}" 
-            rowSelector='20px' selectionMode='none' columnReordering='true' headerMenu="btGridMenu">
+            rowSelector='20px' columnReordering='true' headerMenu="btGridMenu">
             <thead>
                 <tr>
                     <th field="id">ID</th>
-                    <th field="name" width='250px;' editable='true' cellType='dojox.grid.cells._Widget' widgetClass='dijit.form.TextBox'>Name</th>
-                    <th field="owner" width='250px;' get='getOrgInfo'>Owning Location</th>
-                    <th field="default_price" editable='true' cellType='dojox.grid.cells._Widget' widgetClass='dijit.form.CurrencyTextBox'>Default Price</th>
+                    <th field="name" width='250px;'>Name</th>
+                    <th field="owner" width='250px;'get='getOrgInfo'>Owning Location</th>
+                    <th field="default_price">Default Price</th>
                 </tr>
             </thead>
         </table>    
     </div>
 </div>
+<div style='display:none;' dojoType="dijit.Dialog" jsId='btEditDialog'>
+    <script>dojo.require('dijit.form.TextBox');</script>
+    <b>Test Editing Dialog</b>
+    <form>
+        <table>
+            <tr>
+                <td>ID</td>
+                <td><span id='btId'/></td>
+            </tr>
+            <tr>
+                <td>Name</td>
+                <td><input dojoType='dijit.form.TextBox' jsId='btName'/></td>
+            </tr>
+            <tr>
+                <td>Owning Location</td>
+                <td><select dojoType='openils.widget.OrgUnitFilteringSelect' jsId='btOwnerLocation' searchAttr='shortname' labelAttr='shortname'/></td>
+            </tr>
+            <tr>
+                <td> DefaultPrice</td>
+                <td><input dojoType='dijit.form.CurrencyTextBox' jsId='btDefaultPrice'></td>
+            </tr>
+            <tr>
+                <td colspan='2' align='center'>
+                    <button jsId='editSave' dojoType='dijit.form.Button'>Save Changes</button>
+                </td>
+            </tr>
+        </table>
+    </form>
+</div>
 
 [% END %]
 



More information about the open-ils-commits mailing list