Design/Controller/Initialize.pm untested

filter: Statementstmt 0.0% 0 / 40 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 48 CC 1 SCAR 6.9
CC
1
Cov
0%
build_check_boxes
2.0
homepage
2.0
BEGIN
2.0
CRAP 2.0
1 package WWW::Garden::Design::Controller::Initialize;
2  
3 use Mojo::Base 'Mojolicious::Controller';
4  
5 use Moo;
6  
7 use Data::Dumper::Concise; # For Dumper().
8  
9 use utf8;
10  
11 our $VERSION = '0.97';
12  
13 # -----------------------------------------------
14  
15 sub build_check_boxes
16 {
17 my($self, $type_names, $fields, $ids) = @_;
18  
19 my($field);
20 my(@html);
21 my($id_index, $id);
22 my($name_index, $name);
23 my($type_name);
24  
25 my(@check_boxes) = map
26 {
27 $name_index = $_;
28 $type_name = $$type_names[$name_index];
29 $name = ucfirst $$type_names[$name_index] =~ s/_/ /gr;
30 @html = map
31 {
32 $id_index = $_;
33 $field = $$fields{$type_name}[$id_index] =~ s/_/ /gr;
34 $id = $$ids[$name_index][$id_index];
35  
36 "<input id = '$id' type = 'checkbox'>"
37 . "<label for = '$id'>$field</label>";
38 } 0 .. $#{$$ids[$name_index]};
39  
40 [$name, join('&nbsp;&nbsp;&nbsp', @html)];
41 } 0 .. $#$type_names;
42  
43 return [@check_boxes];
44  
45 } # End of build_check_boxes.
46  
47 # -----------------------------------------------
48  
49 sub homepage
50 {
51 my($self) = @_;
52  
53 $self -> app -> log -> debug('Initialize.homepage()');
54  
55 my($defaults) = $self -> app -> defaults;
56  
57 $self -> stash(attribute_check_boxes => $self -> build_check_boxes($$defaults{attribute_type_names}, $$defaults{attribute_type_fields}, $$defaults{attribute_attribute_ids}) );
58 $self -> stash(csrf_token => $self -> session('csrf_token') );
59 $self -> stash(search_check_boxes => $self -> build_check_boxes($$defaults{attribute_type_names}, $$defaults{attribute_type_fields}, $$defaults{search_attribute_ids}) );
60  
61 # These parameters are passed to homepage.html.ep for incorporation into JS code.
62  
63 $self -> render
64 (
65 features_current_feature_id => $$defaults{features_current_feature_id},
66 attribute_elements => $$defaults{attribute_elements},
67 constants => $$defaults{constants_table},
68 design_garden_menu => $$defaults{design_garden_menu},
69 design_property_menu => $$defaults{design_property_menu},
70 features_current_feature_id => $$defaults{features_current_feature_id},
71 feature_menu => $$defaults{feature_menu},
72 gardens_current_garden_id => $$defaults{gardens_current_garden_id},
73 gardens_current_property_id_1 => $$defaults{gardens_current_property_id_1},
74 gardens_current_property_id_2 => $$defaults{properties_current_property_id},
75 gardens_garden_menu => $$defaults{gardens_garden_menu},
76 gardens_property_menu_1 => $$defaults{gardens_property_menu_1},
77 gardens_property_menu_2 => $$defaults{gardens_property_menu_2},
78 joiner => '><',
79 properties_current_property_id => $$defaults{properties_current_property_id},
80 properties_property_menu => $$defaults{properties_property_menu},
81 version => $VERSION,
82 );
83  
84 } # End of homepage.
85  
86 # -----------------------------------------------
87  
88 1;
89  
90 =pod
91  
92 =head1 NAME
93  
94 WWW::Garden::Design::Controller::Initialize - Manage the 'flowers' database
95  
96 =head1 Machine-Readable Change Log
97  
98 The file Changes was converted into Changelog.ini by L<Module::Metadata::Changes>.
99  
100 =head1 Version Numbers
101  
102 Version numbers < 1.00 represent development versions. From 1.00 up, they are production versions.
103  
104 =head1 Repository
105  
106 L<https://github.com/ronsavage/WWW-Garden-Design>
107  
108 =head1 Support
109  
110 Email the author, or log a bug on RT:
111  
112 L<https://rt.cpan.org/Public/Dist/Display.html?Name=WWW::Garden::Design>.
113  
114 =head1 Author
115  
116 L<WWW::Garden::Design> was written by Ron Savage I<E<lt>ron@savage.net.auE<gt>> in 2014.
117  
118 My homepage: L<https://savage.net.au/>.
119  
120 =head1 Copyright
121  
122 Australian copyright (c) 2018, Ron Savage.
123  
124 All Programs of mine are 'OSI Certified Open Source Software';
125 you can redistribute them and/or modify them under the terms of
126 The Perl License, a copy of which is available at:
127 http://dev.perl.org/licenses/
128  
129 =cut