Bug 25402: Put OPAC cart download options into dropdown menu
authorOwen Leonard <oleonard@myacpl.org>
Wed, 6 May 2020 20:30:32 +0000 (20:30 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 24 Jun 2020 13:05:02 +0000 (15:05 +0200)
This patch modifies the process of downloading a cart so that it doesn't
involve a separate popup window.

To test, apply the patch and add some titles to the cart in the OPAC.

 - Open the cart
 - The "Download" button should now be a dropdown menu.
 - Selecting any of the download options should trigger a download
   prompt.
 - Test with and without some CSV profiles which have been configured
   for use in the OPAC

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt
opac/opac-basket.pl

index a89bf8b..2a94ae9 100644 (file)
                                 [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
                                     <a class="btn btn-link send" href="opac-basket.pl"><i class="fa fa-fw fa-envelope" aria-hidden="true"></i> Send</a>
                                 [% END %]
-                                <a class="btn btn-link download" href="opac-basket.pl"><i class="fa fa-fw fa-download" aria-hidden="true"></i> Download</a>
+
+                                <div id="download-cart" class="btn-group dropdown">
+                                    <a id="format" class="btn btn-link dropdown-toggle" data-toggle="dropdown" href="#"><i class="fa fa-fw fa-download" aria-hidden="true"></i> Download <b class="caret"></b></a>
+                                    <ul class="dropdown-menu pull-left" role="menu" aria-labelledby="format">
+                                        <li><a role="menuitem" class="download-cart" data-format="bibtex" href="#">BibTeX</a></li>
+                                        <li><a role="menuitem" class="download-cart" data-format="isbd" href="#">ISBD</a></li>
+                                        <li><a role="menuitem" class="download-cart" data-format="iso2709" href="#">MARC</a></li>
+                                        <li><a role="menuitem" class="download-cart" data-format="ris" href="#">RIS (Zotero, EndNote, others)</a></li>
+                                        [% FOREACH csv_profile IN csv_profiles %]
+                                            <li>
+                                                <a role="menuitem" class="download-cart" data-format="[% csv_profile.export_format_id | html %]" href="#">CSV - [% csv_profile.profile | html %]</a>
+                                            </li>
+                                        [% END %]
+                                    </ul>
+                                </div>
+
                                 <a class="btn btn-link remove empty" href="opac-basket.pl"><i class="fa fa-fw fa-trash" aria-hidden="true"></i> Empty and close</a>
                                 <a class="btn btn-link close" href="opac-basket.pl"><i class="fa fa-fw fa-times-circle" aria-hidden="true"></i> Hide window</a>
                                 [% IF ( verbose ) %]
                             <form name="myform" action="opac-basket.pl" method="get">
                                 <input type="hidden" name="records" id="records" />
                             </form>
+                            <form method="post" id="download_cart" action="/cgi-bin/koha/opac-downloadcart.pl">
+                                <input type="hidden" name="format" id="download_format" value="" />
+                                <input type="hidden" name="bib_list" value="[% bib_list | html %]" />
+                            </form>
 
                 </div> <!-- / #userbasket -->
             </div> <!-- / .span10 -->
                     sendBasket();
                 });
 
-                $(".download").click(function(e){
+                $(".download-cart").on("click", function(e){
                     e.preventDefault();
-                    downloadBasket();
+                    var format = $(this).data("format");
+                    $("#download_format").val( format );
+                    $("#download_cart").submit();
                 });
 
                 $(".empty").click(function(e){
index 6a454be..4a8d9f4 100755 (executable)
@@ -26,7 +26,7 @@ use C4::Circulation;
 use C4::Auth;
 use C4::Output;
 use Koha::RecordProcessor;
-
+use Koha::CsvProfiles;
 use Koha::AuthorisedValues;
 
 my $query = new CGI;
@@ -167,6 +167,7 @@ my $resultsarray = \@results;
 # my $itemsarray=\@items;
 
 $template->param(
+    csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records', opac_option => 1 }) ],
     bib_list => $bib_list,
     BIBLIO_RESULTS => $resultsarray,
 );