| 1 | package HTML::EditableTable::Vertical; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | @ISA = qw(HTML::EditableTable); | |||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Carp qw(confess); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | HTML::EditableTable::Vertical | ||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | Version 0.21 | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | our $VERSION = '0.21'; | |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | Implementation of the EditableTable class for the construction of 'Vertical' Tables, where the first column of the table presents the header. See L<HTML::EditableTable> for documentation. | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | # makeTable is the 'abstract virtual' method that must be implemented by a derivative of HTML::EditableTable | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | sub makeTable { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeTable: not called CC=16 SCAR=56.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | my $data = $self->{'data'}; # data is a hash of values for a single dataset or an hashes of hashes for the multi-column case | |||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | my $fields = $self->{'tableFields'}; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | my $mode = $self->{'editMode'}; | |||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my $title = undef; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | my $tabindex = undef; | |||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my $headingOrder = undef; | |||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | if (exists $self->{'title'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | $title = $self->{'title'}; | |||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | if (exists $self->{'tabindex'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | $tabindex = $self->{'tabindex'}; | |||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | if (exists $self->{'sortOrder'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | $headingOrder = $self->{'sortOrder'}; # optional array fieldsifing heading order for multi column case | |||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | if (!$data || !$fields || !$mode) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$data and $fields and $mode
$data and $fields
MC/DC0%0/3
$data and $fields and $mode
$data
$fields
$mode
Truth table0%0/4
A and B and C
A= $dataB= $fieldsC= $mode
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | confess "Missing requirement for table, throwing exception"; | |||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | # determine case by probing $data | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my @dataKeys = keys %$data; | |||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my $case; | |||||||||||||||||||||||||||||||||||||||||
| 62 | my $datasetCount; | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my $datasets = {}; | |||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my @datasetHeaders = (); | |||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | if (ref($data->{$dataKeys[0]}) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $datasets = $data; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $datasetCount = scalar(keys %$data); | |||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | if ($headingOrder) { @datasetHeaders = @$headingOrder; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | else { @datasetHeaders = sort keys %$data; } | |||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 76 | # cast the single hash case to the multi column case | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | $datasets = {'1' => $data }; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $datasetCount = 1; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | @datasetHeaders = ('1'); | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | my $tableAttributes = $self->getTableTagAttributes(); | |||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | print "\n<table $tableAttributes>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | # optional title | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | if ($title) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | my $colCount = $datasetCount + 1; | |||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | print "<tr><th colspan=$colCount>" . $title . "</th></tr>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | # headers for multi-column case | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | if (scalar(@datasetHeaders) > 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | print "<tr>"; | |||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | print "<td></td>"; | |||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | foreach my $datasetName (@datasetHeaders) { | |||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | print "<th>" . $datasetName . "</th>"; | |||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | print "</tr>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | foreach my $row (@$fields) { | |||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | my @oneSpec = (); | |||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | push @oneSpec, $row; | |||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | # set the first column flag, which will be reset in staticTableRow(); | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | $self->{'vtableFirstColumn'} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | print "<tr>"; | |||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | foreach my $datasetName (@datasetHeaders) { | |||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | my $data = $datasets->{$datasetName}; | |||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | unless($self->{'suppressUndefinedFields'} && !defined($data->{$row->{'dbfield'}})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"suppressUndefinedFields"} and not defined $$data{$row->{"dbfield"}}
MC/DC0%0/2
$self->{"suppressUndefinedFields"} and not defined $$data{$row->{"dbfield"}}
$self->{"suppressUndefinedFields"}
not defined $$data{$row->{"dbfield"}}
Truth table0%0/3
A and not(B)
A= $self->{"suppressUndefinedFields"}B= not defined $$data{$row->{"dbfield"}}
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | $self->staticTableRow($data, \@oneSpec); | |||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | print "</tr>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | print "</table>"; | |||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | =head1 COPYRIGHT & LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | Copyright 2010 Freescale Semiconductor, all rights reserved. | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||
| 139 | under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | 1 | 1; # End of HTML::EditableTable::Vertical | |||||||||||||||||||||||||||||||||||||||||