From cf01cd6fc0705fa7268a74e0993cb8495ed22aba Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Tue, 8 Jul 2025 13:30:00 +0000 Subject: [PATCH] Bug 26258: Circulation tabs inconsistent with counters This patch makes changes to the markup, style, and behaviour of counters which are displayed on the patron's account tabs: Checkouts, Holds, etc. This is a simplified patch compared to previous versions in order to try to get this moving foward. The patch no longer includes added code to keep tab counts up to date as, for instance, claims are added or removed. To test, apply the patch and rebuild the staff interface CSS. - Enable features if necessary: recalls, article requests, claims, clubs, and patron lists. Test both from the checkout page and the patron detail page. Recalls: - If necessary, check out some items to patrons so that there are titles which can be recalled. - Log in to the OPAC and place one or more recalls. - Return to the staff interface and view the "Recalls" tab on the patron's account. Return claims: - If necessary, check out some items to a patron. Click the "Claim returned" button on a few of the patron's checkouts. - As you add claims, the "Claims" tab should update the count of claims. *** NOTE: This changes the display of claims in the tab so that the count of unresolved claims appears first: "Unresolved / Resolved". I think it makes more sense for the first number to be the one which shows the number of "active" issues. - Test setting the ClaimReturnedWarningThreshold system preference to various values: e.g. empty, 1, 5. - If the pref is empty, OR if the pref is set to a number higher than the number of patron claims, the count of claims should be styled with the "info" blue background and the count of resolved claims is not shown. *** NOTE: Hiding the resolved claims seems logical if there is not a concern about the total number of claims. - If the number of all claims exceeds the value of the preference, the tab should show a count of "Unresolved claims / Resolved claims" with the yellow warning style. Restrictions: - Adding a restriction to the account should cause a counter with a red background to appear on the tab. Clubs: - If necessary, create at least one club template and then multiple clubs. - From the "Clubs" tab on the patron's account, try enrolling and cancelling enrollments to confirm that the count on the tab updates correctly. *** NOTE: I have removed the count of available clubs because I think it's not relevant to this interface. We don't do it with patron lists, so this makes it a little more consistent.. Patron lists: - If necessary, create two ore more patron lists. - From the "Patron lists" tab, try adding and removing the patron from lists. Sponsored-by: Athens County Public Libraries --- .../prog/css/src/staff-global.scss | 42 ++++++++++ .../prog/en/includes/patron-detail-tabs.inc | 76 +++++++++++++------ .../prog/en/includes/recalls.inc | 30 ++++---- koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 16 ---- 4 files changed, 107 insertions(+), 57 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss index ae6c2b97398..ee1c9c5dd87 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -4361,6 +4361,48 @@ div .suggestion_note { } } +.nav.nav-tabs > li > a { + align-items: center; + display: flex; + gap: 5px; + + span[class*="badge"] { + color: #000; + font-size: 85%; + font-weight: bold; + + &.text-bg-info { + background-color: #9BD6E8; + } + + &.text-bg-danger { + background-color: #FF7873; + } + + &:has( span:empty + span:empty ), /* If the element contains two empty spans */ + &:has( span:only-child:empty ) { /* If the element contains only one span and it is empty */ + background-color: transparent; + padding: 0; + } + + &:has( span + span:empty ) { /* If the element has a non-empty span followed by an empty one, reset style */ + background-color: #9BD6E8; + } + } +} + +.count-active { /* Add separator between two counts in a tab */ + & + .count-inactive { + &:empty::before { + content: ""; + } + + &::before { + content: " / "; + } + } +} + .ac-library { background-color: #EEE !important; font-weight: normal; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-detail-tabs.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-detail-tabs.inc index 24e01ea9b38..15cdf7ac17a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-detail-tabs.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-detail-tabs.inc @@ -4,69 +4,89 @@ [% WRAPPER tabs id= "finesholdsissues" %] [% WRAPPER tabs_nav %] [% WRAPPER tab_item tabname= "checkouts" bt_active= 1 %] - Checkouts ([% issuecount || 0 | html %]) + Checkouts + [% IF ( issuecount ) %] + [% issuecount || 0 | html %] + [% END %] [% END %] [% IF relatives_issues_count %] [% WRAPPER tab_item tabname= "relatives-issues" %] - Relatives' checkouts ([% relatives_issues_count | html %]) + Relatives' checkouts + [% IF ( relatives_issues_count ) %] + [% relatives_issues_count | html %] + [% END %] [% END %] [% END %] [% IF ( guarantees_fines ) %] [% WRAPPER tab_item tabname= "guarantees_finesandcharges" %] - Guarantees' charges ([% guarantees_fines | $Price %]) + Guarantees' charges + [% IF ( guarantees_fines ) %] + [% guarantees_fines | $Price %] + [% END %] [% END %] [% END %] [% IF ( CAN_user_circulate_circulate_remaining_permissions ) %] [% WRAPPER tab_item tabname= "holds" %] - Holds ([% holds_count || 0 | html %]) + Holds + [% IF ( holds_count ) %] + [% holds_count | html %] + [% END %] [% END %] [% WRAPPER tab_item tabname="bookings" %] [% SET bookings_count = patron.bookings.filter_by_active.count %] [% SET expired_bookings_count = patron.bookings.count - bookings_count %] - Bookings ([% bookings_count || 0 | html %]) + Bookings + [% IF ( bookings_count ) %] + [% bookings_count || 0 | html %] + [% END %] [% END %] [% END %] [% IF Koha.Preference('UseRecalls') %] [% WRAPPER tab_item tabname= "recalls" %] - Recalls ([% recalls.count || 0 | html %]) + Recalls + [% IF ( recalls.count ) %] + [% recalls.count | html %] + [% END %] [% END %] [% END %] [% IF Koha.Preference('ArticleRequests') %] [% SET article_requests = Context.Scalar( Context.Scalar( patron, 'article_requests' ), 'filter_by_current') %] [% WRAPPER tab_item tabname= "article-requests" %] - Article requests ([% article_requests.count || 0 | html %]) + Article requests + [% IF ( article_requests.count ) %] + [% article_requests.count | html %] + [% END %] [% END %] [% END %] [% IF Koha.Preference('ClaimReturnedLostValue') || Koha.Preference('BundleLostValue') %] [% WRAPPER tab_item tabname= "return-claims" %] Claims - [% IF ( patron.return_claims.count ) %] - ([% IF patron.return_claims.resolved.count == 0 %] - [% patron.return_claims.resolved.count | html %] - [% ELSE %] - [% patron.return_claims.resolved.count | html %] - [% END %] - [% IF patron.return_claims.unresolved.count == 0 %] - [% patron.return_claims.unresolved.count | html %] - [% ELSE %] - [% patron.return_claims.unresolved.count | html %] - [% END %]) + [% SET warning_threshold = Koha.Preference('ClaimReturnedWarningThreshold') %] + [% IF warning_threshold != '' && ( patron.return_claims.count > warning_threshold ) %] + + [% patron.return_claims.unresolved.count | html %] + [% patron.return_claims.resolved.count | html %] + [% ELSE %] - [% no_claims = 0 %] - ([% no_claims | html %] - [% no_claims | html %]) - [% END # /IF patron.return_claims.count %] + + [% patron.return_claims.unresolved.count || "" | html %] + [% patron.return_claims.resolved.count || "" | html %] + + [% END %] [% END # /WRAPPER tab_item return-claims %] [% END %] [% WRAPPER tab_item tabname= "reldebarments" %] - Restrictions ([% patron.restrictions.count || 0 | html %]) + Restrictions + [% IF ( patron.restrictions.count ) %] + [% patron.restrictions.count | html %] + [% END %] [% END %] [% SET enrollments = patron.get_club_enrollments %] @@ -74,13 +94,19 @@ [% IF CAN_user_clubs && ( enrollable.count || enrollments.count ) %] [% WRAPPER tab_item tabname= "clubs" %] - Clubs ([% enrollments.count | html %]/[% enrollable.count | html %]) + Clubs + + [% enrollments.count || "" | html %] + [% END %] [% END %] [% IF CAN_user_tools_manage_patron_lists || patron_lists_count %] [% WRAPPER tab_item tabname="pat_lists" %] - Patron lists ([% patron_lists_count | html %]) + Patron lists + + [%~ patron_lists_count || "" | html ~%] + [% END %] [% END %] [% END # /WRAPPER tabs_nav %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/recalls.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/recalls.inc index cdc0cffa11d..8915ab1f352 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/recalls.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/recalls.inc @@ -94,27 +94,25 @@ diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js index 185a5488db5..3552366f7fd 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js +++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js @@ -1546,22 +1546,6 @@ $(document).ready(function () { url: "/cgi-bin/koha/svc/return_claims?borrowernumber=%s".format( borrowernumber ), - complete: function (json) { - let resolved = json.resolved; - let unresolved = json.unresolved; - - if (unresolved > 0) { - $("#return-claims-count-unresolved") - .text(unresolved) - .removeClass("text-bg-info") - .addClass("text-bg-warning"); - } else { - $("#return-claims-count-unresolved") - .text(unresolved) - .removeClass("text-bg-warning") - .addClass("text-bg-info"); - } - }, }, bKohaAjaxSVC: true, search: { search: "is_unresolved" }, -- 2.39.5