Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 3c6e133b

Von Moritz Bunkus vor fast 12 Jahren hinzugefügt

  • ID 3c6e133b2e272859f39c7541c8b10eb567831989
  • Vorgänger d093f01c
  • Nachfolger 6395006f

Tag-Presenter: man_days_tag()-Funktion

Unterschiede anzeigen:

SL/Presenter/Tag.pm
use parent qw(Exporter);
use Exporter qw(import);
our @EXPORT = qw(html_tag input_tag name_to_id select_tag stringify_attributes);
our @EXPORT = qw(html_tag input_tag man_days_tag name_to_id select_tag stringify_attributes);
use Carp;
......
readonly selected
);
sub _call_on {
my ($object, $method, @params) = @_;
return $object->$method(@params);
}
sub stringify_attributes {
my ($self, %params) = @_;
......
return $self->html_tag('input', undef, %attributes, name => $name, value => $value);
}
sub man_days_tag {
my ($self, $name, $object, %attributes) = @_;
my $size = delete($attributes{size}) || 5;
my $method = $name;
$method =~ s/^.*\.//;
my $time_selection = $self->input_tag( "${name}_as_man_days_string", _call_on($object, "${method}_as_man_days_string"), %attributes, size => $size);
my $unit_selection = $self->select_tag("${name}_as_man_days_unit", [[ 'h', $::locale->text('h') ], [ 'man_day', $::locale->text('MD') ]],
%attributes, default => _call_on($object, "${method}_as_man_days_unit"));
return $time_selection . $unit_selection;
}
sub name_to_id {
my ($self, $name) = @_;
......
C<$value> and with arbitrary HTML attributes from C<%attributes>. The
tag's C<id> defaults to C<name_to_id($name)>.
=item C<man_days_tag $name, $object, %attributes>
Creates two HTML inputs: a text input for entering a number and a drop
down box for chosing the unit (either 'man days' or 'hours').
C<$object> must be a L<Rose::DB::Object> instance using the
L<SL::DB::Helper::AttrDuration> helper.
C<$name> is supposed to be the name of the underlying column,
e.g. C<time_estimation> for an instance of
C<SL::DB::RequirementSpecItem>. If C<$name> has the form
C<prefix.method> then the full C<$name> is used for the input's base
names while the methods called on C<$object> are only the suffix. This
makes it possible to write statements like e.g.
[% P.man_days_tag("requirement_spec_item.time_estimation", SELF.item) %]
The attribute C<size> can be used to set the text input's size. It
defaults to 5.
=item C<select_tag $name, \@collection, %attributes>
Creates a HTML 'select' tag named C<$name> with the contents of one
locale/de/all
'Long Dates' => 'Lange Monatsnamen',
'Long Description' => 'Langtext',
'MAILED' => 'Gesendet',
'MD' => 'PT',
'Main Preferences' => 'Grundeinstellungen',
'Main sorting' => 'Hauptsortierung',
'Make' => 'Lieferant',
......
'found' => 'Gefunden',
'from (time)' => 'von',
'general_ledger_list' => 'buchungsjournal',
'h' => 'h',
'history' => 'Historie',
'history search engine' => 'Historien Suchmaschine',
'inactive' => 'inaktiv',

Auch abrufbar als: Unified diff