[open-ils-commits] r990 - in conifer/branches/rel_1_6_1/web/opac/skin/algoma: . js xml xml/reserves (risard)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Sep 13 16:16:37 EDT 2010
Author: risard
Date: 2010-09-13 16:16:32 -0400 (Mon, 13 Sep 2010)
New Revision: 990
Added:
conifer/branches/rel_1_6_1/web/opac/skin/algoma/js/
conifer/branches/rel_1_6_1/web/opac/skin/algoma/js/reserves.js
conifer/branches/rel_1_6_1/web/opac/skin/algoma/xml/reserves/
conifer/branches/rel_1_6_1/web/opac/skin/algoma/xml/reserves/reserves.xml
Log:
fist pass at a course reserves system
Added: conifer/branches/rel_1_6_1/web/opac/skin/algoma/js/reserves.js
===================================================================
--- conifer/branches/rel_1_6_1/web/opac/skin/algoma/js/reserves.js (rev 0)
+++ conifer/branches/rel_1_6_1/web/opac/skin/algoma/js/reserves.js 2010-09-13 20:16:32 UTC (rev 990)
@@ -0,0 +1,411 @@
+
+dojo.require("dijit.form.TextBox");
+dojo.require("dijit.Dialog");
+dojo.require('openils.PermaCrud');
+dojo.require("dijit.form.Button");
+dojo.require("dijit.form.FilteringSelect");
+
+dojo.require('fieldmapper.AutoIDL'); //reads /openils/var/reports/fm_IDL.xml to generate a list of class properties
+dojo.require('fieldmapper.dojoData'); //seems to provide a store for Evergreen data accessed via Dojo
+dojo.require('fieldmapper.Fieldmapper'); //converts the list of class properties into actual classes.
+dojo.require('openils.Util');
+dojo.require('openils.Event');
+
+/*
+===== Bookbag manipulation =====
+*/
+
+function containerCresDoRequest( req, callback, args ) {
+
+ if( callback ) {
+ req.callback( callback );
+ req.request.args = args;
+ req.send();
+ return null;
+ }
+
+ req.send(true);
+ return req.result();
+}
+
+function containerCresFetchAll( callback, args ) {
+
+ var req = new Request(
+ FETCH_CONTAINERS, G.user.session, G.user.id(), 'copy', 'cres' );
+
+ return containerCresDoRequest( req, callback, args );
+}
+
+function containerCresFlesh( id, callback, args ) {
+
+ var req = new Request( FLESH_CONTAINER, G.user.session, 'copy', id );
+ return containerCresDoRequest( req, callback, args );
+}
+
+function containerCresDelete( id, callback, args ) {
+
+ var len = cresFleshedContainers[id].items().length;
+
+ if (len != 0){
+ for( var i = 0; i != len; i++ ) {
+ var itm = cresFleshedContainers[id].items()[i].id();
+ containerCresRemoveItem( itm );
+ }
+
+ }
+ var req = new Request( DELETE_CONTAINER, G.user.session, 'copy', id );
+ return containerCresDoRequest(req, callback, args );
+}
+
+function containerCresCreate( name, pub, callback, args ) {
+
+ var container = new ccb();
+ container.name(name);
+ container.btype('cres');
+
+ container.owner( G.user.id() );
+ if(pub) container.pub('t');
+ else container.pub('f');
+
+ var req = new Request(
+ CREATE_CONTAINER, G.user.session, 'copy', container );
+ return containerCresDoRequest( req, callback, args );
+}
+
+function containerCresUpdate( container, callback, args ) {
+
+ var req = new Request(UPDATE_CONTAINER, G.user.session, 'copy', container);
+ return containerCresDoRequest(req, callback, args);
+}
+
+
+function containerCresCreateItem( containerId, target, callback, args ) {
+
+ var item = new ccbi();
+ item.target_copy(target);
+ item.bucket(containerId);
+
+ var req = new Request( CREATE_CONTAINER_ITEM,
+ G.user.session, 'copy', item );
+
+ return containerCresDoRequest( req, callback, args );
+}
+
+
+function containerCresRemoveItem( id, callback, args ) {
+
+ var search = {'item':id};
+ var pcrudnote = new openils.PermaCrud({"authtoken":G.user.session});
+ note = pcrudnote.search('ccbin', search);
+ var oldparams = dojo.fromJson(note[0].note());
+
+ var pcrudcpy = new openils.PermaCrud({"authtoken":G.user.session});
+ var cpy = pcrudcpy.retrieve("acp", oldparams.id);
+ cpy.location(oldparams.location);
+ cpy.circ_modifier(oldparams.circ_modifier);
+ pcrudcpy.update(cpy);
+
+ var req = new Request( DELETE_CONTAINER_ITEM, G.user.session, 'copy', id );
+ return containerCresDoRequest( req, callback, args );
+}
+
+function containerCresCreateNote(itemId, circ_mod, copy_location) {
+
+ var oldparams = {'id': cresCopy.id(), 'location': cresCopy.location().id(), 'circ_modifier': cresCopy.circ_modifier()};
+ var joldparams = dojo.toJson(oldparams);
+ var pcrudcpy = new openils.PermaCrud({"authtoken":G.user.session});
+ var cpy = pcrudcpy.retrieve("acp", cresCopy.id());
+ cpy.location(copy_location);
+ cpy.circ_modifier(circ_mod);
+ pcrudcpy.update(cpy);
+
+ var pcrudnote = new openils.PermaCrud({"authtoken":G.user.session});
+ var note = new ccbin();
+ note.note(joldparams);
+ note.item(itemId);
+ pcrudnote.create(note);
+
+ return true;
+}
+
+/*
+===== reserves dialog stuff =====
+*/
+
+var cresCopy;
+function cresInit(currentCopy){
+
+ cresCopy = currentCopy;
+
+ var cresDlg = dijit.byId("cresSelectorDlg");
+ cresBuildSelector();
+ cresDlg.show();
+}
+
+function cresCreate( pub, callback, args ) {
+
+ var name = dijit.byId("cresNewName");
+ containerCresCreate(name.value);
+ cresBuildSelector();
+ name.attr("value", "");
+}
+
+function cresBuildSelector() {
+
+ var req = new Request(
+ FETCH_CONTAINERS, G.user.session, G.user.id(), 'copy', 'cres' );
+ req.callback(cresAddBookbags);
+ req.send();
+}
+
+
+function cresAddBookbags(r) {
+/*yeah, this sucks. Need to replace this.
+need to refresh the drop down otherwise it duplicates values
+everytime the dialog is given focus.
+Easiest way to do this likely is to use a dijit list, I can
+then use it's reset property
+*/
+$('cresSelector').options.length = 0;
+$('cresSelector').options[0] = new Option("Add to Reserve", "start");
+$('cresSelector').options[1] = new Option("--------------");
+$('cresSelector').options[1].disabled = true;
+$('cresSelector').options[2] = new Option("Add to Reserve");
+$('cresSelector').options[2].disabled = true;
+$('cresSelector').options[3] = new Option("--------------");
+$('cresSelector').options[3].disabled = true;
+
+ var containers = r.getResultObject();
+ var selector = $('cresSelector');
+ var found = false;
+ var index = 3;
+ doSelectorActions(selector);
+
+
+ for( var i = 0; i != containers.length; i++ ) {
+ found = true;
+ var container = containers[i];
+ insertSelectorVal( selector, index++, container.name(),
+ "container_" + container.id(), cresAddToBookbag, 1 );
+ }
+
+ nextContainerIndex = index;
+}
+
+
+function cresAddToBookbag() {
+
+ var selector = $('cresSelector');
+ var id = selector.options[selector.selectedIndex].value;
+ setSelector( selector, 'start' );
+ var circmod = $('cresCircModSelector');
+ var loc = $('cresLocSelector');
+
+ var cresInsert = containerCresCreateItem( id.substring(10), cresCopy.id() )
+
+ if ( cresInsert ) {
+ if ( containerCresCreateNote(cresInsert, circmod, loc)) { alert($('rdetail_bb_item_success').innerHTML);}
+ }
+
+}
+
+function cresShowManager() {
+
+ var cresManageDlg = dijit.byId('cresManageDialog');
+ cresManageDlg.show();
+
+}
+
+/*
+===== "My Reserves" interface stuff =====
+*/
+
+var cresFleshedContainers = {};
+var cresContainerTemplate;
+
+function myOPACCresShowBookbags(force) {
+
+ var tbody =$('myopac_cres_bookbag_tbody') ;
+
+ if(!cresContainerTemplate)
+ cresContainerTemplate = tbody.removeChild($('myopac_cres_bookbag_tr'));
+ else if(!force) return;
+
+ removeChildren(tbody);
+
+ var containers = containerCresFetchAll();
+
+ var found = false;
+ for( var i in containers ) {
+ found = true;
+ var cont = containers[i];
+ var row = cresContainerTemplate.cloneNode(true);
+ row.id = 'myopac_cres_bookbag_row_' + cont.id();
+ var link = $n(row, 'myopac_cres_expand_bookbag');
+ var dlink = $n(row, 'myopac_cres_container_delete');
+ link.appendChild( text(cont.name()) );
+ link.setAttribute('href',
+ 'javascript:myOPACCresExpandBookbag("' + cont.id() + '","' + cont.name() + '");');
+ myOPACCresFetchBBItems( cont.id(), row );
+ dlink.setAttribute('href', 'javascript:myOPACCresDeleteBookbag("'+cont.id()+'");');
+
+ if( isTrue(cont.pub()) ) {
+ unHideMe($n(row, 'myopac_cres_bb_published_yes'));
+ var link = $n(row, 'myopac_cres_bb_published_view');
+ link.setAttribute('href', buildExtrasLink( 'feed/bookbag/html-full/'+cont.id(), false));
+ link.setAttribute('target', '_blank' );
+ unHideMe(link);
+ link = $n(row, 'myopac_cres_bb_published_atom');
+ link.setAttribute('href', buildExtrasLink( 'feed/bookbag/rss2-full/'+cont.id(), false));
+ link.setAttribute('target', '_blank' );
+ unHideMe(link);
+
+ link = $n(row, 'myopac_cres_bb_make_unpublished');
+ link.setAttribute('href', 'javascript:myOPACCresMakeBBPublished("'+cont.id()+'", true);');
+ unHideMe(link);
+
+ var RW = $n(row, 'myopac_cres_bb_exp_refworks');
+ if (RW && myopacEnableRefWorks) {
+ var here = (findOrgUnit(getLocation())).name();
+ var org_name = here.replace(" ", "+");
+ var cgi = new CGI();
+
+ RW.setAttribute('href',
+ myopacRefWorksHost + '/express/expressimport.asp?vendor='
+ + org_name
+ + '&filter=MARC+Format&database=All+MARC+Formats&encoding=65001&url=http%3A%2F%2F'
+ + cgi.server_name + '/opac/extras/feed/bookbag/marctxt-full/'
+ + cont.id()
+ );
+ RW.setAttribute('target', 'RefWorksMain');
+ unHideMe($n(row, 'myopac_cres_bb_exp_refworks'));
+ }
+ } else {
+ unHideMe($n(row, 'myopac_cres_bb_published_no'));
+ var link = $n(row, 'myopac_cres_bb_make_published');
+ link.setAttribute('href', 'javascript:myOPACCresMakeBBPublished("'+cont.id()+'");');
+ unHideMe(link);
+ }
+ tbody.appendChild(row);
+ }
+
+ if(!found) unHideMe($('myopac_cres_bookbags_none'));
+ else unHideMe($('myopac_cres_bookbag_table'));
+}
+
+
+function myOPACCresMakeBBPublished(bbid, hideme) {
+
+ var bb = cresFleshedContainers[bbid];
+
+ if(hideme) {
+ if(!confirm($('myopac_make_unpublished_confirm').innerHTML)) return;
+ bb.pub('f');
+ } else {
+ if(!confirm($('myopac_make_published_confirm').innerHTML)) return;
+ bb.pub('t');
+ }
+
+ var result = containerCresUpdate(bb, 'copy');
+
+ var code = checkILSEvent(result);
+ if(code) { alertILSEvent(result); return; }
+
+ alert($('myopac_bb_update_success').innerHTML);
+ myOPACCresShowBookbags(true);
+}
+
+function myOPACCresDeleteBookbag(id) {
+ if( confirm( $('myopac_cres_delete_bookbag_warn').innerHTML ) ) {
+ var result = containerCresDelete(id);
+ var code = checkILSEvent(result);
+ if(code) { alertILSEvent(result); return; }
+ alert($('myopac_cres_bb_update_success').innerHTML);
+ hideMe($('myopac_cres_bookbag_items_table'));
+ hideMe($('myopac_cres_bookbag_items_name'));
+ hideMe($('myopac_cres_bookbag_no_items'));
+ myOPACCresShowBookbags(true);
+ }
+}
+
+function myOPACCresFetchBBItems( id, row, block ) {
+ if(!block) {
+ containerCresFlesh( id, _myOPACCresSetBBItems, { row: row } );
+ } else {
+ var cont = containerCresFlesh( id );
+ myOPACCresSetBBItems( cont, row );
+ }
+}
+
+function _myOPACCresSetBBItems(r) { myOPACCresSetBBItems( r.getResultObject(), r.args.row ); }
+
+function myOPACCresSetBBItems( container, row ) {
+ cresFleshedContainers[container.id()] = container;
+ var node = $n(row, 'myopac_cres_bookbag_item_count');
+ removeChildren(node);
+ node.appendChild( text(container.items().length) );
+}
+
+var cresBBItemsRow;
+function myOPACCresExpandBookbag( id, name ) {
+
+ var tbody = $('myopac_cres_bookbag_items_tbody');
+ if(!cresBBItemsRow) cresBBItemsRow = tbody.removeChild($('myopac_cres_bookbag_items_row'));
+ removeChildren(tbody);
+ removeChildren($('myopac_cres_bookbag_items_name'));
+
+ $('myopac_cres_bookbag_items_name').appendChild(text(name));
+
+ if( cresFleshedContainers[id] ) {
+ var len = cresFleshedContainers[id].items().length;
+
+ if( len == 0 ) {
+ unHideMe($('myopac_cres_bookbag_no_items'));
+ hideMe($('myopac_cres_bookbag_items_table'));
+ return;
+ }
+
+ hideMe($('myopac_cres_bookbag_no_items'));
+ unHideMe($('myopac_cres_bookbag_items_table'));
+
+ for( var i = 0; i != len; i++ ) {
+ var row = cresBBItemsRow.cloneNode(true);
+ found = true;
+
+ var item = cresFleshedContainers[id].items()[i];
+ var tlink = $n(row,'myopac_cres_bookbag_items_title');
+ var alink = $n(row,'myopac_cres_bookbag_items_author');
+
+ var req = new Request( FETCH_RMODS, item.target_copy() );
+ req.request.tlink = tlink;
+ req.request.alink = alink;
+ req.callback(myOPACCresShowBBItem);
+ req.send();
+
+ var clink = $n(row, 'myopac_cres_bookbag_items_remove');
+ clink.setAttribute('href', 'javascript:myOPACCresRemoveBBItem("'+item.id()+'","'+id+'","'+name+'");');
+
+ tbody.appendChild(row);
+ }
+ }
+}
+
+function myOPACCresRemoveBBItem( id, containerid, container_name ) {
+ if(!confirm($('myopac_cres_remove_bb_item_confirm').innerHTML)) return;
+ var stat = containerCresRemoveItem( id );
+ if(stat) alert($('myopac_cres_bb_update_success').innerHTML);
+ myOPACCresFetchBBItems( containerid, $('myopac_cres_bookbag_row_' + containerid), true);
+ myOPACCresExpandBookbag( containerid, container_name );
+}
+
+function myOPACCresShowBBItem(r) {
+ var record = r.getResultObject();
+ buildTitleDetailLink(record, r.tlink);
+ buildSearchLink(STYPE_AUTHOR, record.author(), r.alink);
+}
+
+/*
+function myOPACCresCreateBookbag() {
+
+}
+ */
Added: conifer/branches/rel_1_6_1/web/opac/skin/algoma/xml/reserves/reserves.xml
===================================================================
--- conifer/branches/rel_1_6_1/web/opac/skin/algoma/xml/reserves/reserves.xml (rev 0)
+++ conifer/branches/rel_1_6_1/web/opac/skin/algoma/xml/reserves/reserves.xml 2010-09-13 20:16:32 UTC (rev 990)
@@ -0,0 +1,37 @@
+<div id="reserves_div" class='hide_me' xmlns:xi="http://www.w3.org/2001/XInclude" >
+
+<script language="javascript" type="text/javascript" src="<!--#echo var="OILS_OPAC_JS_HOST"-->/skin/default/js/reserves.js"></script>
+
+ <div dojoType="dijit.Dialog" id="cresSelectorDlg" title="Add copy to a Reserve">
+
+ <input type="text" name="cresNewName" dojoType="dijit.form.TextBox" trim="true" id="cresNewName"></input>
+ <input type="button" name="cresNewCreate" dojoType="dijit.form.Button" id="cresNewCreate" label="Create" onClick="cresCreate();"></input>
+ <br></br>
+<!--
+add your circ modifiers for reserves to this dropdown value = code, test = description
+yes, i should automate that
+-->
+ <select id='cresCircModSelector'>
+ <option value='start'>Select a Circ Modifier</option>
+ <option value='CRES'>Reserves - 2 hour</option>
+ </select>
+<!--
+This hidden field hold the default circ location for reserves. At algoma
+we only have the one, so this works. If you have more just turn this into
+a select box
+-->
+ <input type="hidden" id='cresLocSelector' value='101'></input>
+ <br></br>
+ <br></br>
+ <select id='cresSelector'>
+ <option value='start'>Add to Reserve</option>
+ <option disabled='disabled'>--------------</option>
+ <option disabled='disabled'>&rdetail.bookbag.add;</option>
+ <option disabled='disabled'>--------------</option>
+ </select>
+ <br></br>
+
+
+ </div>
+
+</div>
More information about the open-ils-commits
mailing list