Add summary creation to embedded alt dist editor
authorDan Wells <dbw2@calvin.edu>
Thu, 4 Apr 2013 20:43:38 +0000 (16:43 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Fri, 5 Apr 2013 19:15:04 +0000 (15:15 -0400)
In the Serial Control View, summaries are created automatically with
a new distribution. To avoid unhappy surprises, the embedded version
of the alt distribution editor should do the same.

Signed-off-by: Dan Wells <dbw2@calvin.edu>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/web/js/ui/default/serial/subscription.js

index 6f1291f..bedb587 100644 (file)
@@ -303,6 +303,24 @@ openils.Util.addOnLoad(
                     "name" : "record_entry"
                 });
             dist_grid.overrideEditWidgets.record_entry.shove = {};
+            dist_grid.onPostCreate = function() { this.refresh(); };
+            dist_grid.createPaneOnSubmit = function(fmObject, opts, pane) {
+                fmObject.isnew(1);
+                fieldmapper.standardRequest(
+                    ['open-ils.serial', 'open-ils.serial.distribution.fleshed.batch.update'],
+                    {
+                        "async":false,
+                        "params":[openils.User.authtoken, [fmObject]],
+                        "oncomplete": function(r) {
+                            // TODO: adjust create method to send back fmObject,
+                            // then pass through to avoid need for onPostCreate
+                            // refresh
+                            // TODO: check for and handle possible errors
+                            pane.onPostSubmit(null, []);
+                        }
+                    }
+                );
+            };
             if (sub_id == 'new') {
                 ssub_grid.overrideEditWidgets.record_entry =
                         new dijit.form.TextBox({