| 1 | package Mojolicious::Plugin::FormFieldsFromJSON; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 87 | ▶ | use Mojo::Base 'Mojolicious::Plugin'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # ABSTRACT: create form fields based on a definition in a JSON file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 87 | our $VERSION = '1.03'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 87 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 87 | ▶ | use File::Basename; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 87 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 87 | ▶ | use IO::Dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 87 | ▶ | use List::Util qw(first); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 87 | ▶ | use Mojo::Asset::File; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 87 | ▶ | use Mojo::Collection; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 87 | ▶ | use Mojo::ByteStream; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 87 | ▶ | use Mojo::File qw(path); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 87 | ▶ | use Mojo::JSON qw(decode_json); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 87 | ▶ | use Mojolicious (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 87 | ▶ | has dir => sub { ["."] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 87 | ▶ | sub register { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register: called CC=6 SCAR=18.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 87 | my ( $self, $app, $config ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 87 | ▶ | $config //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$config //= {}
MC/DC0%0/1
$config //= {}
$config
Truth table50%1/2
A
A= $config
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 87 | ▶ | if ( $config->{template_file} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | $config->{template} = path( $app->home, 'templates', $config->{template_file} )->slurp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | ▶ | $config->{template} //= $app->renderer->get_data_template( $config->{template_file} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$config->{"template"} //= $app->renderer->get_data_template($config->{"template_file"})
MC/DC0%0/2
$config->{"template"} //= $app->renderer->get_data_template($config->{"template_file"})
$config->{"template"}
$app->renderer->get_data_template($config->{"template_file"})
Truth table33%1/3
A //= B
A= $config->{"template"}B= $app->renderer->get_data_template($config->{"template_file"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 87 | my %configs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 87 | ▶ | if ( ref $config->{dir} eq "ARRAY" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 1 | @{ $self->dir } = @{ $config->{dir} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 86 | @{ $self->dir } = ( $config->{dir} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | my %valid_types = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 87 | ▶ | %{ $config->{types} || {} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$config->{'types'} || {}
MC/DC100%1/1
$config->{'types'} || {}
$config->{'types'}
Truth table100%2/2
A
A= $config->{'types'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | text => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | checkbox => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | select => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | radio => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | hidden => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | textarea => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | password => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 87 | my %configfiles; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | $app->helper( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 1 | ▶ | forms => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 1 | ▶ | if (%configfiles) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | my @sorted_configfiles = sort keys %configfiles; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | return @sorted_configfiles; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | for my $dir ( @{ $self->dir } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | my $dir = IO::Dir->new($dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | FILE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 1 | ▶ | while ( my $file = $dir->read ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 5 | ▶ | next FILE if $file !~ m{\.json\z}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 3 | my $filename = basename $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 3 | $filename =~ s{\.json\z}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 3 | $configfiles{$filename} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 1 | my @sorted_configfiles = sort keys %configfiles; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | return @sorted_configfiles; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 87 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 87 | ▶ | $app->helper( "form_fields_from_json_dir" => sub { return $self->dir } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | $app->helper( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 2 | ▶ | fields => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=21.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 2 | my ( $c, $file, $params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 2 | ▶ | if ( !$configs{$file} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | $self->_load_config_from_file( $c, \%configs, $file ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 2 | my @fields; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | my @fields_long; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 2 | for my $field ( @{ $configs{$file} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 4 | ▶ | my $name = $field->{label} // $field->{name} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
($field->{"label"} // $field->{"name"}) // ""
$field->{"label"} // $field->{"name"}
MC/DC0%0/2
($field->{"label"} // $field->{"name"}) // ""
$field->{"label"}
$field->{"name"}
Truth table33%1/3
A // B
A= $field->{"label"}B= $field->{"name"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 4 | push @fields, $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 4 | ▶ | push @fields_long, +{ label => $name, name => $field->{name} // '' }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$field->{"name"} // ""
MC/DC0%0/1
$field->{"name"} // ""
$field->{"name"}
Truth table50%1/2
A
A= $field->{"name"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 2 | ▶ | if ( $params and $params->{hash} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$params and $params->{"hash"}
MC/DC50%1/2
$params and $params->{"hash"}
$params
$params->{"hash"}
Truth table66%2/3
A and B
A= $paramsB= $params->{"hash"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 1 | return @fields_long; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 1 | return @fields; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 87 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | $app->helper( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 35 | ▶ | 'validate_form_fields' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=33 SCAR=36.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 35 | my ( $c, $file ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 35 | ▶ | return '' if !$file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 35 | ▶ | if ( !$configs{$file} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 12 | $self->_load_config_from_file( $c, \%configs, $file ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 35 | ▶ | return '' if !$configs{$file}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 35 | my $config = $configs{$file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 35 | my $validation = $c->validation; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 35 | my $params_hash = $c->req->params->to_hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 35 | ▶ | my @param_names = keys %{ $params_hash || {} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$params_hash || {}
MC/DC0%0/1
$params_hash || {}
$params_hash
Truth table50%1/2
A
A= $params_hash
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 35 | my %params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 35 | for my $name ( @param_names ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 31 | my $param_values = $c->every_param($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 31 | ▶ | $params{$name} = @{$param_values || [] } > 1 ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$param_values || []
MC/DC0%0/1
$param_values || []
$param_values
Truth table50%1/2
A
A= $param_values
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | $param_values : $param_values->[-1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 35 | $validation->input( \%params ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 35 | my %errors; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | FIELD: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 35 | for my $field ( @{$config} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 35 | ▶ | if ( 'HASH' ne ref $field ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $app->log->error('Field definition must be a HASH - skipping field'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | next FIELD; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 35 | ▶ | if ( !$field->{validation} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | next FIELD; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 35 | ▶ | if ( 'HASH' ne ref $field->{validation} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | $app->log->warn('Validation settings must be a HASH - skipping field'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | next FIELD; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 35 | my $filters = $field->{validation}->{filters}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 35 | ▶ | my $name = $field->{name} // $field->{label} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
($field->{"name"} // $field->{"label"}) // ""
$field->{"name"} // $field->{"label"}
MC/DC0%0/2
($field->{"name"} // $field->{"label"}) // ""
$field->{"name"}
$field->{"label"}
Truth table33%1/3
A // B
A= $field->{"name"}B= $field->{"label"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 35 | my $global_error = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 35 | ▶ | if ( $field->{validation}->{required} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 12 | ▶ | $validation->required($name, @{ $filters || [] }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$filters || []
MC/DC100%1/1
$filters || []
$filters
Truth table100%2/2
A
A= $filters
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 12 | my $value = $field->{validation}->{required}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 12 | ▶ | if ( ref $value && 'HASH' eq ref $value ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $value and "HASH" eq ref $value
MC/DC50%1/2
ref $value and "HASH" eq ref $value
ref $value
"HASH" eq ref $value
Truth table66%2/3
A and B
A= ref $valueB= "HASH" eq ref $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 2 | ▶ | $global_error = $value->{msg} // 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$value->{"msg"} // 1
MC/DC0%0/1
$value->{"msg"} // 1
$value->{"msg"}
Truth table50%1/2
A
A= $value->{"msg"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 23 | ▶ | $validation->optional($name, @{ $filters || [] }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$filters || []
MC/DC100%1/1
$filters || []
$filters
Truth table100%2/2
A
A= $filters
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | RULE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 35 | for my $rule ( sort keys %{ $field->{validation} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 54 | ▶ | last RULE if !defined $params{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 48 | ▶ | next RULE if $rule eq 'required'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 41 | ▶ | next RULE if $rule eq 'filters'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 30 | my $value = $field->{validation}->{$rule}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 30 | my $ref = ref $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 30 | my $method = $rule; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 30 | my $error = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 30 | my @params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 30 | ▶ | if ( !$ref ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 3 | @params = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | elsif ( $ref eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 17 | @params = @{$value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | elsif ( $ref eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 10 | ▶ | @params = ref $value->{args} ? @{ $value->{args} } : $value->{args}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 10 | ▶ | $error = $value->{msg} // 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$value->{"msg"} // 1
MC/DC0%0/1
$value->{"msg"} // 1
$value->{"msg"}
Truth table50%1/2
A
A= $value->{"msg"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 30 | $validation->check( $method, @params ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 30 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 30 | ▶ | } or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $app->log->error("Validating $name with rule $method failed: $@"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 30 | ▶ | if ( $validation->has_error($name) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 10 | $errors{$name} = $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 10 | last RULE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 35 | ▶ | if ( $validation->has_error($name) && !defined $errors{$name} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$validation->has_error($name) and not defined $errors{$name}
MC/DC100%2/2
$validation->has_error($name) and not defined $errors{$name}
$validation->has_error($name)
not defined $errors{$name}
Truth table100%3/3
A and not(B)
A= $validation->has_error($name)B= not defined $errors{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 5 | $errors{$name} = $global_error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 35 | return %errors; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 87 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | $app->helper( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 107 | ▶ | 'form_fields' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=10 SCAR=23.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 107 | my ( $c, $file, %params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | # get form config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 107 | ▶ | return '' if !$self->_load_config_from_file( $c, \%configs, $file ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 106 | ▶ | return '' if !$configs{$file} && !ref $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$configs{$file} or ref $file
MC/DC0%0/2
$configs{$file} or ref $file
$configs{$file}
ref $file
Truth table66%2/3
A or B
A= $configs{$file}B= ref $file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 106 | ▶ | my $field_config = $configs{$file} || $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$configs{$file} || $file
MC/DC0%0/2
$configs{$file} || $file
$configs{$file}
$file
Truth table66%2/3
A || B
A= $configs{$file}B= $file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 106 | my @fields; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 106 | ▶ | my %fields_to_show = map { $_ => 1 } @{ $params{fields} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$params{'fields'} || []
MC/DC100%1/1
$params{'fields'} || []
$params{'fields'}
Truth table100%2/2
A
A= $params{'fields'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | FIELD: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 106 | for my $field ( @{$field_config} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 145 | ▶ | next FIELD if %fields_to_show && !$fields_to_show{ $field->{name} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
%fields_to_show and not $fields_to_show{$field->{"name"}}
MC/DC100%2/2
%fields_to_show and not $fields_to_show{$field->{"name"}}
%fields_to_show
not $fields_to_show{$field->{"name"}}
Truth table100%3/3
A and not(B)
A= %fields_to_showB= not $fields_to_show{$field->{"name"}}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 143 | my $field_content = $self->_build_form_field( $c, $field, \%params, $config, \%valid_types ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 143 | ▶ | if ( length $field_content ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 143 | push @fields, $field_content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 106 | return Mojo::ByteStream->new( join "\n\n", @fields ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 87 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | $app->helper( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 4 | ▶ | 'form_field_by_name' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=19.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 4 | my ( $c, $file, $field_name, %params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | # get form config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 4 | ▶ | return '' if !$self->_load_config_from_file( $c, \%configs, $file ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 4 | ▶ | return '' if !$configs{$file} && !ref $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$configs{$file} or ref $file
MC/DC0%0/2
$configs{$file} or ref $file
$configs{$file}
ref $file
Truth table33%1/3
A or B
A= $configs{$file}B= ref $file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 4 | ▶ | my $field_config = $configs{$file} || $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$configs{$file} || $file
MC/DC0%0/2
$configs{$file} || $file
$configs{$file}
$file
Truth table33%1/3
A || B
A= $configs{$file}B= $file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | # find field config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 4 | my @fields_filtered = grep { $_->{name} eq $field_name } @{$field_config}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 4 | ▶ | return '' if !( scalar @fields_filtered ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 4 | return $self->_build_form_field( $c, $fields_filtered[0], \%params, $config, \%valid_types ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 87 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 87 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 124 | ▶ | sub _load_config_from_file { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_config_from_file: called CC=11 SCAR=24.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 124 | my ( $self, $c, $configs, $file ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 124 | ▶ | return 0 if !$file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 124 | ▶ | if ( !$configs->{$file} && !ref $file ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$configs->{$file} or ref $file
MC/DC100%2/2
$configs->{$file} or ref $file
$configs->{$file}
ref $file
Truth table100%3/3
A or B
A= $configs->{$file}B= ref $file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 87 | my $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | # search until first match | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 87 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 91 | my $_path = File::Spec->catfile( $self->dir->[$i], $file . '.json' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 91 | ▶ | $path = $_path if -r $_path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 87 | ▶ | } while ( not defined $path and ++$i <= $#{ $self->dir } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $path and ++$i <= $#{$self->dir;}
MC/DC100%2/2
not defined $path and ++$i <= $#{$self->dir;}
not defined $path
++$i <= $#{$self->dir;}
Truth table100%3/3
not(A) and B
A= not defined $pathB= ++$i <= $#{$self->dir;}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 87 | ▶ | if ( not defined $path ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 1 | $c->app->log->error("FORMFIELDS $file: not found in directories"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 1 | $c->app->log->error(" $_") for @{ $self->dir }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 86 | my $content = Mojo::Asset::File->new( path => $path )->slurp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 86 | $configs->{$file} = decode_json $content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 86 | ▶ | } or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | $c->app->log->error("FORMFIELDS $file: $@"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 86 | ▶ | if ( 'ARRAY' ne ref $configs->{$file} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | $c->app->log->error('Definition JSON must be an ARRAY'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 123 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 147 | ▶ | sub _build_form_field { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_form_field: called CC=28 SCAR=34.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 147 | my ( $self, $c, $field, $params, $plugin_config, $valid_types ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 147 | ▶ | if ( 'HASH' ne ref $field ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | $c->app->log->error('Field definition must be an HASH - skipping field'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 147 | my $type = lc $field->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 147 | my $orig_type = $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 147 | ▶ | if ( $plugin_config->{alias} && $plugin_config->{alias}->{$type} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$plugin_config->{"alias"} and $plugin_config->{"alias"}{$type}
MC/DC100%2/2
$plugin_config->{"alias"} and $plugin_config->{"alias"}{$type}
$plugin_config->{"alias"}
$plugin_config->{"alias"}{$type}
Truth table100%3/3
A and B
A= $plugin_config->{"alias"}B= $plugin_config->{"alias"}{$type}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 3 | $type = $plugin_config->{alias}->{$type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 147 | ▶ | if ( !$valid_types->{$type} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | $c->app->log->warn("Invalid field type $type - falling back to 'text'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | $type = 'text'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 147 | ▶ | if ( $plugin_config->{global_attributes} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$plugin_config->{"global_attributes"} and $type ne "hidden" and "HASH" eq ref $plugin_config->{"global_attributes"}
$plugin_config->{"global_attributes"} and $type ne "hidden"
MC/DC66%2/3
$plugin_config->{"global_attributes"} and $type ne "hidden" and "HASH" eq ref $plugin_config->{"global_attributes"}
$plugin_config->{"global_attributes"}
$type ne "hidden"
"HASH" eq ref $plugin_config->{"global_attributes"}
Truth table75%3/4
A and B and C
A= $plugin_config->{"global_attributes"}B= $type ne "hidden"C= "HASH" eq ref $plugin_config->{"global_attributes"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | && $type ne 'hidden' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | && 'HASH' eq ref $plugin_config->{global_attributes} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | ATTRIBUTE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 24 | for my $attribute ( keys %{ $plugin_config->{global_attributes} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 24 | ▶ | $field->{attributes}->{$attribute} //= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$field->{"attributes"}{$attribute} //= ""
MC/DC100%1/1
$field->{"attributes"}{$attribute} //= ""
$field->{"attributes"}{$attribute}
Truth table100%2/2
A
A= $field->{"attributes"}{$attribute}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 24 | my $field_attr = $field->{attributes}->{$attribute}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 24 | my $global_attr = $plugin_config->{global_attributes}->{$attribute}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 24 | ▶ | next ATTRIBUTE if $field_attr =~ m{\Q$global_attr}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 18 | ▶ | my $space = length $field_attr ? ' ' : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 18 | $field->{attributes}->{$attribute} .= $space . $global_attr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 147 | ▶ | if ( $field->{translate_sublabels} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$field->{"translate_sublabels"} and $plugin_config->{"translation_method"} and not $field->{"translation_method"}
$field->{"translate_sublabels"} and $plugin_config->{"translation_method"}
MC/DC33%1/3
$field->{"translate_sublabels"} and $plugin_config->{"translation_method"} and not $field->{"translation_method"}
$field->{"translate_sublabels"}
$plugin_config->{"translation_method"}
not $field->{"translation_method"}
Truth table50%2/4
A and B and not(C)
A= $field->{"translate_sublabels"}B= $plugin_config->{"translation_method"}C= not $field->{"translation_method"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | && $plugin_config->{translation_method} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | && !$field->{translation_method} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 2 | $field->{translation_method} = $plugin_config->{translation_method}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 147 | my $sub = $self->can( '_' . $type ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 147 | my $form_field = $self->$sub( $c, $field, %{$params} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 147 | $form_field = Mojo::ByteStream->new($form_field); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | my $template = $field->{template} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | // $plugin_config->{templates}->{$orig_type} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 147 | ▶ | // $plugin_config->{template}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
($field->{"template"} // $plugin_config->{"templates"}{$orig_type}) // $plugin_config->{"template"}
$field->{"template"} // $plugin_config->{"templates"}{$orig_type}
MC/DC100%3/3
($field->{"template"} // $plugin_config->{"templates"}{$orig_type}) // $plugin_config->{"template"}
$field->{"template"}
$plugin_config->{"templates"}{$orig_type}
$plugin_config->{"template"}
Truth table100%4/4
A // B // C
A= $field->{"template"}B= $plugin_config->{"templates"}{$orig_type}C= $plugin_config->{"template"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 147 | ▶ | if ( $template && $type ne 'hidden' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$template and $type ne "hidden"
MC/DC50%1/2
$template and $type ne "hidden"
$template
$type ne "hidden"
Truth table66%2/3
A and B
A= $templateB= $type ne "hidden"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 23 | ▶ | my $label = $field->{label} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$field->{"label"} // ""
MC/DC0%0/1
$field->{"label"} // ""
$field->{"label"}
Truth table50%1/2
A
A= $field->{"label"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 23 | my $loc = $plugin_config->{translation_method}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 23 | ▶ | if ( $plugin_config->{translate_labels} && $loc && 'CODE' eq ref $loc ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$plugin_config->{"translate_labels"} and $loc and "CODE" eq ref $loc
$plugin_config->{"translate_labels"} and $loc
MC/DC33%1/3
$plugin_config->{"translate_labels"} and $loc and "CODE" eq ref $loc
$plugin_config->{"translate_labels"}
$loc
"CODE" eq ref $loc
Truth table50%2/4
A and B and C
A= $plugin_config->{"translate_labels"}B= $locC= "CODE" eq ref $loc
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 1 | $label = $loc->( $c, $label ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | $form_field = Mojo::ByteStream->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | $c->render_to_string( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | inline => $template, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | id => $field->{id} // $field->{name} // $field->{label} // '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | label => $label, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | field => $form_field, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | message => $field->{msg} // '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 23 | ▶ | info => $field->{info} // '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition58%7/12
(($field->{"id"} // $field->{"name"}) // $field->{"label"}) // ""
($field->{"id"} // $field->{"name"}) // $field->{"label"}
$field->{"id"} // $field->{"name"}
$field->{"msg"} // ""
$field->{"info"} // ""
MC/DC0%0/3
(($field->{"id"} // $field->{"name"}) // $field->{"label"}) // ""
$field->{"id"}
$field->{"name"}
$field->{"label"}
MC/DC100%1/1
$field->{"msg"} // ""
$field->{"msg"}
MC/DC100%1/1
$field->{"info"} // ""
$field->{"info"}
Truth table25%1/4
A // B // C
A= $field->{"id"}B= $field->{"name"}C= $field->{"label"}
Truth table100%2/2
A
A= $field->{"msg"}
Truth table100%2/2
A
A= $field->{"info"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | # $c->app->log->debug("rendered formfield: ".$form_field); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 147 | return $form_field; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 8 | ▶ | sub _hidden { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_hidden: called CC=11 SCAR=26.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 8 | my ( $self, $c, $field, %params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 8 | ▶ | my $name = $field->{name} // $field->{label} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
($field->{"name"} // $field->{"label"}) // ""
$field->{"name"} // $field->{"label"}
MC/DC0%0/2
($field->{"name"} // $field->{"label"}) // ""
$field->{"name"}
$field->{"label"}
Truth table33%1/3
A // B
A= $field->{"name"}B= $field->{"label"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 8 | my $from_stash_key = $params{from_stash}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | my $from_stash = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | $from_stash_key | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 8 | ▶ | ? $c->stash($from_stash_key)->{$name} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | my $value = $params{$name}->{data} // $from_stash // $c->stash($name) // $c->param($name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 8 | ▶ | // $field->{data} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition71%10/14
(((($params{$name}{"data"} // $from_stash) // $c->stash($name)) // $c->param($name)) // $field->{"data"}) // ""
((($params{$name}{"data"} // $from_stash) // $c->stash($name)) // $c->param($name)) // $field->{"data"}
(($params{$name}{"data"} // $from_stash) // $c->stash($name)) // $c->param($name)
($params{$name}{"data"} // $from_stash) // $c->stash($name)
$params{$name}{"data"} // $from_stash
MC/DC0%0/5
(((($params{$name}{"data"} // $from_stash) // $c->stash($name)) // $c->param($name)) // $field->{"data"}) // ""
$params{$name}{"data"}
$from_stash
$c->stash($name)
$c->param($name)
$field->{"data"}
Truth table50%3/6
A // B // C // D // E
A= $params{$name}{"data"}B= $from_stashC= $c->stash($name)D= $c->param($name)E= $field->{"data"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 8 | ▶ | my $id = $field->{id} // $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$field->{"id"} // $name
MC/DC0%0/2
$field->{"id"} // $name
$field->{"id"}
$name
Truth table33%1/3
A // B
A= $field->{"id"}B= $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 8 | ▶ | my %attrs = %{ $field->{attributes} || {} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$field->{'attributes'} || {}
MC/DC0%0/1
$field->{'attributes'} || {}
$field->{'attributes'}
Truth table50%1/2
A
A= $field->{'attributes'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 8 | return $c->hidden_field( $name, $value, id => $id, %attrs ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 33 | ▶ | sub _text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_text: called CC=11 SCAR=24.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 33 | my ( $self, $c, $field, %params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 33 | ▶ | my $name = $field->{name} // $field->{label} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
($field->{"name"} // $field->{"label"}) // ""
$field->{"name"} // $field->{"label"}
MC/DC0%0/2
($field->{"name"} // $field->{"label"}) // ""
$field->{"name"}
$field->{"label"}
Truth table33%1/3
A // B
A= $field->{"name"}B= $field->{"label"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 33 | my $from_stash_key = $params{from_stash}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | my $from_stash = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | $from_stash_key | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 33 | ▶ | ? $c->stash($from_stash_key)->{$name} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | my $value = $params{$name}->{data} // $from_stash // $c->stash($name) // $c->param($name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 33 | ▶ | // $field->{data} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%14/14
(((($params{$name}{"data"} // $from_stash) // $c->stash($name)) // $c->param($name)) // $field->{"data"}) // ""
((($params{$name}{"data"} // $from_stash) // $c->stash($name)) // $c->param($name)) // $field->{"data"}
(($params{$name}{"data"} // $from_stash) // $c->stash($name)) // $c->param($name)
($params{$name}{"data"} // $from_stash) // $c->stash($name)
$params{$name}{"data"} // $from_stash
MC/DC100%5/5
(((($params{$name}{"data"} // $from_stash) // $c->stash($name)) // $c->param($name)) // $field->{"data"}) // ""
$params{$name}{"data"}
$from_stash
$c->stash($name)
$c->param($name)
$field->{"data"}
Truth table100%6/6
A // B // C // D // E
A= $params{$name}{"data"}B= $from_stashC= $c->stash($name)D= $c->param($name)E= $field->{"data"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 33 | ▶ | my $id = $field->{id} // $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$field->{"id"} // $name
MC/DC0%0/2
$field->{"id"} // $name
$field->{"id"}
$name
Truth table33%1/3
A // B
A= $field->{"id"}B= $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 33 | ▶ | my %attrs = %{ $field->{attributes} || {} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$field->{'attributes'} || {}
MC/DC100%1/1
$field->{'attributes'} || {}
$field->{'attributes'}
Truth table100%2/2
A
A= $field->{'attributes'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 33 | return $c->text_field( $name, $value, id => $id, %attrs ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 38 | ▶ | sub _select { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_select: called CC=24 SCAR=32.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 38 | my ( $self, $c, $field, %params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 38 | ▶ | my $name = $field->{name} // $field->{label} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
($field->{"name"} // $field->{"label"}) // ""
$field->{"name"} // $field->{"label"}
MC/DC0%0/2
($field->{"name"} // $field->{"label"}) // ""
$field->{"name"}
$field->{"label"}
Truth table33%1/3
A // B
A= $field->{"name"}B= $field->{"label"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 38 | my $from_stash_key = $params{from_stash}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | my $from_stash = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | $from_stash_key | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 38 | ▶ | ? $c->stash($from_stash_key)->{$name} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 38 | ▶ | my $field_params = $params{$name} || {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$params{$name} || {}
MC/DC100%1/1
$params{$name} || {}
$params{$name}
Truth table100%2/2
A
A= $params{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | my %select_params = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | disabled => $self->_get_highlighted_values( $field, 'disabled' ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | selected => $self->_get_highlighted_values( $field, 'selected' ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 38 | my $stash_values = $c->every_param($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 38 | ▶ | if ( scalar( @{ $stash_values || [] } ) == 0 && defined( $c->stash($name) ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
scalar @{$stash_values or [];} == 0 and defined $c->stash($name)
$stash_values || []
MC/DC100%2/2
scalar @{$stash_values or [];} == 0 and defined $c->stash($name)
scalar @{$stash_values or [];} == 0
defined $c->stash($name)
MC/DC0%0/1
$stash_values || []
$stash_values
Truth table100%3/3
A and B
A= scalar @{$stash_values or [];} == 0B= defined $c->stash($name)
Truth table50%1/2
A
A= $stash_values
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 3 | my $local_stash = $c->stash($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 3 | ▶ | $stash_values = ref $local_stash ? $local_stash : [$local_stash]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 38 | ▶ | if ($from_stash) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 1 | ▶ | $stash_values = ref $from_stash ? $from_stash : [$from_stash]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 38 | my $reset; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 38 | ▶ | if ( @{ $stash_values || [] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$stash_values || []
MC/DC0%0/1
$stash_values || []
$stash_values
Truth table50%1/2
A
A= $stash_values
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | $select_params{selected} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 13 | $self->_get_highlighted_values( +{ selected => $stash_values }, 'selected', ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 13 | $reset = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 38 | for my $key (qw/disabled selected/) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 76 | my $hashref = $self->_get_highlighted_values( $field_params, $key ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 76 | ▶ | if ( keys %{$hashref} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 7 | $select_params{$key} = $hashref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 38 | ▶ | if ( $field_params->{data} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 5 | $select_params{data} = $field_params->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 38 | my @values = $self->_get_select_values( $c, $field, %select_params ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 38 | ▶ | my $id = $field->{id} // $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$field->{"id"} // $name
MC/DC0%0/2
$field->{"id"} // $name
$field->{"id"}
$name
Truth table33%1/3
A // B
A= $field->{"id"}B= $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 38 | ▶ | my %attrs = %{ $field->{attributes} || {} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$field->{'attributes'} || {}
MC/DC100%1/1
$field->{'attributes'} || {}
$field->{'attributes'}
Truth table100%2/2
A
A= $field->{'attributes'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 38 | ▶ | if ( $field->{multiple} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 4 | $attrs{multiple} = 'multiple'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 4 | ▶ | $attrs{size} = $field->{size} || 5; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$field->{'size'} || 5
MC/DC0%0/1
$field->{'size'} || 5
$field->{'size'}
Truth table50%1/2
A
A= $field->{'size'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 38 | my @selected = keys %{ $select_params{selected} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 38 | ▶ | if (@selected) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 18 | my $single = scalar @selected; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 18 | ▶ | my $param = $single == 1 ? $selected[0] : \@selected; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 18 | $c->param( $name, $param ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 38 | my $select_field = $c->select_field( $name, [@values], id => $id, %attrs ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | # reset parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 38 | ▶ | if ($reset) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 13 | my $single = scalar @{$stash_values}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 13 | ▶ | my $param = $single == 1 ? $stash_values->[0] : $stash_values; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 13 | $c->param( $name, $param ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 38 | return $select_field; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 386 | ▶ | sub _get_highlighted_values { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_highlighted_values: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 386 | my ( $self, $field, $key ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 386 | ▶ | return +{} if !$field->{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 69 | my %highlighted; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 69 | ▶ | if ( !ref $field->{$key} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 25 | my $value = $field->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 25 | $highlighted{$value} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | elsif ( 'ARRAY' eq ref $field->{$key} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 44 | for my $value ( @{ $field->{$key} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 52 | $highlighted{$value} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 69 | return \%highlighted; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 39 | ▶ | sub _get_select_values { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_select_values: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 39 | my ( $self, $c, $field, %params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 39 | ▶ | my $data = $params{data} || $field->{data} || []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%5/5
$params{'data'} || $field->{'data'} || []
$params{"data"} or $field->{"data"}
MC/DC100%2/2
$params{'data'} || $field->{'data'} || []
$params{"data"}
$field->{"data"}
Truth table100%3/3
A or B
A= $params{"data"}B= $field->{"data"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 39 | ▶ | if ( $field->{data_cb} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 1 | my @parts = split /::/, $field->{data_cb}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 1 | my $subname = pop @parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 1 | my $class = join '::', @parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 1 | my $sub = $class->can($subname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 1 | ▶ | $data = $sub->() if $sub; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 39 | my @values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 39 | ▶ | if ( 'ARRAY' eq ref $data ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 35 | @values = $self->_transform_array_values( $data, %params ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | elsif ( 'HASH' eq ref $data ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 4 | @values = $self->_transform_hash_values( $c, $data, %params ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 39 | return @values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 4 | ▶ | sub _transform_hash_values { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_transform_hash_values: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 4 | my ( $self, $c, $data, %params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 4 | my @values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 4 | my $numeric = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 4 | my $counter = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 4 | my %mapping; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | KEY: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 4 | for my $key ( keys %{$data} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 7 | ▶ | if ( ref $data->{$key} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 1 | my @group_values = $self->_get_select_values( $c, +{ data => $data->{$key} }, %params ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 1 | $values[$counter] = Mojo::Collection->new( $key => \@group_values ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 1 | $mapping{$key} = $counter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 6 | my %opts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 6 | ▶ | $opts{disabled} = 'disabled' if $params{disabled}->{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 6 | ▶ | $opts{selected} = undef if $params{selected}->{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | #$opts{selected} = undef if $params{selected}->{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 6 | $values[$counter] = [ $data->{$key} => $key, %opts ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 6 | $mapping{$key} = $counter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 7 | $counter++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 4 | ▶ | if ( first { $_ =~ m{[^0-9]} } keys %mapping ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 3 | $numeric = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | my @sorted_keys = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | $numeric | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 1 | ? sort { $a <=> $b } keys %mapping | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 4 | ▶ | : sort { $a cmp $b } keys %mapping; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 4 | my @indexes = @mapping{@sorted_keys}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 4 | my @sorted_values = @values[@indexes]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 4 | return @sorted_values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 35 | ▶ | sub _transform_array_values { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_transform_array_values: called CC=7 SCAR=19.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 35 | my ( $self, $data, %params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 35 | my @values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 35 | my $numeric = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 35 | for my $value ( @{$data} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 93 | ▶ | if ( $numeric && $value =~ m{[^0-9]} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$numeric and $value =~ /[^0-9]/u
MC/DC50%1/2
$numeric and $value =~ /[^0-9]/u
$numeric
$value =~ /[^0-9]/u
Truth table66%2/3
A and B
A= $numericB= $value =~ /[^0-9]/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 35 | $numeric = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 93 | my %opts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 93 | ▶ | $opts{disabled} = 'disabled' if $params{disabled}->{$value}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 93 | ▶ | $opts{selected} = undef if $params{selected}->{$value}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | #$opts{selected} = undef if $params{selected}->{$value}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 93 | push @values, [ $value => $value, %opts ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | @values = $numeric | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | ? sort { $a->[0] <=> $b->[0] } @values | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 35 | ▶ | : sort { $a->[0] cmp $b->[0] } @values; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 35 | return @values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 25 | ▶ | sub _radio { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_radio: called CC=31 SCAR=35.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 25 | my ( $self, $c, $field, %params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 25 | ▶ | my $name = $field->{name} // $field->{label} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
($field->{"name"} // $field->{"label"}) // ""
$field->{"name"} // $field->{"label"}
MC/DC0%0/2
($field->{"name"} // $field->{"label"}) // ""
$field->{"name"}
$field->{"label"}
Truth table33%1/3
A // B
A= $field->{"name"}B= $field->{"label"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 25 | ▶ | my $id = $field->{id} // $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$field->{"id"} // $name
MC/DC0%0/2
$field->{"id"} // $name
$field->{"id"}
$name
Truth table33%1/3
A // B
A= $field->{"id"}B= $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 25 | ▶ | my %attrs = %{ $field->{attributes} || {} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$field->{'attributes'} || {}
MC/DC100%1/1
$field->{'attributes'} || {}
$field->{'attributes'}
Truth table100%2/2
A
A= $field->{'attributes'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 25 | ▶ | my $data = $params{$name}->{data} // $field->{data} // []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition60%3/5
($params{$name}{"data"} // $field->{"data"}) // []
$params{$name}{"data"} // $field->{"data"}
MC/DC0%0/2
($params{$name}{"data"} // $field->{"data"}) // []
$params{$name}{"data"}
$field->{"data"}
Truth table66%2/3
A // B
A= $params{$name}{"data"}B= $field->{"data"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 25 | ▶ | my @values = ref $data ? @{$data} : ($data); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 25 | ▶ | my $field_params = $params{$name} || {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$params{$name} || {}
MC/DC0%0/1
$params{$name} || {}
$params{$name}
Truth table50%1/2
A
A= $params{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | my %select_params = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | disabled => $self->_get_highlighted_values( $field, 'disabled' ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | selected => $self->_get_highlighted_values( $field, 'selected' ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 25 | my $stash_values = $c->every_param($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 25 | ▶ | if ( scalar( @{ $stash_values || [] } ) == 0 && defined( $c->stash($name) ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
scalar @{$stash_values or [];} == 0 and defined $c->stash($name)
$stash_values || []
MC/DC100%2/2
scalar @{$stash_values or [];} == 0 and defined $c->stash($name)
scalar @{$stash_values or [];} == 0
defined $c->stash($name)
MC/DC0%0/1
$stash_values || []
$stash_values
Truth table100%3/3
A and B
A= scalar @{$stash_values or [];} == 0B= defined $c->stash($name)
Truth table50%1/2
A
A= $stash_values
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 1 | my $local_stash = $c->stash($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 1 | ▶ | $stash_values = ref $local_stash ? $local_stash : [$local_stash]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 25 | my $reset; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 25 | ▶ | if ( @{ $stash_values || [] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$stash_values || []
MC/DC0%0/1
$stash_values || []
$stash_values
Truth table50%1/2
A
A= $stash_values
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 4 | $select_params{selected} = $self->_get_highlighted_values( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | +{ selected => $stash_values }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 'selected', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 4 | $reset = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 25 | for my $key (qw/disabled selected/) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 50 | my $hashref = $self->_get_highlighted_values( $field_params, $key ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 50 | ▶ | if ( keys %{$hashref} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 5 | $select_params{$key} = $hashref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 25 | my @selected = keys %{ $select_params{selected} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 25 | ▶ | if (@selected) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 6 | my $single = scalar @selected; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 6 | ▶ | my $param = $single == 1 ? $selected[0] : \@selected; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 6 | $c->param( $name, $param ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 25 | my $radiobuttons = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 25 | for my $radio_value (@values) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 42 | my %value_attributes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 42 | ▶ | if ( $select_params{disabled}->{$radio_value} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 3 | $value_attributes{disabled} = 'disabled'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 42 | ▶ | if ( $select_params{selected}->{$radio_value} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 6 | $value_attributes{checked} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 42 | my $local_label = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 42 | ▶ | if ( $field->{show_value} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 4 | $local_label = $radio_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 42 | my $loc = $field->{translation_method}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 42 | ▶ | if ( length $local_label && $field->{translate_sublabels} && $loc && 'CODE' eq ref $loc ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
length $local_label and $field->{"translate_sublabels"} and $loc and "CODE" eq ref $loc
length $local_label and $field->{"translate_sublabels"} and $loc
length $local_label and $field->{"translate_sublabels"}
MC/DC50%2/4
length $local_label and $field->{"translate_sublabels"} and $loc and "CODE" eq ref $loc
length $local_label
$field->{"translate_sublabels"}
$loc
"CODE" eq ref $loc
Truth table60%3/5
A and B and C and D
A= length $local_labelB= $field->{"translate_sublabels"}C= $locD= "CODE" eq ref $loc
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 2 | $local_label = $loc->( $c, $local_label ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 42 | ▶ | $local_label = " " . $local_label if length $local_label; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 42 | $radiobuttons .= $c->radio_button( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | $name => $radio_value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | id => $id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | %attrs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | %value_attributes, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | ) . "$local_label\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 42 | ▶ | if ( defined $field->{after_element} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 2 | $radiobuttons .= $field->{after_element}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 25 | ▶ | if ($reset) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 4 | my $single = scalar @{$stash_values}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 4 | ▶ | my $param = $single == 1 ? $stash_values->[0] : $stash_values; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 4 | $c->param( $name, $param ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 25 | return $radiobuttons; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 28 | ▶ | sub _checkbox { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_checkbox: called CC=31 SCAR=34.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 28 | my ( $self, $c, $field, %params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 28 | ▶ | my $name = $field->{name} // $field->{label} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
($field->{"name"} // $field->{"label"}) // ""
$field->{"name"} // $field->{"label"}
MC/DC0%0/2
($field->{"name"} // $field->{"label"}) // ""
$field->{"name"}
$field->{"label"}
Truth table33%1/3
A // B
A= $field->{"name"}B= $field->{"label"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 28 | ▶ | my $id = $field->{id} // $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$field->{"id"} // $name
MC/DC0%0/2
$field->{"id"} // $name
$field->{"id"}
$name
Truth table33%1/3
A // B
A= $field->{"id"}B= $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 28 | ▶ | my %attrs = %{ $field->{attributes} || {} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$field->{'attributes'} || {}
MC/DC100%1/1
$field->{'attributes'} || {}
$field->{'attributes'}
Truth table100%2/2
A
A= $field->{'attributes'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 28 | ▶ | my $data = $params{$name}->{data} // $field->{data} // []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition60%3/5
($params{$name}{"data"} // $field->{"data"}) // []
$params{$name}{"data"} // $field->{"data"}
MC/DC0%0/2
($params{$name}{"data"} // $field->{"data"}) // []
$params{$name}{"data"}
$field->{"data"}
Truth table66%2/3
A // B
A= $params{$name}{"data"}B= $field->{"data"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 28 | ▶ | my @values = ref $data ? @{$data} : ($data); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 28 | ▶ | my $field_params = $params{$name} || {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$params{$name} || {}
MC/DC0%0/1
$params{$name} || {}
$params{$name}
Truth table50%1/2
A
A= $params{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | my %select_params = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | disabled => $self->_get_highlighted_values( $field, 'disabled' ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | selected => $self->_get_highlighted_values( $field, 'selected' ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 28 | my $stash_values = $c->every_param($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 28 | ▶ | if ( scalar( @{ $stash_values || [] } ) == 0 && defined( $c->stash($name) ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
scalar @{$stash_values or [];} == 0 and defined $c->stash($name)
$stash_values || []
MC/DC100%2/2
scalar @{$stash_values or [];} == 0 and defined $c->stash($name)
scalar @{$stash_values or [];} == 0
defined $c->stash($name)
MC/DC0%0/1
$stash_values || []
$stash_values
Truth table100%3/3
A and B
A= scalar @{$stash_values or [];} == 0B= defined $c->stash($name)
Truth table50%1/2
A
A= $stash_values
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 2 | my $local_stash = $c->stash($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 2 | ▶ | $stash_values = ref $local_stash ? $local_stash : [$local_stash]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 28 | my $reset; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 28 | ▶ | if ( @{ $stash_values || [] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$stash_values || []
MC/DC0%0/1
$stash_values || []
$stash_values
Truth table50%1/2
A
A= $stash_values
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | $select_params{selected} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 5 | $self->_get_highlighted_values( +{ selected => $stash_values }, 'selected', ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 5 | $c->param( $name, '' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 5 | $reset = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 28 | for my $key (qw/disabled selected/) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 56 | my $hashref = $self->_get_highlighted_values( $field_params, $key ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 56 | ▶ | if ( keys %{$hashref} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 6 | $select_params{$key} = $hashref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 28 | my @selected = keys %{ $select_params{selected} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 28 | ▶ | if (@selected) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 8 | my $single = scalar @selected; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 8 | ▶ | my $param = $single == 1 ? $selected[0] : \@selected; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 8 | $c->param( $name, $param ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 28 | my $checkboxes = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 28 | for my $checkbox_value (@values) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 44 | my %value_attributes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 44 | ▶ | if ( $select_params{disabled}->{$checkbox_value} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 3 | $value_attributes{disabled} = 'disabled'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 44 | ▶ | if ( $select_params{selected}->{$checkbox_value} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 9 | $value_attributes{checked} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 44 | my $local_label = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 44 | ▶ | if ( $field->{show_value} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 4 | $local_label = $checkbox_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 44 | my $loc = $field->{translation_method}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 44 | ▶ | if ( length $local_label && $field->{translate_sublabels} && $loc && 'CODE' eq ref $loc ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
length $local_label and $field->{"translate_sublabels"} and $loc and "CODE" eq ref $loc
length $local_label and $field->{"translate_sublabels"} and $loc
length $local_label and $field->{"translate_sublabels"}
MC/DC50%2/4
length $local_label and $field->{"translate_sublabels"} and $loc and "CODE" eq ref $loc
length $local_label
$field->{"translate_sublabels"}
$loc
"CODE" eq ref $loc
Truth table60%3/5
A and B and C and D
A= length $local_labelB= $field->{"translate_sublabels"}C= $locD= "CODE" eq ref $loc
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 2 | $local_label = $loc->( $c, $local_label ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 44 | ▶ | $local_label = " " . $local_label if length $local_label; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 44 | $checkboxes .= $c->check_box( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | $name => $checkbox_value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | id => $id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | %attrs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | %value_attributes, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | ) . "$local_label\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 44 | ▶ | if ( defined $field->{after_element} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 3 | $checkboxes .= $field->{after_element}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 28 | ▶ | if ($reset) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 5 | my $single = scalar @{$stash_values}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 5 | ▶ | my $param = $single == 1 ? $stash_values->[0] : $stash_values; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 5 | $c->param( $name, $param ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 28 | return $checkboxes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 8 | ▶ | sub _textarea { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_textarea: called CC=9 SCAR=22.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 8 | my ( $self, $c, $field, %params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 8 | ▶ | my $name = $field->{name} // $field->{label} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
($field->{"name"} // $field->{"label"}) // ""
$field->{"name"} // $field->{"label"}
MC/DC0%0/2
($field->{"name"} // $field->{"label"}) // ""
$field->{"name"}
$field->{"label"}
Truth table33%1/3
A // B
A= $field->{"name"}B= $field->{"label"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 8 | ▶ | my $value = $params{$name}->{data} // $c->stash($name) // $c->param($name) // $field->{data} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition90%10/11
((($params{$name}{"data"} // $c->stash($name)) // $c->param($name)) // $field->{"data"}) // ""
(($params{$name}{"data"} // $c->stash($name)) // $c->param($name)) // $field->{"data"}
($params{$name}{"data"} // $c->stash($name)) // $c->param($name)
$params{$name}{"data"} // $c->stash($name)
MC/DC75%3/4
((($params{$name}{"data"} // $c->stash($name)) // $c->param($name)) // $field->{"data"}) // ""
$params{$name}{"data"}
$c->stash($name)
$c->param($name)
$field->{"data"}
Truth table80%4/5
A // B // C // D
A= $params{$name}{"data"}B= $c->stash($name)C= $c->param($name)D= $field->{"data"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 8 | ▶ | my $id = $field->{id} // $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$field->{"id"} // $name
MC/DC0%0/2
$field->{"id"} // $name
$field->{"id"}
$name
Truth table33%1/3
A // B
A= $field->{"id"}B= $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 8 | ▶ | my %attrs = %{ $field->{attributes} || {} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$field->{'attributes'} || {}
MC/DC100%1/1
$field->{'attributes'} || {}
$field->{'attributes'}
Truth table100%2/2
A
A= $field->{'attributes'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 8 | return $c->text_area( $name, $value, id => $id, %attrs ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 6 | ▶ | sub _password { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_password: called CC=9 SCAR=24.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 6 | my ( $self, $c, $field, %params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 6 | ▶ | my $name = $field->{name} // $field->{label} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
($field->{"name"} // $field->{"label"}) // ""
$field->{"name"} // $field->{"label"}
MC/DC0%0/2
($field->{"name"} // $field->{"label"}) // ""
$field->{"name"}
$field->{"label"}
Truth table33%1/3
A // B
A= $field->{"name"}B= $field->{"label"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 6 | ▶ | my $value = $params{$name}->{data} // $c->stash($name) // $c->param($name) // $field->{data} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition63%7/11
((($params{$name}{"data"} // $c->stash($name)) // $c->param($name)) // $field->{"data"}) // ""
(($params{$name}{"data"} // $c->stash($name)) // $c->param($name)) // $field->{"data"}
($params{$name}{"data"} // $c->stash($name)) // $c->param($name)
$params{$name}{"data"} // $c->stash($name)
MC/DC25%1/4
((($params{$name}{"data"} // $c->stash($name)) // $c->param($name)) // $field->{"data"}) // ""
$params{$name}{"data"}
$c->stash($name)
$c->param($name)
$field->{"data"}
Truth table40%2/5
A // B // C // D
A= $params{$name}{"data"}B= $c->stash($name)C= $c->param($name)D= $field->{"data"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 6 | ▶ | my $id = $field->{id} // $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$field->{"id"} // $name
MC/DC0%0/2
$field->{"id"} // $name
$field->{"id"}
$name
Truth table33%1/3
A // B
A= $field->{"id"}B= $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 6 | ▶ | my %attrs = %{ $field->{attributes} || {} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$field->{'attributes'} || {}
MC/DC100%1/1
$field->{'attributes'} || {}
$field->{'attributes'}
Truth table100%2/2
A
A= $field->{'attributes'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 6 | return $c->password_field( $name, value => $value, id => $id, %attrs ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 87 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||