Enable offset based paging
[catagits/Catalyst-Controller-DBIC-API.git] / lib / Catalyst / Controller / DBIC / API.pm
index 561508a..89aca62 100644 (file)
@@ -221,7 +221,7 @@ sub deserialize :ActionClass('Deserialize')
     {
         $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
@@ -369,7 +369,12 @@ sub list_perform_search
         $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
     {