my %options = (
show_reqs => checkbox( -name => 'show_reqids',
-checked => 0,
-value => 'ON',
-label => 'Show requirement
+ IDs?'),
date => "<b>Created: </b>"
. radio_group(
-name=>'bef_since',
-values=>['before', 'since'],
-default=>'none',
-labels => {'before' => 'b
+efore ',
'since' => 's
+ince (inclusive)'}
)
. " <b>Date</b> (YYYY-MM-DD
+): "
. textfield(-name=>'date', -size=>10,
+-maxlength=>10),
req_type => "<b>Requirement Type</b> (e.g. BRQ): "
. textfield( -name => 'reqtype',
-size => 5,
-maxlength=>5),
);
my %report_types = (
0 => {
name => "Project Requirements: Filtered by
+Creation Date",
opts => ['show_reqs', 'date'],
coderef => \&report_type_two
},
1 => {
name => "Project Requirement Revisions: Fil
+tered by Creation Date, Type, and Version Reason",
opts => ['show_reqs', 'req_type', 'date'],
coderef => \&report_type_three},
);
It is now more obvious that you are generating the actual elements a little soon. I would make the options sub refs that take the report name as an argument (and possibly more) so that you could create unique instances. At least they should take the fields own name as an argument. I think the following will be close:
my %options = (
show_reqs => sub { my $report = shift;
return checkbox(
-name => $report . '_show_
+reqids',
-checked => 0,
-value => 'ON',
-label => 'Show requirement
+ IDs?'),
}
);
print $options{$option}->($report), "\n";
In this manner your options are constructors. They could even take in more arguments, like default values or something, so that each report could have different defaults.
|