From a8203d80ef673ed876dc39cf16db32192dc4186d Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 26 Sep 2014 12:08:36 +0200 Subject: [PATCH] Bug 6279: Follow-up for pagination and confirm This follow-up patch restores the pagination and removes the Confirm buttons. This is not really needed since you already confirmed a javascript messagebox. The code needs refactoring. This is a quick fix. Test plan: Delete lists from the second page (from list view and detail view) in both OPAC and staff. Signed-off-by: Jonathan Druart Signed-off-by: Fridolin Somers --- C4/VirtualShelves/Page.pm | 26 +++++++++------------- .../prog/en/modules/virtualshelves/shelves.tt | 24 +++----------------- .../opac-tmpl/bootstrap/en/modules/opac-shelves.tt | 22 +++++------------- 3 files changed, 18 insertions(+), 54 deletions(-) diff --git a/C4/VirtualShelves/Page.pm b/C4/VirtualShelves/Page.pm index fa0ded0..066704a 100644 --- a/C4/VirtualShelves/Page.pm +++ b/C4/VirtualShelves/Page.pm @@ -379,20 +379,7 @@ sub shelfpage { } my $contents; ( $contents, $totshelves ) = GetShelfContents( $number, $shelveslimit, $shelvesoffset ); - if ( $totshelves > 0 ) { - unless ( scalar grep { /^CONFIRM-$number$/ } $query->param() ) { - if ( defined $shelflist->{$number} ) { - push( @paramsloop, { need_confirm => $shelflist->{$number}->{shelfname}, count => $totshelves, single => ($totshelves eq 1 ? 1:0) } ); - $shelflist->{$number}->{confirm} = $number; - } else { - push( @paramsloop, { need_confirm => $privshelflist->{$number}->{shelfname}, count => $totshelves } ); - $privshelflist->{$number}->{confirm} = $number; - } - $stay = 0; - next; - } - } - my $name; + my $name=$number; if ( defined $shelflist->{$number} ) { $name = $shelflist->{$number}->{'shelfname'}; delete $shelflist->{$number}; @@ -423,8 +410,15 @@ sub shelfpage { my @shelveslooppriv; my $numberCanManage = 0; - # rebuild shelflist in case a shelf has been added - ( $shelflist, $totshelves ) = GetShelves( $category, $shelveslimit, $shelvesoffset, $loggedinuser ) unless $delflag; + # rebuild shelflist + ( $shelflist, $totshelves ) = GetShelves( $category, $shelveslimit, $shelvesoffset, $loggedinuser ); + if( $shelvesoffset > 0 && !keys %$shelflist ) { + #retry if we deleted the last list of the page + $shelfoff--; + $shelvesoffset-= $shelflimit; + $template->param( shelfoff => $shelfoff ); + ( $shelflist, $totshelves ) = GetShelves( $category, $shelveslimit, $shelvesoffset, $loggedinuser ); + } foreach my $element ( sort { lc( $shelflist->{$a}->{'shelfname'} ) cmp lc( $shelflist->{$b}->{'shelfname'} ) } keys %$shelflist ) { my %line; $shelflist->{$element}->{shelf} = $element; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt index 97e47a7..c6d851a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt @@ -91,7 +91,7 @@ $(document).ready(function(){ function confirmDelete(message){ if (window.confirm(message)) { - location.href="/cgi-bin/koha/virtualshelves/shelves.pl?[% IF ( showprivateshelves ) %]display=privateshelves&[% END %]shelves=1&DEL-[% shelfnumber %]=1&shelfoff=[% shelfoff %]"; + location.href="/cgi-bin/koha/virtualshelves/shelves.pl?[% IF ( showprivateshelves ) %]display=privateshelves&[% END %]shelves=1&DEL-[% shelfnumber %]=1&CONFIRM-[% shelfnumber %]&shelfoff=[% shelfoff %]"; } else { return false; } @@ -232,16 +232,6 @@ function placeHold () { [% IF ( paramsloo.status ) %]
[% paramsloo.string %]
[% END %] [% IF ( paramsloo.nobarcode ) %]
ERROR: No barcode given.
[% END %] [% IF ( paramsloo.noshelfnumber ) %]
ERROR: No list number given.
[% END %] - [% IF ( paramsloo.need_confirm ) %] -
The list [% paramsloo.need_confirm %] is not empty. - [% IF ( paramsloo.single ) %] -
It has [% paramsloo.count %] entry. - [% ELSE %] -
It has [% paramsloo.count %] entries. - [% END %] -
Use the "Confirm" button below to confirm deletion. -
- [% END %] [% IF ( paramsloo.nopermission ) %]
ERROR: You do not have adequate permission for that action on list [% paramsloo.nopermission %].
[% END %] @@ -562,12 +552,8 @@ function placeHold () { - [% IF ( shelveslooppri.confirm ) %] - - - [% ELSE %] + - [% END %] [% ELSE %] None @@ -610,12 +596,8 @@ function placeHold () { - [% IF ( shelvesloo.confirm ) %] - - - [% ELSE %] + - [% END %] [% ELSE %] None 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 b6374ac..3dde806 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt @@ -113,13 +113,6 @@ [% IF ( paramsloo.status ) %]
[% paramsloo.string %]
[% END %] [% IF ( paramsloo.nobarcode ) %]
ERROR: No barcode given.
[% END %] [% IF ( paramsloo.noshelfnumber ) %]
ERROR: No shelfnumber given.
[% END %] - [% IF ( paramsloo.need_confirm ) %] -
- The list [% paramsloo.need_confirm %] is not empty. -
It has [% paramsloo.count %] [% IF ( paramsloo.single ) %]entry[% ELSE %]entries[% END %]. -
Use the "Confirm" button below to confirm deletion. -
- [% END %] [% IF ( paramsloo.nopermission ) %]
ERROR: You do not have adequate permission for that action on list [% paramsloo.nopermission |html%].
[% END %] @@ -493,6 +486,7 @@
+ [% IF ( showprivateshelves ) %] [% END %] @@ -519,6 +513,7 @@ [% ELSIF ( !itemsloop && manageshelf ) %] + @@ -654,13 +649,9 @@ + - [% IF ( shelveslooppri.confirm ) %] - - - [% ELSE %] - [% END %]
[% IF Koha.Preference('OpacAllowSharingPrivateLists') %] Share @@ -726,13 +717,10 @@
+ - [% IF ( shelvesloo.confirm ) %] - - - [% ELSE %] + - [% END %]
[% END %]  -- 1.9.1