Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 3c6e133b

Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt

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

Tag-Presenter: man_days_tag()-Funktion

Unterschiede anzeigen:

SL/Presenter/Tag.pm
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
locale/de/all
1162 1162
  'Long Dates'                  => 'Lange Monatsnamen',
1163 1163
  'Long Description'            => 'Langtext',
1164 1164
  'MAILED'                      => 'Gesendet',
1165
  'MD'                          => 'PT',
1165 1166
  'Main Preferences'            => 'Grundeinstellungen',
1166 1167
  'Main sorting'                => 'Hauptsortierung',
1167 1168
  'Make'                        => 'Lieferant',
......
2416 2417
  'found'                       => 'Gefunden',
2417 2418
  'from (time)'                 => 'von',
2418 2419
  'general_ledger_list'         => 'buchungsjournal',
2420
  'h'                           => 'h',
2419 2421
  'history'                     => 'Historie',
2420 2422
  'history search engine'       => 'Historien Suchmaschine',
2421 2423
  'inactive'                    => 'inaktiv',

Auch abrufbar als: Unified diff