LP1895676: Record Print and Email Enhancements for Bootstrap OPAC
authorJason Boyer <JBoyer@equinoxinitiative.org>
Fri, 4 Dec 2020 19:13:48 +0000 (14:13 -0500)
committerGalen Charlton <gmc@equinoxinitiative.org>
Mon, 8 Feb 2021 15:56:46 +0000 (10:56 -0500)
Bring the improvements from LP1749475 to the Bootstrap OPAC.

Signed-off-by: Jason Boyer <JBoyer@equinoxinitiative.org>
Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Open-ILS/src/templates-bootstrap/opac/parts/anon_list.tt2
Open-ILS/src/templates-bootstrap/opac/parts/cart.tt2
Open-ILS/src/templates-bootstrap/opac/parts/record/summary.tt2
Open-ILS/src/templates-bootstrap/opac/record/email.tt2
Open-ILS/src/templates-bootstrap/opac/record/email_preview.tt2 [new file with mode: 0644]
Open-ILS/src/templates-bootstrap/opac/record/print.tt2
Open-ILS/src/templates-bootstrap/opac/record/print_preview.tt2 [new file with mode: 0644]

index 3012d28..5aa3181 100755 (executable)
@@ -4,6 +4,7 @@
         <h3>[% l('Basket') %]</h3>
 
         <form action="[% mkurl(ctx.opac_root _ '/mylist/move') %]" method="post">
+        <input type="hidden" name="anonsort" value="[% CGI.param('anonsort') %]" />
         <input type="hidden" name="orig_referrer" value="[% CGI.referer | html %]" />
         <input type="hidden" name="redirect_to" value="[% mkurl('', {}, ['list_none_selected', 'cart_none_selected']) %]" />
         <div class="bbag-action" style="clear:both;">
index 8451413..9a97f36 100755 (executable)
@@ -4,8 +4,8 @@
       <option value="">[% l('-- Basket Actions --') %]</option>
       <option value="[% mkurl(ctx.opac_root _ '/mylist', {}) %]">[% l('View Basket') %]</option>
       <option value="[% mkurl(ctx.opac_root _ '/mylist/move', { action => 'place_hold', entire_list => 1 }) %]">[% l('Place Holds') %]</option>
-      <option value="[% mkurl(ctx.opac_root _ '/mylist/print', {}) %]">[% l('Print Title Details') %]</option>
-      <option value="[% mkurl(ctx.opac_root _ '/mylist/email', {}) %]">[% l('Email Title Details') %]</option>
+      <option value="[% mkurl(ctx.opac_root _ '/mylist/move', { action => 'print', entire_list => 1}) %]">[% l('Print Title Details') %]</option>
+      <option value="[% mkurl(ctx.opac_root _ '/mylist/move', { action => 'email', entire_list => 1}) %]">[% l('Email Title Details') %]</option>
       [% IF !ctx.is_browser_staff %]
       <option value="[% mkurl(ctx.opac_root _ '/myopac/lists', { move_cart_by_default => 1, from_basket => 1 }) %]">[% l('Add Basket to Saved List') %]</option>
       [% END %]
index 6ae5c9b..8d4d810 100755 (executable)
@@ -415,9 +415,9 @@ ctx.metalinks.push('
 
                
                   
-                    <a href="[% mkurl(ctx.opac_root _ '/record/print/' _ ctx.bre_id) %]" class="btn btn-action" role="button" rel="nofollow"
+                    <a href="[% mkurl(ctx.opac_root _ '/record/print_preview/' _ ctx.bre_id) %]" class="btn btn-action" role="button" rel="nofollow"
                         vocab=""><i class="fas fa-print" aria-hidden="true"></i>[% l('Print') %]</a> 
-                    <a href="[% mkurl(ctx.opac_root _ '/record/email/' _ ctx.bre_id) %]" class="btn btn-action" role="button" rel="nofollow"
+                    <a href="[% mkurl(ctx.opac_root _ '/record/email_preview/' _ ctx.bre_id) %]" class="btn btn-action" role="button" rel="nofollow"
                         vocab=""> <i class="fas fa-envelope-open-text" aria-hidden="true"></i>[% l('Email') %]</a>
                 
                 [%- IF ctx.refworks.enabled == 'true' %]
@@ -564,4 +564,4 @@ ctx.metalinks.push('
 <hr>
 <div class="col-12">
     [%- INCLUDE "opac/parts/record/extras.tt2" %]
-</div>
\ No newline at end of file
+</div>
index 70da6d2..a08b743 100755 (executable)
@@ -7,14 +7,13 @@
     <br class="clear-both" />
     <div id="content-wrapper" class="content-wrapper-record-page">
         <div id='main-content'>
-            [% IF ctx.user.email %]
             <div class="alert alert-success" role="alert">
-                <h2>[% l('Your email has been queued for delivery to [_1]', ctx.user.email ) %]</h2>
+                <h2>[% l('Your email has been queued for delivery to [_1]', ctx.email ) %]</h2>
             </div>
-            [% ELSE %]
+            [% IF ctx.user && !ctx.user.email %]
             <div class="alert alert-danger" role="alert">
             <h2>
-                [% here_link_text = "<a href=\"${ctx.opac_root}/myopac/update_email?return_to_referer=1\">";
+                [% here_link_text = "<a href=\"${ctx.opac_root}/myopac/update_email\">";
                    here_link_text = here_link_text _ l("Set your email address here");
                    here_link_text = here_link_text _ "</a>";
                    l('Your account does not currently have an email address set. [_1]', here_link_text) %]
diff --git a/Open-ILS/src/templates-bootstrap/opac/record/email_preview.tt2 b/Open-ILS/src/templates-bootstrap/opac/record/email_preview.tt2
new file mode 100644 (file)
index 0000000..f28cf89
--- /dev/null
@@ -0,0 +1,116 @@
+[%- PROCESS "opac/parts/header.tt2";
+    WRAPPER "opac/parts/base.tt2";
+    INCLUDE "opac/parts/topnav.tt2";
+    ctx.page_title = l("Email Record Preview");
+    PROCESS "opac/parts/org_selector.tt2";
+-%]
+    <h2 class="sr-only">[% l('Email Record Preview') %]</h2>
+    [% INCLUDE "opac/parts/searchbar.tt2" %]
+    <br class="clear-both" />
+    <div id="content-wrapper" class="content-wrapper-record-page">
+
+    <form id="previewForm" method="POST" action="[% mkurl('',{},['locg','format','sort','sort_dir','context_org','bre_id','is_list']) %]">
+        <input type="hidden" name="old_event" value="[% ctx.preview_record.id %]"/>
+        <input type="hidden" name="bre_id" value="[% ctx.bre_id %]"/>
+        <input type="hidden" name="locg" value="[% ctx.selected_print_email_loc %]"/>
+        <input type="hidden" name="is_list" value="[% ctx.is_list %]"/>
+        <input type="hidden" name="redirect_to" value="[% ctx.redirect_to | html %]"/>
+
+        <div class="searchbar">
+            <label for="email">[% l('Email Address: ') %]
+                <input class="form-control" id="email" type="text" name="email" value="[% ctx.email || ctx.user.email %]"/>
+            </label>
+        </div>
+
+        <div class="searchbar">
+            <label for="subject">[% l('Custom Email Subject: ') %]
+                <input class="form-control" id="subject" type="text" name="subject" value="[% ctx.subject || '' %]"/>
+            </label>
+        </div>
+
+        <div class="searchbar">
+            <label for="formats">[% l('Format: ') %]
+                <select class="form-control" id="formats" name="format">
+                    [% FOR f IN ctx.formats %]
+                        [% IF !ctx.format_obj; ctx.format_obj = f; END %]
+                        <option [% IF f.id == ctx.format; ctx.format_obj = f; 'selected="selected"'; END %] value="[% f.id %]">[% f.name | html %]</option>
+                    [% END %]
+                </select>
+            </label>
+        </div>
+
+        [% IF ctx.is_list == '1' %]
+        <div class="searchbar">
+            <label for="sortby">[% l('Sort by: ') %]
+                <select class="form-control" id="sortby" name="sort">
+                    <option [% IF ctx.sort == 'author'; 'selected="selected"'; END %] value="author">[% l('Author') %]</option>
+                    <option [% IF ctx.sort == 'title'; 'selected="selected"'; END %] value="title">[% l('Title') %]</option>
+                    <option [% IF ctx.sort == 'pubdate'; 'selected="selected"'; END %] value="pubdate">[% l('Publication Date') %]</option>
+                </select>
+                <select class="form-control" id="sort_dir" name="sort_dir">
+                    <option [% IF ctx.sort_dir == 'ascending'; 'selected="selected"'; END %] value="ascending">[% l('Ascending') %]</option>
+                    <option [% IF ctx.sort_dir == 'descending'; 'selected="selected"'; END %] value="descending">[% l('Descending') %]</option>
+                </select>
+            </label>
+        </div>
+        [% END %]
+
+        [% IF ctx.format_obj.holdings == 't' %]
+        <div class="searchbar">
+            <label for="context_org">[% l('Holdings Library: ') %]
+                [% INCLUDE build_org_selector id='context_org' name='context_org' value=ctx.selected_print_email_loc %]</br>
+            </label>
+        </div>
+        [% END %]
+
+        <br/>
+        <div class="searchbar">
+            <button type="submit" class="btn btn-confirm">[% l("Update") %]</button>
+        </div>
+        <br/>
+    </form>
+
+        <hr/>
+
+    <form id="emailForm" method="POST" action="[% mkurl('../email/' _ ctx.preview_record.id,{},['locg','old_event','email','format','sort','bre_id','is_list']) %]">
+        <input type="hidden" name="old_event" value="[% ctx.preview_record.id %]"/>
+        <input type="hidden" name="bre_id" value="[% ctx.bre_id %]"/>
+        <input type="hidden" name="locg" value="[% ctx.selected_print_email_loc %]"/>
+        <input type="hidden" name="is_list" value="[% ctx.is_list %]"/>
+        <input type="hidden" name="redirect_to" value="[% ctx.redirect_to | html %]"/>
+        <input type="hidden" name="email" value="[% ctx.email || ctx.user.email %]"/>
+
+
+        [% IF ctx.preview_record.template_output %]
+            [% IF ctx.captcha.key %]
+            <div class="searchbar">
+                <p>[% l('Please prove you are not a robot by answering the following addition problem:') %]</p>
+                <p>[% ctx.captcha.left %] + [% ctx.captcha.right %] = <input type="text" name="capanswer"/></p>
+                <input type="hidden" name="capkey" value="[% ctx.captcha.key %]"/>
+            </div>
+            [% END %]
+            <div class="searchbar">
+                <button type="submit" class="btn btn-confirm">[% l("Email Now") %]</button> |
+                <a class="btn btn-confirm" href="[% ctx.redirect_to | html %]">[% l("Return") %]</a>
+                <br/>
+                <br/>
+                <pre>[% ctx.preview_record.template_output.data %]</pre>
+            </div>
+        [% ELSE %]
+            <div class="alert alert-danger" role="alert">
+                [% l(
+                    'Error previewing record: [_1]',
+                        (ctx.preview_record.textcode ? ctx.preview_record.textcode _ ' / ' _ ctx.preview_record.desc : 0) ||
+                        ctx.preview_record.error_output.data ||
+                        l('No record data returned from server')
+                    ) | html %]
+            </div>
+            <hr />
+            <div class="searchbar">
+                <a class="btn btn-confirm" href="[% ctx.redirect_to | html %]">[% l("Return") %]</a>
+            </div>
+        [% END %]
+        <br class="clear-both" />
+    </form>
+    </div>
+[%- END %]
index ee2577c..15fbc21 100755 (executable)
@@ -6,18 +6,21 @@
         <style type="text/css" media="print">.noprint {display: none}</style>
     </head>
     <body onload="if (document.getElementById('printable-record')) window.print();">
-        [% IF ctx.printable_record.template_output %]
-        <tt id="printable-record">
-            [% ctx.printable_record.template_output.data %]
-        </tt>
+        <div class='noprint'>
+            [% IF ctx.redirect_to %]
+            <p>[ <a href="[% ctx.redirect_to | html %]">[% l("Return") %]</a> ] </p>
+            [% ELSE %]
+            <p>[ <a href="[% mkurl(ctx.opac_root  _ '/record/' _ ctx.bre_id) %]">[% l("Back to Record") %]</a> ]</p>
+            [% END %]
+            <hr />
+        </div>
+        [% IF ctx.print_data %]
+        <div id="printable-record">
+            [% ctx.print_data %]
+        </div>
         [% ELSE %]
         <div class="noprint print-error">
-            [% l(
-                'Error printing record: [_1]',
-                    (ctx.printable_record.textcode ? ctx.printable_record.textcode _ ' / ' _ ctx.printable_record.desc : 0) ||
-                    ctx.printable_record.error_output.data ||
-                    l('No record data returned from server')
-                ) | html %]
+            [% l( 'Error printing record: [_1]', l('No record data returned from server')) | html %]
         </div>
         [% END %]
         <div class='noprint'>
diff --git a/Open-ILS/src/templates-bootstrap/opac/record/print_preview.tt2 b/Open-ILS/src/templates-bootstrap/opac/record/print_preview.tt2
new file mode 100644 (file)
index 0000000..8880ba1
--- /dev/null
@@ -0,0 +1,85 @@
+[%- PROCESS "opac/parts/header.tt2";
+    WRAPPER "opac/parts/base.tt2";
+    INCLUDE "opac/parts/topnav.tt2";
+    ctx.page_title = l("Print Record Preview");
+    PROCESS "opac/parts/org_selector.tt2";
+-%]
+    <h2 class="sr-only">[% l('Print Record Preview') %]</h2>
+    [% INCLUDE "opac/parts/searchbar.tt2" %]
+    <br class="clear-both" />
+    <div id="content-wrapper" class="content-wrapper-record-page">
+
+    <form id="previewForm" action="[% mkurl('',{},['locg','format','sort','sort_dir','context_org','bre_id','is_list']) %]">
+        <input type="hidden" name="old_event" value="[% ctx.preview_record.id %]"/>
+        <input type="hidden" name="bre_id" value="[% ctx.bre_id %]"/>
+        <input type="hidden" name="locg" value="[% ctx.selected_print_email_loc %]"/>
+        <input type="hidden" name="is_list" value="[% ctx.is_list %]"/>
+        <input type="hidden" name="redirect_to" value="[% ctx.redirect_to | html %]"/>
+
+        <div class="searchbar">
+            <label for="formats">[% l('Format: ') %]
+                <select class="form-control w-100" id="formats" name="format">
+                    [% FOR f IN ctx.formats %]
+                        [% IF !ctx.format_obj; ctx.format_obj = f; END %]
+                        <option [% IF f.id == ctx.format; ctx.format_obj = f; 'selected="selected"'; END %] value="[% f.id %]">[% f.name | html %]</option>
+                    [% END %]
+                </select>
+            </label>
+        </div>
+
+        [% IF ctx.is_list == '1' %]
+        <div class="searchbar">
+            <label for="sortby">[% l('Sort by: ') %]
+                <select id="sortby" name="sort">
+                    <option [% IF ctx.sort == 'author'; 'selected="selected"'; END %] value="author">[% l('Author') %]</option>
+                    <option [% IF ctx.sort == 'title'; 'selected="selected"'; END %] value="title">[% l('Title') %]</option>
+                    <option [% IF ctx.sort == 'pubdate'; 'selected="selected"'; END %] value="pubdate">[% l('Publication Date') %]</option>
+                </select>
+                <select id="sort_dir" name="sort_dir">
+                    <option [% IF ctx.sort_dir == 'ascending'; 'selected="selected"'; END %] value="ascending">[% l('Ascending') %]</option>
+                    <option [% IF ctx.sort_dir == 'descending'; 'selected="selected"'; END %] value="descending">[% l('Descending') %]</option>
+                </select>
+            </label>
+        </div>
+        [% END %]
+
+        [% IF ctx.format_obj.holdings == 't' %]
+        <div class="searchbar">
+            <label for="context_org">[% l('Holdings Library: ') %]
+                [% INCLUDE build_org_selector id='context_org' name='context_org' value=ctx.selected_print_email_loc %]</br>
+            </label>
+        </div>
+        [% END %]
+
+        <br/>
+        <div class="searchbar">
+            <button type="submit" class="btn btn-confirm" >[% l("Update") %]</button>
+        </div>
+        <br/>
+        <hr/>
+       
+        [% IF ctx.preview_record.template_output %]
+        <div class="searchbar">
+            <a class="btn btn-confirm" href="[% mkurl('../print/' _ ctx.preview_record.id, {redirect_to => ctx.redirect_to}) %]">[% l("Print Now") %]</a> |
+            <a class="btn btn-confirm" href="[% ctx.redirect_to | html %]">[% l("Return") %]</a>
+        </div>
+            <br/>
+            <div>[% ctx.preview_record.template_output.data %]</div>
+        [% ELSE %]
+            <div class="alert alert-danger" role="alert">
+                [% l(
+                    'Error previewing record: [_1]',
+                        (ctx.preview_record.textcode ? ctx.preview_record.textcode _ ' / ' _ ctx.preview_record.desc : 0) ||
+                        ctx.preview_record.error_output.data ||
+                        l('No record data returned from server')
+                    ) | html %]
+            </div>
+            <hr />
+            <div>
+                <a class="opac-button" href="[% ctx.redirect_to | html %]">[% l("Return") %]</a>
+            </div>
+        [% END %]
+        <br class="clear-both" />
+    </form>
+    </div>
+[%- END %]