From bcb2adb604d74f9eebee462b19d6493a426bb67c Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Tue, 17 Oct 2023 09:20:59 +0000 Subject: [PATCH] Bug 35073: Default to existing value if there is one For values that dont exist in the batch edit submission, i.e. UI says 'No change', we default to existing value if there is one. Test plan: Preparation - Additional fields: 1) Add a new 'additional field', visit: /cgi-bin/koha/admin/additional-fields.pl 2) Click 'subscription' and '+ New field'. Enter a 'name' and hit 'save'. Serials: 1) Add a new serial, visit: /cgi-bin/koha/serials/subscription-add.pl 2) Put a biblionumber in the 'record' field, i.e. '112'. Press 'next' and click 'ok' on the alert box 3) Fill all the required fields and click 'test prediction' 4) Input something in the additional field created previously. 5) Click 'save subscription'. Notice the additional field is as expected. 6) Repeat steps 1-5 to create a second serial. Batch edit: 1) Visit serials and hit the 'Search' button: /cgi-bin/koha/serials/serials-home.pl 2) Click the 2 checkboxes for the 2 serials we created previously and click the new link that pops up 'edit selected serials'. 3) Click 'Save' without changing anything. 4) Go back to either of the serials, notice the value for the additional field is unchanged. Visit: /cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=1 Signed-off-by: Katrin Fischer Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 7294908de35a46f491af4e170fb9f6294a5fb4bf) Signed-off-by: Fridolin Somers --- serials/subscription-batchedit.pl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/serials/subscription-batchedit.pl b/serials/subscription-batchedit.pl index dd06fe4a22..2c31fa9f12 100755 --- a/serials/subscription-batchedit.pl +++ b/serials/subscription-batchedit.pl @@ -84,6 +84,14 @@ if ($batchedit) { id => $field->id, value => $value, }; + }else{ + my $existing = $subscription->additional_field_values->search( { field_id => $field->id } )->last; + if($existing && $existing->value){ + push @additional_field_values, { + id => $field->id, + value => $existing->value, + }; + } } } $subscription->set_additional_fields(\@additional_field_values); -- 2.39.5