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

(-)a/Koha/REST/Plugin/Objects.pm (-8 / +15 lines)
Lines 114-131 sub register { Link Here
114
            }
114
            }
115
            # Perform search
115
            # Perform search
116
            my $objects = $result_set->search( $filtered_params, $attributes );
116
            my $objects = $result_set->search( $filtered_params, $attributes );
117
            my $total   = $result_set->search->count;
117
118
118
            if ($objects->is_paged) {
119
            if ($objects->is_paged) {
119
                $c->add_pagination_headers({
120
                $c->add_pagination_headers(
120
                    total => $objects->pager->total_entries,
121
                    {
121
                    params => $args,
122
                        total      => $objects->pager->total_entries,
122
                });
123
                        base_total => $total,
124
                        params     => $args,
125
                    }
126
                );
123
            }
127
            }
124
            else {
128
            else {
125
                $c->add_pagination_headers({
129
                $c->add_pagination_headers(
126
                    total => $objects->count,
130
                    {
127
                    params => $args,
131
                        total      => $objects->count,
128
                });
132
                        base_total => $total,
133
                        params     => $args,
134
                    }
135
                );
129
            }
136
            }
130
137
131
            return $objects->to_api({ embed => $embed });
138
            return $objects->to_api({ embed => $embed });
(-)a/Koha/REST/Plugin/Pagination.pm (-1 / +3 lines)
Lines 50-56 sub register { Link Here
50
50
51
Adds a Link header to the response message $c carries, following RFC5988, including
51
Adds a Link header to the response message $c carries, following RFC5988, including
52
the following relation types: 'prev', 'next', 'first' and 'last'.
52
the following relation types: 'prev', 'next', 'first' and 'last'.
53
It also adds X-Total-Count, containing the total results count.
53
It also adds X-Total-Count containing the total results count, and X-Base-Total-Count containing the total of the non-filtered results count.
54
54
55
If page size is omitted, it defaults to the value of the RESTdefaultPageSize syspref.
55
If page size is omitted, it defaults to the value of the RESTdefaultPageSize syspref.
56
56
Lines 61-66 If page size is omitted, it defaults to the value of the RESTdefaultPageSize sys Link Here
61
            my ( $c, $args ) = @_;
61
            my ( $c, $args ) = @_;
62
62
63
            my $total    = $args->{total};
63
            my $total    = $args->{total};
64
            my $base_total = $args->{base_total};
64
            my $req_page = $args->{params}->{_page} // 1;
65
            my $req_page = $args->{params}->{_page} // 1;
65
            my $per_page = $args->{params}->{_per_page} //
66
            my $per_page = $args->{params}->{_per_page} //
66
                            C4::Context->preference('RESTdefaultPageSize') // 20;
67
                            C4::Context->preference('RESTdefaultPageSize') // 20;
Lines 114-119 If page size is omitted, it defaults to the value of the RESTdefaultPageSize sys Link Here
114
115
115
            # Add X-Total-Count header
116
            # Add X-Total-Count header
116
            $c->res->headers->add( 'X-Total-Count' => $total );
117
            $c->res->headers->add( 'X-Total-Count' => $total );
118
            $c->res->headers->add( 'X-Base-Total-Count' => $base_total );
117
            return $c;
119
            return $c;
118
        }
120
        }
119
    );
121
    );
(-)a/koha-tmpl/intranet-tmpl/prog/js/datatables.js (-1 / +3 lines)
Lines 544-549 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
544
                                    json.recordsTotal = total;
544
                                    json.recordsTotal = total;
545
                                    json.recordsFiltered = total;
545
                                    json.recordsFiltered = total;
546
                                }
546
                                }
547
                                if(total = this._xhr.getResponseHeader('x-base-total-count')) {
548
                                    json.recordsTotal = total;
549
                                }
547
                                return JSON.stringify(json);
550
                                return JSON.stringify(json);
548
                            },
551
                            },
549
                            'data': function( data, settings ) {
552
                            'data': function( data, settings ) {
550
- 

Return to bug 27353