these new bits untested, to be continued
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Thu, 30 Aug 2012 15:44:57 +0000 (11:44 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Fri, 21 Sep 2012 15:06:59 +0000 (11:06 -0400)
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/templates/url_verify/select_urls.tt2
Open-ILS/web/js/dojo/openils/URLVerify/SelectURLs.js [new file with mode: 0644]

index ccc9ae0..4c79124 100644 (file)
@@ -1,25 +1,20 @@
 [% WRAPPER base.tt2 %]
-[% ctx.page_title = 'Link Checker - Select URLs' %]
+[% ctx.page_title = "Link Checker - Select URLs" %]
 <script type="text/javascript">
     dojo.require("dijit.form.Button");
     dojo.require("openils.widget.FlattenerGrid");
     dojo.require("openils.Util");
     dojo.require("openils.CGI");
+    dojo.require("openils.URLVerify.SelectURLs");
 
-    /* XXX TODO move everything except the require's above and the addOnLoad
-       below into a dojo module */
-    var initial_query = {};
+    /* Minimize namespace pollution, but save us some typing later. */
+    var module = openils.URLVerify.SelectURLs;
 
     openils.Util.addOnLoad(
         function() {
             var cgi = new openils.CGI();
 
-            initial_query.session_id = cgi.param("session_id");
-
-            grid.refresh();
-            // XXX Instead of grid.refresh(), once filter stuff is done:
-            //  grid.fetchLock = false;
-            //  grid.filterUi.doApply();
+            module.setup(grid);
         }
     );
 </script>
          layoutAlign="top" class="oils-header-panel">
         <div>[% ctx.page_title %]</div>
         <div>
-            <span id="select-all-indicator"></span>
+            <button dojoType="dijit.form.Button"
+                onClick="module.validate_selected();">[%
+                l("Validate selected")
+            %]</button>
         </div>
     </div>
     <!-- <div class="oils-acq-basic-roomy">
-        <label for="org_selector">Show the pull list for:</label>
-        <select
-            id="org_selector" jsId="org_selector"
-            dojoType="openils.widget.OrgUnitFilteringSelect"
-            searchAttr="name" labelAttr="name">
-        </select>
+        XXX Controls that should go below the title but above the grid
+        could be placed here.
     </div> -->
     <table
         jsid="grid"
diff --git a/Open-ILS/web/js/dojo/openils/URLVerify/SelectURLs.js b/Open-ILS/web/js/dojo/openils/URLVerify/SelectURLs.js
new file mode 100644 (file)
index 0000000..e1c4938
--- /dev/null
@@ -0,0 +1,47 @@
+if (!dojo._hasResource["openils.URLVerify.SelectURLs"]) {
+    dojo.require("openils.CGI");
+
+    dojo.requireLocalization("openils.URLVerify", "URLVerify");
+
+    dojo._hasResource["openils.URLVerify.SelectURLs"] = true;
+    dojo.provide("openils.URLVerify.SelectURLs");
+
+    dojo.declare("openils.URLVerify.SelectURLs", 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 a specific interface. */
+
+(function() {
+    var module = openils.URLVerify.SelectURLs;
+    var localeStrings =
+        dojo.i18n.getLocalization("openils.URLVerify", "URLVerify");
+
+    module.setup = function(grid) {
+        var cgi = new openils.CGI();
+        module.grid = grid;
+
+        module.grid.attr("query", {"session_id": cgi.param("session_id")});
+        module.grid.refresh();
+        // Alternative to grid.refresh() once filter is set up
+        //module.grid.fetchLock = false;
+        //module.grid.filterUi.doApply();
+    };
+
+    module.validate_selected = function() {
+        if (module.grid.everythingSeemsSelected()) {
+            if (confirm(localeStrings.VALIDATE_ALL)) {
+                return module.validate_all();
+            }
+        }
+
+        console.info("module.validate_selected() sees IDs: " + dojo.toJson(module.grid.getSelectedIDs()));
+    };
+
+    module.validate_all = function() {
+        console.info("module.validate_all() called");
+    };
+
+}());
+
+}