[open-ils-commits] r17255 - in trunk/Open-ILS: examples web/templates/default web/templates/default/cat web/templates/default/cat/authority (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Aug 18 21:24:05 EDT 2010


Author: dbs
Date: 2010-08-18 21:24:03 -0400 (Wed, 18 Aug 2010)
New Revision: 17255

Added:
   trunk/Open-ILS/web/templates/default/cat/
   trunk/Open-ILS/web/templates/default/cat/authority/
   trunk/Open-ILS/web/templates/default/cat/authority/list.tt2
Modified:
   trunk/Open-ILS/examples/fm_IDL.xml
Log:
Add basic authority browse/edit/delete interface

http://localhost/eg/cat/authority/list should get you where you need to be

The paging is comical, the JS should probably be split out from the
declarative markup, the interface needs i18n, the UI needs to become
usable - but at least we have exposed some functionality for working
with authority records now.

Ideally this becomes a widget that we can just embed into other
interfaces to maintain context (which suggests using openils.cgi
to seed the initial values of the widget).

Note that the delete function works - it sets the deleted flag for
an are to "true" - but the underlying authorities browse interface
currently doesn't care about such niceties and always returns deleted
records along with undeleted records. So that might be the next stop.


Modified: trunk/Open-ILS/examples/fm_IDL.xml
===================================================================
--- trunk/Open-ILS/examples/fm_IDL.xml	2010-08-18 21:30:26 UTC (rev 17254)
+++ trunk/Open-ILS/examples/fm_IDL.xml	2010-08-19 01:24:03 UTC (rev 17255)
@@ -1425,6 +1425,15 @@
 			<link field="bib_links" reltype="has_many" key="authority" map="" class="abl"/>
 			<link field="fixed_fields" reltype="might_have" key="record" map="" class="ard"/>
 		</links>
+		<permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+            <actions>
+                <create permission="CREATE_MARC IMPORT_MARC" global_required="true"/>
+                <retrieve/>
+                <update permission="UPDATE_MARC" global_required="true"/>
+                <delete permission="UPDATE_MARC" global_required="true"/>
+            </actions>
+        </permacrud>
+
 	</class>
 	<class id="ard" controller="open-ils.cstore" oils_obj:fieldmapper="authority::record_descriptor" oils_persist:tablename="authority.rec_descriptor" reporter:label="Authority Record Descriptor">
 		<fields oils_persist:primary="id" oils_persist:sequence="authority.rec_descriptor_id_seq">

Added: trunk/Open-ILS/web/templates/default/cat/authority/list.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/cat/authority/list.tt2	                        (rev 0)
+++ trunk/Open-ILS/web/templates/default/cat/authority/list.tt2	2010-08-19 01:24:03 UTC (rev 17255)
@@ -0,0 +1,131 @@
+[% ctx.page_title = 'Authority record list' %]
+[% WRAPPER default/base.tt2 %]
+
+<script>
+dojo.require('dijit.form.Button');
+dojo.require('dijit.form.DropDownButton');
+dojo.require('dijit.form.FilteringSelect');
+dojo.require('dijit.form.Form');
+dojo.require('dijit.form.NumberSpinner');
+dojo.require('dijit.form.TextBox');
+dojo.require("dijit.Menu");
+dojo.require("dijit.MenuItem");
+dojo.require('dojox.xml.parser');
+dojo.require('openils.PermaCrud');
+dojo.require('openils.XUL');
+dojo.require('openils.widget.OrgUnitFilteringSelect');
+
+/*
+// OrgUnits do not currently affect the retrieval of authority records,
+// but this is how to display them if they become OrgUnit-aware
+function authOUListInit() {
+    new openils.User().buildPermOrgSelector(
+        "STAFF_LOGIN", // anywhere you can log in
+        dijit.byId("authOU"),
+        null, // pre-selected org
+        null
+    );
+}
+dojo.addOnLoad(authOUListInit);
+*/
+function displayAuthorities(data) { 
+    // Grab each record from the returned authority records
+    dojo.query("record", data).forEach(function(node) {
+        authText = '';
+        authId = 0;
+
+        // Grab each authority record field from the authority record
+        dojo.query("datafield[tag^='1']", node).forEach(function(dfNode) {
+            authText += dojox.xml.parser.textContent(dfNode); 
+        });
+        // Grab the ID of the authority record
+        dojo.query("datafield[tag='901'] subfield[code='c']", node).forEach(function(dfNode) {
+            authId = dojox.xml.parser.textContent(dfNode); 
+        });
+
+        // Create the authority record listing entry
+        dojo.place('<div class="authEntry" id="auth' + authId + '">' + authText + '</div>', "authlist-div", "last");
+        // Add the menu of new/edit/delete/mark-for-merge options
+        var auth_menu = new dijit.Menu({});
+        new dijit.MenuItem({"onClick": function(){
+            pcrud = new openils.PermaCrud();
+            var auth_rec = pcrud.retrieve("are", authId);
+            if (auth_rec) {
+                loadMarcEditor(pcrud, auth_rec);
+            }
+        }, "label":"Edit"}).placeAt(auth_menu, "first");
+        new dijit.MenuItem({"onClick":function(){
+            pcrud = new openils.PermaCrud();
+            var auth_rec = pcrud.retrieve("are", authId);
+            if (auth_rec) {
+                pcrud.eliminate(auth_rec);
+                alert("Deleted authority record # " + authId);
+            }
+        }, "label":"Delete"}).placeAt(auth_menu, "last");
+        var auth_mb = new dijit.form.DropDownButton({dropDown: auth_menu, label:"Actions"});
+        auth_mb.placeAt("auth" + authId, "first");
+        auth_menu.startup();
+    });
+}
+
+function loadMarcEditor(pcrud, rec) {
+    /*
+       To run in Firefox directly, must set signed.applets.codebase_principal_support
+       to true in about:config
+     */
+    netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+    win = window.open('/xul/server/cat/marcedit.xul'); // XXX version?
+
+    win.xulG = {
+        "record": {"marc": rec.marc()},
+        "save": {
+            "label": "Save",
+            "func": function(xmlString) {
+                rec.marc(xmlString);
+                rec.ischanged(true);
+                pcrud.update(rec);
+                alert("Record was saved");
+                win.close();
+            }
+        }
+    };
+}
+</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">
+        <option value="authority.author">Author</option>
+        <option value="authority.subject">Subject</option>
+        <option value="authority.title">Title</option>
+        <option value="authority.topic">Topic</option>
+    </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
+        <script type="dojo/method" event="onClick" args="evt">
+            /* Protect against null input */
+            if (!dijit.byId('authTerm').attr('value')) {
+                return;
+            }
+
+            /* Clear out the current contents of the page */
+            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"}, "load":displayAuthorities });
+        </script>
+    </div>
+</div>
+
+<div id='authlist-div'></div>
+
+[% END %]
+



More information about the open-ils-commits mailing list