Revision d5cb059b
Von Sven Schöling vor etwa 11 Jahren hinzugefügt
SL/Controller/Helper/GetModels.pm | ||
---|---|---|
23 | 23 |
sub get { |
24 | 24 |
my ($self) = @_; |
25 | 25 |
my %params = $self->finalize; |
26 |
%params = $self->_run_handlers('get_models', %params); |
|
27 | 26 |
|
28 | 27 |
return $self->manager->get_all(%params); |
29 | 28 |
} |
... | ... | |
160 | 159 |
sub init_handlers { |
161 | 160 |
{ |
162 | 161 |
callback => [], |
163 |
get_models => [], |
|
164 | 162 |
} |
165 | 163 |
} |
166 | 164 |
|
SL/Controller/Helper/GetModels/Base.pm | ||
---|---|---|
27 | 27 |
$final_args->{$field} = [ map { @{ $_->{$field} || [] } } @args ]; |
28 | 28 |
} |
29 | 29 |
|
30 |
for my $field (qw(page per_page sort_by sort_dir )) {
|
|
30 |
for my $field (qw(page per_page sort_by)) { |
|
31 | 31 |
for my $arg (@args) { |
32 |
next unless defined $_->{$field};
|
|
33 |
$final_args->{$field} //= $_->{$field};
|
|
32 |
next unless defined $arg->{$field};
|
|
33 |
$final_args->{$field} //= $arg->{$field};
|
|
34 | 34 |
} |
35 | 35 |
} |
36 | 36 |
|
SL/Controller/Helper/GetModels/Filtered.pm | ||
---|---|---|
70 | 70 |
|
71 | 71 |
sub finalize { |
72 | 72 |
my ($self, %params) = @_; |
73 |
%params; |
|
73 |
|
|
74 |
my %filter_params; |
|
75 |
%filter_params = $self->read_params(%params) if $self->is_enabled; |
|
76 |
|
|
77 |
# $::lxdebug->dump(0, "GM handler for filtered; params nach modif (is_enabled? " . $self->is_enabled . ")", \%params); |
|
78 |
|
|
79 |
return $self->merge_args(\%params, \%filter_params); |
|
74 | 80 |
} |
75 | 81 |
|
76 | 82 |
# |
... | ... | |
98 | 104 |
return %params; |
99 | 105 |
} |
100 | 106 |
|
101 |
sub _get_models_handler_for_filtered { |
|
102 |
my ($self, %params) = @_; |
|
103 |
|
|
104 |
# $::lxdebug->dump(0, "params in get_models_for_filtered", \%params); |
|
105 |
|
|
106 |
my %filter_params; |
|
107 |
%filter_params = $self->read_params(%params) if $self->is_enabled; |
|
108 |
|
|
109 |
# $::lxdebug->dump(0, "GM handler for filtered; params nach modif (is_enabled? " . $self->is_enabled . ")", \%params); |
|
110 |
|
|
111 |
return $self->merge_args(\%params, \%filter_params); |
|
112 |
} |
|
113 |
|
|
114 | 107 |
sub init_form_params { |
115 | 108 |
'filter' |
116 | 109 |
} |
SL/Controller/Helper/GetModels/Paginated.pm | ||
---|---|---|
96 | 96 |
return %params; |
97 | 97 |
} |
98 | 98 |
|
99 |
sub _get_models_handler_for_paginated { |
|
100 |
my ($self, %params) = @_; |
|
101 |
|
|
102 |
$self->get_models->manager->paginate(%{ $self->calculated_params }, args => \%params) if $self->is_enabled; |
|
103 |
|
|
104 |
# $::lxdebug->dump(0, "GM handler for paginated; params nach modif (is_enabled? " . _is_enabled($self) . ")", \%params); |
|
105 |
return %params; |
|
106 |
} |
|
107 |
|
|
108 | 99 |
sub init_form_params { |
109 | 100 |
[ qw(page per_page) ] |
110 | 101 |
} |
SL/Controller/Helper/GetModels/Sorted.pm | ||
---|---|---|
73 | 73 |
|
74 | 74 |
sub finalize { |
75 | 75 |
my ($self, %params) = @_; |
76 |
|
|
77 |
my %sort_params = $self->read_params; |
|
78 |
my $sort_spec = $self->specs->{ $sort_params{sort_by} }; |
|
79 |
|
|
80 |
$params{sort_by} = "SL::DB::Manager::$sort_spec->{model}"->make_sort_string(sort_by => $sort_spec->{model_column}, sort_dir => $sort_params{sort_dir}); |
|
81 |
|
|
76 | 82 |
%params; |
77 | 83 |
} |
78 | 84 |
|
... | ... | |
118 | 124 |
return %params; |
119 | 125 |
} |
120 | 126 |
|
121 |
sub _get_models_handler_for_sorted { |
|
122 |
my ($self, %params) = @_; |
|
123 |
|
|
124 |
my %sort_params = $self->read_params; |
|
125 |
my $sort_spec = $self->specs->{ $sort_params{sort_by} }; |
|
126 |
|
|
127 |
$params{sort_by} = "SL::DB::Manager::$sort_spec->{model}"->make_sort_string(sort_by => $sort_spec->{model_column}, sort_dir => $sort_params{sort_dir}); |
|
128 |
|
|
129 |
# $::lxdebug->dump(0, "GM handler for sorted; params nach modif:", \%params); |
|
130 |
|
|
131 |
return %params; |
|
132 |
} |
|
127 |
#sub _get_models_handler_for_sorted { |
|
128 |
# my ($self, %params) = @_; |
|
129 |
# |
|
130 |
# |
|
131 |
# |
|
132 |
# # $::lxdebug->dump(0, "GM handler for sorted; params nach modif:", \%params); |
|
133 |
# |
|
134 |
# return %params; |
|
135 |
#} |
|
133 | 136 |
|
134 | 137 |
|
135 | 138 |
sub init_form_params { |
Auch abrufbar als: Unified diff
get_models callback entefrnt und in den finalize prozess integriert