lib/OpusVL/AppKit/RolesFor/Controller/GUI.pm

filter: Statementstmt 71.7% 84 / 117 Branchbran 54.7% 23 / 42 Conditioncond 22.2% 2 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 70.0% 14 / 20 Podpod 81.8% 9 / 11 totaltotal 64.7% 132 / 204 CC 27 SCAR 23.6
CC
27
Cov
65%
__ANON__
22.9
flag_callback_error_ex
20.0
london_date
6.0
CRAP 10.6
« blib/lib/OpusVL/AppKit/Plugin/AppKitControllerSorter.pm ↑ Summary blib/lib/OpusVL/AppKit/FormFu/Constraint/AppKitPassword.pm »
1 package OpusVL::AppKit::RolesFor::Controller::GUI;
2  
3  
4 ##################################################################################################################################
5 # use lines.
6 ##################################################################################################################################
7 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 9 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 ##################################################################################################################################
11 # moose calls.
12 ##################################################################################################################################
13  
14 9 has appkit => ( is => 'ro', isa => 'Int', default => 1 );
15 9 has appkit_name => ( is => 'rw', isa => 'Str', default => 'AppKit' );
16 9 has appkit_myclass => ( is => 'ro', isa => 'Str', );
17 9 has appkit_shared_module => ( is => 'rw', isa => 'Str');
18 9 has navigation_items_merged => ( is => 'rw', isa => 'Bool', default => 0 );
19 9 has appkit_method_group_order => ( is => 'rw', isa => 'Int', default => 0);
20 9 has appkit_method_group => ( is => 'rw', isa => 'Str', default => '');
21 9 has appkit_order => ( is => 'rw', isa => 'Int', default => 0);
22  
23 9 has _default_order => ( is => 'rw', isa => 'Int', default => 0);
24  
25  
26 9 has home_action => ( is => 'rw', isa => 'HashRef' );
27  
28  
29 119 ▶has navigation_actions => ( is => 'rw', isa => 'ArrayRef', default => sub { [] } );
Subroutine __ANON__: called CC=1 SCAR=0.0
30  
31  
32 119 ▶has navigation_actions_grouped => ( is => 'rw', isa => 'ArrayRef', default => sub { [] } );
Subroutine __ANON__: called CC=1 SCAR=0.0
33  
34  
35 119 ▶has portlet_actions => ( is => 'rw', isa => 'ArrayRef', default => sub { [] } );
Subroutine __ANON__: called CC=1 SCAR=0.0
36  
37  
38 119 ▶has search_actions => ( is => 'rw', isa => 'ArrayRef', default => sub { [] } );
Subroutine __ANON__: called CC=1 SCAR=0.0
39  
40  
41 before create_action => sub
42 976 ▶{
Subroutine __ANON__: called CC=15 SCAR=31.3
43 976 my $self = shift;
44 976 my %args = @_;
45  
46 # add any ActionClass's to this action.. so when it is called, some extra code is excuted....
47 976 ▶ if ( defined $args{attributes}{AppKitForm} ) { push @{ $args{attributes}{ActionClass} }, "OpusVL::AppKit::Action::AppKitForm"; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"attributes"}{"AppKitForm"}) 72 904 976
48  
49 976 ▶ if ( defined $args{attributes}{NavigationHome} )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"attributes"}{"NavigationHome"}) 24 952 976
50 {
51 # This action has been identified as a Home action...
52 $self->home_action
53 (
54 {
55 actionpath => $args{reverse},
56 actionname => $args{name},
57 }
58 24 );
59 }
60  
61 976 ▶ if ( defined $args{attributes}{NavigationName} )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"attributes"}{"NavigationName"}) 120 856 976
62 {
63 # This action has been identified as a Navigation item..
64 120 my $array = $self->navigation_actions;
65 120 ▶ $array = [] unless defined $array;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $array 0 120 120
66 120 $self->_default_order($self->_default_order+1);
67 120 my $order;
68 120 ▶ if(defined $args{attributes}{NavigationOrder})
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{'attributes'}{'NavigationOrder'}) { } 16 104 120
69 {
70 16 $order = $args{attributes}{NavigationOrder}->[0]
71 }
72 else
73 {
74 104 $order = $self->_default_order;
75 }
76  
77 120 my $hide = {};
78 120 ▶ if ($args{attributes}{Hide}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"attributes"}{"Hide"}) 0 120 120
79 0 my ($key, $value) = split(':', $args{attributes}{Hide}->[0]);
80 0 ▶ if ($key && $value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($key and $value) 0 0 0
Condition0%0/3
$key and $value
!ll&&!rl&&r
000
MC/DC0%0/2
$key and $value
$key $value
Truth table0%0/3
A and B
A= $keyB= $value
ABresult
0X0
100
111
81 0 $hide = {
82 hidden => 1,
83 as => $key,
84 with => $value
85 };
86 }
87 }
88  
89 push
90 (
91 @$array,
92 {
93 value => $args{attributes}{NavigationName}->[0],
94 actionpath => $args{reverse},
95 actionname => $args{name},
96 title => $args{attributes}{Description}->[0],
97 controller => $self,
98 sort_index => $order,
99 hide_as => $hide->{as}||0,
100 120 ▶ hide_with => $hide->{with}||0,
Condition50%2/4
$hide->{'as'} || 0
l!l
0120
$hide->{'with'} || 0
l!l
0120
MC/DC0%0/1
$hide->{'as'} || 0
$hide->{'as'}
MC/DC0%0/1
$hide->{'with'} || 0
$hide->{'with'}
Truth table50%1/2
A
A= $hide->{'as'}
Aresult
11
00
Truth table50%1/2
A
A= $hide->{'with'}
Aresult
11
00
101 }
102 );
103  
104 120 $self->navigation_actions( $array );
105 }
106
107 976 ▶ if ( defined $args{attributes}{PortletName} )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"attributes"}{"PortletName"}) 8 968 976
108 {
109 # This action has been identified as a Portlet action...
110 8 my $array = $self->portlet_actions;
111 8 ▶ $array = [] unless defined $array;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $array 0 8 8
112 push
113 (
114 @$array,
115 {
116 value => $args{attributes}{PortletName}->[0],
117 actionpath => $args{reverse},
118 actionname => $args{name},
119 }
120 8 );
121 8 $self->portlet_actions ( $array );
122 }
123  
124 976 ▶ if ( defined $args{attributes}{SearchName} )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"attributes"}{"SearchName"}) 0 976 976
125 {
126 # This action has been identified as a Search action...
127 0 my $array = $self->search_actions;
128 0 ▶ $array = [] unless defined $array;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $array 0 0 0
129 push
130 (
131 @$array,
132 {
133 value => $args{attributes}{SearchName}->[0],
134 actionpath => $args{reverse},
135 actionname => $args{name},
136 }
137 0 );
138 0 $self->search_actions ( $array );
139 }
140 9 };
141  
142 sub intranet_action_list
143 40 ▶{
Subroutine intranet_action_list: called CC=1 SCAR=0.0
Pod documented
144 40 my $self = shift;
145 40 my $c = shift;
146  
147 40 my $actions = $self->navigation_actions;
148 40 return $self->_sorted_filtered_actions($c, $actions);
149 }
150  
151 sub _sorted_filtered_actions
152 46 ▶{
Subroutine _sorted_filtered_actions: called CC=2 SCAR=7.0
153 46 my $self = shift;
154 46 my $c = shift;
155 46 my $actions = shift;
156  
157 46 ▶ return [] if !$actions;
Branch: 1 branch
BranchTrueFalseTotal
unless $actions 0 46 46
158 12 my @actions = sort { $a->{sort_index} <=> $b->{sort_index} }
159 46 grep { $c->can_access($_->{controller}->action_for($_->{actionname})) } @$actions;
160 46 return \@actions;
161 }
162  
163 sub application_action_list
164 22 ▶{
Subroutine application_action_list: called CC=4 SCAR=13.9
Pod documented
165 # this list includes groups too.
166 22 my $self = shift;
167 22 my $c = shift;
168  
169 22 my $grouped_actions = $self->navigation_actions_grouped;
170 22 ▶ return [] if !$grouped_actions;
Branch: 1 branch
BranchTrueFalseTotal
unless $grouped_actions 0 22 22
171 22 my @groups;
172 22 for my $group (@$grouped_actions)
173 {
174 6 my $filtered = $self->_sorted_filtered_actions($c, $group->{actions});
175 6 ▶ push @groups, { group => $group->{group}, actions => $filtered } if @$filtered;
Branch: 1 branch
BranchTrueFalseTotal
if @$filtered 1 5 6
176 }
177 22 return \@groups;
178 }
179  
180  
181 ##################################################################################################################################
182 # controller actions.
183 ##################################################################################################################################
184  
185 sub date_long
186 51 ▶{
Subroutine date_long: called CC=2 SCAR=6.9
Pod documented
187 51 my ($self, $dt) = @_;
188
189 51 ▶ return if !$dt;
Branch: 1 branch
BranchTrueFalseTotal
unless $dt 9 42 51
190 42 return join '',
191 $dt->day_name,
192 ', ',
193 sprintf("%02d ",$dt->day),
194 $dt->month_name,
195 ' ',
196 $dt->year;
197 }
198  
199 sub date_short
200 1 ▶{
Subroutine date_short: called CC=2 SCAR=7.1
Pod documented
201 1 my ($self, $dt) = @_;
202 1 ▶ return if !$dt;
Branch: 1 branch
BranchTrueFalseTotal
unless $dt 0 1 1
203 1 return join '',
204 sprintf("%02d", $dt->day),
205 '-',
206 $dt->month_abbr,
207 '-',
208 $dt->year;
209 }
210  
211 sub london_date
212 0 ▶{
Subroutine london_date: not called CC=2 SCAR=17.9
Pod undocumented
213 0 my ($self, $dt) = @_;
214 0 ▶ return if !$dt;
Branch: 1 branch
BranchTrueFalseTotal
unless $dt 0 0 0
215 0 $dt->set_time_zone('Europe/London');
216 }
217  
218 sub time_long
219 1 ▶{
Subroutine time_long: called CC=2 SCAR=7.1
Pod documented
220 1 my ($self, $dt) = @_;
221 1 ▶ return if !$dt;
Branch: 1 branch
BranchTrueFalseTotal
unless $dt 0 1 1
222  
223 1 return join '',
224 sprintf('%02d', $dt->hour),
225 ':',
226 sprintf('%02d', $dt->minute),
227 ':',
228 sprintf('%02d', $dt->second);
229  
230 }
231  
232 sub time_short
233 1 ▶{
Subroutine time_short: called CC=2 SCAR=7.1
Pod documented
234 1 my ($self, $dt) = @_;
235 1 ▶ return if !$dt;
Branch: 1 branch
BranchTrueFalseTotal
unless $dt 0 1 1
236  
237 1 return join '',
238 sprintf('%02d', $dt->hour),
239 ':',
240 sprintf('%02d', $dt->minute);
241  
242 }
243  
244  
245 sub add_breadcrumb
246 0 ▶{
Subroutine add_breadcrumb: not called CC=1 SCAR=6.9
Pod documented
247 0 my $self = shift;
248 0 my $c = shift;
249 0 my $args = shift;
250 0 push @{$c->stash->{breadcrumbs}}, $args;
251 }
252  
253  
254 sub add_final_crumb
255 0 ▶{
Subroutine add_final_crumb: not called CC=1 SCAR=6.9
Pod documented
256 0 my $self = shift;
257 0 my $c = shift;
258 0 my $title = shift;
259 0 push @{$c->stash->{breadcrumbs}}, { name => $title, url => $c->req->uri };
260 }
261  
262  
263 sub flag_callback_error
264 0 ▶{
Subroutine flag_callback_error: not called CC=1 SCAR=6.9
Pod documented
265 0 my ($self, $c, $field_name, $message) = @_;
266 0 return $self->flag_callback_error_ex($c, $field_name, { message => $message });
267 }
268  
269 sub flag_callback_error_ex
270 0 ▶{
Subroutine flag_callback_error_ex: not called CC=4 SCAR=30.0
Pod undocumented
271 0 my ($self, $c, $field_name, $args) = @_;
272  
273 0 ▶ $args //= {};
Condition0%0/2
$args //= {}
l!l
00
MC/DC0%0/1
$args //= {}
$args
Truth table0%0/2
A
A= $args
Aresult
11
00
274 0 my $message = $args->{message};
275 0 my $no_detach = $args->{no_detach};
276  
277 0 my $form = $c->stash->{form};
278 0 my $constraint = $form->get_field($field_name)->get_constraint({ type => 'Callback' });
279 0 ▶ $constraint->callback(sub { 0});
Subroutine __ANON__: not called CC=1 SCAR=6.9
280 0 ▶ $constraint->message($message) if $message;
Branch: 1 branch
BranchTrueFalseTotal
if $message 0 0 0
281 0 $form->process;
282 0 ▶ $c->detach unless $no_detach;
Branch: 1 branch
BranchTrueFalseTotal
unless $no_detach 0 0 0
283 }
284  
285 ##
286 9 1;
287  
288 __END__
« blib/lib/OpusVL/AppKit/Plugin/AppKitControllerSorter.pm ↑ Summary blib/lib/OpusVL/AppKit/FormFu/Constraint/AppKitPassword.pm »