5 |
5 |
use parent qw(Exporter);
|
6 |
6 |
|
7 |
7 |
use Exporter qw(import);
|
8 |
|
our @EXPORT = qw(html_tag input_tag name_to_id select_tag stringify_attributes);
|
|
8 |
our @EXPORT = qw(html_tag input_tag man_days_tag name_to_id select_tag stringify_attributes);
|
9 |
9 |
|
10 |
10 |
use Carp;
|
11 |
11 |
|
... | ... | |
14 |
14 |
readonly selected
|
15 |
15 |
);
|
16 |
16 |
|
|
17 |
sub _call_on {
|
|
18 |
my ($object, $method, @params) = @_;
|
|
19 |
return $object->$method(@params);
|
|
20 |
}
|
|
21 |
|
|
22 |
|
17 |
23 |
sub stringify_attributes {
|
18 |
24 |
my ($self, %params) = @_;
|
19 |
25 |
|
... | ... | |
45 |
51 |
return $self->html_tag('input', undef, %attributes, name => $name, value => $value);
|
46 |
52 |
}
|
47 |
53 |
|
|
54 |
sub man_days_tag {
|
|
55 |
my ($self, $name, $object, %attributes) = @_;
|
|
56 |
|
|
57 |
my $size = delete($attributes{size}) || 5;
|
|
58 |
my $method = $name;
|
|
59 |
$method =~ s/^.*\.//;
|
|
60 |
|
|
61 |
my $time_selection = $self->input_tag( "${name}_as_man_days_string", _call_on($object, "${method}_as_man_days_string"), %attributes, size => $size);
|
|
62 |
my $unit_selection = $self->select_tag("${name}_as_man_days_unit", [[ 'h', $::locale->text('h') ], [ 'man_day', $::locale->text('MD') ]],
|
|
63 |
%attributes, default => _call_on($object, "${method}_as_man_days_unit"));
|
|
64 |
|
|
65 |
return $time_selection . $unit_selection;
|
|
66 |
}
|
|
67 |
|
48 |
68 |
sub name_to_id {
|
49 |
69 |
my ($self, $name) = @_;
|
50 |
70 |
|
... | ... | |
225 |
245 |
C<$value> and with arbitrary HTML attributes from C<%attributes>. The
|
226 |
246 |
tag's C<id> defaults to C<name_to_id($name)>.
|
227 |
247 |
|
|
248 |
=item C<man_days_tag $name, $object, %attributes>
|
|
249 |
|
|
250 |
Creates two HTML inputs: a text input for entering a number and a drop
|
|
251 |
down box for chosing the unit (either 'man days' or 'hours').
|
|
252 |
|
|
253 |
C<$object> must be a L<Rose::DB::Object> instance using the
|
|
254 |
L<SL::DB::Helper::AttrDuration> helper.
|
|
255 |
|
|
256 |
C<$name> is supposed to be the name of the underlying column,
|
|
257 |
e.g. C<time_estimation> for an instance of
|
|
258 |
C<SL::DB::RequirementSpecItem>. If C<$name> has the form
|
|
259 |
C<prefix.method> then the full C<$name> is used for the input's base
|
|
260 |
names while the methods called on C<$object> are only the suffix. This
|
|
261 |
makes it possible to write statements like e.g.
|
|
262 |
|
|
263 |
[% P.man_days_tag("requirement_spec_item.time_estimation", SELF.item) %]
|
|
264 |
|
|
265 |
The attribute C<size> can be used to set the text input's size. It
|
|
266 |
defaults to 5.
|
|
267 |
|
228 |
268 |
=item C<select_tag $name, \@collection, %attributes>
|
229 |
269 |
|
230 |
270 |
Creates a HTML 'select' tag named C<$name> with the contents of one
|
Tag-Presenter: man_days_tag()-Funktion