From: Sven Schöling Date: Fri, 13 Sep 2013 12:01:12 +0000 (+0200) Subject: Manager/Project: custom filter und paginate default. X-Git-Tag: release-3.1.0beta1~52 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=71e2b75e559e40e0dc7126cecf46584b5a7ad5dd;p=kivitendo-erp.git Manager/Project: custom filter und paginate default. --- 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__