From e21b4cf5b20f30d2c556132a791922720382b65c 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. Signed-off-by: Martin Renvoize Signed-off-by: Julian Maurice https://bugs.koha-community.org/show_bug.cgi?id=25044 --- 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 38a555ef52..1a6ef3ca47 100755 --- a/acqui/basket.pl +++ b/acqui/basket.pl @@ -442,9 +442,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 70a424941f..96a7e95e26 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 c502ee391f..e85fffa822 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt @@ -164,6 +164,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' %]