Bugzilla – Attachment 185484 Details for
Bug 39482
Link to edit OpacLibraryInfo from library edit page broken
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39482: Correct the link to edit OpacLibraryInfo from library edit page
Bug-39482-Correct-the-link-to-edit-OpacLibraryInfo.patch (text/plain), 14.98 KB, created by
David Nind
on 2025-08-15 22:17:05 UTC
(
hide
)
Description:
Bug 39482: Correct the link to edit OpacLibraryInfo from library edit page
Filename:
MIME Type:
Creator:
David Nind
Created:
2025-08-15 22:17:05 UTC
Size:
14.98 KB
patch
obsolete
>From 10d5d7375d1fb05f8e48be56189e5714bb7491b2 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >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 <david@davidnind.com> >--- > 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 %] >+ <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 %] >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 @@ > <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> >@@ -1396,7 +1395,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 %] >@@ -1557,6 +1556,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') %] >@@ -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 %] >- <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 %] >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
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 39482
:
185452
|
185484
|
185561
|
185674