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

(-)a/Koha/Template/Plugin/AuthorisedValues.pm (-11 / +6 lines)
Lines 81-97 sub GetDescriptionByKohaField { Link Here
81
            authorised_value => $params->{authorised_value},
81
            authorised_value => $params->{authorised_value},
82
        }
82
        }
83
    );
83
    );
84
    my $av_check = $params->{authorised_value};
84
85
    if ($params->{opac}) {
85
    my $description = $av->{lib} || $params->{authorised_value} || '';
86
        if ($av->{opac_description}) {
86
87
            $av_check = $av->{opac_description}
87
    return $params->{opac}
88
        } elsif ($av->{lib}) {
88
      ? $av->{opac_description} || $description
89
            $av_check = $av->{lib}
89
      : $description;
90
        }
91
    } elsif ($av->{lib}) {
92
        $av_check = $av->{lib}
93
    }
94
    return $av_check
95
}
90
}
96
91
97
1;
92
1;
(-)a/t/db_dependent/Template/Plugin/AuthorisedValues.t (-2 / +4 lines)
Lines 73-79 subtest 'GetByCode' => sub { Link Here
73
73
74
subtest 'GetDescriptionByKohaField' => sub {
74
subtest 'GetDescriptionByKohaField' => sub {
75
75
76
    plan tests => 7;
76
    plan tests => 8;
77
77
78
    $schema->storage->txn_begin;
78
    $schema->storage->txn_begin;
79
79
Lines 145-150 subtest 'GetDescriptionByKohaField' => sub { Link Here
145
    $av = Koha::Template::Plugin::AuthorisedValues->GetDescriptionByKohaField(
145
    $av = Koha::Template::Plugin::AuthorisedValues->GetDescriptionByKohaField(
146
        { kohafield => 'dummy.field', authorised_value => $non_existent_av } );
146
        { kohafield => 'dummy.field', authorised_value => $non_existent_av } );
147
    is( $av, $non_existent_av, 'If both OPAC and staff descriptions are missing, the parameter should be displayed');
147
    is( $av, $non_existent_av, 'If both OPAC and staff descriptions are missing, the parameter should be displayed');
148
    $av = Koha::Template::Plugin::AuthorisedValues->GetDescriptionByKohaField(
149
        { kohafield => 'dummy.field', authorised_value => undef } );
150
    is( $av, '', 'If both OPAC and staff descriptions are missing, and the parameter is undef, an empty string should be displayed');
148
151
149
    $schema->storage->txn_rollback;
152
    $schema->storage->txn_rollback;
150
};
153
};
151
- 

Return to bug 21503