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 <david@davidnind.com>
Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit bfa29d0dc0)
Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk>
This commit is contained in:
Owen Leonard 2025-08-08 13:49:00 +00:00 committed by Jacob O'Mara
parent c8f869180d
commit 51d8bbc3f5
No known key found for this signature in database
6 changed files with 80 additions and 46 deletions

View File

@ -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',

View File

@ -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 %]
<style>
.opac-library-info {
border: 1px solid #dedede;
border-radius: 2px;
padding: 0.375rem 0.75rem;
}
.opac-library-info + .opac-library-info {
margin-top: 0.5rem;
}
</style>
[% END %]
</head>
<body id="admin_branches" class="admin">
@ -330,10 +342,20 @@
<div class="fg-input">
[% IF OpacLibraryInfo %]
<!-- opac_info -->
<div>[% OpacLibraryInfo.content | $raw %]</div>
<a class="btn btn-link" href="/cgi-bin/koha/tools/additional-contents.pl?category=html_customizations&op=add_form&id=[% OpacLibraryInfo.id | $raw %]&editmode=wysiwyg" target="_blank">Edit HTML content</a>
[% FOREACH info IN OpacLibraryInfo %]
[% IF library.branchcode == info.branchcode %]
<div id="opac_library_info_[% info.additional_content_id | $raw %]" class="opac-library-info">[% info.content | $raw %]</div>
[% IF ( CAN_user_tools_edit_additional_contents ) %]
<a class="btn btn-link" href="/cgi-bin/koha/tools/additional-contents.pl?category=html_customizations&op=add_form&id=[% info.additional_content_id | $raw %]&editmode=wysiwyg" target="_blank">
<i class="fa fa-pencil"></i> Edit HTML content
</a>
[% END %]
[% END %]
[% END %]
[% ELSE %]
<a class="btn btn-link" href="/cgi-bin/koha/tools/additional-contents.pl?category=html_customizations&op=add_form&editmode=wysiwyg" target="_blank">Add HTML content</a>
[% IF ( CAN_user_tools_edit_additional_contents ) %]
<a class="btn btn-link" href="/cgi-bin/koha/tools/additional-contents.pl?category=html_customizations&op=add_form&editmode=wysiwyg" target="_blank"> <i class="fa fa-plus"></i> Add HTML content </a>
[% END %]
[% END %]
</div>
</div>
@ -741,7 +763,23 @@
<div class="row page-section">
<div class="col-sm-12">
<h2>OPAC information</h2>
<div>[% OpacLibraryInfo.content | $raw %]</div>
[% IF OpacLibraryInfo %]
<!-- opac_info -->
[% FOREACH info IN OpacLibraryInfo %]
[% IF library.branchcode == info.branchcode %]
<div id="opac_library_info_[% info.additional_content_id | $raw %]" class="opac-library-info">[% info.content | $raw %]</div>
[% IF ( CAN_user_tools_edit_additional_contents ) %]
<a class="btn btn-link" href="/cgi-bin/koha/tools/additional-contents.pl?category=html_customizations&op=add_form&id=[% info.additional_content_id | $raw %]&editmode=wysiwyg" target="_blank">
<i class="fa fa-pencil"></i> Edit HTML content
</a>
[% END %]
[% END %]
[% END %]
[% ELSE %]
[% IF ( CAN_user_tools_edit_additional_contents ) %]
<a class="btn btn-link" href="/cgi-bin/koha/tools/additional-contents.pl?category=html_customizations&op=add_form&editmode=wysiwyg" target="_blank"> <i class="fa fa-plus"></i> Add HTML content </a>
[% END %]
[% END %]
</div>
</div>
[% END %]

View File

@ -907,6 +907,12 @@ div {
background-color: #333333;
}
.library-description {
& + .library-description {
margin-top: .5rem;
}
}
fieldset {
&.rows {
clear: left;

View File

@ -1360,10 +1360,9 @@
<td class="location" property="seller" data-order="[% holding_library_name | html %]">
<link property="itemOffered" href="#record" />
<link property="businessFunction" href="http://purl.org/goodrelations/v1#LeaseOut" />
[% IF ( ITEM_RESULT.holding_library_info ) %]
<a href="[% holding_library_url | url %]" class="library_info" data-info="[% ITEM_RESULT.holding_library_info | html %]" data-name="[% holding_library_name | html %]">
<i class="fa fa-info-circle" aria-hidden="true"></i> [% holding_library_name | html %]
<a href="[% holding_library_url | url %]" class="library_info" data-index="[% loop.index | html %]" data-name="[% holding_library_name | html %]">
<i class="fa fa-info-circle" aria-hidden="true"></i> [% holding_library_name | html %][% my_library_info | html %]
</a>
[% ELSIF holding_library_url %]
<a href="[% holding_library_url | url %]"> [% holding_library_name | html %] </a>
@ -1389,7 +1388,7 @@
<link property="businessFunction" href="http://purl.org/goodrelations/v1#LeaseOut" />
[% IF ( ITEM_RESULT.home_library_info ) %]
<a href="[% home_library_url | url %]" class="library_info" data-info="[% ITEM_RESULT.home_library_info | html %]" data-name="[% home_library_name | html %]">
<a href="[% home_library_url | url %]" class="library_info" data-index="[% loop.index | html %]" data-name="[% home_library_name | html %]">
<i class="fa fa-info-circle" aria-hidden="true"></i> [% home_library_name | html %]
</a>
[% ELSIF home_library_url %]
@ -1604,6 +1603,16 @@
[% END %]
</tbody>
</table>
[% FOREACH ITEM_RESULT IN items %]
[% IF ( ITEM_RESULT.holding_library_info ) %]
<div style="display:none" id="library_info_[% loop.index | html %]">
[% FOREACH info IN ITEM_RESULT.holding_library_info %]
<div id="library_description_[% info.additional_content_id | $raw %]" class="library-description">[% info.content | $raw %]</div>
[% END %]
</div>
[% END %]
[% END %]
[% END %][%# end of items_table block %]
[% IF Koha.Preference('OpacCatalogConcerns') %]
@ -2189,41 +2198,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("");

View File

@ -36,7 +36,11 @@
[% INCLUDE 'masthead.inc' %]
[% BLOCK library_description %]
<div property="description"> [% IF OpacLibraryInfo %][% OpacLibraryInfo.content | $raw %][% END %] </div>
<div property="description">
[% FOREACH info IN OpacLibraryInfo %]
<div id="library_description_[% info.additional_content_id | $raw %]" class="library-description">[% info.content | $raw %]</div>
[% END %]
</div>
[% END %]
[% BLOCK library_info %]

View File

@ -718,8 +718,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