UI cleanup for batch-holds from lists
authorBill Erickson <berick@esilibrary.com>
Tue, 23 Aug 2011 14:42:54 +0000 (10:42 -0400)
committerBill Erickson <berick@esilibrary.com>
Tue, 23 Aug 2011 14:42:54 +0000 (10:42 -0400)
* Handle hold placement override with a single form and checkboxes
instead of a series individual forms

* Added a cancel button on the override page

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/web/css/skin/default/opac/style.css
Open-ILS/web/templates/default/opac/parts/place_hold.tt2
Open-ILS/web/templates/default/opac/parts/place_hold_result.tt2

index 547c578..b329daa 100644 (file)
@@ -401,6 +401,8 @@ sub load_place_hold {
     $ctx->{hold_type} = $cgi->param('hold_type');
     $ctx->{default_pickup_lib} = $e->requestor->home_ou; # unless changed below
 
+    return $self->post_hold_redirect unless @targets;
+
     $logger->info("Looking at hold targets: @targets");
 
     # if the staff client provides a patron barcode, fetch the patron
@@ -585,6 +587,12 @@ sub load_place_hold {
     # if successful, do some cleanup and return the 
     # user to the requesting page.
 
+    return $self->post_hold_redirect;
+}
+
+sub post_hold_redirect {
+    my $self = shift;
+
     # We also clear the patron_barcode (from the staff client)
     # cookie at this point (otherwise it haunts the staff user
     # later). XXX todo make sure this is best; also see that
@@ -599,8 +607,6 @@ sub load_place_hold {
             -expires => "-1h"
         )
     );
-
-    return Apache2::Const::OK;
 }
 
 
index f5354ff..72a5566 100644 (file)
@@ -1024,7 +1024,7 @@ a.dash-link:hover { text-decoration: underline !important; }
 .results-paginator-selected { color: red; }
 .inactive-hold { background: #e5e5e5; }
 
-#hold-items-list li { margin-bottom: 20px; }
+#hold-items-list td { padding: 5px; margin-bottom: 20px; }
 .hold-items-list-title { font-size: 120%; }
 .hold-items-list-problem { color: red; }
 
index d9fb32c..f3a564c 100644 (file)
         [% END %]
 
         <!-- loop through the holds and display status of request where appropriate -->
-        <ul id='hold-items-list'>
+        <table id='hold-items-list'>
         [% FOR hdata IN ctx.hold_data;
             attrs = {marc_xml => hdata.marc_xml};
             PROCESS get_marc_attrs args=attrs %]
-            <li>
-                <input type="hidden" name="hold_target" value="[% hdata.target.id | html %]" />
-                <div class='hold-items-list-title'>[% attrs.title_extended | html %]</div>
-            </li>
+            <tr>
+                <td>
+                    <input type="hidden" name="hold_target" value="[% hdata.target.id | html %]" />
+                    <div class='hold-items-list-title'>[% attrs.title_extended | html %]</div>
+                </td>
+            </tr>
         [% END %]
-        </ul>
+        </table>
 
         <p>
             [% l('Pickup location:') %]
index 0f03fa8..ac07c0d 100644 (file)
@@ -1,7 +1,6 @@
 [%  PROCESS "default/opac/parts/misc_util.tt2";
     PROCESS "default/opac/parts/hold_error_messages.tt2";
-    override_ok = [];
-    fail_count = 0;
+    override_possible = 0;
 %]
 
 <!-- TODO: CSS for big/strong-->
@@ -9,95 +8,90 @@
 <div id='holds_box' class='canvas' style='margin-top: 6px;'>
     <h1>[% l('Place Hold') %]</h1>
 
-    <ul id='hold-items-list'>
-
-    [% FOR hdata IN ctx.hold_data;
-        attrs = {marc_xml => hdata.marc_xml};
-        PROCESS get_marc_attrs args=attrs %]
-        <li>
-            <div class='hold-items-list-title'>[% attrs.title_extended | html %]</div>
-            <div>
-                [% IF hdata.hold_success %]
-
-                <div>[% l("Hold was successfully placed"); %]</div>
+    <form method="POST">
+        <input type="hidden" type="name" name="override" value="1" />
+        [% FOR k IN ctx.orig_params.keys %]
+        <input type="hidden" name="[% k %]" value="[% ctx.orig_params.$k | html %]" />
+        [% END %]
 
-                [% ELSIF hdata.hold_failed;
-                    fail_count = fail_count + 1 %]
+        <table id='hold-items-list'>
 
+        [% FOR hdata IN ctx.hold_data;
+            attrs = {marc_xml => hdata.marc_xml};
+            PROCESS get_marc_attrs args=attrs %]
+            <tr>
+                <td>
+                    [% 
+                        override = 0;
+                        IF hdata.could_override || hdata.hold_local_alert;
+                            override_possible = 1;
+                            override = 1;
+                        END;
+                    %]
+                    <input 
+                        type="checkbox" name="hold_target" value="[% hdata.target.id | html %]"
+                        [% IF override %] checked='checked' [% ELSE %] disabled='disabled' [% END %]/>
+                </td>
+                <td>
+                    <div class='hold-items-list-title'>[% attrs.title_extended | html %]</div>
+                    <div>
+                        [% IF hdata.hold_success %]
 
-                    <div><big><strong>[% l("Hold was not successfully placed"); %]</strong></big></div>
-                    [% IF hdata.hold_local_block %]
-                        <div>[% l("There is already a copy available at your local library.") %]</div>
-                    [% ELSIF hdata.hold_failed_event || hdata.hold_local_alert %]
-                        <div>
-                            <span class='hold-items-list-problem'>[% l('Problem:') %]</span>
-                            <span title="[% hdata.hold_failed_event.textcode | html %]">
-                                <em>[%
-                                        fail_part_key = hdata.hold_failed_event.payload.fail_part;
-                                        event_key = hdata.hold_failed_event.textcode;
+                        <div>[% l("Hold was successfully placed"); %]</div>
 
-                                        # display:
-                                        l(FAIL_PART_MSG_MAP.$fail_part_key) ||
-                                        l(EVENT_MSG_MAP.$event_key) ||
-                                        l(hdata.hold_failed_event.desc) ||
-                                        hdata.hold_failed_event.payload.fail_part ||
-                                        hdata.hold_failed_event.textcode ||
-                                        (hdata.hold_local_alert ?
-                                            l("There is already a copy available at your local library.") :
-                                            l("Unknown problem")) | html
-                                    %]</em>
-                                    [% IF event_key == 'PERM_FAILURE' %]
-                                    <div>[% l('Permission: "[_1]"', hdata.hold_failed_event.ilsperm) | html %]</div>
-                                    [% END %]
-                            </span>
+                        [% ELSIF hdata.hold_failed %]
 
-                            [% IF hdata.hold_copy_available %]
-                                <p>[%  l('Find a copy in the shelving location, "[_1]."', locname) | html %]</p>
-                            [% END %]
+                            <div><big><strong>[% l("Hold was not successfully placed"); %]</strong></big></div>
+                            [% IF hdata.hold_local_block %]
+                                <div>[% l("There is already a copy available at your local library.") %]</div>
+                            [% ELSIF hdata.hold_failed_event || hdata.hold_local_alert %]
+                                <div>
+                                    <span class='hold-items-list-problem'>[% l('Problem:') %]</span>
+                                    <span title="[% hdata.hold_failed_event.textcode | html %]">
+                                        <em>[%
+                                                fail_part_key = hdata.hold_failed_event.payload.fail_part;
+                                                event_key = hdata.hold_failed_event.textcode;
 
-                            [% IF hdata.could_override || hdata.hold_local_alert %]
-                                [% override_ok.push(hdata.target.id) %]
-                                <p>
-                                    <big>[% l("You have permission to place this hold anyway.") %]</big>
-                                    <br />
-                                    [% l("Click submit below to override and place your hold.") %]
-                                </p>
-                                <form method="POST">
-                                    <input type="hidden" type="name" name="override" value="1" />
-                                    <input type="hidden" name="hold_target" value="[% hdata.target.id | html %]" />
-                                    [% FOR k IN ctx.orig_params.keys %]
-                                    <input type="hidden" name="[% k %]" value="[% ctx.orig_params.$k | html %]" />
+                                                # display:
+                                                l(FAIL_PART_MSG_MAP.$fail_part_key) ||
+                                                l(EVENT_MSG_MAP.$event_key) ||
+                                                l(hdata.hold_failed_event.desc) ||
+                                                hdata.hold_failed_event.payload.fail_part ||
+                                                hdata.hold_failed_event.textcode ||
+                                                (hdata.hold_local_alert ?
+                                                    l("There is already a copy available at your local library.") :
+                                                    l("Unknown problem")) | html
+                                            %]</em>
+                                            [% IF event_key == 'PERM_FAILURE' %]
+                                            <div>[% l('Permission: "[_1]"', hdata.hold_failed_event.ilsperm) | html %]</div>
+                                            [% END %]
+                                    </span>
+                                    [% IF hdata.hold_copy_available %]
+                                        <p>[%  l('Find a copy in the shelving location, "[_1]."', locname) | html %]</p>
                                     [% END %]
-                                    <input type="image" name="submit" value="submit" title="[% l('Submit') %]"
-                                        alt="[% l('Submit') %]" src="[% ctx.media_prefix %]/images/btnSubmit.png" />
-                                </form>
-                            [% END %]
-                        </div>
-                    [% ELSIF hdata.hold_local_block;
-                        l("There is already a copy available at your local library");
-                    END;
-                END %]
-            </div>
-        </li>
-    [% END %]
-    <div>
-        [% IF fail_count > 1 AND fail_count == override_ok.size %]
+                                </div>
+                            [% END;
+                        END %]
+                    </div>
+                </td>
+            </tr>
+        [% END %]
+        </table>
+        [% IF override_possible %]
+            <br/>
             <hr/>
-            <form method="POST">
-                <input type="hidden" type="name" name="override" value="1" />
-                [% FOR k IN ctx.orig_params.keys %]
-                <input type="hidden" name="[% k %]" value="[% ctx.orig_params.$k | html %]" />
-                [% END %]
-                [% FOR target IN override_ok %]
-                    <input type="hidden" name="hold_target" value="[% target | html %]" />
-                [% END %]
-                <div class='big-strong'>[% l('Override all holds') %]</div>
-                <br/>
+            <div class='big-strong'>
+                [% |l %]You have permission to override some of the failed holds.<br/>  Click Submit to override and place your hold on the selected items.[% END %]
+            </div>
+            <span style='padding-right: 10px;'>
                 <input type="image" name="submit" value="submit" title="[% l('Submit') %]"
                     alt="[% l('Submit') %]" src="[% ctx.media_prefix %]/images/btnSubmit.png" />
-            </form>
+            </span>
         [% END %]
-    </div>
-    </ul>
+        <span>
+        <a href="[% CGI.param('redirect_to') || CGI.referer | html %]" id="holds_cancel"><img
+            alt="[% l('Cancel') %]" src="[% ctx.media_prefix %]/images/btnCancel.png" /></a>
+        </span>
+    </form>
 </div>