| 1 | package Data::MuForm::Field::Multiple; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: multiple select list | ||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 5 | extends 'Data::MuForm::Field::Select'; | |||||||||||||||||||||||||||
| 5 | 5 | our $VERSION = '0.01'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 5 | has '+multiple' => ( default => 1 ); | |||||||||||||||||||||||||||
| 9 | #has '+size' => ( default => 5 ); rendering info | ||||||||||||||||||||||||||||
| 10 | # TODO: deal with setting methods in base field classes | ||||||||||||||||||||||||||||
| 11 | 0 | ▶ | sub build_base_methods { { sort_options => \&default_sort_options } } | ||||||||||||||||||||||||||
|
Subroutine
build_base_methods: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | sub default_sort_options { | ||||||||||||||||||||||||||||
| 14 | 0 | ▶ | my ( $self, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
default_sort_options: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 0 | ▶ | return $options unless scalar @$options && defined $self->value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
scalar @$options and defined $self->value
MC/DC0%0/2
scalar @$options and defined $self->value
scalar @$options
defined $self->value
Truth table0%0/3
A and B
A= scalar @$optionsB= defined $self->value
| |||||||||||||||||||||||||||||
| 17 | 0 | my $value = $self->deflate($self->value); | |||||||||||||||||||||||||||
| 18 | 0 | ▶ | return $options unless scalar @$value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 19 | # This places the currently selected options at the top of the list | ||||||||||||||||||||||||||||
| 20 | # Makes the drop down lists a bit nicer | ||||||||||||||||||||||||||||
| 21 | 0 | my %selected = map { $_ => 1 } @$value; | |||||||||||||||||||||||||||
| 22 | 0 | my @out = grep { $selected{ $_->{value} } } @$options; | |||||||||||||||||||||||||||
| 23 | 0 | push @out, grep { !$selected{ $_->{value} } } @$options; | |||||||||||||||||||||||||||
| 24 | 0 | return \@out; | |||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 5 | 1; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | __END__ | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | =pod | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | =head1 NAME | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | Data::MuForm::Field::Multiple - multiple select list | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | =head1 VERSION | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | version 0.04 | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | This is a convenience field that inherits from the Select field and | ||||||||||||||||||||||||||||
| 46 | pre-sets some attributes. It sets the 'multiple' flag, | ||||||||||||||||||||||||||||
| 47 | sets the 'size' attribute to 5, and sets the 'sort_options_method' to | ||||||||||||||||||||||||||||
| 48 | move the currently selected options to the top of the options list. | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | Gerda Shank | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | This software is copyright (c) 2017 by Gerda Shank. | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 59 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =cut | ||||||||||||||||||||||||||||