View | Details | Raw Unified | Return to bug 19370
Collapse All | Expand All

(-)a/Koha/REST/Plugin/Pagination.pm (-8 / +9 lines)
Lines 110-136 It also adds X-Total-Count, containing the total results count. Link Here
110
110
111
=head3 dbic_merge_pagination
111
=head3 dbic_merge_pagination
112
112
113
    $filter = $c->dbic_merge_pagination({
113
    $attributes = $c->dbic_merge_pagination({
114
        filter => $filter,
114
        attributes => $attributes,
115
        params => {
115
        params => {
116
            page     => $params->{_page},
116
            page     => $params->{_page},
117
            per_page => $params->{_per_page}
117
            per_page => $params->{_per_page},
118
            ...
118
        }
119
        }
119
    });
120
    });
120
121
121
Adds I<page> and I<rows> elements to the filter parameter.
122
Adds I<page> and I<rows> elements to the I<attributes> parameter.
122
123
123
=cut
124
=cut
124
125
125
    $app->helper(
126
    $app->helper(
126
        'dbic_merge_pagination' => sub {
127
        'dbic_merge_pagination' => sub {
127
            my ( $c, $args ) = @_;
128
            my ( $c, $args ) = @_;
128
            my $filter = $args->{filter};
129
            my $attributes = $args->{attributes};
129
130
130
            $filter->{page} = $args->{params}->{_page};
131
            $attributes->{page} = $args->{params}->{_page};
131
            $filter->{rows} = $args->{params}->{_per_page};
132
            $attributes->{rows} = $args->{params}->{_per_page};
132
133
133
            return $filter;
134
            return $attributes;
134
        }
135
        }
135
    );
136
    );
136
}
137
}
(-)a/t/Koha/REST/Plugin/Pagination.t (-4 / +3 lines)
Lines 53-61 get '/pagination_headers_last_page' => sub { Link Here
53
53
54
get '/dbic_merge_pagination' => sub {
54
get '/dbic_merge_pagination' => sub {
55
    my $c = shift;
55
    my $c = shift;
56
    my $filter = { firstname => 'Kyle', surname => 'Hall' };
56
    my $attributes = { firstname => 'Kyle', surname => 'Hall' };
57
    $filter = $c->dbic_merge_pagination({ filter => $filter, params => { _page => 1, _per_page => 3 } });
57
    $attributes = $c->dbic_merge_pagination({ attributes => $attributes, params => { _page => 1, _per_page => 3 } });
58
    $c->render( json => $filter, status => 200 );
58
    $c->render( json => $attributes, status => 200 );
59
};
59
};
60
60
61
# The tests
61
# The tests
62
- 

Return to bug 19370