From 10d5d7375d1fb05f8e48be56189e5714bb7491b2 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Fri, 8 Aug 2025 13:49:00 +0000 Subject: [PATCH] Bug 39482: Correct the link to edit OpacLibraryInfo from library edit page When editing a library which has an associated OpacLibraryInfo HTML customization the "Edit HTML content" link passes the wrong id parameter. To test, apply the patch and restart services. - Rebuild OPAC CSS. - Go to Administration -> Libraries. - Edit a library. - If there is no OpacLibraryInfo customization associated with that library, add at least two OpacLibraryInfo entries and then return to the library edit form. - By the "OPAC information" label you should see all of the OpacLibraryInfo entries you added for that library. - If you have permission to edit HTML customizations you should see an edit link. - Test each to confirm that it opens the correct entry for editing. - Return to Administration -> Libraries and click the library name to view it (rather than edit). - The correct HTML customizations should appear. If you have permission to edit HTML customizations you should see corresponding "Edit" links. - Test each to confirm that it opens the correct entry for editing. - In the OPAC, locate a bibliographic record which has one or more items from the library you added OpacLibraryInfo to. - In the holdings table, click the one of the library links to trigger the info modal. - Confirm that all the correct information displays. - Go to "Libraries" link in the menu under the quick search bar. - Click the library you modified. Confirm that the correct OpacLibraryInfo entries display. Sponsored-by: Athens County Public Libraries Signed-off-by: David Nind --- Koha/Library.pm | 4 +- .../prog/en/modules/admin/branches.tt | 46 ++++++++++++-- .../opac-tmpl/bootstrap/css/src/opac.scss | 6 ++ .../bootstrap/en/modules/opac-detail.tt | 60 +++++++------------ .../bootstrap/en/modules/opac-library.tt | 6 +- opac/opac-detail.pl | 4 +- 6 files changed, 80 insertions(+), 46 deletions(-) diff --git a/Koha/Library.pm b/Koha/Library.pm index 90db8e978c0..3991e53671f 100644 --- a/Koha/Library.pm +++ b/Koha/Library.pm @@ -377,7 +377,7 @@ sub to_api_mapping { $library->opac_info({ lang => $lang }); -Returns additional contents block OpacLibraryInfo for $lang or 'default'. +Returns all additional contents blocks OpacLibraryInfo by library and $lang (or 'default'). Note: This replaces the former branches.opac_info column. @@ -385,7 +385,7 @@ Note: This replaces the former branches.opac_info column. sub opac_info { my ( $self, $params ) = @_; - return Koha::AdditionalContents->find_best_match( + return Koha::AdditionalContents->search_for_display( { category => 'html_customizations', location => 'OpacLibraryInfo', diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt index 828c5225fe3..b3e68fbb188 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt @@ -29,6 +29,18 @@ [% INCLUDE 'doc-head-close.inc' %] [% Asset.css("lib/codemirror/codemirror.min.css") | $raw %] [% Asset.css("lib/codemirror/lint.min.css") | $raw %] +[% FILTER collapse %] + +[% END %] @@ -330,10 +342,20 @@
[% IF OpacLibraryInfo %] -
[% OpacLibraryInfo.content | $raw %]
- Edit HTML content + [% FOREACH info IN OpacLibraryInfo %] + [% IF library.branchcode == info.branchcode %] +
[% info.content | $raw %]
+ [% IF ( CAN_user_tools_edit_additional_contents ) %] + + Edit HTML content + + [% END %] + [% END %] + [% END %] [% ELSE %] - Add HTML content + [% IF ( CAN_user_tools_edit_additional_contents ) %] + Add HTML content + [% END %] [% END %]
@@ -741,7 +763,23 @@

OPAC information

-
[% OpacLibraryInfo.content | $raw %]
+ [% IF OpacLibraryInfo %] + + [% FOREACH info IN OpacLibraryInfo %] + [% IF library.branchcode == info.branchcode %] +
[% info.content | $raw %]
+ [% IF ( CAN_user_tools_edit_additional_contents ) %] + + Edit HTML content + + [% END %] + [% END %] + [% END %] + [% ELSE %] + [% IF ( CAN_user_tools_edit_additional_contents ) %] + Add HTML content + [% END %] + [% END %]
[% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss b/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss index 52cfc9a2f98..8c622cc80a0 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss +++ b/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss @@ -912,6 +912,12 @@ div { background-color: #333333; } +.library-description { + & + .library-description { + margin-top: .5rem; + } +} + fieldset { &.rows { clear: left; diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt index 2f17db5377e..682eda6a77a 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -1370,10 +1370,9 @@ - [% IF ( ITEM_RESULT.holding_library_info ) %] - - [% holding_library_name | html %] + + [% holding_library_name | html %][% my_library_info | html %] [% ELSIF holding_library_url %] [% holding_library_name | html %] @@ -1396,7 +1395,7 @@ [% IF ( ITEM_RESULT.home_library_info ) %] - + [% home_library_name | html %] [% ELSIF home_library_url %] @@ -1557,6 +1556,16 @@ [% END %] + + [% FOREACH ITEM_RESULT IN items %] + [% IF ( ITEM_RESULT.holding_library_info ) %] + + [% END %] + [% END %] [% END %][%# end of items_table block %] [% IF Koha.Preference('OpacCatalogConcerns') %] @@ -2139,41 +2148,18 @@ $(".library_info").on("click", function(e){ e.preventDefault(); var library_name = $(this).data("name"); - var opac_info = $(this).data("info"); + var index = $(this).data("index"); var url = $(this).attr("href"); - if( 1 ) { - $("#libraryInfoModalLabel").html( library_name ); - $("#libraryInfo").html( opac_info ); - if( url ){ - $("#libraryInfoLink").attr("href", url ); - $("#libraryInfoLink").show(); - } else { - $("#libraryInfoLink").hide(); - } - $("#libraryInfoModal").modal("show"); - } else { // FIXME Temporary disabled: see BZ 29144 - $.ajax({ - url: "/api/v1/public/libraries/" + branchcode, - type: 'GET', - dataType: 'json', - success: function(result) { - $("#libraryInfoModalLabel").html( result.name ); - $("#libraryInfo").html( opac_info ); - if( result.url ){ - $("#libraryInfoLink").attr("href", result.url ); - $("#libraryInfoLink").show(); - } else { - $("#libraryInfoLink").hide(); - } - $("#libraryInfoModal").modal("show"); - }, - error: function(xhr, status, error) { - if( url ){ - location.href = url; - } - } - }); + let library_info = $("#library_info_" + index).html(); + $("#libraryInfoModalLabel").html( library_name ); + $("#libraryInfo").html( library_info ); + if( url ){ + $("#libraryInfoLink").attr("href", url ); + $("#libraryInfoLink").show(); + } else { + $("#libraryInfoLink").hide(); } + $("#libraryInfoModal").modal("show"); }); $("#libraryInfoModal").on("hide.bs.modal", function(){ $("#libraryInfoModalLabel, #libraryInfo").html(""); diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-library.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-library.tt index 8806eaa1b70..8939ac7b624 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-library.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-library.tt @@ -41,7 +41,11 @@ [% INCLUDE 'masthead.inc' %] [% BLOCK library_description %] -
[% IF OpacLibraryInfo %][% OpacLibraryInfo.content | $raw %][% END %]
+
+ [% FOREACH info IN OpacLibraryInfo %] +
[% info.content | $raw %]
+ [% END %] +
[% END %] [% BLOCK library_info %] diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 7222edc6d65..7be2e2a4314 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -741,8 +741,8 @@ if ( not $viewallitems and $items->count > $max_items_to_display ) { $library_info->{ $item->holdingbranch } = $opac_info_holding; $opac_info_home = $library_info->{ $item->homebranch } // $item->home_branch->opac_info( { lang => $lang } ); $library_info->{ $item->homebranch } = $opac_info_home; - $item_info->{holding_library_info} = $opac_info_holding->content if $opac_info_holding; - $item_info->{home_library_info} = $opac_info_home->content if $opac_info_home; + $item_info->{holding_library_info} = $opac_info_holding if $opac_info_holding; + $item_info->{home_library_info} = $opac_info_home if $opac_info_home; # We only need to check if we haven't determined holds can be placed # and if we don't have patron, we have already decided -- 2.39.5