added delete functionality. fixed some tabbing
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 17 Dec 2008 20:24:04 +0000 (20:24 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 17 Dec 2008 20:24:04 +0000 (20:24 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@11606 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/ui/default/conify/global/config/circ_modifier.js
Open-ILS/web/templates/default/conify/global/config/circ_modifier.tt2

index 6aef571..4a58f9a 100644 (file)
@@ -11,15 +11,15 @@ function buildCMGrid() {
     cmGrid.render();
 
     fieldmapper.standardRequest(
-       ['open-ils.permacrud', 'open-ils.permacrud.search.ccm'],
-       {   async: true,
-           params: [openils.User.authtoken, {code:{'!=':null}}],
-           onresponse: function (r) { 
+        ['open-ils.permacrud', 'open-ils.permacrud.search.ccm'],
+        {   async: true,
+            params: [openils.User.authtoken, {code:{'!=':null}}],
+            onresponse: function (r) { 
                 if(obj = openils.Util.readResponse(r)) {
                     store.newItem(ccm.itemToStoreData(obj));
                     cmCache[obj.code()] = obj;
                 }
-            }
+           }
         }
     );
 }
@@ -58,6 +58,32 @@ function cmCreate(args) {
     );
 }
 
-    
+function deleteFromGrid() {
+    _deleteFromGrid(cmGrid.selection.getSelected(), 0);
+}   
+
+function _deleteFromGrid(list, idx) {
+    if(idx >= list.length) // we've made it through the list
+        return;
+
+    var item = list[idx];
+
+    fieldmapper.standardRequest(
+        ['open-ils.permacrud', 'open-ils.permacrud.delete.ccm'],
+        {   async: true,
+            params: [openils.User.authtoken, item.code],
+            oncomplete: function(r) {
+                if(stat = openils.Util.readResponse(r)) {
+                    // delete succeeded, remove it from the grid and the local cache
+                    cmGrid.store.deleteItem(item); 
+                    delete cmCache[item.code];
+                }
+                _deleteFromGrid(list, ++idx);
+            }
+        }
+    );
+}
+
 openils.Util.addOnLoad(buildCMGrid);
 
+
index 50e0890..4c8c9d9 100644 (file)
         </div>
     </div> 
 
+    <button dojoType='dijit.form.Button' onclick='deleteFromGrid();'>Delete Selected</button>
+
     <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:600px;'>
         <table jsId="cmGrid" dojoType="dojox.grid.DataGrid" query="{name: '*'}" rowSelector='20px'>
             <thead>
                 <tr>
                     <th field="code">Code</th>
-                    <th field="name" width='auto'>Name</th>
+                    <th field="name" width='auto' editable='true' 
+                        cellType='dojox.grid.cells._Widget' widgetClass='dijit.form.TextBox'>Name</th>
                     <th field="description" width='auto'>Description</th>
                     <th field="sip2_media_type" width='auto'>SIP2 Media Type</th>
                     <th field="magnetic_media" width='auto' get='getMagneticMedia'>Magnetic Media</th>