Page past the 100-row cap in pickers and batch label sheets

This commit is contained in:
2026-08-17 14:17:28 -04:00
parent 7df79e50d9
commit ece0e15f03
12 changed files with 133 additions and 35 deletions

View File

@@ -50,6 +50,30 @@ api.interceptors.response.use(
export default api
// The backend clamps perpage to MAX_PAGE_SIZE (100) and says nothing about it,
// so asking for `perpage: 1000` silently returns the first 100 rows and drops
// the rest. A picker built that way looks complete and is not: with 126
// applications on a live site, the 26 sorting last were simply unselectable.
//
// Use this wherever a control needs the WHOLE list (dropdowns, pickers, label
// batches) rather than a page of it. Returns the full array directly, not an
// axios response. Anything that renders a paged table should keep calling
// list() with a real page number instead.
export async function fetchAllPages(path, params = {}) {
const first = await api.get(path, { params: { ...params, perpage: 100, page: 1 } })
let items = first.data.data || []
const totalpages = first.data.meta?.pagination?.totalpages || 1
if (totalpages > 1) {
const rest = await Promise.all(
Array.from({ length: totalpages - 1 }, (_, i) =>
api.get(path, { params: { ...params, perpage: 100, page: i + 2 } })
)
)
rest.forEach(response => { items = items.concat(response.data.data || []) })
}
return items
}
// Auth API
export const authApi = {
login(username, password) {
@@ -77,6 +101,13 @@ export const machinesApi = {
list(params = {}) {
return api.get('/machines', { params })
},
// Every machine, paged past the backend's 100-row cap. Batch label printing
// and "pick any record" dropdowns must use this: list() with a large
// perpage is clamped to 100 and still returns a success response, so
// the tail simply goes missing.
listAll(params = {}) {
return fetchAllPages('/machines', params)
},
get(id) {
return api.get(`/machines/${id}`)
},
@@ -120,6 +151,13 @@ export const computersApi = {
list(params = {}) {
return api.get('/computers', { params })
},
// Every PC, paged past the backend's 100-row cap. Batch label printing
// and "pick any record" dropdowns must use this: list() with a large
// perpage is clamped to 100 and still returns a success response, so
// the tail simply goes missing.
listAll(params = {}) {
return fetchAllPages('/computers', params)
},
displayKiosks() {
return api.get('/computers/display-kiosks')
},
@@ -268,6 +306,13 @@ export const printersApi = {
list(params = {}) {
return api.get('/printers', { params })
},
// Every printer, paged past the backend's 100-row cap. Batch label printing
// and "pick any record" dropdowns must use this: list() with a large
// perpage is clamped to 100 and still returns a success response, so
// the tail simply goes missing.
listAll(params = {}) {
return fetchAllPages('/printers', params)
},
get(id) {
return api.get(`/printers/${id}`)
},
@@ -388,19 +433,8 @@ export const modelsApi = {
// Backend caps perpage at 100, so page through every model. Returns the
// full array directly (not an axios response). Use in forms whose model
// dropdown must include the editing record's model regardless of page.
async listAll() {
const first = await api.get('/models', { params: { perpage: 100, page: 1 } })
let items = first.data.data || []
const totalpages = first.data.meta?.pagination?.totalpages || 1
if (totalpages > 1) {
const rest = await Promise.all(
Array.from({ length: totalpages - 1 }, (_, i) =>
api.get('/models', { params: { perpage: 100, page: i + 2 } })
)
)
rest.forEach(r => { items = items.concat(r.data.data || []) })
}
return items
listAll(params = {}) {
return fetchAllPages('/models', params)
},
get(id) {
return api.get(`/models/${id}`)
@@ -468,6 +502,12 @@ export const applicationsApi = {
list(params = {}) {
return api.get('/applications', { params })
},
// Every application, paged past the backend's 100-row cap. The catalogue is
// already over 100 entries on a live site, so any picker offering "all
// applications" must use this and not list({ perpage: <big number> }).
listAll(params = {}) {
return fetchAllPages('/applications', params)
},
get(id) {
return api.get(`/applications/${id}`)
},
@@ -713,6 +753,13 @@ export const usbApi = {
list(params = {}) {
return api.get('/usb', { params })
},
// Every USB device, paged past the backend's 100-row cap. Batch label printing
// and "pick any record" dropdowns must use this: list() with a large
// perpage is clamped to 100 and still returns a success response, so
// the tail simply goes missing.
listAll(params = {}) {
return fetchAllPages('/usb', params)
},
get(id) {
return api.get(`/usb/${id}`)
},
@@ -1046,6 +1093,13 @@ export const networkApi = {
list(params = {}) {
return api.get('/network', { params })
},
// Every network device, paged past the backend's 100-row cap. Batch label
// printing and "pick any record" dropdowns must use this: list() with a
// large perpage is clamped to 100 and still returns a success response, so
// the tail simply goes missing.
listAll(params = {}) {
return fetchAllPages('/network', params)
},
get(id) {
return api.get(`/network/${id}`)
},
@@ -1192,6 +1246,13 @@ export const measuringtoolsApi = {
list(params = {}) {
return api.get('/measuringtools', { params })
},
// Every measuring tool, paged past the backend's 100-row cap. Batch label printing
// and "pick any record" dropdowns must use this: list() with a large
// perpage is clamped to 100 and still returns a success response, so
// the tail simply goes missing.
listAll(params = {}) {
return fetchAllPages('/measuringtools', params)
},
get(id) {
return api.get(`/measuringtools/${id}`)
},
@@ -1235,6 +1296,11 @@ export const printedpartsApi = {
list(params = {}) {
return api.get('/printedparts/items', { params })
},
// Every printed item, paged past the backend's 100-row cap. The label sheet
// must print the whole selection, not the first page of it.
listAll(params = {}) {
return fetchAllPages('/printedparts/items', params)
},
get(printeditemid) {
return api.get(`/printedparts/items/${printeditemid}`)
},

View File

@@ -295,8 +295,10 @@ onMounted(async () => {
codetype.value = (await getSetting('label_default_codetype', 'qr')) === 'barcode' ? 'barcode' : 'qr'
encodes.value = await resolveDefaultEncodes(assettype)
try {
const response = await config.api.list({ perpage: 500 })
assets.value = response.data.data || []
// listAll, not list: perpage is clamped to 100 server-side, so a batch
// sheet built from list() silently omitted every asset past the first
// 100 and printed a short run that looked complete.
assets.value = await config.api.listAll()
} catch (err) {
console.error('Error loading assets:', err)
} finally {

View File

@@ -270,8 +270,10 @@ async function loadFilterOptions(fields) {
filterOptions.value.locations = response.data.data || []
}
if (fields.includes('application') && !filterOptions.value.applications.length) {
const response = await applicationsApi.list({ perpage: 100 })
filterOptions.value.applications = response.data.data || []
// listAll: 100 is the server-side cap, not a generous limit, and the
// catalogue is past it - a report filtered by a late-alphabet
// application could not be built.
filterOptions.value.applications = await applicationsApi.listAll()
}
} catch (error) {
console.error('Error loading filter options:', error)