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

(-)a/Koha/REST/Plugin/Objects.pm (-12 / +8 lines)
Lines 124-142 sub register { Link Here
124
            }
124
            }
125
            # Perform search
125
            # Perform search
126
            my $objects = $result_set->search( $filtered_params, $attributes );
126
            my $objects = $result_set->search( $filtered_params, $attributes );
127
            my $total   = $result_set->search->count;
127
128
128
            if ($objects->is_paged) {
129
            $c->add_pagination_headers(
129
                $c->add_pagination_headers({
130
                {
130
                    total => $objects->pager->total_entries,
131
                    total      => ($objects->is_paged ? $objects->pager->total_entries : $objects->count),
131
                    params => $args,
132
                    base_total => $total,
132
                });
133
                    params     => $args,
133
            }
134
                }
134
            else {
135
            );
135
                $c->add_pagination_headers({
136
                    total => $objects->count,
137
                    params => $args,
138
                });
139
            }
140
136
141
            return $objects->to_api({ embed => $embed });
137
            return $objects->to_api({ embed => $embed });
142
        }
138
        }
(-)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/REST/V1/Patrons.pm (-8 / +9 lines)
Lines 82-95 sub list { Link Here
82
          if $restricted;
82
          if $restricted;
83
83
84
        my $patrons = $patrons_rs->search( $filtered_params, $attributes );
84
        my $patrons = $patrons_rs->search( $filtered_params, $attributes );
85
        if ( $patrons_rs->is_paged ) {
85
        my $total   = $patrons_rs->search->count;
86
            $c->add_pagination_headers(
86
87
                {
87
        $c->add_pagination_headers(
88
                    total  => $patrons->pager->total_entries,
88
            {
89
                    params => $args,
89
                total      => ($patrons->is_paged ? $patrons->pager->total_entries : $patrons->count),
90
                }
90
                base_total => $total,
91
            );
91
                params => $args,
92
        }
92
            }
93
        );
93
94
94
        return $c->render( status => 200, openapi => $patrons->to_api );
95
        return $c->render( status => 200, openapi => $patrons->to_api );
95
    }
96
    }
(-)a/koha-tmpl/intranet-tmpl/prog/js/datatables.js (+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 ) {
(-)a/koha-tmpl/opac-tmpl/bootstrap/js/datatables.js (-1 / +3 lines)
Lines 207-212 jQuery.extend( jQuery.fn.dataTableExt.oSort, { Link Here
207
                                    json.recordsTotal = total;
207
                                    json.recordsTotal = total;
208
                                    json.recordsFiltered = total;
208
                                    json.recordsFiltered = total;
209
                                }
209
                                }
210
                                if(total = this._xhr.getResponseHeader('x-base-total-count')) {
211
                                    json.recordsTotal = total;
212
                                }
210
                                return JSON.stringify(json);
213
                                return JSON.stringify(json);
211
                            },
214
                            },
212
                            'data': function( data, settings ) {
215
                            'data': function( data, settings ) {
213
- 

Return to bug 27353