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>

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

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Owen Leonard 2020-10-20 13:40:04 +00:00 committed by Jonathan Druart
parent 23292b53a8
commit 70570debf3
2 changed files with 29 additions and 10 deletions

View File

@ -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 ){

View File

@ -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;