From edf246f4147fef60885c8b368977a361a55643f7 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 21 Mar 2024 17:29:47 +0000 Subject: [PATCH 3/3] Bug 36166: Convert Cart and Lists conrols 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 converst 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. --- .../opac-tmpl/bootstrap/css/src/opac.scss | 9 +- .../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 | 144 ++------ .../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 b164c200ce6..9c9ee736460 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss +++ b/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss @@ -595,6 +595,10 @@ th { white-space: nowrap; } +.dropdown-menu > .dropdown-header:first-child { + border-top: 0; +} + .btn-group.open { .btn-link { &.dropdown-toggle { @@ -1103,7 +1107,6 @@ fieldset { .toolbar { background-color: #EEEEEE; - border: 1px solid #E8E8E8; font-size: .9rem; padding: 3px 3px 5px 5px; vertical-align: middle; @@ -1173,13 +1176,11 @@ fieldset { .selections-toolbar { background: linear-gradient( #B2B2B2 0%, #E0E0E0 14%, #E8E8E8 100% ); - border-bottom: none; display: flex; + flex-wrap: wrap; margin: 0; - margin-top: 3px; 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 00000000000..eed84b5736d --- /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 d2b050cd4fb..57c72ca2c7b 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 a592e2f8e78..de0e45396a4 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') %] @@ -191,94 +199,7 @@ [% END # /UNLESS tag %]
-
- [% IF ( OpacHighlightedWords ) %] - - [% END %] - -
- - - Select all - - - Clear all - -
- - - [% IF ( TagsInputEnabled && loggedinusername ) %] - - - [% END %] -
+ [% INCLUDE 'result-batch-controls.inc' results=1 %] @@ -530,7 +451,6 @@
- Pages
@@ -580,91 +500,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 aab73c6d4c2..a90ddd54b78 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' %]
@@ -547,6 +515,10 @@ [% END %]
+
+ + +
[% ELSE %]
@@ -836,26 +808,18 @@ [% IF OpenLibraryCovers || OpenLibrarySearch %] [% Asset.js("js/openlibrary.js") | $raw %] [% END %] + +[% Asset.js("js/results-list.js") | $raw %] +[% Asset.js("js/results-list.js") | $raw %]