implemented delete
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 5 Jan 2009 21:28:30 +0000 (21:28 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 5 Jan 2009 21:28:30 +0000 (21:28 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@11747 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/ui/default/conify/global/config/hold_matrix_matchpoint.js

index 3ad0ea1..cceaddc 100644 (file)
@@ -12,7 +12,7 @@ var marcType = {};
 var marcForm = {};
 var vrForm = {};
 var pcrud = new openils.PermaCrud();
-
+var hmCache = [];
 
 function getOrgInfo(rowIndex, item) {
     if(!item) return '';
@@ -136,5 +136,31 @@ function buildHMGrid() {
         }
     );
 }
+function deleteFromGrid() {
+    _deleteFromGrid(hmGrid.selection.getSelected(), 0);
+}   
+
+function _deleteFromGrid(list, idx) {
+    if(idx >= list.length) // we've made it through the list
+        return;
+
+    var item = list[idx];
+    var id = hmGrid.store.getValue(item, 'id');
+
+    fieldmapper.standardRequest(
+        ['open-ils.permacrud', 'open-ils.permacrud.delete.chmm'],
+        {   async: true,
+            params: [openils.User.authtoken, id],
+            oncomplete: function(r) {
+                if(stat = openils.Util.readResponse(r)) {
+                    // delete succeeded, remove it from the grid and the local cache
+                    hmGrid.store.deleteItem(item); 
+                    delete hmCache[item.code];
+                }
+                _deleteFromGrid(list, ++idx);
+            }
+        }
+    );
+}
 
 openils.Util.addOnLoad(init);
\ No newline at end of file