From 0299987c2c4040b729fd843283e0ae7d848793e9 Mon Sep 17 00:00:00 2001 From: dbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4> Date: Thu, 19 Aug 2010 16:51:00 +0000 Subject: [PATCH] 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 git-svn-id: svn://svn.open-ils.org/ILS/trunk@17267 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../web/templates/default/cat/authority/list.tt2 | 96 +++++++++++++++++----- 1 file changed, 77 insertions(+), 19 deletions(-) diff --git a/Open-ILS/web/templates/default/cat/authority/list.tt2 b/Open-ILS/web/templates/default/cat/authority/list.tt2 index f340a48ade..a85c799aac 100644 --- a/Open-ILS/web/templates/default/cat/authority/list.tt2 +++ b/Open-ILS/web/templates/default/cat/authority/list.tt2 @@ -11,10 +11,13 @@ dojo.require('dijit.form.TextBox'); 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 loadMarcEditor(pcrud, rec) { } }; } + +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 @@ function loadMarcEditor(pcrud, rec) { </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> -- 2.11.0