- Fixed missing requirement for MooseX::Types::Structured
- Fixed MooseX::Aliases usage (we don't any more)
- Object inflation during end was broken out into its own method: each_object_inflate
+- Enable offset based paging
2.001001
**************************************************************
{
$req_params = CGI::Expand->expand_hash($c->req->params);
- foreach my $param (@{[$self->search_arg, $self->count_arg, $self->page_arg, $self->ordered_by_arg, $self->grouped_by_arg, $self->prefetch_arg]})
+ foreach my $param (@{[$self->search_arg, $self->count_arg, $self->page_arg, $self->offset_arg, $self->ordered_by_arg, $self->grouped_by_arg, $self->prefetch_arg]})
{
# these params can also be composed of JSON
# but skip if the parameter is not provided
$req->_set_current_result_set($rs);
$req->_set_search_total_entries($req->current_result_set->pager->total_entries)
- if $req->has_search_attributes && $req->search_attributes->{page};
+ if $req->has_search_attributes &&
+ (
+ (exists($req->search_attributes->{page}) && defined($req->search_attributes->{page}) && length($req->search_attributes->{page}))
+ ||(exists($req->search_attributes->{offset}) && defined($req->search_attributes->{offset}) && length($req->search_attributes->{offset}))
+ ||(exists($req->search_attributes->{rows}) && defined($req->search_attributes->{rows}) && length($req->search_attributes->{rows}))
+ );
}
catch
{
predicate => 'has_page',
);
+=attribute_public offset is ro, isa: Int
+
+offset specifies where to start the paged result (think SQL LIMIT)
+
+=cut
+
+ has 'offset' =>
+ (
+ is => 'ro',
+ writer => '_set_offset',
+ isa => Int,
+ predicate => 'has_offset',
+ );
+
=attribute_public ordered_by is: ro, isa: L<Catalyst::Controller::DBIC::API::Types/OrderedBy>
ordered_by is passed to ->search to determine sorting
$self->_set_search($new->{$controller->search_arg}) if exists $new->{$controller->search_arg};
$self->_set_count($new->{$controller->count_arg}) if exists $new->{$controller->count_arg};
$self->_set_page($new->{$controller->page_arg}) if exists $new->{$controller->page_arg};
+ $self->_set_offset($new->{$controller->offset_arg}) if exists $new->{$controller->offset_arg};
}
);
as => $self->as || ((scalar(@{$static->as})) ? $static->as : undef),
prefetch => $self->prefetch || $static->prefetch || undef,
rows => $self->count || $static->count,
- page => $self->page,
+ offset => $self->offset,
join => $self->build_joins,
};
+ if($self->has_page)
+ {
+ $search_attributes->{page} = $self->page;
+ }
+ elsif(!$self->has_page && defined($search_attributes->{offset}) && defined($search_attributes->{rows}))
+ {
+ $search_attributes->{page} = $search_attributes->{offset} / $search_attributes->{rows} + 1;
+ }
+
+
$search_attributes =
{
map { @$_ }
has 'page_arg' => ( is => 'ro', isa => Str, default => 'list_page' );
+=attribute_public offset_arg is: ro, isa: Str, default: 'offset'
+
+offset_arg controls how to reference 'offset' in the the request_data
+
+=cut
+
+has 'offset_arg' => ( is => 'ro', isa => Str, default => 'list_offset' );
+
=attribute_public select_arg is: ro, isa: Str, default: 'list_returns'
select_arg controls how to reference 'select' in the the request_data