| 1 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||
| 3 | =encoding utf8 | ||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||
| 5 | =head1 NAME | ||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||
| 7 | Quiq::Html::Widget::CheckBoxBar - Zeile von CheckBoxes | ||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||
| 9 | =head1 BASE CLASS | ||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||
| 11 | L<Quiq::Html::Widget> | ||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||
| 13 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||
| 15 | =over 4 | ||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||
| 17 | =item class => $class (Default: undef) | ||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||
| 19 | CSS Klasse des Konstruktes. | ||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||
| 21 | =item disabled => $bool (Default: 0) | ||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||
| 23 | Das gesamte Konstrukt ist disabled. Keine Auswahl möglich. | ||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||
| 25 | =item hidden => $bool (Default: 0) | ||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||
| 27 | Das gesamte Konstrukt ist nicht sichtbar. | ||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||
| 29 | =item id => $id (Default: undef) | ||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||
| 31 | CSS-Id des Konstruktes. | ||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||
| 33 | =item labels => \@labels (Default: []) | ||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||
| 35 | Liste der Label rechts neben den CheckBoxes. | ||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||
| 37 | =item name => $name (Default: undef) | ||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||
| 39 | Name, unter dem die ausgewählten CheckBoxes kommuniziert werden. | ||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||
| 41 | =item onClick => \@onClick (Default: []) | ||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||
| 43 | Liste der OnClick-Handler. | ||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||
| 45 | =item options => \@options (Default: []) | ||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||
| 47 | Liste der CheckBox-Werte. Die Werte der ausgewählten CheckBoxes | ||||||||||||||||||||||||||||||||||
| 48 | werden gesendet. | ||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||
| 50 | =item orientation => 'h'|'v' (Default: 'h') | ||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||
| 52 | Horizentale oder vertikale Ausrichtung der CheckBoxes. | ||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||
| 54 | =item buttonClass => $class (Default: undef) | ||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||
| 56 | CSS Klasse der CheckBoxes. | ||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||
| 58 | =item style => $style (Default: undef) | ||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||
| 60 | CSS Definition des Konstruktes (inline). | ||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||
| 62 | =item titles => \@titles (Default: []) | ||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||
| 64 | Tooltip-Texte der CheckBoxes. | ||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||
| 66 | =item undefIf => $bool (Default: 0) | ||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||
| 68 | Wenn wahr, liefere C<undef> als Widget-Code. | ||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||
| 70 | =item values => \@values (Default: undef) | ||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||
| 72 | Aktuelle Werte. Die CheckBoxes mit den betreffenden Werten werden | ||||||||||||||||||||||||||||||||||
| 73 | aktiviert. | ||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||
| 75 | =back | ||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||
| 77 | =cut | ||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||
| 79 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||
| 81 | package Quiq::Html::Widget::CheckBoxBar; | ||||||||||||||||||||||||||||||||||
| 82 | 1 | ▶ | use base qw/Quiq::Html::Widget/; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||
| 84 | 1 | ▶ | use v5.10; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 85 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 86 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||
| 88 | 1 | our $VERSION = '1.240'; | |||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||
| 90 | 1 | ▶ | use Quiq::Html::Widget::CheckBox; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||
| 92 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||
| 94 | =head1 METHODS | ||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||
| 96 | =head2 Konstruktor | ||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||
| 98 | =head3 new() - Konstruktor | ||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||
| 100 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||
| 102 | $e = $class->new(@keyVal); | ||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||
| 104 | =head4 Description | ||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||
| 106 | Instantiiere ein CheckBoxBar-Objekt und liefere eine Referenz | ||||||||||||||||||||||||||||||||||
| 107 | auf dieses Objekt zurück. | ||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||
| 109 | =cut | ||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||
| 111 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||
| 113 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 114 | 2 | my $class = shift; | |||||||||||||||||||||||||||||||||
| 115 | # @_: @keyVal | ||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||
| 117 | # Defaultwerte | ||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||
| 119 | 2 | my $self = $class->SUPER::new( | |||||||||||||||||||||||||||||||||
| 120 | class => undef, | ||||||||||||||||||||||||||||||||||
| 121 | disabled => 0, | ||||||||||||||||||||||||||||||||||
| 122 | hidden => 0, | ||||||||||||||||||||||||||||||||||
| 123 | id => undef, | ||||||||||||||||||||||||||||||||||
| 124 | labels => [], | ||||||||||||||||||||||||||||||||||
| 125 | name => undef, | ||||||||||||||||||||||||||||||||||
| 126 | onClick => [], | ||||||||||||||||||||||||||||||||||
| 127 | options => [], | ||||||||||||||||||||||||||||||||||
| 128 | orientation => 'h', | ||||||||||||||||||||||||||||||||||
| 129 | buttonClass => undef, | ||||||||||||||||||||||||||||||||||
| 130 | style => undef, | ||||||||||||||||||||||||||||||||||
| 131 | titles => [], | ||||||||||||||||||||||||||||||||||
| 132 | undefIf => 0, | ||||||||||||||||||||||||||||||||||
| 133 | values => [], | ||||||||||||||||||||||||||||||||||
| 134 | ); | ||||||||||||||||||||||||||||||||||
| 135 | 2 | $self->set(@_); | |||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||
| 137 | 2 | return $self; | |||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||
| 140 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||
| 142 | =head2 Objektmethoden | ||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||
| 144 | =head3 html() - Generiere HTML | ||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||
| 146 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||
| 148 | $html = $e->html($h); | ||||||||||||||||||||||||||||||||||
| 149 | $html = $class->html($h,@keyVal); | ||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||
| 151 | =head4 Description | ||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||
| 153 | Generiere den HTML-Code des CheckBoxBar-Objekts und liefere | ||||||||||||||||||||||||||||||||||
| 154 | diesen zurück. Als Klassenmethode gerufen, wird das Objekt intern | ||||||||||||||||||||||||||||||||||
| 155 | erzeugt und mit den Attributen @keyVal instantiiert. | ||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||
| 157 | =cut | ||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||
| 159 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||
| 161 | 2 | ▶ | sub html { | ||||||||||||||||||||||||||||||||
|
Subroutine
html: called CC=12 SCAR=26.5
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 162 | 2 | my $this = shift; | |||||||||||||||||||||||||||||||||
| 163 | 2 | my $h = shift; | |||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||
| 165 | 2 | ▶ | my $self = ref $this? $this: $this->new(@_); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||
| 167 | # Attribute | ||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||
| 169 | 2 | my ($class,$disabled,$hidden,$id,$labelA,$name,$onClickA,$optionA, | |||||||||||||||||||||||||||||||||
| 170 | $orientation,$buttonClass,$style,$titleA,$undefIf,$valueA) = | ||||||||||||||||||||||||||||||||||
| 171 | $self->get(qw/class disabled hidden id labels name onClick options | ||||||||||||||||||||||||||||||||||
| 172 | orientation buttonClass style titles undefIf values/); | ||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||
| 174 | # Generierung | ||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||
| 176 | 2 | ▶ | if ($undefIf) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 177 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||
| 180 | 2 | ▶ | if ($hidden || !@$optionA) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$hidden or not @$optionA
MC/DC50%1/2
$hidden or not @$optionA
$hidden
not @$optionA
Truth table66%2/3
A or not(B)
A= $hiddenB= not @$optionA
| |||||||||||||||||||||||||||||||||||
| 181 | 1 | return ''; | |||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||
| 184 | 1 | my %values; | |||||||||||||||||||||||||||||||||
| 185 | 1 | @values{@$valueA} = (1) x @$valueA; | |||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||
| 187 | return $h->tag('span', | ||||||||||||||||||||||||||||||||||
| 188 | -fmt => 'v', # generierten Code einzeilig belassen | ||||||||||||||||||||||||||||||||||
| 189 | -ignoreTagIf => !$id && !$class && !$style, | ||||||||||||||||||||||||||||||||||
| 190 | id => $id, | ||||||||||||||||||||||||||||||||||
| 191 | class => $class, | ||||||||||||||||||||||||||||||||||
| 192 | style => $style, | ||||||||||||||||||||||||||||||||||
| 193 | 1 | ▶ | do { | ||||||||||||||||||||||||||||||||
|
Condition33%2/6
$id || $class || $style
$id or $class
MC/DC0%0/3
$id || $class || $style
$id
$class
$style
Truth table25%1/4
A or B || C
A= $idB= $classC= $style
| |||||||||||||||||||||||||||||||||||
| 194 | 1 | my $html; | |||||||||||||||||||||||||||||||||
| 195 | 1 | ▶ | for (my $i = 0; $i < @$optionA; $i++) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 196 | 3 | my $option = $optionA->[$i]; | |||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||
| 198 | 3 | ▶ | if ($html) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 199 | 2 | ▶ | $html .= $orientation eq 'v'? $h->tag('br',-nl=>0): ' '; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||
| 201 | $html .= Quiq::Html::Widget::CheckBox->html($h, | ||||||||||||||||||||||||||||||||||
| 202 | class => $buttonClass, | ||||||||||||||||||||||||||||||||||
| 203 | disabled => $disabled, | ||||||||||||||||||||||||||||||||||
| 204 | label => $labelA->[$i] // $option, | ||||||||||||||||||||||||||||||||||
| 205 | name => $name, | ||||||||||||||||||||||||||||||||||
| 206 | onClick => $onClickA->[$i], | ||||||||||||||||||||||||||||||||||
| 207 | option => $option, | ||||||||||||||||||||||||||||||||||
| 208 | title => $titleA->[$i], | ||||||||||||||||||||||||||||||||||
| 209 | 3 | ▶ | value => $values{$option}? $option: undef, | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$labelA->[$i] // $option
MC/DC0%0/2
$labelA->[$i] // $option
$labelA->[$i]
$option
Truth table33%1/3
A // B
A= $labelA->[$i]B= $option
| |||||||||||||||||||||||||||||||||||
| 210 | ); | ||||||||||||||||||||||||||||||||||
| 211 | 3 | chomp $html; | |||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||
| 213 | 1 | $html; | |||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||
| 215 | ); | ||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||
| 218 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||
| 220 | =head1 VERSION | ||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||
| 222 | 1.240 | ||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||
| 224 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||
| 226 | Frank Seitz, L<http://fseitz.de/> | ||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||
| 228 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||
| 230 | Copyright (C) 2026 Frank Seitz | ||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||
| 232 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||
| 234 | This code is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||
| 235 | it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||
| 237 | =cut | ||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||
| 239 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||
| 241 | 1 | 1; | |||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||
| 243 | # eof | ||||||||||||||||||||||||||||||||||