From 50b4885087a55b9c92cffd8a0a87cbea0d73e194 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Mon, 16 Oct 2023 09:32:44 +0000 Subject: [PATCH] Bug 35044: Update: Order baskets Test plan, k-t-d: Preparation: Create additional fields for table 'aqbasket': 2 text fields, one repeatable, one not-repeatable 2 AV fields, one repeatable, one not-repeatable 1) Add a new basket, visit: /cgi-bin/koha/acqui/basketheader.pl?booksellerid=1&op=add_form 2) Fill in name and all additional fields, click the '+New' and 'Clear' links, hit 'Save' 3) Notice the basket screen shows repeated fields separated by comma. 4) Notice that only non-null additional fields labels are shown. 5) Edit the basket. Notice all fields are shown as expected. Additional testing: Having a repeatable field with multiple instances, go back to the additional fields configuration and make the additional field non-repeatable again. Edit the basket again. Notice the multiple text instances are still shown, but the '+New' link no longer shows. You're able to remove existing multiple instances, but unable to add new ones, this is because the field is no longer repeatable. --- acqui/basket.pl | 5 ++--- acqui/basketheader.pl | 19 +++++++++---------- .../prog/en/modules/acqui/basketheader.tt | 1 + 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/acqui/basket.pl b/acqui/basket.pl index 33253aad47..0450482d8e 100755 --- a/acqui/basket.pl +++ b/acqui/basket.pl @@ -426,9 +426,8 @@ if ( $op eq 'list' ) { duplinbatch => $duplinbatch, csv_profiles => Koha::CsvProfiles->search({ type => 'sql', used_for => 'export_basket' }), available_additional_fields => Koha::AdditionalFields->search( { tablename => 'aqbasket' } ), - additional_field_values => { map { - $_->field->name => $_->value - } Koha::Acquisition::Baskets->find($basketno)->additional_field_values->as_list }, + additional_field_values => + Koha::Acquisition::Baskets->find($basketno)->get_additional_field_values_for_template, ); } diff --git a/acqui/basketheader.pl b/acqui/basketheader.pl index 4cf1736715..10a62c6829 100755 --- a/acqui/basketheader.pl +++ b/acqui/basketheader.pl @@ -96,11 +96,8 @@ if ( $op eq 'add_form' ) { } } $template->param( is_an_edit => 1); - $template->param( - additional_field_values => { map { - $_->field->id => $_->value - } Koha::Acquisition::Baskets->find($basketno)->additional_field_values->as_list }, - ); + $template->param( additional_field_values => + Koha::Acquisition::Baskets->find($basketno)->get_additional_field_values_for_template ); } else { #new basket my $basket; @@ -168,11 +165,13 @@ if ( $op eq 'add_form' ) { my @additional_fields; my $basket_fields = Koha::AdditionalFields->search({ tablename => 'aqbasket' }); while ( my $field = $basket_fields->next ) { - my $value = $input->param('additional_field_' . $field->id); - push @additional_fields, { - id => $field->id, - value => $value, - }; + my @field_values = $input->param( 'additional_field_' . $field->id ); + foreach my $value (@field_values) { + push @additional_fields, { + id => $field->id, + value => $value, + } if $value; + } } Koha::Acquisition::Baskets->find($basketno)->set_additional_fields(\@additional_fields); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt index 88bda81a43..85827c80a3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt @@ -162,6 +162,7 @@ [% MACRO jsinclude BLOCK %] [% Asset.js("js/acquisitions-menu.js") | $raw %] [% Asset.js("js/acq.js") | $raw %] + [% Asset.js("js/additional-fields-entry.js") | $raw %] [% INCLUDE 'select2.inc' %]