Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 3d1ae2d9

Von Moritz Bunkus vor fast 12 Jahren hinzugefügt

  • ID 3d1ae2d96b65e88a5b12dde2b2524dc10f7932fa
  • Vorgänger f46bab53
  • Nachfolger 23a596b9

Refactoring: list_objects() aus Controllern in ReportGenerator-Helfer verschieben

Unterschiede anzeigen:

SL/Controller/Project.pm
77 77

  
78 78
  $self->prepare_report;
79 79

  
80
  $self->{projects} = $self->get_models(%{ $self->db_args });
80
  my $projects = $self->get_models(%{ $self->db_args });
81 81

  
82
  $self->list_objects;
82
  $self->report_generator_list_objects(report => $self->{report}, objects => $projects);
83 83
}
84 84

  
85 85
sub action_new {
......
274 274
  $self->set_report_generator_sort_options(report => $report, sortable_columns => \@sortable);
275 275

  
276 276
  $self->disable_pagination if $report->{options}{output_format} =~ /^(pdf|csv)$/i;
277

  
278
  $self->{report_data} = {
279
    column_defs        => \%column_defs,
280
    columns            => \@columns,
281
  };
282
}
283

  
284
sub list_objects {
285
  my ($self)      = @_;
286
  my $column_defs = $self->{report_data}->{column_defs};
287

  
288
  for my $obj (@{ $self->{projects} || [] }) {
289
    my %data = map {
290
      $_ => {
291
        data => $column_defs->{$_}{sub} ? $column_defs->{$_}{sub}->($obj)
292
              : $obj->can($_)           ? $obj->$_
293
              :                           $obj->{$_},
294
        link => $column_defs->{$_}{obj_link} ? $column_defs->{$_}{obj_link}->($obj) : '',
295
      },
296
    } @{ $self->{report_data}{columns} || {} };
297

  
298
    $self->{report}->add_data(\%data);
299
  }
300

  
301
  return $self->{report}->generate_with_headers;
302 277
}
303 278

  
304 279
1;

Auch abrufbar als: Unified diff