| 1 | package HTML::FormHandler::Widget::Theme::BootstrapFormMessages; | ||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: role to render form messages using Bootstrap styling | ||||||||||||||||||||||||||||||||
| 3 | 7 | $HTML::FormHandler::Widget::Theme::BootstrapFormMessages::VERSION = '0.410002'; | |||||||||||||||||||||||||||||||
| 4 | 7 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 7 | ▶ | use HTML::Entities qw( encode_entities ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||
| 8 | 6 | ▶ | sub render_form_messages { | ||||||||||||||||||||||||||||||
|
Subroutine
render_form_messages: called CC=11 SCAR=24.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 9 | 6 | my ( $self, $result ) = @_; | |||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||
| 11 | 6 | ▶ | return '' if $self->get_tag('no_form_message_div'); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||
| 13 | 6 | ▶ | $result ||= $self->result; | ||||||||||||||||||||||||||||||
|
Condition66%2/3
$result ||= $self->result
MC/DC0%0/2
$result ||= $self->result
$result
$self->result
Truth table66%2/3
A ||= B
A= $resultB= $self->result
| |||||||||||||||||||||||||||||||||
| 14 | 6 | my $output = ''; | |||||||||||||||||||||||||||||||
| 15 | 6 | ▶ | if ( $result->has_form_errors || $result->has_errors ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$result->has_form_errors or $result->has_errors
MC/DC50%1/2
$result->has_form_errors or $result->has_errors
$result->has_form_errors
$result->has_errors
Truth table66%2/3
A or B
A= $result->has_form_errorsB= $result->has_errors
| |||||||||||||||||||||||||||||||||
| 16 | 1 | my $alert_error_class = $self->form_messages_alert_error_class; | |||||||||||||||||||||||||||||||
| 17 | 1 | $output = qq{\n<div class="alert $alert_error_class">}; | |||||||||||||||||||||||||||||||
| 18 | 1 | my $msg = $self->error_message; | |||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | $msg ||= 'There were errors in your form'; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$msg ||= "There were errors in your form"
MC/DC0%0/1
$msg ||= "There were errors in your form"
$msg
Truth table50%1/2
A
A= $msg
| |||||||||||||||||||||||||||||||||
| 20 | 1 | $msg = encode_entities($self->_localize($msg)); | |||||||||||||||||||||||||||||||
| 21 | 1 | $output .= qq{\n<span class="error_message">$msg</span>}; | |||||||||||||||||||||||||||||||
| 22 | $output .= qq{\n<span class="error_message">$_</span>} | ||||||||||||||||||||||||||||||||
| 23 | 0 | for map { encode_entities($_) } $result->all_form_errors; | |||||||||||||||||||||||||||||||
| 24 | 1 | $output .= "\n</div>"; | |||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||
| 26 | elsif ( $result->validated ) { | ||||||||||||||||||||||||||||||||
| 27 | 1 | my $msg = $self->success_message; | |||||||||||||||||||||||||||||||
| 28 | 1 | ▶ | $msg ||= "Your form was successfully submitted"; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$msg ||= "Your form was successfully submitted"
MC/DC0%0/1
$msg ||= "Your form was successfully submitted"
$msg
Truth table50%1/2
A
A= $msg
| |||||||||||||||||||||||||||||||||
| 29 | 1 | $msg = encode_entities($self->_localize($msg)); | |||||||||||||||||||||||||||||||
| 30 | 1 | $output = qq{\n<div class="alert alert-success">}; | |||||||||||||||||||||||||||||||
| 31 | 1 | $output .= qq{\n<span>$msg</span>}; | |||||||||||||||||||||||||||||||
| 32 | 1 | $output .= "\n</div>"; | |||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||
| 34 | 6 | ▶ | if ( $self->has_info_message && $self->info_message ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->has_info_message and $self->info_message
MC/DC50%1/2
$self->has_info_message and $self->info_message
$self->has_info_message
$self->info_message
Truth table66%2/3
A and B
A= $self->has_info_messageB= $self->info_message
| |||||||||||||||||||||||||||||||||
| 35 | 1 | my $msg = $self->info_message; | |||||||||||||||||||||||||||||||
| 36 | 1 | $msg = encode_entities($self->_localize($msg)); | |||||||||||||||||||||||||||||||
| 37 | 1 | $output = qq{\n<div class="alert alert-info">}; | |||||||||||||||||||||||||||||||
| 38 | 1 | $output .= qq{\n<span>$msg</span>}; | |||||||||||||||||||||||||||||||
| 39 | 1 | $output .= "\n</div>"; | |||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||
| 41 | 6 | return $output; | |||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | 1 | ▶ | sub form_messages_alert_error_class { 'alert-error' } | ||||||||||||||||||||||||||||||
|
Subroutine
form_messages_alert_error_class: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | 7 | 1; | |||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||
| 48 | __END__ | ||||||||||||||||||||||||||||||||