Various fixes, largely UI
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Tue, 28 Aug 2012 18:08:28 +0000 (14:08 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Fri, 21 Sep 2012 15:06:58 +0000 (11:06 -0400)
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/URLVerify.pm
Open-ILS/src/templates/url_verify/create_session.tt2
Open-ILS/web/js/dojo/openils/url_verify/nls/url_verify.js
Open-ILS/web/js/ui/default/url_verify/create_session.js

index 4d0c876..ebe79ea 100644 (file)
@@ -11,6 +11,10 @@ use OpenILS::Utils::CStoreEditor q/:funcs/;
 use OpenILS::Application::AppUtils;
 use LWP::UserAgent;
 
+use Data::Dumper;
+
+$Data::Dumper::Indent = 0;
+
 my $U = 'OpenILS::Application::AppUtils';
 
 
@@ -730,7 +734,7 @@ __PACKAGE__->register_method(
         return => {
             desc => q/stream of numbers: first number of search results, then
                 numbers of extracted URLs for each record, grouped into arrays
-                of 10/,
+                of 100/,
             type => "number"
         }
     }
@@ -797,26 +801,24 @@ sub session_search_and_extract {
     $client->respond($pos); # first response: the number of items created
                             # (number of search results)
 
-    $pos = 0;
-    my @url_counts;
-
     # For each contain item, extract URLs.  Report counts of URLs extracted
-    # from each record in batches at every ten records.
+    # from each record in batches at every hundred records.  XXX Arbitrary.
 
+    my @url_counts;
     foreach my $item_id (@item_ids) {
         my $res = $e->json_query({
             from => ["url_verify.extract_urls", $ses_id, $item_id]
         }) or return $e->die_event;
 
-        push @url_counts, $res->[0]{extract_urls};
+        push @url_counts, $res->[0]{"url_verify.extract_urls"};
 
-        if (++$pos % 10 == 0) {
-            $client->respond(\@url_counts);
+        if (scalar(@url_counts) % 100 == 0) {
+            $client->respond([ @url_counts ]);
             @url_counts = ();
         }
     }
 
-    $client->respond(\@url_counts) if @url_counts;
+    $client->respond([ @url_counts ]) if @url_counts;
 
     $e->disconnect;
     return;
index 16758dd..0df3b4a 100644 (file)
@@ -31,6 +31,7 @@
     <div dojoType="dijit.layout.ContentPane"
          layoutAlign="top" class="oils-header-panel">
         <div> [% ctx.page_title %] </div>
+        <div> <!-- buttons could go here --></div>
     </div>
     <div>
         <table class="create-session-form">
                         <input type="text" size="4" maxlength="3" />
                         [% l("Subfield(s)") %]
                         <input type="text" size="15" />
-                        <a href="javascript:create_session.tag_and_subfields.add();">[% l('Add') %]
+                        <a href="javascript:create_session.tag_and_subfields.add();">[% l('Add') %]</a>
                     </div>
                 </td>
                 <td class="note">
index 3a3527f..91244ff 100644 (file)
@@ -2,5 +2,7 @@
     "CREATING": "Creating session ...",
     "SAVING_TAGS": "Saving tag/subfield selectors ...",
     "PERFORMING_SEARCH": "Performing search ...",
-    "EXTRACTING_URLS": "Extracting URLs..."
+    "EXTRACTING_URLS": "Extracting URLs ...",
+    "NEED_UVUS": "You must add some tag and subfield combinations",
+    "REDIRECTING": "Loading next interface ..."
 }
index 4b1bd3e..867d2aa 100644 (file)
@@ -31,6 +31,7 @@ var create_session = {};
 
     /* Reacting to the interface's "Begin" button, this function triggers the
      * first of three server-side processes necessary to create a session:
+     *
      * 1) create the session itself (API call), */
     create_session.begin = function() {
         var name = uv_session_name.attr("value");
@@ -57,6 +58,11 @@ var create_session = {};
             scope
         );
 
+        if (!create_session.tag_and_subfields.any()) {
+            alert(localeStrings.NEED_UVUS);
+            return;
+        }
+
         progress_dialog.attr("title", localeStrings.CREATING);
         progress_dialog.show(true);
         fieldmapper.standardRequest(
@@ -148,7 +154,6 @@ var create_session = {};
                     r = openils.Util.readResponse(r);
                     if (!search_result_count) {
                         search_result_count = Number(r);
-                        console.log("search_result_count: " + r);
 
                         progress_dialog.show(); /* sic */
                         progress_dialog.attr(
@@ -158,23 +163,32 @@ var create_session = {};
                             {"maximum": search_result_count, "progress": 0}
                         );
                     } else {
-                        console.log("r.length: " + r.length);
                         progress_dialog.update({"progress": r.length})
                     }
                 },
                 "oncomplete": function() {
-                    progress_dialog.attr("title", "");
-                    progress_dialog.hide();
-                    console.warn("XXX TODO redirect to next interface");
+                    progress_dialog.attr("title", localeStrings.REDIRECTING);
+                    progress_dialog.show(true);
+
+                    if (no_url_selection.checked) {
+                        location.href = oilsBasePath +
+                            "/url_verify/validation_review?" +
+                            "session_id=" + create_session.session_id +
+                            "&validate=1";
+                    } else {
+                        location.href = oilsBasePath +
+                            "/url_verify/select_urls?session_id=" +
+                            create_session.session_id;
+                    }
                 }
             }
         );
     };
 
     /* At least in Dojo 1.3.3 (I know, I know), dijit.form.MultiSelect does
-     * not behave like FilteringSelect, like you might thing, and work from a
+     * not behave like FilteringSelect, like you might expect, or work from a
      * data store.  So we'll use a native <select> control, which will have
-     * fewer moving parts to go haywire anyway.
+     * fewer moving parts that can go haywire anyway.
      */
     create_session.populate_saved_searches = function(node) {
         var list = (new openils.PermaCrud()).retrieveAll(
@@ -252,6 +266,17 @@ var create_session = {};
             this.counter++;
         };
 
+        /* return a boolean indicating whether or not we have any rows */
+        this.any = function() {
+            return Boolean(
+                dojo.query(
+                    '[id^="t-and-s-row-"]', dojo.byId(this.container_id)
+                ).length
+            );
+        };
+
+        /* Return one uvus object for each unique tag we have a row for,
+         * and use the given session_id for the uvus.session field. */
         this.generate_uvus = function(session_id) {
             var uniquely_grouped = {};
             dojo.query(