From 29b58aa0f8f66107fbe6c47ac7c6b10995373bb9 Mon Sep 17 00:00:00 2001 From: Louis Charette Date: Sat, 5 Oct 2024 23:16:23 -0400 Subject: [PATCH] Fix totalPages --- app/assets/composables/sprunjer.ts | 3 +-- dist/sprunjer.cjs | 2 +- dist/sprunjer.js | 10 +++++----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/assets/composables/sprunjer.ts b/app/assets/composables/sprunjer.ts index 691a87e7..73255a9c 100644 --- a/app/assets/composables/sprunjer.ts +++ b/app/assets/composables/sprunjer.ts @@ -71,8 +71,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.max(Math.ceil((data.value.count_filtered ?? 0) / size.value) - 1, 1) + return Math.ceil((data.value.count_filtered ?? 0) / size.value) - 1 }) const count = computed(() => { diff --git a/dist/sprunjer.cjs b/dist/sprunjer.cjs index 0a3b19ac..fbf94dff 100644 --- a/dist/sprunjer.cjs +++ b/dist/sprunjer.cjs @@ -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.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; +"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 p=e.computed(()=>Math.ceil((t.value.count_filtered??0)/o.value)-1),m=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)),w=e.computed(()=>t.value.count_filtered??0),y=e.computed(()=>t.value.rows??[]);function M(){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:M,totalPages:p,countFiltered:w,count:m,rows:y,first:g,last:h}};exports.useSprunjer=j; diff --git a/dist/sprunjer.js b/dist/sprunjer.js index 123c6791..2d885452 100644 --- a/dist/sprunjer.js +++ b/dist/sprunjer.js @@ -1,7 +1,7 @@ -import { ref as e, computed as o, watchEffect as z, toValue as _ } from "vue"; +import { ref as t, computed as o, watchEffect as z, toValue as _ } from "vue"; import { a as j } from "./axios-CXDYiOMX.js"; 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); + const a = t(m), n = t(d), l = t(i), c = t(f), e = t({}), u = t(!1); async function v() { u.value = !0, j.get(_(s), { params: { @@ -11,12 +11,12 @@ const F = (s, i = {}, f = {}, m = 10, d = 0) => { filters: c.value } }).then((r) => { - t.value = r.data, u.value = !1; + e.value = r.data, u.value = !1; }).catch((r) => { console.error(r); }); } - 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 ?? []); + const p = o(() => Math.ceil((e.value.count_filtered ?? 0) / a.value) - 1), h = o(() => e.value.count ?? 0), g = o(() => Math.min(n.value * a.value + 1, e.value.count ?? 0)), w = o(() => Math.min((n.value + 1) * a.value, e.value.count ?? 0)), M = o(() => e.value.count_filtered ?? 0), x = o(() => e.value.rows ?? []); function y() { console.log("Not yet implemented"); } @@ -28,7 +28,7 @@ const F = (s, i = {}, f = {}, m = 10, d = 0) => { page: n, sorts: l, filters: c, - data: t, + data: e, fetch: v, loading: u, downloadCsv: y,