Commit f98fd1ae authored by Mike Greiling's avatar Mike Greiling

Prefer nextPage over totalPages as later is omitted in some contexts

parent 76a272ba
import axios from './axios_utils'; import axios from './axios_utils';
import { normalizeHeaders } from './common_utils'; import { normalizeHeaders, parseIntPagination } from './common_utils';
// This is used in the select2 config to replace jQuery.ajax with axios // This is used in the select2 config to replace jQuery.ajax with axios
export const select2AxiosTransport = (params) => { export const select2AxiosTransport = (params) => {
...@@ -9,9 +9,8 @@ export const select2AxiosTransport = (params) => { ...@@ -9,9 +9,8 @@ export const select2AxiosTransport = (params) => {
.then((res) => { .then((res) => {
const results = res.data || []; const results = res.data || [];
const headers = normalizeHeaders(res.headers); const headers = normalizeHeaders(res.headers);
const currentPage = parseInt(headers['X-PAGE'], 10) || 0; const pagination = parseIntPagination(headers);
const totalPages = parseInt(headers['X-TOTAL-PAGES'], 10) || 0; const more = pagination.nextPage > pagination.page;
const more = currentPage < totalPages;
params.success({ params.success({
results, results,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment