From e185aaf19b1efeee342fc32a35323a0a9ea03a58 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 2 Jul 2014 12:50:54 -0400 Subject: [PATCH] Bug 12519 - Convert OPAC list download pop-up to modal dialog This patch changes the OPAC list download process so that the download link triggers a modal dialog instead of a pop-up window. This streamlines the process a little bit and makes it work better on mobile devices. The download list page has been altered so that it works better as a standalone page, as it might be seen if JavaScript is disabled. Simple form validation has been added to help prevent submission of the form without choosing a format. To test the virtualshelves system preference must be enabled. - View an existing list in the OPAC and click the "download list" link. - A modal dialog should be displayed with the download form. - Submitting the form without selecting a format should trigger either a browser-based form validation error (in HTML5-supporting browsers) or a JavaScript alert (if your browser doesn't support the "required" attribute. - Choosing a download format and submitting the form should close the dialog and trigger the correct download. - Clicking the "Cancel" link should close the dialog. Test with JavaScript disabled: - Clicking the "download list" link should take you to a page which contains the same form which appeared in the modal dialog. - Submitting the form without selecting a format should trigger either a browser-based form validation error (in HTML5-supporting browsers) or a JavaScript alert (if your browser doesn't support the "required" attribute.. - Choosing a download format and submitting the form should result in the corect download. - Clicking the "Cancel" link should return you to the correct list. Signed-off-by: Aleisha Signed-off-by: Katrin Fischer Passes QA script and tests, works as described. Signed-off-by: Chris Cormack --- .../en/modules/opac-downloadshelf.tt | 102 ++++++++++++++---- .../bootstrap/en/modules/opac-shelves.tt | 17 ++- opac/opac-downloadshelf.pl | 20 +++- 3 files changed, 118 insertions(+), 21 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt index 1d38e61f55..a8523995fc 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt @@ -1,12 +1,44 @@ -[% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Download list[% INCLUDE 'doc-head-close.inc' %] -[% BLOCK cssinclude %][% END %] - - -
-
-
-
-
+[% USE Koha %] +[% IF ( fullpage ) %] + [% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Download list [% shelfname %][% INCLUDE 'doc-head-close.inc' %] + [% BLOCK cssinclude %][% END %] + + + [% INCLUDE 'masthead.inc' %] +
+ +
+
+ [% IF ( OpacNav||loggedinusername ) %] +
+ +
+ [% END %] + + [% IF ( OpacNav||loggedinusername ) %] +
+ [% ELSE %] +
+ [% END %] +[% END # / IF fullpage %] + +
[% UNLESS ( invalidlist ) %] [% IF ( format ) %] @@ -14,10 +46,10 @@

Your download should begin automatically.

[% ELSE %] -

Download list

+

Download list [% shelfname %]

- @@ -26,15 +58,31 @@ [% END %] + Required
- Cancel + Cancel
- + [% IF ( modal ) %] + + [% END %] [% END # / IF format %] [% ELSE %] @@ -46,9 +94,25 @@ [% END # / invalidlist %]
-
-
-
-
-[% INCLUDE 'opac-bottom.inc' is_popup=1 %] -[% BLOCK jsinclude %][% END %] + +[% IF ( fullpage ) %] +
+
+
+
+ [% INCLUDE 'opac-bottom.inc' %] + [% BLOCK jsinclude %] + + [% END %] +[% END # / IF fullpage %] \ No newline at end of file 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 a6d9040be0..a65be1b307 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt @@ -156,7 +156,7 @@
New list | - Download list + Download list [% IF Koha.Preference( 'opacuserlogin' ) == 1 %] Send list @@ -805,6 +805,16 @@
+ +
@@ -905,6 +915,11 @@ $(function() { }); [% END %] + // If JS is enabled add paramter to download link + var dialoglink = $(".download").attr("href"); + dialoglink += "&context=modal"; + $(".download").attr("href",dialoglink); + $("#CheckAll").click(function(){ $(".checkboxed").checkCheckboxes(); enableCheckboxActions(); diff --git a/opac/opac-downloadshelf.pl b/opac/opac-downloadshelf.pl index 17ee166da8..012e51b6a1 100755 --- a/opac/opac-downloadshelf.pl +++ b/opac/opac-downloadshelf.pl @@ -46,6 +46,8 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user ( my $shelfid = $query->param('shelfid'); my $format = $query->param('format'); +my $context = $query->param('context'); +my $showprivateshelves = $query->param('showprivateshelves'); my $dbh = C4::Context->dbh; if ( ShelfPossibleAction( (defined($borrowernumber) ? $borrowernumber : -1), $shelfid, 'view' ) ) { @@ -94,8 +96,24 @@ if ( ShelfPossibleAction( (defined($borrowernumber) ? $borrowernumber : -1), $sh print $output; } else { + + # get details of the list + my ($shelfnumber,$shelfname,$owner,$category,$sorton) = GetShelf($shelfid); + + # if modal context is passed set a variable so that page markup can be different + if($context eq "modal"){ + $template->param(modal => 1); + } else { + $template->param(fullpage => 1); + } $template->param(csv_profiles => GetCsvProfilesLoop('marc')); - $template->param(shelfid => $shelfid); + $template->param( + showprivateshelves => $showprivateshelves, + shelfid => $shelfid, + shelfname => $shelfname, + shelfnumber => $shelfnumber, + viewshelf => $shelfnumber + ); output_html_with_http_headers $query, $cookie, $template->output; } -- 2.39.5