From 911d44133cdea12003dd3cc0d714dbae8e8b08ed Mon Sep 17 00:00:00 2001 From: Owen Leonard <oleonard@myacpl.org> Date: Tue, 20 Oct 2020 13:40:04 +0000 Subject: [PATCH] Bug 26752: Convert OPAC list download modal to dropdown This patch modifies the OPAC list page so that download options are shown in a dropdown menu instead of a modal dialog. This solves a bug introduced by the Bootstrap 4 upgrade and makes it consistent with the cart interface. To test, apply the patch and view the contents of a list in the OPAC which has multiple items on it. - In the toolbar at the top of the list contents table 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: Julian Maurice <julian.maurice@biblibre.com> --- .../bootstrap/en/modules/opac-shelves.tt | 33 +++++++++++++------ opac/opac-shelves.pl | 6 ++++ 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt index bf42a7072f..9328ac4857 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt @@ -208,7 +208,18 @@ <div class="list-actions"> <a class="btn btn-link newshelf" href="/cgi-bin/koha/opac-shelves.pl?op=add_form"><i class="fa fa-fw fa-plus" aria-hidden="true"></i> New list</a> <span class="sep">|</span> - <a href="/cgi-bin/koha/opac-downloadshelf.pl?shelfnumber=[% shelf.shelfnumber | uri %]" class="btn btn-link download" data-toggle="modal" data-target="#modalWin"><i class="fa fa-fw fa-download" aria-hidden="true"></i> Download list</a> + <div id="download-list" class="btn-group dropdown"> + <a id="format" class="btn btn-link dropdown-toggle" data-toggle="dropdown" href="/cgi-bin/koha/opac-downloadshelf.pl?shelfnumber=[% shelf.shelfnumber | html %]"><i class="fa fa-fw fa-download" aria-hidden="true"></i> Download <b class="caret"></b></a> + <div class="dropdown-menu pull-left" role="menu" aria-labelledby="format"> + <a role="menuitem" class="dropdown-item download-list" data-format="bibtex" href="#">BibTeX</a> + <a role="menuitem" class="dropdown-item download-list" data-format="isbd" href="#">ISBD</a> + <a role="menuitem" class="dropdown-item download-list" data-format="iso2709" href="#">MARC</a> + <a role="menuitem" class="dropdown-item download-list" data-format="ris" href="#">RIS (Zotero, EndNote, others)</a> + [% FOREACH csv_profile IN csv_profiles %] + <a role="menuitem" class="dropdown-item download-list" data-format="[% csv_profile.export_format_id | html %]" href="#">CSV - [% csv_profile.profile | html %]</a> + [% END %] + </div> + </div> [% IF Koha.Preference( 'opacuserlogin' ) == 1 %] <span class="sendlist"><a href="/cgi-bin/koha/opac-sendshelf.pl?shelfid=[% shelf.shelfnumber | uri %]" class="btn btn-link send" onclick="open('/cgi-bin/koha/opac-sendshelf.pl?shelfid=[% shelf.shelfnumber | html %]','win_form','scrollbars=yes,resizable=yes,height=400,width=500,top=50,left=100'); return false; "><i class="fa fa-fw fa-envelope" aria-hidden="true"></i> Send list</a></span> @@ -782,15 +793,10 @@ </div> <!-- / .container-fluid --> </div> <!-- / .main --> -<div class="modal" id="modalWin" role="dialog" aria-hidden="true" tabindex="-1"> - <div class="modal-content"> - <div class="modal-body"> - <div style="margin:1em;padding:1em;font-size:150%;"> - <img src="[% interface | html %]/[% theme | html %]/images/loading.gif" alt="" /> Loading - </div> - </div> - </div> -</div> +<form method="post" id="download_list" action="/cgi-bin/koha/opac-downloadshelf.pl"> + <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" /> + <input type="hidden" name="format" id="download_format" value="" /> +</form> <!-- DEBUG --> <div id="debug"></div> @@ -1044,6 +1050,13 @@ $(function() { ); }); + $(".download-list").on("click", function(e){ + e.preventDefault(); + var format = $(this).data("format"); + $("#download_format").val( format ); + $("#download_list").submit(); + }); + }); // document.ready function sortMenu( sorting_form ){ diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl index 0bcd273798..b94b4126ea 100755 --- a/opac/opac-shelves.pl +++ b/opac/opac-shelves.pl @@ -33,6 +33,7 @@ use C4::XSLT; use Koha::Biblios; use Koha::Biblioitems; use Koha::CirculationRules; +use Koha::CsvProfiles; use Koha::Items; use Koha::ItemTypes; use Koha::Patrons; @@ -385,6 +386,11 @@ if ( $op eq 'view' ) { itemsloop => \@items, sortfield => $sortfield, direction => $direction, + csv_profiles => [ + Koha::CsvProfiles->search( + { type => 'marc', used_for => 'export_records', staff_only => 0 } + ) + ], ); if ( $page ) { my $pager = $contents->pager; -- 2.20.1