From 71e2b75e559e40e0dc7126cecf46584b5a7ad5dd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Fri, 13 Sep 2013 14:01:12 +0200 Subject: [PATCH] Manager/Project: custom filter und paginate default. --- SL/DB/Manager/Project.pm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/SL/DB/Manager/Project.pm b/SL/DB/Manager/Project.pm index 388c359d7..6c5563fe7 100644 --- a/SL/DB/Manager/Project.pm +++ b/SL/DB/Manager/Project.pm @@ -6,10 +6,31 @@ use parent qw(SL::DB::Helper::Manager); use SL::DB::Helper::Paginated; use SL::DB::Helper::Sorted; +use SL::DB::Helper::Filtered; sub object_class { 'SL::DB::Project' } __PACKAGE__->make_manager_methods; +__PACKAGE__->add_filter_specs( + active => sub { + my ($key, $value, $prefix) = @_; + # TODO add boolean context + return () if $value eq 'both'; + return ($prefix . "active" => 1) if $value eq 'active'; + return (or => [ $prefix . "active" => 0, $prefix . "active" => undef ]) if $value eq 'inactive'; + }, + valid => sub { + my ($key, $value, $prefix) = @_; + return () if $value eq 'both'; + return ($prefix . "valid" => 1) if $value eq 'valid'; + return (or => [ $prefix . "valid" => 0, $prefix . "valid" => undef ]) if $value eq 'invalid'; + }, + status => sub { + my ($key, $value, $prefix) = @_; + return () if $value eq 'all'; + return __PACKAGE__->is_not_used_filter($prefix); + }, +); our %project_id_column_prefixes = ( ar => 'global', @@ -40,6 +61,10 @@ sub is_not_used_filter { return ("!${prefix}id" => [ \"(${query})" ]); } +sub default_objects_per_page { + 20; +} + 1; __END__ -- 2.20.1