Revision cf826cc8
Von Sven Schöling vor etwa 11 Jahren hinzugefügt
SL/Controller/Project.pm | ||
---|---|---|
9 | 9 |
use SL::Controller::Helper::GetModels; |
10 | 10 |
use SL::Controller::Helper::Paginated; |
11 | 11 |
use SL::Controller::Helper::Sorted; |
12 |
use SL::Controller::Helper::Filtered; |
|
12 | 13 |
use SL::Controller::Helper::ParseFilter; |
13 | 14 |
use SL::Controller::Helper::ReportGenerator; |
14 | 15 |
use SL::CVar; |
... | ... | |
23 | 24 |
|
24 | 25 |
use Rose::Object::MakeMethods::Generic |
25 | 26 |
( |
26 |
scalar => [ qw(project db_args flat_filter linked_records) ],
|
|
27 |
scalar => [ qw(project linked_records) ], |
|
27 | 28 |
); |
28 | 29 |
|
29 | 30 |
__PACKAGE__->run_before('check_auth'); |
30 | 31 |
__PACKAGE__->run_before('load_project', only => [ qw(edit update destroy) ]); |
31 | 32 |
|
32 |
__PACKAGE__->get_models_url_params('flat_filter'); |
|
33 |
__PACKAGE__->make_filtered( |
|
34 |
MODEL => 'Project', |
|
35 |
LAUNDER_TO => 'filter', |
|
36 |
ONLY => [ qw(list) ], |
|
37 |
); |
|
33 | 38 |
__PACKAGE__->make_paginated( |
34 | 39 |
MODEL => 'Project', |
35 |
PAGINATE_ARGS => 'db_args', |
|
40 |
# PAGINATE_ARGS => 'db_args',
|
|
36 | 41 |
ONLY => [ qw(list) ], |
37 | 42 |
); |
38 | 43 |
|
... | ... | |
71 | 76 |
sub action_list { |
72 | 77 |
my ($self) = @_; |
73 | 78 |
|
74 |
$self->setup_db_args_from_filter; |
|
75 |
$self->flat_filter({ map { $_->{key} => $_->{value} } $::form->flatten_variables('filter') }); |
|
76 | 79 |
# $self->make_filter_summary; |
77 | 80 |
|
78 |
$self->prepare_report; |
|
81 |
my $projects = $self->get_models( |
|
82 |
with_objects => [ 'customer' ], |
|
83 |
); |
|
79 | 84 |
|
80 |
my $projects = $self->get_models(%{ $self->db_args });
|
|
85 |
$self->prepare_report;
|
|
81 | 86 |
|
82 | 87 |
$self->report_generator_list_objects(report => $self->{report}, objects => $projects); |
83 | 88 |
} |
... | ... | |
202 | 207 |
$self->db_args(\%args); |
203 | 208 |
} |
204 | 209 |
|
205 |
# unfortunately ParseFilter can't handle compount filters. |
|
206 |
# so we clone the original filter (still need that for serializing) |
|
207 |
# rip out the options we know an replace them with the compound options. |
|
208 |
# ParseFilter will take care of the prefixing then. |
|
209 |
sub _pre_parse_filter { |
|
210 |
my ($self, $orig_filter, $launder_to) = @_; |
|
211 |
|
|
212 |
return undef unless $orig_filter; |
|
213 |
|
|
214 |
my $filter = clone($orig_filter); |
|
215 |
|
|
216 |
$launder_to->{active} = delete $filter->{active}; |
|
217 |
if ($orig_filter->{active} ne 'both') { |
|
218 |
push @{ $filter->{and} }, $orig_filter->{active} eq 'active' ? (active => 1) : (or => [ active => 0, active => undef ]); |
|
219 |
} |
|
220 |
|
|
221 |
$launder_to->{valid} = delete $filter->{valid}; |
|
222 |
if ($orig_filter->{valid} ne 'both') { |
|
223 |
push @{ $filter->{and} }, $orig_filter->{valid} eq 'valid' ? (valid => 1) : (or => [ valid => 0, valid => undef ]); |
|
224 |
} |
|
225 |
|
|
226 |
$launder_to->{status} = delete $filter->{status}; |
|
227 |
if ($orig_filter->{status} ne 'all') { |
|
228 |
push @{ $filter->{and} }, SL::DB::Manager::Project->is_not_used_filter; |
|
229 |
} |
|
230 |
|
|
231 |
return $filter; |
|
232 |
} |
|
233 |
|
|
234 | 210 |
sub prepare_report { |
235 | 211 |
my ($self) = @_; |
236 | 212 |
|
Auch abrufbar als: Unified diff
C/Project: filtered eingeführt; db_args, pre_parse_filter und flat_filter entfernt