[open-ils-commits] r17267 - trunk/Open-ILS/web/templates/default/cat/authority (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Aug 19 12:51:04 EDT 2010


Author: dbs
Date: 2010-08-19 12:51:00 -0400 (Thu, 19 Aug 2010)
New Revision: 17267

Modified:
   trunk/Open-ILS/web/templates/default/cat/authority/list.tt2
Log:
Further enhancements to the authority list interface

  * Offer Next / Previous buttons instead of forcing the number spinner
  * Submit searches onBlur of the search box instead of having to click Submit
  * Accept CGI params so we can kick off a search from other interfaces
  * Factor out the displayRecords() code so we can attach other events to it


Modified: trunk/Open-ILS/web/templates/default/cat/authority/list.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/cat/authority/list.tt2	2010-08-19 15:51:06 UTC (rev 17266)
+++ trunk/Open-ILS/web/templates/default/cat/authority/list.tt2	2010-08-19 16:51:00 UTC (rev 17267)
@@ -11,10 +11,13 @@
 dojo.require("dijit.Menu");
 dojo.require("dijit.MenuItem");
 dojo.require('dojox.xml.parser');
+dojo.require('openils.CGI');
 dojo.require('openils.PermaCrud');
 dojo.require('openils.XUL');
 dojo.require('openils.widget.OrgUnitFilteringSelect');
 
+var cgi = new openils.CGI();
+
 /*
 // OrgUnits do not currently affect the retrieval of authority records,
 // but this is how to display them if they become OrgUnit-aware
@@ -97,11 +100,70 @@
         }
     };
 }
+
+function authListInit() {
+    /* Parse CGI params so we can display records on load */
+    term = cgi.param('authTerm') || '';
+    page = cgi.param('authPage') || 0;
+    axis = cgi.param('authAxis') || 'authority.author';
+    if (axis) {
+        dijit.byId('authAxis').attr('value', axis);
+    }
+    if (page) {
+        dijit.byId('authPage').attr('value', page);
+    }
+
+    /* If we receive a term, go ahead and display the records */
+    if (term) {
+        dijit.byId('authTerm').attr('value', term);
+        displayRecords();
+    }
+
+    /* Make searching possible without having to click Submit */
+    dojo.connect(dijit.byId('authTerm'), 'onBlur', 'displayRecords');
+}
+
+function displayRecords(parms) {
+
+    if (parms && parms.page) {
+        if (parms.page == 'next') {
+            page = dijit.byId('authPage').attr('value');
+            dijit.byId('authPage').attr('value', page + 1);
+        } else if (parms.page == 'prev') {
+            page = dijit.byId('authPage').attr('value');
+            dijit.byId('authPage').attr('value', page - 1);
+        } else {
+            dijit.byId('authPage').attr('value', parms.page);
+        }
+    }
+
+    /* Protect against null input */
+    if (!dijit.byId('authTerm').attr('value')) {
+        return;
+    }
+
+    /* Clear out the current contents of the page */
+    widgets = dijit.findWidgets(dojo.byId('authlist-div'));
+    dojo.forEach(widgets, function(w) { w.destroyRecursive(true); });
+
+    dojo.query("#authlist-div div").orphan();
+
+    url = '/opac/extras/startwith/marcxml/'
+        + dijit.byId('authAxis').attr('value')
+        // + '/' + dijit.byId('authOU').attr('value')
+        + '/1' // replace with preceding line if OUs gain some meaning
+        + '/' + dijit.byId('authTerm').attr('value')
+        + '/' + dijit.byId('authPage').attr('value')
+    ;
+    dojo.xhrGet({"url":url, "handleAs":"xml", "content":{"format":"marcxml"}, "preventCache": true, "load":displayAuthorities });
+}
+
+dojo.addOnLoad(authListInit);
 </script>
 
 <div dojoType="dijit.form.Form" id="myForm" jsId="myForm" encType="multipart/form-data" action="" method="">
     <label for="authTerm">Search term: </label><input type="text" name="authTerm" value="" dojoType="dijit.form.TextBox" trim="true" id="authTerm" propercase="false"/>
-    <label for="authAxis">Authority type: </label><select type="text" name="authAxis" value="" dojoType="dijit.form.FilteringSelect" trim="true" id="authAxis" propercase="false">
+    <label for="authAxis">Authority type: </label><select type="text" name="authAxis" value="" dojoType="dijit.form.FilteringSelect" trim="true" id="authAxis" propercase="false" style="width: 10em;">
         <option value="authority.author">Author</option>
         <option value="authority.subject">Subject</option>
         <option value="authority.title">Title</option>
@@ -109,28 +171,24 @@
     </select>
 <!-- Not currently useful - see authOUListInit() above -->
 <!--    <label for="authOU">Library: </label><select dojoType="openils.widget.OrgUnitFilteringSelect" id="authOU" name="authOU" searchAttr="shortname" labelAttr="shortname"></select> -->
-    <label for="authPage">Page: </label><input dojoType="dijit.form.NumberSpinner" value="0" constraints="{min:-100,max:100,places:0}" smallDelta="1" id="authPage" name="authPage"/>
-    <div dojoType="dijit.form.Button" type="button" value="Submit">Submit
+
+    <div dojoType="dijit.form.Button" type="button" value="Previous">Previous
         <script type="dojo/method" event="onClick" args="evt">
-            /* Protect against null input */
-            if (!dijit.byId('authTerm').attr('value')) {
-                return;
-            }
+            displayRecords({"page":"prev"});
+        </script>
+    </div>
 
-            /* Clear out the current contents of the page */
-            widgets = dijit.findWidgets(dojo.byId('authlist-div'));
-            dojo.forEach(widgets, function(w) { w.destroyRecursive(true); });
+    <label for="authPage">Page: </label><input dojoType="dijit.form.NumberSpinner" value="0" constraints="{min:-100,max:100,places:0}" smallDelta="1" id="authPage" name="authPage" style="width:5em;" />
 
-            dojo.query("#authlist-div div").orphan();
+    <div dojoType="dijit.form.Button" type="button" value="Next">Next
+        <script type="dojo/method" event="onClick" args="evt">
+            displayRecords({"page":"next"});
+        </script>
+    </div>
 
-            url = '/opac/extras/startwith/marcxml/'
-                + dijit.byId('authAxis').attr('value')
-                // + '/' + dijit.byId('authOU').attr('value')
-                + '/1' // replace with preceding line if OUs gain some meaning
-                + '/' + dijit.byId('authTerm').attr('value')
-                + '/' + dijit.byId('authPage').attr('value')
-            ;
-            dojo.xhrGet({"url":url, "handleAs":"xml", "content":{"format":"marcxml"}, "preventCache": true, "load":displayAuthorities });
+    <div dojoType="dijit.form.Button" type="button" value="Submit">Submit
+        <script type="dojo/method" event="onClick" args="evt">
+            displayRecords();
         </script>
     </div>
 </div>



More information about the open-ils-commits mailing list