From ab808aa4773e60ceabed294f92036ac7c80dc34c Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 29 Feb 2024 15:26:54 +0000 Subject: [PATCH] Bug 34920: Ensure 'description' property is an empty string if 'lib' is null Test plan: 1. Enable ERM module 2. Confirm that you can open the ERM module in the staff interface. 3. Go to the authorized values, select 'ERM_AGREEMENT_CLOSURE_REASON' and edit the 'Cancelled' authorized value by removing the description. Making this change with any of the ERM authorized values will result in an error. 4. Go back to the ERM module and notice that there is an error. 'Something went wrong: Error: Expected string - got null.' 5. Apply patch. Run yarn js:build. Repeat test plan 6. Create a new agreement. Pick status 'Closed'. 7. Open 'Closure reason'. Confirm there is an entry for 'Expired' and an empty entry below that. Signed-off-by: Laura Escamilla --- Koha/AuthorisedValue.pm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Koha/AuthorisedValue.pm b/Koha/AuthorisedValue.pm index da25d5e058..09d2a4a149 100644 --- a/Koha/AuthorisedValue.pm +++ b/Koha/AuthorisedValue.pm @@ -113,6 +113,26 @@ sub to_api_mapping { }; } +=head3 to_api + + my $json = $av->to_api; + +Overloaded method that returns a JSON representation of the Koha::AuthorisedValue object, +suitable for API output. + +=cut + +sub to_api { + my ( $self, $params ) = @_; + + my $response = $self->SUPER::to_api($params); + my $overrides = {}; + + $overrides->{description} = $self->lib // q{}; + + return { %$response, %$overrides }; +} + =head2 Internal methods =head3 _type -- 2.30.2