View | Details | Raw Unified | Return to bug 28445
Collapse All | Expand All

(-)a/Koha/UI/Form/Builder/Item.pm (-4 / +10 lines)
Lines 16-21 package Koha::UI::Form::Builder::Item; Link Here
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
use MARC::Record;
19
use C4::Context;
20
use C4::Context;
20
use C4::Biblio qw( GetFrameworkCode GetMarcBiblio GetMarcStructure IsMarcStructureInternal );
21
use C4::Biblio qw( GetFrameworkCode GetMarcBiblio GetMarcStructure IsMarcStructureInternal );
21
use C4::Koha qw( GetAuthorisedValues );
22
use C4::Koha qw( GetAuthorisedValues );
Lines 475-481 sub edit_form { Link Here
475
        $library->{selected} = 1 if $branchcode && $library->{branchcode} eq $branchcode;
476
        $library->{selected} = 1 if $branchcode && $library->{branchcode} eq $branchcode;
476
    }
477
    }
477
478
478
    my $item           = $self->{item};
479
    my $item                = $self->{item};
480
    my $marc_more_subfields = $item->{more_subfields_xml}
481
      ?
482
        # FIXME Use Maybe MARC::Record::new_from_xml if encoding issues on subfield (??)
483
        MARC::Record->new_from_xml( $item->{more_subfields_xml}, 'UTF-8' )
484
      : undef;
485
479
    my $biblionumber   = $self->{biblionumber};
486
    my $biblionumber   = $self->{biblionumber};
480
    my $frameworkcode  = $biblionumber ? GetFrameworkCode($biblionumber) : q{};
487
    my $frameworkcode  = $biblionumber ? GetFrameworkCode($biblionumber) : q{};
481
    my $marc_record    = $biblionumber ? GetMarcBiblio( { biblionumber => $biblionumber } ) : undef;
488
    my $marc_record    = $biblionumber ? GetMarcBiblio( { biblionumber => $biblionumber } ) : undef;
Lines 527-535 sub edit_form { Link Here
527
                }
534
                }
528
                else {
535
                else {
529
                  # Not mapped, picked the values from more_subfields_xml's MARC
536
                  # Not mapped, picked the values from more_subfields_xml's MARC
530
                    my $marc_more = $item->{marc_more_subfields_xml};
537
                    if ($marc_more_subfields) {
531
                    if ($marc_more) {
538
                        for my $f ( $marc_more_subfields->fields($tag) ) {
532
                        for my $f ( $marc_more->fields($tag) ) {
533
                            push @values, $f->subfield($subfieldtag);
539
                            push @values, $f->subfield($subfieldtag);
534
                        }
540
                        }
535
                    }
541
                    }
(-)a/t/db_dependent/Koha/UI/Form/Builder/Item.t (-2 / +20 lines)
Lines 16-22 Link Here
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
use Test::More tests => 6;
19
use Test::More tests => 7;
20
use utf8;
20
use utf8;
21
21
22
use List::MoreUtils qw( uniq );
22
use List::MoreUtils qw( uniq );
Lines 153-158 subtest 'prefill_with_default_values' => sub { Link Here
153
153
154
};
154
};
155
155
156
subtest 'subfields_to_prefill' => sub {
157
    plan tests => 2;
158
159
    my $biblio = $builder->build_sample_biblio({ value => {frameworkcode => ''}});
160
161
    my $more_subfields_xml = Koha::Item::Attributes->new({ "é" => "prefill é" })->to_marcxml;
162
    my $subfields =
163
      Koha::UI::Form::Builder::Item->new(
164
        { biblionumber => $biblio->biblionumber, item => {more_subfields_xml => $more_subfields_xml}})->edit_form({subfields_to_prefill => ['é']});
165
    my ($subfield) = grep { $_->{subfield} eq 'é' } @$subfields;
166
    is( $subfield->{marc_value}->{value}, 'prefill é', 'Not mapped subfield prefilled if needed' );
167
168
    $subfields =
169
      Koha::UI::Form::Builder::Item->new(
170
        { biblionumber => $biblio->biblionumber, item => {itemnotes => 'prefill z'}})->edit_form({subfields_to_prefill => ['z']});
171
    ($subfield) = grep { $_->{subfield} eq 'z' } @$subfields;
172
    is( $subfield->{marc_value}->{value}, 'prefill z', 'Mapped subfield prefilled if needed');
173
};
174
156
subtest 'branchcode' => sub {
175
subtest 'branchcode' => sub {
157
    plan tests => 2;
176
    plan tests => 2;
158
177
159
- 

Return to bug 28445