| 1 | package HTML::FormHandler::Field::Multiple; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: multiple select list | ||||||||||||||||||||||||||||
| 3 | 19 | $HTML::FormHandler::Field::Multiple::VERSION = '0.410002'; | |||||||||||||||||||||||||||
| 4 | 19 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 19 | extends 'HTML::FormHandler::Field::Select'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 19 | has '+multiple' => ( default => 1 ); | |||||||||||||||||||||||||||
| 9 | 19 | has '+size' => ( default => 5 ); | |||||||||||||||||||||||||||
| 10 | 31 | ▶ | has '+sort_options_method' => ( default => sub { \&default_sort_options } ); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 48 | ▶ | sub default_sort_options { | ||||||||||||||||||||||||||
|
Subroutine
default_sort_options: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 13 | 48 | my ( $self, $options ) = @_; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 48 | ▶ | return $options unless scalar @$options && defined $self->value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
scalar @$options and defined $self->value
MC/DC50%1/2
scalar @$options and defined $self->value
scalar @$options
defined $self->value
Truth table66%2/3
A and B
A= scalar @$optionsB= defined $self->value
| |||||||||||||||||||||||||||||
| 16 | 44 | my $value = $self->deflate($self->value); | |||||||||||||||||||||||||||
| 17 | 44 | ▶ | return $options unless scalar @$value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 18 | # This places the currently selected options at the top of the list | ||||||||||||||||||||||||||||
| 19 | # Makes the drop down lists a bit nicer | ||||||||||||||||||||||||||||
| 20 | 6 | my %selected = map { $_ => 1 } @$value; | |||||||||||||||||||||||||||
| 21 | 6 | my @out = grep { $selected{ $_->{value} } } @$options; | |||||||||||||||||||||||||||
| 22 | 6 | push @out, grep { !$selected{ $_->{value} } } @$options; | |||||||||||||||||||||||||||
| 23 | 6 | return \@out; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 19 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 27 | 19 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | 19 | 1; | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | __END__ | ||||||||||||||||||||||||||||