implement the "process immediately" switch, hitherto unhooked up
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Tue, 11 Sep 2012 02:12:39 +0000 (22:12 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Fri, 21 Sep 2012 15:07:00 +0000 (11:07 -0400)
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/web/js/dojo/openils/URLVerify/CreateSession.js
Open-ILS/web/js/dojo/openils/URLVerify/SelectURLs.js
Open-ILS/web/js/dojo/openils/URLVerify/Verify.js [new file with mode: 0644]

index cb79e82..e0c1619 100644 (file)
@@ -5,6 +5,7 @@ if (!dojo._hasResource["openils.URLVerify.CreateSession"]) {
     dojo.require("openils.Util");
     dojo.require("openils.PermaCrud");
     dojo.require("openils.widget.FilteringTreeSelect");
+    dojo.require("openils.URLVerify.Verify");
 
     dojo.requireLocalization("openils.URLVerify", "URLVerify");
 
@@ -87,7 +88,7 @@ if (!dojo._hasResource["openils.URLVerify.CreateSession"]) {
         );
     };
 
-    /* 2) save the tag/subfield sets for URL extraction, */
+    /* 2a) save the tag/subfield sets for URL extraction, */
     module.save_tags = function() {
         module.progress_dialog.attr("title", localeStrings.SAVING_TAGS);
         module.progress_dialog.show(); /* sic */
@@ -95,7 +96,8 @@ if (!dojo._hasResource["openils.URLVerify.CreateSession"]) {
         uvus_progress = 0;
 
         /* Note we're not using openils.PermaCrud, which is inadequate
-         * when you want transactions. Thanks for figuring it out, Bill. */
+         * when you need one big transaction. Thanks for figuring it
+         * out Bill. */
         var pcrud_raw = new OpenSRF.ClientSession("open-ils.pcrud");
 
         pcrud_raw.connect();
@@ -106,9 +108,7 @@ if (!dojo._hasResource["openils.URLVerify.CreateSession"]) {
             "oncomplete": function(r) {
                 module._create_uvus_one_at_a_time(
                     pcrud_raw,
-                    module.tag_and_subfields.generate_uvus(
-                        module.session_id
-                    )
+                    module.tag_and_subfields.generate_uvus(module.session_id)
                 );
             }
         }).send();
@@ -125,7 +125,7 @@ if (!dojo._hasResource["openils.URLVerify.CreateSession"]) {
                     {"maximum": uvus_list.length, "progress": ++uvus_progress}
                 );
 
-                uvus_list.shift();  /* /now/ actually shorten the list */
+                uvus_list.shift();  /* /now/ actually shorten working list */
 
                 if (uvus_list.length < 1) {
                     pcrud_raw.request({
@@ -147,8 +147,9 @@ if (!dojo._hasResource["openils.URLVerify.CreateSession"]) {
     };
 
     /* 3) search and populate the container (API call). */
-    var search_result_count = 0;
     module.perform_search = function() {
+        var search_result_count = 0;
+
         module.progress_dialog.attr("title", localeStrings.PERFORMING_SEARCH);
         module.progress_dialog.show(true);
 
@@ -180,11 +181,13 @@ if (!dojo._hasResource["openils.URLVerify.CreateSession"]) {
                     module.progress_dialog.show(true);
 
                     if (no_url_selection.checked) {
-                        location.href = oilsBasePath +
-                            "/url_verify/validation_review?" +
-                            "session_id=" + module.session_id +
-                            "&validate=1";
+                        /* verify URLs and ultimately redirect to review page */
+                        openils.URLVerify.Verify.go(
+                            module.session_id, null, module.progress_dialog
+                        );
                     } else {
+                        /* go to the URL selection page, allowing users to
+                         * selectively verify URLs */
                         location.href = oilsBasePath +
                             "/url_verify/select_urls?session_id=" +
                             module.session_id;
@@ -201,13 +204,10 @@ if (!dojo._hasResource["openils.URLVerify.CreateSession"]) {
      */
     module._populate_saved_searches = function(node) {
         var pcrud = new openils.PermaCrud();
-        var list = pcrud.retrieveAll(
-            "asq", {"order_by": {"asq": "label"}}
-        );
+        var list = pcrud.retrieveAll("asq", {"order_by": {"asq": "label"}});
 
         dojo.forEach(
-            list,
-            function(o) {
+            list, function(o) {
                 dojo.create(
                     "option", {
                         "innerHTML": o.label(),
index 1c479da..8c1cde9 100644 (file)
@@ -2,6 +2,7 @@ if (!dojo._hasResource["openils.URLVerify.SelectURLs"]) {
     dojo.require("dojo.string");
     dojo.require("openils.CGI");
     dojo.require("openils.Util");
+    dojo.require("openils.URLVerify.Verify");
 
     dojo.requireLocalization("openils.URLVerify", "URLVerify");
 
@@ -51,47 +52,11 @@ if (!dojo._hasResource["openils.URLVerify.SelectURLs"]) {
          * terms
          */
 
-        module.progress_dialog.attr("title", localeStrings.VERIFICATION_DIALOG);
-        module.progress_dialog.show();
-
-        fieldmapper.standardRequest(
-            ["open-ils.url_verify", "open-ils.url_verify.session.verify"], {
-                "params": [
-                    openils.User.authtoken,
-                    module.session_id,
-                    really_everything ? null : module.grid.getSelectedIDs()
-                ],
-                "async": true,
-                "onresponse": function(r) {
-                    if (r = openils.Util.readResponse(r)) {
-                        module.progress_dialog.update({
-                            "maximum": r.url_count,
-                            "progress": r.total_excluding_redirects
-                        });
-
-                        if (r.attempt) {
-                            module.attempt = r.attempt;
-                            module.progress_dialog.show(
-                                false,
-                                dojo.string.substitute(
-                                    localeStrings.VERIFICATION_ATTEMPT_ID,
-                                    [r.attempt.id()]
-                                )
-                            );
-                        }
-                    }
-                },
-                "oncomplete": function() {
-                    module.progress_dialog.show(true);
-                    module.progress_dialog.attr(
-                        "title", localeStrings.REDIRECTING
-                    );
-                    location.href = oilsBasePath +
-                        "/url_verify/review_attempt?attempt_id=" +
-                        module.attempt.id();
-                }
-            }
-        )
+        openils.URLVerify.Verify.go(
+            module.session_id,
+            really_everything ? null : module.grid.getSelectedIDs(),
+            module.progress_dialog
+        );
     };
 
 }());
diff --git a/Open-ILS/web/js/dojo/openils/URLVerify/Verify.js b/Open-ILS/web/js/dojo/openils/URLVerify/Verify.js
new file mode 100644 (file)
index 0000000..1839af8
--- /dev/null
@@ -0,0 +1,59 @@
+if (!dojo._hasResource["openils.URLVerify.Verify"]) {
+
+    dojo.requireLocalization("openils.URLVerify", "URLVerify");
+
+    dojo._hasResource["openils.URLVerify.Verify"] = true;
+    dojo.provide("openils.URLVerify.Verify");
+
+    dojo.declare("openils.URLVerify.Verify", null, {});
+
+    /* Take care that we add nothing to the global namespace.
+     * This is not an OO module so much as a container for
+     * functions needed by specific interfaces. */
+
+(function() {
+    var module = openils.URLVerify.Verify;
+    var localeStrings =
+        dojo.i18n.getLocalization("openils.URLVerify", "URLVerify");
+
+    module.go = function(session_id, url_id_list, progress_dialog) {
+        progress_dialog.attr("title", localeStrings.VERIFICATION_DIALOG);
+        progress_dialog.show();
+
+        fieldmapper.standardRequest(
+            ["open-ils.url_verify", "open-ils.url_verify.session.verify"], {
+                "params": [openils.User.authtoken, session_id, url_id_list],
+                "async": true,
+                "onresponse": function(r) {
+                    if (r = openils.Util.readResponse(r)) {
+                        progress_dialog.update({
+                            "maximum": r.url_count,
+                            "progress": r.total_excluding_redirects
+                        });
+
+                        if (r.attempt) {
+                            module.attempt = r.attempt;
+                            progress_dialog.show(
+                                false,
+                                dojo.string.substitute(
+                                    localeStrings.VERIFICATION_ATTEMPT_ID,
+                                    [r.attempt.id()]
+                                )
+                            );
+                        }
+                    }
+                },
+                "oncomplete": function() {
+                    progress_dialog.show(true);
+                    progress_dialog.attr("title", localeStrings.REDIRECTING);
+                    location.href = oilsBasePath +
+                        "/url_verify/review_attempt?attempt_id=" +
+                        module.attempt.id();
+                }
+            }
+        );
+    };
+
+}());
+
+}