deleting items now implemented. All four of the CRUD family are done!
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Fri, 30 Mar 2012 20:14:33 +0000 (16:14 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Fri, 30 Mar 2012 20:14:33 +0000 (16:14 -0400)
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/web/js/dojo/openils/FlattenerStore.js
Open-ILS/web/js/dojo/openils/widget/FlattenerGrid.js

index 7c8f4ae..e5cbdd7 100644 (file)
@@ -316,7 +316,13 @@ if (!dojo._hasResource["openils.FlattenerStore"]) {
                     if (response.status == 402) {   /* 'Payment Required' stands
                                                        in for cache miss */
                         if (self._retried_map_key_already) {
-                            console.error("Server won't cache flattener map?");
+                            var e = new FlattenerStoreError(
+                                "Server won't cache flattener map?"
+                            );
+                            if (typeof req.onError == "function")
+                                req.onError.call(callback_scope, e);
+                            else
+                                throw e;
                         } else {
                             self._retried_map_key_already = true;
                             delete self.mapKey;
@@ -326,8 +332,6 @@ if (!dojo._hasResource["openils.FlattenerStore"]) {
                 }
             });
 
-            /* as for onError: what to do? */
-
             return req;
         },
 
@@ -418,7 +422,12 @@ if (!dojo._hasResource["openils.FlattenerStore"]) {
          * need most of the methods. */
 
         "deleteItem": function(item) {
-            console.warn("[unimplemented] deleteItem() XXX TODO");
+            //console.log("deleteItem()");
+
+            var identity = this.getIdentity(item);
+            delete this._current_items[identity];   /* safe even if missing */
+
+            this.onDelete(item);
         },
 
         "setValue": function(item, attribute, value) {
index 647b2a8..572e5ca 100644 (file)
@@ -24,8 +24,11 @@ if (!dojo._hasResource["openils.widget.FlattenerGrid"]) {
             "fmClass": null,
             "fmIdentifier": null,
             "mapExtras": null,
-            "defaultSort": null,  /* whatever the UI says /replaces/ this */
-            "baseSort": null,     /* whatever the UI says /follows/ this */
+            "defaultSort": null,  /* whatever any part of the UI says will
+                                     /replace/ this */
+            "baseSort": null,     /* will contains what the columnpicker
+                                     dictates, and precedes whatever the column
+                                     headers provide. */
 
             /* These potential constructor arguments are for functionality
              * copied from AutoGrid */
@@ -633,6 +636,26 @@ if (!dojo._hasResource["openils.widget.FlattenerGrid"]) {
                 delete this.editPane;
                 dojo.style(this.domNode, "display", "block");
                 this.update();
+            },
+
+            "deleteSelected": function() {
+                var self = this;
+
+                this.getSelectedItems().forEach(
+                    function(item) {
+                        var fmobj = new fieldmapper[self.fmClass]();
+                        fmobj[self.fmIdentifier](
+                            self.store.getIdentity(item)
+                        );
+                        (new openils.PermaCrud()).eliminate(
+                            fmobj, {
+                                "oncomplete": function() {
+                                    self.store.deleteItem(item);
+                                }
+                            }
+                        );
+                    }
+                );
             }
         }
     );