Support for most of the actions on lists and bookbags
authorsenator <lebbeous@esilibrary.com>
Fri, 11 Mar 2011 23:07:54 +0000 (18:07 -0500)
committersenator <lebbeous@esilibrary.com>
Fri, 11 Mar 2011 23:07:54 +0000 (18:07 -0500)
Show authors too. And other little stuff.

Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm
Open-ILS/web/css/skin/default/opac/semiauto.css
Open-ILS/web/templates/default/opac/mylist.tt2
Open-ILS/web/templates/default/opac/myopac/lists.tt2
Open-ILS/web/templates/default/opac/parts/anon_list.tt2

index 7fcdfa9..5195b8d 100644 (file)
@@ -528,7 +528,8 @@ sub load_myopac_bookbag_update {
     my $action = $cgi->param('action');
     my $list_id = $cgi->param('list');
     my $add_rec = $cgi->param('add_rec');
-    my $del_item = $cgi->param('del_item');
+    my @del_item = $cgi->param('del_item');
+    my $shared = $cgi->param('shared');
     my $name = $cgi->param('name');
     my $success = 0;
     my $list;
@@ -538,7 +539,7 @@ sub load_myopac_bookbag_update {
         $list->name($name);
         $list->owner($e->requestor->id);
         $list->btype('bookbag');
-        $list->pub('f');
+        $list->pub($shared ? 't' : 'f');
         $success = $U->simplereq('open-ils.actor', 
             'open-ils.actor.container.create', $e->authtoken, 'biblio', $list)
 
@@ -583,8 +584,13 @@ sub load_myopac_bookbag_update {
             'open-ils.actor.container.item.create', $e->authtoken, 'biblio', $item);
 
     } elsif($action eq 'del_item') {
-        $success = $U->simplereq('open-ils.actor', 
-            'open-ils.actor.container.item.delete', $e->authtoken, 'biblio', $del_item);
+        foreach (@del_item) {
+            $success = $U->simplereq(
+                'open-ils.actor',
+                'open-ils.actor.container.item.delete', $e->authtoken, 'biblio', $_
+            );
+            last unless $success;
+        }
     }
 
     return $self->generic_redirect if $success;
index 5a73fdb..38a9755 100644 (file)
@@ -60,17 +60,19 @@ sub load_mylist_add {
 # Removes a record ID from My List
 sub load_mylist_del {
     my $self = shift;
-    my $rec_id = $self->cgi->param('record');
+    my @rec_ids = $self->cgi->param('record');
 
     my ($cache_key, $list) = $self->fetch_mylist;
     return $self->mylist_action_redirect unless $cache_key;
 
-    $list = [ grep { $_ ne $rec_id } @$list ];
+    my @keep;
+    foreach my $id (@$list) { push(@keep, $id) unless grep { $id eq $_ } @rec_ids; }
 
     $cache_key = $U->simplereq(
         'open-ils.actor',
         'open-ils.actor.anon_cache.set_value', 
-        $cache_key, ANON_CACHE_MYLIST, $list);
+        $cache_key, ANON_CACHE_MYLIST, \@keep
+    );
 
     return $self->mylist_action_redirect($cache_key);
 }
index 84748d0..602c9d2 100644 (file)
@@ -24,8 +24,8 @@
 
 #lib_selector_span { display: none }
 .float-left { float: left; }
-.opac-auto-039 { float: left; font-weight: bold; padding-top: 5px; }
-.opac-auto-040 { float: left; padding: 5px 0px 0px 10px; }
+.bookbag-name { float: left; font-weight: bold; padding-top: 5px; }
+.bookbag-share { float: left; padding: 5px 0px 0px 10px; }
 .left-corner { float: left; width: 163px; height: 30px; background: url('/images/utils-corner-mid.png') repeat-x top; }
 .float-right { float: right; }
 .opac-auto-045 { float: right; margin-right: 17px; }
@@ -55,7 +55,7 @@
 .opac-auto-070 { margin-bottom: 20px; }
 .opac-auto-071 { margin-bottom: 5px; }
 .opac-auto-072 { margin-left: 20px; }
-.opac-auto-073 { margin-left: 5px; margin-top: 5px; }
+.bookbag-list { margin-left: 5px; margin-top: 5px; width: 91%; border: 0;}
 #cn_browse_where { margin-left: 6px; }
 .opac-auto-075 { margin-right: 20px; }
 .opac-auto-076 { margin-right: 3px; }
 .opac-auto-168 { width: 100%; border: 2px solid #E0F0E0; margin-bottom: 20px; }
 .opac-auto-169 { width: 100%; height: 100%; }
 .opac-auto-170 { width: 100%; margin-top: 20px; border-top: 1px dotted #ccc; padding-top: 8px; }
-.opac-auto-171 { width: 100%; text-align: center; font-weight: 700; margin-top: 10px; }
+.opac-auto-171 { font-size: 120%; text-align: center; font-style: italic; }
 .opac-auto-172 { width: 100%; text-align: center; padding-bottom: 5px; }
 .opac-auto-173 { width: 10px; }
 .opac-auto-174 { width: 111px; height: 25px; }
index f115441..daccdb7 100644 (file)
@@ -9,7 +9,11 @@
     </div>
     <div id="content-wrapper">
         <div id="main-content">
-            [% INCLUDE "default/opac/parts/anon_list.tt2" %]
+            [%  IF ctx.mylist.size;
+                    INCLUDE "default/opac/parts/anon_list.tt2";
+                ELSE %]
+                <div class="opac-auto-171 opac-auto-097">[% l("You have not created a list yet."); %]</div>
+                [% END %]
             <div class="common-full-pad"></div>        
         </div>
     </div>
index 3da5062..85cf1c0 100644 (file)
         [% INCLUDE "default/opac/parts/anon_list.tt2" %]
         [% IF ctx.bookbags.size %]
         <div id='acct_lists_prime'>
+            [% FOR bbag IN ctx.bookbags %]
             <div id='acct_list_template'>
                 <div style="width:100%">
-                    <div style="float:left;font-weight:bold;padding-top:5px;" name='list_name'></div>
-
-                    <div style="float:left;padding:5px 0px 0px 10px;">
-
-                        <a target='_blank' name='share_list_rss' class='hide_me'><img 
-                            alt="[% l('RSS Feed') %]" border="0" src="[% ctx.media_prefix %]/images/small-rss.png"
-                            title="[% l('You are sharing this list') %]"/></a>
-                    </div>
-                    <div style="float:left;padding:5px 0px 0px 10px;">
-                        <a href="#" name="share_list_link">[% l('Share') %]</a>
-                    </div>
-                    <div style="float:left;padding:5px 0px 0px 10px;">
-                        <a href="#" name="remove_list">[% l('Remove') %]</a>
+                    <div class="bookbag-name">[% bbag.name %]</div>
+                    <div class="bookbag-share">
+                        [% IF bbag.pub == 't'; # XXX TODO %]
+                        <!-- <a target='_blank' name='share_list_rss'><img
+                            alt="[% l('RSS Feed') %]" border="0"
+                            src="[% ctx.media_prefix %]/images/small-rss.png"
+                            title="[% l('You are sharing this list') %]" /></a> -->
+                        [% END %]
                     </div>
+                    <form action="[% ctx.opac_root %]/myopac/list/update"
+                        method="POST">
+                        <div class="bookbag-share">
+                            <input type="hidden" name="list" value="[% bbag.id %]" />
+                            [% IF bbag.pub != 't' %]
+                            <input type="hidden" name="action" value="show" />
+                            <input type="submit" value="[% l('Share') %]" />
+                            [% ELSE %]
+                            <input type="hidden" name="action" value="hide" />
+                            <input type="submit" value="[% l('Hide') %]" />
+                            [% END %]
+                        </div>
+                    </form>
+                    <form action="[% ctx.opac_root %]/myopac/list/update"
+                        method="POST">
+                        <div class="bookbag-share">
+                            <input type="hidden" name="list" value="[% bbag.id %]" />
+                            <input type="hidden" name="action" value="delete" />
+                            <input type="submit" value="[% l('Delete List') %]" />
+                        </div>
+                    </form>
                     <div class="clear-both pad-bottom-five"></div>
                 </div>
-                <table id="acct_list_header" cellpadding='0' cellspacing='0' border='0'>
-                    <tr>
-                        <td width="1%" style="padding-left:10px;">
-                            <input type="checkbox" id="check_all_list" />
-                        </td>
-                        <td width="98%" style="padding-left:5px;">Title</td>
-                        <td width="1%">
-                            <select class="opac-auto-179" name="list_actions">
-                                <option value="0">[% l('-- Actions for this list --') %]</option>
-                                <option value="hold">[% l('Place Hold') %]</option>
-                                <option value="remove">[% l('Remove Items') %]</option>
-                            </select>
-                        </td>
-                    </tr>
-                </table>
-                <table cellpadding='0' cellspacing='5' border='0'
-                    width='91%' style='margin-left:5px;margin-top:5px;'>
-                    <tbody name='list_tbody'></tbody>
+                <form action="[% ctx.opac_root %]/myopac/list/update"
+                    method="POST">
+                <input type="hidden" name="list" value="[% bbag.id %]" />
+                <table cellpadding='0' cellspacing='0' border='0'>
+                    <thead id="acct_list_header">
+                        <tr>
+                            <td width="1%" style="padding-left: 10px;">
+                                <input type="checkbox" />
+                            </td>
+                            <td width="49%" style="padding-left: 5px;">[% l('Title') %]</td>
+                            <td width="49%">[% l('Author(s)') %]</td>
+                            <td width="1%" class="nowrap">
+                                <select class="opac-auto-179" name="action">
+                                    <option>[% l('-- Actions for this list --') %]</option>
+                                    <!-- XXX not ready yet<option value="hold">[% l('Place Hold') %]</option> -->
+                                    <option value="del_item">[% l('Remove Items') %]</option>
+                                </select>
+                                <input type="submit" value="[% l('Go') %]" />
+                            </td>
+                        </tr>
+                    </thead>
+                    <tbody>
+                        [% UNLESS bbag.items.size %]
+                        <tr><td colspan="4" class="opac-auto-171 opac-auto-097">
+                            [% l("This list contains no items.") %]
+                        </td></tr>
+                        [% END %]
+                        [% FOR item IN bbag.items;
+                            item_id = item.id;
+                            attrs = {marc_xml => ctx.bookbags_marc_xml.$item_id};
+                            PROCESS get_marc_attrs args=attrs %]
+                        <tr>
+                            <td class="opac-auto-097b" style="padding-left: 10px;"><input type="checkbox" name="del_item" value="[% item_id %]" /></td>
+                            <td class="opac-auto-097b" style="padding-left: 5px;">[% attrs.title %]</td>
+                            <td class="opac-auto-097b">[% attrs.author %]</td>
+                        </tr>
+                        [% END %]
+                    </tbody>
                 </table>
+                </form>
                 <br /><br />
             </div>
+            [% END %]
         </div>
         [% END %]
     </div>
     </div>
     <div style='text-align: center; font-weight: bold;' 
         class='hide_me' id='myopac_bookbags_none'>[% l("You have not created any bookbags") %]</div>
-    <table width='100%' class='data_grid data_grid_center hide_me'
-        id='myopac_bookbag_table'>
-        <thead>
-            <tr>
-                <td>[% l("Name") %]</td>
-                <td>[% l("# Items") %]</td>
-                <td>[% l("Shared") %]</td>
-                <td>[% l("Share / Hide") %]</td>
-                <td>[% l("Delete this bookbag?") %]</td>
-            </tr>
-        </thead>
-        <tbody id='myopac_bookbag_tbody'>
-            <tr>
-                <td>
-                    <a href='#' class='classic_link' name='myopac_expand_bookbag'> </a>
-                </td>
-                <td>
-                    <span name='myopac_bookbag_item_count'> </span>
-                    <span>[% l("Items") %]</span>
-                </td>
-                <td>
-                    <span name='myopac_bb_published_no' class='hide_me'>[% l("No") %]</span>
-                    <span name='myopac_bb_published_yes' class='hide_me'>[% l("Yes") %]</span>
-                    <a class='classic_link hide_me'>[% l("(View)") %]</a>
-
-                    <a class='unadorned_link hide_me'><img 
-                        alt="[% l('RSS Feed') %]" border="0"
-                        src="[% ctx.media_prefix %]/images/small-rss.png" title="[% l("ATOM Feed") %]" />
-                    </a>
-                </td>
-                <td>
-                    <a class='classic_link hide_me'>[% l("Hide") %]</a>
-                    <a class='classic_link hide_me'>[% l("Share this Bookbag") %]</a>
-                </td>
-                <td>
-                    <a class='classic_link' href='#'>[% l("Delete") %]</a>
-                </td>
-            </tr>
-        </tbody>
-    </table>
     <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'>
-        [% l("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>[% l("Title") %]</td>
-                <td>[% l("Authors") %]</td>
-                <td>[% l("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 name='myopac_bookbag_items_author'></td>
-                <td>
-                    <a name='myopac_bookbag_items_remove' class='classic_link'>[% l("remove") %]</a>
-                </td>    
-            </tr>
-        </tbody>
-    </table>
     <span id='bb_publish_text' class='hide_me'>[% l("Sharing a Bookbag means that the contents of the Bookbag will be visible to others.  To see the public view of a shared Bookbag, click the \"View\" link in the \"Shared\" column of the Bookbag list at the top of this page.") %]</span>
     <span id='myopac_remove_bb_item_confirm' class='hide_me'>
         [% l("Are you sure you wish to remove this bookbag item?") %]
         [% l("Bookbag successfully updated") %]
     </span>
 </div>
-<div style="margin-top: 6px;margin-left:20px;width:250px;padding:5px;" id="mylist_div">
-
-    <!-- new list creation -->
-    <div style="padding-bottom: 7px;">
-        <h2 style="font-weight:normal;">[% l('Create new list') %]</h2>
-        [% l('Enter the name of the new list:') %]<br/>
-        <input type="text" id="mylist_new" />
-    </div>
-
-    <table cellpadding="0" cellspacing="10" border="0">
-        <tr>
-            <td>
-                [% l('Share this list?') %]
-                <a href="#"><img alt="[% l('Sharing Help') %]"
-                    src="[% ctx.media_prefix %]/images/question-mark.png" /></a>
-            </td>
-            <td>
-                <input type="radio" value="0" name="shareList" checked="checked" />[% l('No') %]
-                <br/>
-                <input type="radio" value="1" name="shareList"/>[% l('Yes') %]
-            </td>
-        </tr>
-    </table>
-    <a href="#"><img alt="[% l('Submit') %]" src="[% ctx.media_prefix %]/images/btnSubmit.png"/></a>
-    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-    <a href="#"><img alt="[% l('Cancel') %]" src="[% ctx.media_prefix %]/images/btnCancel.png" /></a>
+<!-- new list creation -->
+<form action="[% ctx.opac_root %]/myopac/list/update" method="POST" id="create_form">
+<div style="padding-bottom: 7px;">
+    <h2>[% l('Create new list') %]</h2><a name="createnewlist"></a>
+    [% l('Enter the name of the new list:') %]<br/>
+    <input type="hidden" name="action" value="create" />
+    <input type="text" name="name" />
 </div>
+
+<table cellpadding="0" cellspacing="10" border="0">
+    <tr>
+        <td>
+            [% l('Share this list?') %]
+            <a href="#"><img alt="[% l('Sharing Help') %]"
+                src="[% ctx.media_prefix %]/images/question-mark.png" /></a>
+        </td>
+        <td>
+            <input type="radio" value="0" name="shared" id="shared_0" checked="checked" /><label for="shared_0">[% l('No') %]</label>
+            <br/>
+            <input type="radio" value="1" name="shared" id="shared_1"/><label for="shared_1">[% l('Yes') %]</label>
+        </td>
+    </tr>
+</table>
+<input type="image" alt="[% l('Submit') %]" src="[% ctx.media_prefix %]/images/btnSubmit.png"/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+<a href="javascript:void(0);"
+    onclick="document.getElementById('create_form').reset(); return false"><img
+    alt="[% l('Cancel') %]"
+    src="[% ctx.media_prefix %]/images/btnCancel.png" /></a>
+</form>
 [% END %]
index 2d1d1e3..e1e72fe 100644 (file)
@@ -1,4 +1,5 @@
         [% IF ctx.mylist.size %]
+        <form action="[% ctx.opac_root %]/mylist/del" method="POST">
         <div id='acct_list_template2'>
             <div style="width:100%">
                 <table cellpadding="0" cellspacing="0" border="0">
                 <div class="float-right"></div>
                 <div class="clear-both pad-bottom-five"></div>
             </div>
-            <table id="acct_list_header_anon" cellpadding='0' cellspacing='0' border='0'>
-                <tr>
-                    <td width="1%" style="padding-left:10px;"><input type="checkbox"/>
-                    </td>
-                    <td width="98%" style="padding-left:5px;">[% l('Title') %]</td>
-                    <td width="1%">
-                        <select class="opac-auto-179"
-                            name="list_actions" id="sel_all_list_anon">
-                            <option value="0">[% l('-- Actions for this list --') %]</option>
-                            <option value="hold">[% l('Place Hold') %]</option>
-                            <option value="remove">[% l('Remove Items') %]</option>
-                        </select>
-                    </td>
-                </tr>
-            </table>
-            <table cellpadding='0' cellspacing='5' border='0'
-                width='91%' style='margin-left:5px;margin-top:5px;'>
+            <table cellpadding='0' cellspacing='0' border='0'>
+                <thead id="acct_list_header_anon">
+                    <tr>
+                        <td width="1%" style="padding-left:10px;"><input type="checkbox"/>
+                        </td>
+                        <td width="49%" style="padding-left:5px;">[% l('Title') %]</td>
+                        <td width="49%" style="padding-left:5px;">[% l('Author(s)') %]</td>
+                        <td width="1%" class="nowrap">
+                            <select class="opac-auto-179" name="action">
+                                <option>[% l('-- Actions for this list --') %]</option>
+                                <!-- XXX not ready <option value="hold">[% l('Place Hold') %]</option> -->
+                                <option value="delete">[% l('Remove Items') %]</option>
+                            </select>
+                            <input type="submit" value="[% l('Go') %]" />
+                        </td>
+                    </tr>
+                </thead>
                 <tbody id='anon_list_tbody'>
                     [% FOR item IN ctx.mylist;
                         attrs = {marc_xml => ctx.mylist_marc_xml.$item};
                         PROCESS get_marc_attrs args=attrs %]
                     <tr>
-                        <td>[% attrs.title %]</td>
+                        <td class="opac-auto-097b" style="padding-left: 10px;">
+                            <input type="checkbox" name="record" value="[% item %]" />
+                        </td>
+                        <td class="opac-auto-097b" style="padding-left: 5px;">[% attrs.title %]</td>
+                        <td class="opac-auto-097b" style="padding-left: 5px;">[% attrs.author %]</td>
                     </tr>
                     [% END %]
                 </tbody>
             </table>
             <br /><br />
         </div>
+        </form>
         [% END %]