Much bookbag integration - more to follow
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 11 Jan 2006 18:45:20 +0000 (18:45 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 11 Jan 2006 18:45:20 +0000 (18:45 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@2684 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/extras/fieldmapper.pl
Open-ILS/web/opac/common/js/config.js
Open-ILS/web/opac/common/js/utils.js
Open-ILS/web/opac/skin/default/js/holds.js
Open-ILS/web/opac/skin/default/js/myopac.js
Open-ILS/web/opac/skin/default/js/rdetail.js
Open-ILS/web/opac/skin/default/xml/myopac/myopac_bookbags.xml
Open-ILS/web/opac/skin/default/xml/page_rdetail.xml

index d664760..9c2282d 100755 (executable)
@@ -13,9 +13,9 @@ if(!$web) { $web = ""; }
 my @web_hints = qw/ asv asva asvr asvq 
                circ acp acpl acn ccs ahn  
                crcd crmf crrf mbts aoc aus 
-               mous mobts cdreb cdrebi /;
+               mous mobts /;
 
-my @web_core = qw/ aou au perm_ex ex aout mvr ccs ahr aua ac actscecm /;
+my @web_core = qw/ aou au perm_ex ex aout mvr ccs ahr aua ac actscecm cbreb cbrebi /;
 
 my @reports = qw/ perm_ex ex ao aou aout /;
 
@@ -24,18 +24,17 @@ print "var _c = {};\n";
 
 for my $object (keys %$map) {
 
+       my $hint = $map->{$object}->{hint};
+
        if($web eq "web") {
-               my $hint = $map->{$object}->{hint};
                next unless (grep { $_ eq $hint } @web_hints );
        }
 
        if($web eq "web_core") {
-               my $hint = $map->{$object}->{hint};
                next unless (grep { $_ eq $hint } @web_core );
        }
 
        if($web eq "reports") {
-               my $hint = $map->{$object}->{hint};
                next unless (grep { $_ eq $hint } @web_core );
        }
 
index 3cb4df8..8af0612 100644 (file)
@@ -238,6 +238,7 @@ var CREATE_CONTAINER                                = 'open-ils.actor:open-ils.actor.container.create';
 var DELETE_CONTAINER                           = 'open-ils.actor:open-ils.actor.container.delete';
 var CREATE_CONTAINER_ITEM              = 'open-ils.actor:open-ils.actor.container.item.create';
 var DELETE_CONTAINER_ITEM              = 'open-ils.actor:open-ils.actor.container.item.delete';
+var FLESH_CONTAINER                            = 'open-ils.actor:open-ils.actor.container.flesh';
 /* ---------------------------------------------------------------------------- */
 
 
index e1a2026..610967e 100644 (file)
@@ -179,6 +179,37 @@ function getSelectorVal( sel ) {
        return sel.options[sel.selectedIndex].value;
 }
 
+function insertSelectorVal( selector, index, name, value, action, indent ) {
+       for( var i = selector.options.length; i != index; i-- ) {
+               selector.options[i] = selector.options[i-1].cloneNode(true);
+       }
+       setSelectorVal( selector, index, name, value, action, indent );
+}
+
+function setSelectorVal( selector, index, name, value, action, indent ) {
+       if(!indent) indent = 0;
+       indent = parseInt(indent);
+
+       var option;
+       if(IE) {
+               var pre = elem("pre");
+               for( var i = 0; i != indent; i++ )
+                       pre.appendChild(text(" "));
+
+               pre.appendChild(text(name));
+               option = new Option("", value);
+               selector.options[index] = option;
+               select.appendChild(pre);
+       
+       } else {
+               indent = indent * 14;
+               option= new Option(name, value);
+               option.setAttribute("style", "padding-left: "+indent+'px;');
+               selector.options[index] = option;
+       }
+       if(action) option.onclick = action;
+}
+
 
 /* split on spaces.  capitalize the first /\w/ character in
    each substring */
index 02165a9..d7ed9f8 100644 (file)
@@ -85,34 +85,16 @@ function holdsDrawWindow(recid, type) {
 }
 
 
-function holdsBuildOrgSelector(node, depth) {
+function holdsBuildOrgSelector(node) {
 
-       if(!node) {
-               node = globalOrgTree;
-               depth = 0;
-       }
+       if(!node) node = globalOrgTree;
 
        var selector = $('holds_org_selector');
        var index = selector.options.length;
 
-       if(IE) {
-               var pre = elem("pre");
-               for(var x=2; x <= findOrgType(node.ou_type()).depth(); x++) {
-                       pre.appendChild(text("    "));
-               }
-               pre.appendChild(text(node.name()));
-               var select = new Option("", node.id());
-               selector.options[index] = select;
-               select.appendChild(pre);
+       var indent = findOrgType(node.ou_type()).depth() - 1;
+       setSelectorVal( selector, index, node.name(), node.id(), null, indent );
        
-       } else {
-               var pad = (findOrgType(node.ou_type()).depth() - 1) * 12;
-               if(pad < 0) pad = 0;
-               var select = new Option(node.name(), node.id());
-               select.setAttribute("style", "padding-left: "+pad+'px;');
-               selector.options[index] = select;
-       }       
-
        if( node.id() == holdRecipient.home_ou() ) {
                selector.selectedIndex = index;
                selector.options[index].selected = true;        
@@ -120,9 +102,7 @@ function holdsBuildOrgSelector(node, depth) {
 
        for( var i in node.children() ) {
                var child = node.children()[i];
-               if(child) {
-                       holdsBuildOrgSelector(child, depth+1);
-               }
+               if(child) holdsBuildOrgSelector(child);
        }
 }
 
index 9b22b36..b61474b 100644 (file)
@@ -3,6 +3,7 @@ attachEvt("common", "run", myOPACInit );
 attachEvt("common", "loggedIn", myOPACInit );
 
 var fleshedUser = null;
+var fleshedContainers = {};
 
 
 function clearNodes( node, keepArray ) {
@@ -529,30 +530,108 @@ function myOPACShowBookbags(force) {
 
        removeChildren(tbody);
 
-
        var req = new Request( 
                FETCH_CONTAINERS, G.user.session, G.user.id(), 'biblio', 'bookbag' );
        
        req.send(true);
        var containers = req.result();
 
+       var found = false;
        for( var i in containers ) {
+               found = true;
                var cont = containers[i];
                var row = containerTemplate.cloneNode(true);
-               row.id = 'bookbag_item_' + cont.id();
+               row.id = 'myopac_bookbag_row_' + cont.id();
                var link = $n(row, 'myopac_expand_bookbag');
                link.appendChild( text(cont.name()) );
                link.setAttribute('href', 
                        'javascript:myOPACExpandBookbag("' + cont.id() + '","' + cont.name() + '");');
+               myOPACFetchBBItems( cont.id(), row );
                tbody.appendChild(row); 
        }
-       
+
+       if(!found) unHideMe($('myopac_bookbags_none'));
+       else unHideMe($('myopac_bookbag_table'));       
+}
+
+function myOPACFetchBBItems( id, row, block ) {
+       var req = new Request( FLESH_CONTAINER, G.user.session, 'biblio', id );
+       req.request.row = row;
+
+       if(!block) {
+               req.callback( myOPACSetBBItems );
+               req.send();
+       } else {
+               req.send(true);
+               myOPACSetBBItems( req.request );
+       }
+}
+
+function myOPACSetBBItems( r ) {
+       var container = r.getResultObject();
+       fleshedContainers[container.id()] = container;
+       var node = $n(r.row, 'myopac_bookbag_item_count');
+       removeChildren(node);
+       node.appendChild( text(container.items().length) );
 }
 
+var BBItemsRow;
 function myOPACExpandBookbag( id, name ) {
-       alert("Expanding: " + id + ' : ' + name );
+       
+       var tbody = $('myopac_bookbag_items_tbody');
+       if(!BBItemsRow) BBItemsRow = tbody.removeChild($('myopac_bookbag_items_row'));
+       removeChildren(tbody);
+       removeChildren($('myopac_bookbag_items_name'));
+
+       $('myopac_bookbag_items_name').appendChild(text(name));
+
+       if( fleshedContainers[id] ) {
+               var len = fleshedContainers[id].items().length;
+
+               if( len == 0 ) {
+                       unHideMe($('myopac_bookbag_no_items'));
+                       hideMe($('myopac_bookbag_items_table'));
+                       return;
+               }
+
+               hideMe($('myopac_bookbag_no_items'));
+               unHideMe($('myopac_bookbag_items_table'));
+
+               for( var i = 0; i != len; i++ ) {
+                       var row = BBItemsRow.cloneNode(true);
+                       found = true;
+
+                       var item = fleshedContainers[id].items()[i];
+                       var tlink = $n(row,'myopac_bookbag_items_title');
+                       var alink = $n(row,'myopac_bookbag_items_author');
+
+                       var req = new Request( FETCH_RMODS, item.target_biblio_record_entry() );
+                       req.request.tlink = tlink;
+                       req.request.alink = alink;
+                       req.callback(myOPACShowBBItem);
+                       req.send();
+
+                       var clink = $n(row, 'myopac_bookbag_items_remove');
+                       clink.setAttribute('href', 'javascript:myOPACRemoveBBItem("'+item.id()+'","'+id+'","'+name+'");');
+
+                       tbody.appendChild(row);
+               }
+       }
+}
+
+function myOPACRemoveBBItem( id, containerid, container_name ) {
+       var req = new Request( DELETE_CONTAINER_ITEM, G.user.session, 'biblio', id );
+       req.send(true);
+       req.result();
+       myOPACFetchBBItems( containerid, $('myopac_bookbag_row_' + containerid), true);
+       myOPACExpandBookbag( containerid, container_name );
 }
 
+function myOPACShowBBItem(r) {
+       var record = r.getResultObject();
+       buildTitleDetailLink(record, r.tlink);
+       buildSearchLink(STYPE_AUTHOR, record.author(), r.alink);
+}
 
 function myOPACCreateBookbag() {
        var name = $('myopac_bookbag_new_name').value;  
index 31b9a0b..1a76b02 100644 (file)
@@ -97,17 +97,56 @@ function _rdetailDraw(r) {
        runEvt("rdetail", "recordDrawn");
        recordsCache.push(record);
 
+       rdetailSetExtrasSelector();
+
        var req = new Request(FETCH_ACONT_SUMMARY, cleanISBN(record.isbn()));
        req.callback(rdetailHandleAddedContent);
        req.send();
 
        resultBuildCaches( [ record ] );
        resultDrawSubjects();
-       //resultDrawAuthors();
        resultDrawSeries();
+}
+
+function rdetailSetExtrasSelector() {
+       if(!grabUser()) return;
+       unHideMe($('rdetail_more_actions'));
+
+
+       var selector = $('rdetail_more_actions_selector');
 
+       var req = new Request( 
+               FETCH_CONTAINERS, G.user.session, G.user.id(), 'biblio', 'bookbag' );
+       req.callback(rdetailAddBookbags);
+       req.send();
 }
 
+function rdetailAddBookbags(r) {
+
+       var containers = r.getResultObject();
+       var selector = $('rdetail_more_actions_selector');
+       var found = false;
+       var index = 3;
+
+       for( var i = 0; i != containers.length; i++ ) {
+               found = true;
+               var container = containers[i];
+               insertSelectorVal( selector, index++, container.name(), 
+                       "container_" + container.id(), rdetailAddToBookbag, 1 );
+       }
+
+       if(!found) insertSelectorVal( selector, 3, "name", "value", 1 );
+}
+
+function rdetailAddToBookbag() {
+       var selector = $('rdetail_more_actions_selector');
+       var id = selector.options[selector.selectedIndex].value;
+       alert(id);
+       setSelector( selector, 'start' );
+}
+
+
+
 var rdetailTocFetched          = false;
 var rdetailReviewFetched       = false;
 var rdetailMarcFetched         = false;
index 1d7f568..82cdb74 100644 (file)
@@ -3,17 +3,18 @@
 
        <br/>
 
-       <span class='hide_me' id='myopac_bookbags_none'>You have not created any bookbags</span>
+       <div style='text-align: center; font-weight: bold;' class='hide_me' id='myopac_bookbags_none'>You have not created any bookbags</div>
 
-       <table width='100%' class='data_grid data_grid_center'>
+       <table width='100%' class='data_grid data_grid_center hide_me' id='myopac_bookbag_table'>
                <thead>
                        <tr><td colspan='2'>My Bookbags</td></tr>
                </thead>
                <tbody id='myopac_bookbag_tbody'>
                        <tr id='myopac_bookbag_tr'>
-                               <td><a href='javascript:void(0);' 
-                                       class='classic_link' name='myopac_expand_bookbag'> </a></td>
-                               <td><span name='myopac_bookbag_item_count'> X </span> <span>Items</span></td>
+                               <td>
+                                       <a href='javascript:void(0);' class='classic_link' name='myopac_expand_bookbag'> </a>
+                               </td>
+                               <td><span name='myopac_bookbag_item_count'> </span> <span>Items</span></td>
                        </tr>
                </tbody>
        </table>
                        <tr><td> 
                                <span>Enter the name of the new Bookbag: </span>
                                <input id='myopac_bookbag_new_name' type='text'> </input> 
-                               <input onclick='myOPACCreateBookbag();' type='submit'> </input>
+                               <input onclick='myOPACCreateBookbag();' type='submit' value='&common.submit;'> </input>
                        </td>
                        </tr>
                </tbody>
        </table>
+
+       <br/><br/>
+
+       <!--
+       <div style='overflow: auto; max-height: 200px;' class='hide_me'>
+       -->
+
+               <div style='width: 99%; text-align: center'> <b id='myopac_bookbag_items_name'> </b></div>
+
+               <div class='hide_me' style='width: 100%; text-align: center; font-weight: 700; margin-top: 10px;'
+                       id='myopac_bookbag_no_items'>The selected bookbag contains no items...</div>
+
+               <table width='100%' class='hide_me data_grid data_grid_center' id='myopac_bookbag_items_table'>
+                       <thead> 
+                               <tr> <td>Title</td> <td>Authors</td> <td>Remove this item?</td> </tr> 
+                       </thead>
+                       <tbody id='myopac_bookbag_items_tbody'>
+                               <tr id='myopac_bookbag_items_row'>
+                                       <td> <a name='myopac_bookbag_items_title' class='classic_link'> </a> </td>
+                                       <td> <a name='myopac_bookbag_items_author' class='classic_link'> </a> </td>
+                                       <td><a name='myopac_bookbag_items_remove' class='classic_link'>remove</a></td>  
+                               </tr>
+                       </tbody>
+               </table>
+       <!--</div>-->
 </div>
 
index 0486721..8c8e4c8 100644 (file)
                                        <span>&rdetail.detailMain.headerLabel;</span>
                                </td>
                                <td align='right' style='padding-right: 7px;'>
-                                       <span style='padding-right: 5px;'>
+                                       <span style='padding-right: 7px;'>
                                                <a id='rdetail_place_hold' class='classic_link'>Place Hold</a>
                                        </span>
+                                       <span style='padding-right: 7px;' class='hide_me' id='rdetail_more_actions'>
+                                               <select id='rdetail_more_actions_selector' style='max-width: 11em;'>
+                                                       <option value='start'>More Actions...</option>
+                                                       <option disabled='disabled'>--------------</option>
+                                                       <option disabled='disabled'>Add to Bookbag</option>
+                                                       <option disabled='disabled'>--------------</option>
+                                                       <option value='new_bookbag'>Create a new bookbag</option>
+                                               </select>
+                                       </span>
+
                                </td>
                        </tr>
                </tbody>
@@ -28,4 +38,6 @@
        <!--#include virtual="rdetail/rdetail_summary.xml"-->
        <br/><br/>
        <!--#include virtual="rdetail/rdetail_extras.xml"-->
+
+       <div class='hide_me' id='rdetail_bb_none'>(none)</div>
 </div>