From 5c646c489d48fd2e29fc74716e227adbec604932 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Wed, 30 Jul 2025 15:40:16 +0000 Subject: [PATCH] Bug 37054: USe try/catch when getting CSS rules or default to Koha green --- Koha/Library.pm | 45 +++++++++---------- Koha/Template/Plugin/Branches.pm | 11 ++++- api/v1/swagger/definitions/library.yaml | 2 +- .../prog/en/includes/doc-head-open.inc | 4 ++ .../opac-tmpl/bootstrap/css/src/_common.scss | 2 +- 5 files changed, 37 insertions(+), 27 deletions(-) diff --git a/Koha/Library.pm b/Koha/Library.pm index f5e68cdca7f..a04481ee376 100644 --- a/Koha/Library.pm +++ b/Koha/Library.pm @@ -348,29 +348,28 @@ on the API. sub to_api_mapping { return { - branchcode => 'library_id', - branchname => 'name', - branchaddress1 => 'address1', - branchaddress2 => 'address2', - branchaddress3 => 'address3', - branchzip => 'postal_code', - branchcity => 'city', - branchstate => 'state', - branchcountry => 'country', - branchphone => 'phone', - branchfax => 'fax', - branchemail => 'email', - branchillemail => 'ill_email', - branchreplyto => 'reply_to_email', - branchreturnpath => 'return_path_email', - branchurl => 'url', - issuing => undef, - branchip => 'ip', - branchnotes => 'notes', - marcorgcode => 'marc_org_code', - opacusercss => undef, - opacuserjs => undef, - ui_staff_customization => undef + branchcode => 'library_id', + branchname => 'name', + branchaddress1 => 'address1', + branchaddress2 => 'address2', + branchaddress3 => 'address3', + branchzip => 'postal_code', + branchcity => 'city', + branchstate => 'state', + branchcountry => 'country', + branchphone => 'phone', + branchfax => 'fax', + branchemail => 'email', + branchillemail => 'ill_email', + branchreplyto => 'reply_to_email', + branchreturnpath => 'return_path_email', + branchurl => 'url', + issuing => undef, + branchip => 'ip', + branchnotes => 'notes', + marcorgcode => 'marc_org_code', + opacusercss => undef, + opacuserjs => undef, }; } diff --git a/Koha/Template/Plugin/Branches.pm b/Koha/Template/Plugin/Branches.pm index e91cb046e02..d320db3084b 100644 --- a/Koha/Template/Plugin/Branches.pm +++ b/Koha/Template/Plugin/Branches.pm @@ -27,7 +27,8 @@ use C4::Koha; use C4::Context; use Koha::Cache::Memory::Lite; use Koha::Libraries; -use JSON qw( decode_json ); +use JSON qw( decode_json ); +use Try::Tiny qw( catch try ); sub GetName { my ( $self, $branchcode ) = @_; @@ -202,7 +203,13 @@ sub GetBranchCustomization { my $library = Koha::Libraries->find($branchcode); my $customizations_json = $library ? $library->ui_staff_customization : q{}; - my $customizations = decode_json($customizations_json); + + my $customizations; + try { + $customizations = decode_json($customizations_json); + } catch { + return q{}; + }; return q{} unless defined $key; diff --git a/api/v1/swagger/definitions/library.yaml b/api/v1/swagger/definitions/library.yaml index d9889c0f615..e9531a9e456 100644 --- a/api/v1/swagger/definitions/library.yaml +++ b/api/v1/swagger/definitions/library.yaml @@ -101,7 +101,7 @@ properties: type: - string - "null" - description: the primary color used by the library + description: a JSON object containing branch specific staff interface UI customization marc_org_code: type: - string diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-open.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-open.inc index 1082b191e7a..0431c5e77f5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-open.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-open.inc @@ -41,5 +41,9 @@ :root { --library-color: [% ui_staff_color_background | html %] } + [% ELSE %] + :root { + --library-color: #408540; + } [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/css/src/_common.scss b/koha-tmpl/opac-tmpl/bootstrap/css/src/_common.scss index 6f4193280b2..87fb0fa0b9b 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/css/src/_common.scss +++ b/koha-tmpl/opac-tmpl/bootstrap/css/src/_common.scss @@ -1222,7 +1222,7 @@ table { .nav-link { background-color: #F0F3F3; border: 1px solid $nav-tabs-border-color; - color: var( --library-color ); + color: var( --bs-link-color ); font-weight: normal; margin-right: .4em; -- 2.39.5