Skip to content

Commit

Permalink
Make sure the totalPages is at least 1 (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
lcharette committed Oct 6, 2024
1 parent 8bcbdad commit cc7efac
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/assets/composables/sprunjer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const useSprunjer = (
const totalPages = computed(() => {
// N.B.: Sprunjer page starts at 0, not 1
// Make sure the totalPages is at least 1
return Math.min(Math.ceil((data.value.count_filtered ?? 0) / size.value) - 1, 1)
return Math.max(Math.ceil((data.value.count_filtered ?? 0) / size.value) - 1, 1)
})

const count = computed(() => {
Expand Down
2 changes: 1 addition & 1 deletion dist/sprunjer.cjs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),S=require("./axios-tuVKNgv9.cjs"),j=(a,i={},v={},f=10,d=0)=>{const o=e.ref(f),u=e.ref(d),c=e.ref(i),s=e.ref(v),t=e.ref({}),n=e.ref(!1);async function l(){n.value=!0,S.axios.get(e.toValue(a),{params:{size:o.value,page:u.value,sorts:c.value,filters:s.value}}).then(r=>{t.value=r.data,n.value=!1}).catch(r=>{console.error(r)})}const m=e.computed(()=>Math.min(Math.ceil((t.value.count_filtered??0)/o.value)-1,1)),p=e.computed(()=>t.value.count??0),g=e.computed(()=>Math.min(u.value*o.value+1,t.value.count??0)),h=e.computed(()=>Math.min((u.value+1)*o.value,t.value.count??0)),M=e.computed(()=>t.value.count_filtered??0),w=e.computed(()=>t.value.rows??[]);function y(){console.log("Not yet implemented")}return e.watchEffect(()=>{l()}),{dataUrl:a,size:o,page:u,sorts:c,filters:s,data:t,fetch:l,loading:n,downloadCsv:y,totalPages:m,countFiltered:M,count:p,rows:w,first:g,last:h}};exports.useSprunjer=j;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),S=require("./axios-tuVKNgv9.cjs"),j=(a,i={},v={},f=10,d=0)=>{const o=e.ref(f),u=e.ref(d),c=e.ref(i),s=e.ref(v),t=e.ref({}),n=e.ref(!1);async function l(){n.value=!0,S.axios.get(e.toValue(a),{params:{size:o.value,page:u.value,sorts:c.value,filters:s.value}}).then(r=>{t.value=r.data,n.value=!1}).catch(r=>{console.error(r)})}const m=e.computed(()=>Math.max(Math.ceil((t.value.count_filtered??0)/o.value)-1,1)),p=e.computed(()=>t.value.count??0),g=e.computed(()=>Math.min(u.value*o.value+1,t.value.count??0)),h=e.computed(()=>Math.min((u.value+1)*o.value,t.value.count??0)),M=e.computed(()=>t.value.count_filtered??0),w=e.computed(()=>t.value.rows??[]);function y(){console.log("Not yet implemented")}return e.watchEffect(()=>{l()}),{dataUrl:a,size:o,page:u,sorts:c,filters:s,data:t,fetch:l,loading:n,downloadCsv:y,totalPages:m,countFiltered:M,count:p,rows:w,first:g,last:h}};exports.useSprunjer=j;
12 changes: 6 additions & 6 deletions dist/sprunjer.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ref as e, computed as o, watchEffect as z, toValue as _ } from "vue";
import { a as j } from "./axios-CXDYiOMX.js";
const F = (s, v = {}, f = {}, m = 10, d = 0) => {
const a = e(m), n = e(d), l = e(v), c = e(f), t = e({}), u = e(!1);
async function i() {
const F = (s, i = {}, f = {}, m = 10, d = 0) => {
const a = e(m), n = e(d), l = e(i), c = e(f), t = e({}), u = e(!1);
async function v() {
u.value = !0, j.get(_(s), {
params: {
size: a.value,
Expand All @@ -16,20 +16,20 @@ const F = (s, v = {}, f = {}, m = 10, d = 0) => {
console.error(r);
});
}
const p = o(() => Math.min(Math.ceil((t.value.count_filtered ?? 0) / a.value) - 1, 1)), h = o(() => t.value.count ?? 0), g = o(() => Math.min(n.value * a.value + 1, t.value.count ?? 0)), w = o(() => Math.min((n.value + 1) * a.value, t.value.count ?? 0)), M = o(() => t.value.count_filtered ?? 0), x = o(() => t.value.rows ?? []);
const p = o(() => Math.max(Math.ceil((t.value.count_filtered ?? 0) / a.value) - 1, 1)), h = o(() => t.value.count ?? 0), g = o(() => Math.min(n.value * a.value + 1, t.value.count ?? 0)), w = o(() => Math.min((n.value + 1) * a.value, t.value.count ?? 0)), M = o(() => t.value.count_filtered ?? 0), x = o(() => t.value.rows ?? []);
function y() {
console.log("Not yet implemented");
}
return z(() => {
i();
v();
}), {
dataUrl: s,
size: a,
page: n,
sorts: l,
filters: c,
data: t,
fetch: i,
fetch: v,
loading: u,
downloadCsv: y,
totalPages: p,
Expand Down

0 comments on commit cc7efac

Please sign in to comment.