From 9917b39d9dcbc6d1903c309bc702dd0486d9cb6e Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 21 Mar 2024 17:29:47 +0000 Subject: [PATCH] Bug 36557: Convert Cart and Lists controls to buttons and rework logic This patch tries to address errors in the way features are displayed in result lists so that controls for holds, tags, lists, etc. are shown or hidden according to system preferences. The patch converts the Cart/Lists dropdown to separate buttons, making the display logic simpler and making the interface more consistent with updates to the staff interface search results. To test, apply the patch and rebuild the OPAC CSS. - In the OPAC, test these pages: - Catalog search results - List contents - Test with various combinations of these system preferences: - opacbookbag - DisplayMultiPlaceHold - virtualshelves - OPACHoldRequests - TagsEnabled - TagsInputOnList - UseRecalls - ArticleRequests With each different combination of settings the right controls should appear in the toolbar at the top (if present), and with each search result. Signed-off-by: David Nind Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- .../opac-tmpl/bootstrap/css/src/opac.scss | 8 +- .../en/includes/result-batch-controls.inc | 90 +++++ .../en/includes/title-actions-menu.inc | 28 +- .../bootstrap/en/modules/opac-results.tt | 315 +----------------- .../bootstrap/en/modules/opac-shelves.tt | 145 ++------ .../bootstrap/en/modules/opac-tags.tt | 18 + .../opac-tmpl/bootstrap/js/results-list.js | 223 +++++++++++++ opac/opac-search.pl | 9 - opac/opac-shelves.pl | 19 ++ 9 files changed, 408 insertions(+), 447 deletions(-) create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/includes/result-batch-controls.inc create mode 100644 koha-tmpl/opac-tmpl/bootstrap/js/results-list.js diff --git a/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss b/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss index 91c425fbe3..c852515e27 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss +++ b/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss @@ -619,6 +619,10 @@ th { white-space: nowrap; } +.dropdown-menu > .dropdown-header:first-child { + border-top: 0; +} + .btn-group.open { .btn-link { &.dropdown-toggle { @@ -1127,7 +1131,6 @@ fieldset { .toolbar { background-color: #EEEEEE; - border: 1px solid #E8E8E8; font-size: .9rem; padding: 3px 3px 5px 5px; vertical-align: middle; @@ -1197,12 +1200,11 @@ fieldset { .selections-toolbar { background: linear-gradient( #B2B2B2 0%, #E0E0E0 14%, #E8E8E8 100% ); - border-bottom: none; display: flex; + flex-wrap: wrap; margin: 0; padding-left: 10px; padding-top: .5em; - flex-wrap: wrap; > div:first-child::before { content: ""; diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/result-batch-controls.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/result-batch-controls.inc new file mode 100644 index 0000000000..eed84b5736 --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/result-batch-controls.inc @@ -0,0 +1,90 @@ +
+ [% IF ( OpacHighlightedWords && results ) %] + + [% END %] + +
+ + + Select all + + + Clear all + +
+ + + [% IF ( TagsInputEnabled ) %] + + + [% END %] +
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/title-actions-menu.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/title-actions-menu.inc index 56edfd1795..79db98d6e4 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/title-actions-menu.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/title-actions-menu.inc @@ -1,27 +1,25 @@
- [% IF Koha.Preference( 'OPACHoldRequests' ) == 1 %] + [% IF ( HoldsEnabled ) %] [% UNLESS ( items.norequests ) %] - [% IF Koha.Preference( 'opacuserlogin' ) == 1 %] - [% IF ( shelf AND op == 'view' ) # Lists view has more granular checking of hold availability %] - [% IF ( items.allow_onshelf_holds ) %] + [% IF ( shelf AND op == 'view' ) # Lists view has more granular checking of hold availability %] + [% IF ( items.allow_onshelf_holds ) %] + Place hold + [% ELSE %] + [% IF ( items.itemsissued ) %] Place hold - [% ELSE %] - [% IF ( items.itemsissued ) %] - Place hold - [% END %] [% END %] - [% ELSE %] - Place hold [% END %] - [% END # / IF opacuserlogin %] + [% ELSE %] + Place hold + [% END %] [% END # / UNLESS items.norequests %] [% END # / OPACHoldRequests %] - [% IF Koha.Preference('UseRecalls') %] + [% IF ( RecallsEnabled ) %] Place recall [% END %] - [% IF ( Koha.Preference( 'opacuserlogin' ) == 1 ) %] + [% IF ( LoginEnabled ) %] [% IF items.artreqpossible %] Request article [% END %] @@ -48,7 +46,7 @@ [% END # IF loggedinusername %] [% END # if TagsInputEnabled %] - [% IF ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) && loggedinusername && ( Koha.Preference( 'virtualshelves' ) == 1 ) ) %] + [% IF ( ListsEnabled ) %] [% IF ( shelf AND op == 'view' ) %] Save to another list [% IF can_remove_biblios %] @@ -59,7 +57,7 @@ [% END # /IF ( shelf AND op == 'view' ) %] [% END # /IF Koha.Preference( 'opacuserlogin' ) %] - [% IF Koha.Preference( 'opacbookbag' ) == 1 %] + [% IF ( CartEnabled ) %] [% IF ( items.incart ) %] In your cart (remove) [% ELSE %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt index 9d9a7bacee..c92819eebf 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt @@ -3,9 +3,17 @@ [% USE Koha %] [% USE KohaPlugins %] [% USE To %] -[% SET TagsShowEnabled = ( ( Koha.Preference( 'TagsEnabled' ) == 1 ) && TagsShowOnList ) %] -[% SET TagsInputEnabled = ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) && ( Koha.Preference( 'TagsEnabled' ) == 1 ) && TagsInputOnList ) %] -[% SET CoverImagePlugins = KohaPlugins.get_plugins_opac_cover_images %] +[% SET LoginEnabled = ( Koha.Preference('opacuserlogin') == 1 ) %] +[% IF ( Koha.Preference('TagsEnabled') ) %] + [% SET TagsShowEnabled = ( ( Koha.Preference('TagsEnabled') == 1 ) && ( Koha.Preference('TagsShowOnList') > 0 ) ) %] + [% SET TagsInputEnabled = LoginEnabled && TagsShowEnabled && ( Koha.Preference('TagsInputOnList') > 0 ) %] +[% END %] +[% SET CartEnabled = ( Koha.Preference('opacbookbag') == 1 ) %] +[% SET ListsEnabled = ( Koha.Preference('virtualshelves') == 1 ) && LoginEnabled %] +[% SET HoldsEnabled = ( Koha.Preference('OPACHoldRequests') == 1 ) && LoginEnabled %] +[% SET RecallsEnabled = ( Koha.Preference('UseRecalls') == 1 ) && LoginEnabled %] +[% SET ArticleRequestsEnabled = ( Koha.Preference('ArticleRequests') == 1 ) && LoginEnabled %] +[% SET MultiHolds = ( Koha.Preference('DisplayMultiPlaceHold') == 1 ) && HoldsEnabled %] [% IF firstPage %] [% SET OverDriveEnabled = Koha.Preference('OverDriveLibraryID') && Koha.Preference('OverDriveClientKey') && Koha.Preference('OverDriveClientSecret') %] @@ -192,94 +200,7 @@ [% END # /UNLESS tag %]
-
- [% IF ( OpacHighlightedWords ) %] - - [% END %] - -
- - - Select all - - - Clear all - -
- - - [% IF ( TagsInputEnabled && loggedinusername ) %] - - - [% END %] -
+ [% INCLUDE 'result-batch-controls.inc' results=1 %] @@ -531,7 +452,6 @@
- Pages
@@ -581,91 +501,12 @@ [% END %] [% CoverImagePlugins | $raw %] + [% Asset.js("js/results-list.js") | $raw %] + [% END %] 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 0990eedd83..1d70e788fe 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt @@ -5,8 +5,17 @@ [% USE AdditionalContents %] [% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] [% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] -[% SET TagsShowEnabled = ( ( Koha.Preference( 'TagsEnabled' ) == 1 ) && Koha.Preference('TagsShowOnList') ) %] -[% SET TagsInputEnabled = ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) && ( Koha.Preference( 'TagsEnabled' ) == 1 ) && Koha.Preference('TagsInputOnList') ) %] +[% SET LoginEnabled = ( Koha.Preference('opacuserlogin') == 1 ) %] +[% IF ( Koha.Preference('TagsEnabled') ) %] + [% SET TagsShowEnabled = ( ( Koha.Preference('TagsEnabled') == 1 ) && ( Koha.Preference('TagsShowOnList') > 0 ) ) %] + [% SET TagsInputEnabled = LoginEnabled && TagsShowEnabled && ( Koha.Preference('TagsInputOnList') > 0 ) %] +[% END %] +[% SET CartEnabled = ( Koha.Preference('opacbookbag') == 1 ) %] +[% SET ListsEnabled = ( Koha.Preference('virtualshelves') == 1 ) && LoginEnabled %] +[% SET HoldsEnabled = ( Koha.Preference('OPACHoldRequests') == 1 ) && LoginEnabled %] +[% SET RecallsEnabled = ( Koha.Preference('UseRecalls') == 1 ) && LoginEnabled %] +[% SET ArticleRequestsEnabled = ( Koha.Preference('ArticleRequests') == 1 ) && LoginEnabled %] +[% SET MultiHolds = ( Koha.Preference('DisplayMultiPlaceHold') == 1 ) && HoldsEnabled %] [% BLOCK delete_shelf %]
@@ -345,48 +354,7 @@
- -
-
- - Select all - - - Clear all - -
- -
+ [% INCLUDE 'result-batch-controls.inc' %]
@@ -556,6 +524,10 @@
[% END %] +
+ + +
[% ELSE %]
@@ -846,21 +818,12 @@ [% Asset.js("js/openlibrary.js") | $raw %] [% END %] +[% Asset.js("js/results-list.js") | $raw %] + +[% Asset.js("js/results-list.js") | $raw %]