Skip to content

Commit

Permalink
Fix totalPages
Browse files Browse the repository at this point in the history
  • Loading branch information
lcharette committed Oct 6, 2024
1 parent cc7efac commit 29b58aa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions app/assets/composables/sprunjer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
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.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;
10 changes: 5 additions & 5 deletions dist/sprunjer.js
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -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");
}
Expand All @@ -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,
Expand Down

0 comments on commit 29b58aa

Please sign in to comment.