X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FHelper%2FActsAsList.pm;fp=SL%2FDB%2FHelper%2FActsAsList.pm;h=49f39a9bcfeba55540ad06c7b6833fb576fb3b53;hb=e6535205268abb2fe58855f627a41ae389e7c509;hp=566422a9db6d2e2a4754cdc7b3bb36550c6b5bd2;hpb=3dee3e56a61f3fdadb9a9608dbfb228a4c1a55ed;p=kivitendo-erp.git diff --git a/SL/DB/Helper/ActsAsList.pm b/SL/DB/Helper/ActsAsList.pm index 566422a9d..49f39a9bc 100644 --- a/SL/DB/Helper/ActsAsList.pm +++ b/SL/DB/Helper/ActsAsList.pm @@ -4,7 +4,7 @@ use strict; use parent qw(Exporter); our @EXPORT = qw(move_position_up move_position_down add_to_list remove_from_list reorder_list configure_acts_as_list - get_previous_in_list get_next_in_list); + get_previous_in_list get_next_in_list get_full_list); use Carp; @@ -123,6 +123,16 @@ sub get_previous_in_list { return get_previous_or_next($self, 'previous'); } +sub get_full_list { + my ($self) = @_; + + my $group_by = get_spec(ref $self, 'group_by') || []; + $group_by = [ $group_by ] if $group_by && !ref $group_by; + my @where = map { ($_ => $self->$_) } @{ $group_by }; + + return $self->_get_manager_class->get_all(where => \@where, sort_by => column_name($self) . ' ASC'); +} + sub reorder_list { my ($class_or_self, @ids) = @_; @@ -417,6 +427,11 @@ already the first one. Fetches the next item in the list. Returns C if C<$self> is already the last one. +=item C + +Fetches all items in the same list as C<$self> and returns them as an +array reference. + =item C Re-orders the objects given in C<@ids> by their position in C<@ids> by