LP#1673870: Use separate templates for ebook checkouts and holds
authorJeff Davis <jdavis@sitka.bclibraries.ca>
Mon, 26 Jun 2017 23:23:54 +0000 (16:23 -0700)
committerBill Erickson <berickxx@gmail.com>
Fri, 1 Sep 2017 20:06:50 +0000 (16:06 -0400)
Previously we used the same TT2 template for listing checkouts and
performing a checkout, and for listing holds and placing a hold.  This
leads to problems; in particular, URL parameters required for checkout
and hold actions were "sticky," so viewing your holds after placing a
hold would show the "Place Hold" UI instead of a list of holds.  This
commit introduces separate templates for ebook actions as a workaround.

Signed-off-by: Jeff Davis <jdavis@sitka.bclibraries.ca>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/templates/opac/myopac/ebook_checkout.tt2 [new file with mode: 0644]
Open-ILS/src/templates/opac/myopac/ebook_circs.tt2
Open-ILS/src/templates/opac/myopac/ebook_holds.tt2
Open-ILS/src/templates/opac/myopac/ebook_place_hold.tt2 [new file with mode: 0644]
Open-ILS/src/templates/opac/parts/record/summary.tt2
Open-ILS/src/templates/opac/parts/result/table.tt2
Open-ILS/web/js/ui/default/opac/ebook_api/loggedin.js

diff --git a/Open-ILS/src/templates/opac/myopac/ebook_checkout.tt2 b/Open-ILS/src/templates/opac/myopac/ebook_checkout.tt2
new file mode 100644 (file)
index 0000000..2b38da3
--- /dev/null
@@ -0,0 +1,33 @@
+[%  PROCESS "opac/parts/header.tt2";
+    PROCESS "opac/parts/misc_util.tt2";
+    PROCESS "opac/parts/myopac/column_sort_support.tt2";
+    WRAPPER "opac/parts/myopac/base.tt2";
+    myopac_page = "ebook_checkout";
+%]
+<h3 class="sr-only">[% l('Check Out E-Item') %]</h3>
+<div id='myopac_checked_div'>
+
+    <div class="header_middle">
+        <span class="float-left">[% l('Check Out E-Item') %]</span>
+    </div>
+    <div class="clear-both"></div>
+    <div id="ebook_checkout_failed" class="warning_box hidden">[% l('E-item could not be checked out.') %]</div>
+    <div id="ebook_checkout_succeeded" class="success hidden">[% l('E-item successfully checked out.') %]</div>
+    <div id='ebook_circs_main' class="hidden">
+        <table id="ebook_circs_main_table"
+            title="[% l('Check Out E-Item') %]"
+            class="table_no_border_space table_no_cell_pad item_list_padding">
+            <thead>
+            <tr>
+                <th>[% l("Title") %]</th>
+                <th>[% l("Author") %]</th>
+                <th>[% l("Due Date") %]</th>
+                <th>[% l("Actions") %]</th>
+            </tr>
+            </thead>
+            <tbody id="ebook_circs_main_table_body"></tbody>
+        </table>
+    </div>
+</div>
+[% END %]
+
index 7af1a8d..1bee6e7 100644 (file)
@@ -3,11 +3,6 @@
     PROCESS "opac/parts/myopac/column_sort_support.tt2";
     WRAPPER "opac/parts/myopac/base.tt2";
     myopac_page = "ebook_circs";
-    IF CGI.param("action") == 'checkout';
-        ebook_circs_title = l('Check Out E-Item');
-    ELSE;
-        ebook_circs_title = l('E-Items Currently Checked Out');
-    END;
 %]
 <h3 class="sr-only">[% l('E-Items Currently Checked Out') %]</h3>
 <div id='myopac_checked_div'>
     </div>
 
     <div class="header_middle">
-        <span class="float-left">[% ebook_circs_title %]</span>
+        <span class="float-left">[% l('E-Items Currently Checked Out') %]</span>
     </div>
     <div class="clear-both"></div>
     <div id="no_ebook_circs" class="warning_box hidden">[% l('You have no e-items checked out.') %]</div>
-    <div id="ebook_checkout_failed" class="warning_box hidden">[% l('E-item could not be checked out.') %]</div>
-    <div id="ebook_checkout_succeeded" class="success hidden">[% l('E-item successfully checked out.') %]</div>
     <div id='ebook_circs_main' class="hidden">
         <table id="ebook_circs_main_table"
-            title="[% ebook_circs_title %]"
+            title="[% l('E-Items Currently Checked Out') %]"
             class="table_no_border_space table_no_cell_pad item_list_padding">
             <thead>
             <tr>
index eeefea3..1a77a71 100644 (file)
@@ -4,13 +4,6 @@
     PROCESS "opac/parts/myopac/column_sort_support.tt2";
     WRAPPER "opac/parts/myopac/base.tt2";
     myopac_page = "ebook_holds";
-    IF CGI.param("action") == 'place_hold';
-        ebook_holds_title = l('Place Hold on E-Item');
-    ELSIF CGI.param("action") == 'cancel_hold';
-        ebook_holds_title = l('Cancel Hold on E-Item');
-    ELSE;
-        ebook_holds_title = l('E-Items on Hold');
-    END;
     limit = (ctx.holds_limit.defined) ? ctx.holds_limit : 0;
     offset = (ctx.holds_offset.defined) ? ctx.holds_offset : 0;
     count = (ctx.holds_ids.size.defined) ? ctx.holds_ids.size : 0;
     </div>
 
     <div class="header_middle">
-        <span class="float-left">[% ebook_holds_title %]</span>
+        <span class="float-left">[% l('E-Items on Hold') %]</span>
     </div>
     <div class="clear-both"></div>
     <div id="no_ebook_holds" class="warning_box hidden">[% l('You have no e-item holds.') %]</div>
-    <div id="ebook_place_hold_failed" class="warning_box hidden">[% l('Hold could not be placed.') %]</div>
-    <div id="ebook_place_hold_succeeded" class="success hidden">[% l('E-item is now on hold.') %]</div>
     <div id="ebook_cancel_hold_failed" class="warning_box hidden">[% l('Hold could not be canceled.') %]</div>
     <div id="ebook_cancel_hold_succeeded" class="success hidden">[% l('Your hold has been canceled.') %]</div>
     <div id='ebook_holds_main' class="hidden">
         <table id="ebook_holds_main_table"
-            title="[% ebook_holds_title %]"
+            title="[% l('E-Items on Hold') %]"
             class="table_no_border_space table_no_cell_pad item_list_padding">
             <thead>
             <tr>
diff --git a/Open-ILS/src/templates/opac/myopac/ebook_place_hold.tt2 b/Open-ILS/src/templates/opac/myopac/ebook_place_hold.tt2
new file mode 100644 (file)
index 0000000..6cdbc54
--- /dev/null
@@ -0,0 +1,35 @@
+[%  PROCESS "opac/parts/header.tt2";
+    PROCESS "opac/parts/misc_util.tt2";
+    PROCESS "opac/parts/hold_status.tt2";
+    PROCESS "opac/parts/myopac/column_sort_support.tt2";
+    WRAPPER "opac/parts/myopac/base.tt2";
+    myopac_page = "ebook_place_hold";
+%]
+<h3 class="sr-only">[% l('Place Hold on E-Item') %]</h3>
+<div id='myopac_holds_div'>
+
+    <div class="header_middle">
+        <span class="float-left">[% l('Place Hold on E-Item') %]</span>
+    </div>
+    <div class="clear-both"></div>
+    <div id="ebook_place_hold_failed" class="warning_box hidden">[% l('Hold could not be placed.') %]</div>
+    <div id="ebook_place_hold_succeeded" class="success hidden">[% l('E-item is now on hold.') %]</div>
+    <div id='ebook_holds_main' class="hidden">
+        <table id="ebook_holds_main_table"
+            title="[% l('Place Hold on E-Item') %]"
+            class="table_no_border_space table_no_cell_pad item_list_padding">
+            <thead>
+            <tr>
+                <th>[% l("Title") %]</th>
+                <th>[% l("Author") %]</th>
+                <th>[% l("Expire Date") %]</th>
+                <th>[% l("Status") %]</th>
+                <th>[% l("Actions") %]</th>
+            </tr>
+            </thead>
+            <tbody id="ebook_holds_main_table_body"></tbody>
+        </table>
+    </div>
+</div>
+[% END %]
+
index c9b9919..f893cf6 100644 (file)
 
             [%- IF ebook_api.enabled == 'true' && args.ebook %]
             <div id="[%- ctx.bre_id -%]_ebook_checkout" class="rdetail_aux_utils ebook_action hidden">
-                <a href="[% mkurl(ctx.opac_root _ '/myopac/ebook_circs',
+                <a href="[% mkurl(ctx.opac_root _ '/myopac/ebook_checkout',
                     {title => args.ebook.ebook_id, vendor => args.ebook.vendor, action => 'checkout'}, stop_parms) %]"
                 class="no-dec" rel="nofollow" vocab=""><img src="[% ctx.media_prefix %]/images/green_check.png"
                     [% img_alt(l('Check Out [_1]', attrs.title)) %]/>
                 <span class="place_hold">[% l('Check Out E-Item') %]</span></a>
             </div>
             <div id="[%- ctx.bre_id -%]_ebook_place_hold" class="rdetail_aux_utils ebook_action hidden">
-                <a href="[% mkurl(ctx.opac_root _ '/myopac/ebook_holds',
+                <a href="[% mkurl(ctx.opac_root _ '/myopac/ebook_place_hold',
                     {title => args.ebook.ebook_id, vendor => args.ebook.vendor, action => 'place_hold'}, stop_parms) %]"
                 class="no-dec" rel="nofollow" vocab=""><img src="[% ctx.media_prefix %]/images/green_check.png"
                     [% img_alt(l('Place Hold on [_1]', attrs.title)) %]/>
index df87911..35dc615 100644 (file)
@@ -399,7 +399,7 @@ END;
 
                                                         [%- IF ebook_api.enabled == 'true' && args.ebook %]
                                                         <div id="[%- rec.id -%]_ebook_checkout" class="results_aux_utils result_util ebook_action hidden">
-                                                            <a href="[% mkurl(ctx.opac_root _ '/myopac/ebook_circs',
+                                                            <a href="[% mkurl(ctx.opac_root _ '/myopac/ebook_checkout',
                                                                 {title => args.ebook.ebook_id, vendor => args.ebook.vendor, action => 'checkout'},
                                                                 ['query','tag','subfield','term','_special','sort','page']) %]"
                                                                 [% html_text_attr('title', l('Check Out [_1]', attrs.title)) %]
@@ -408,7 +408,7 @@ END;
                                                                 alt=""/><span class="result_place_hold">[% l('Check Out E-Item') %]</span></a>
                                                         </div>
                                                         <div id="[%- rec.id -%]_ebook_place_hold" class="results_aux_utils result_util ebook_action hidden">
-                                                            <a href="[% mkurl(ctx.opac_root _ '/myopac/ebook_holds',
+                                                            <a href="[% mkurl(ctx.opac_root _ '/myopac/ebook_place_hold',
                                                                 {title => args.ebook.ebook_id, vendor => args.ebook.vendor, action => 'place_hold'},
                                                                 ['query','tag','subfield','term','_special','sort','page']) %]"
                                                                 [% html_text_attr('title', l('Place Hold on [_1]', attrs.title)) %]
index ae2cd38..6f73789 100644 (file)
@@ -70,6 +70,10 @@ function addTransactionsToPage() {
             updateHoldView();
         if (myopac_page === 'ebook_holds_ready')
             updateHoldView();
+        if (myopac_page === 'ebook_checkout')
+            getReadyForCheckout();
+        if (myopac_page === 'ebook_place_hold')
+            getReadyForHold();
     }
 }
         
@@ -104,11 +108,7 @@ function updateMyAccountSummary() {
 }
 
 function updateCheckoutView() {
-    if (typeof ebook_action.type !== 'undefined') {
-        if (ebook_action.type == 'checkout') {
-            getReadyForCheckout();
-        }
-    } else if (xacts.checkouts.length < 1) {
+    if (xacts.checkouts.length < 1) {
         dojo.removeClass('no_ebook_circs', "hidden");
     } else {
         dojo.forEach(xacts.checkouts, function(x) {
@@ -127,12 +127,6 @@ function updateCheckoutView() {
 }
 
 function updateHoldView() {
-    // handle hold actions
-    if (typeof ebook_action.type !== 'undefined') {
-        getReadyForHold();
-        return;
-    }
-
     if (myopac_page === 'ebook_holds_ready') {
         // only show holds that are ready for checkout
         var holds = xacts.holds_ready;