From 2cde2c35e0b01c03a419716ac6928c578e58c43b Mon Sep 17 00:00:00 2001 From: Louis Charette Date: Sat, 12 Oct 2024 16:34:37 -0400 Subject: [PATCH] Revert "Allow dataUrl to be changed after initial load" and allow any as dataUrl instead This reverts commit 9cb8f5452aa0cc1122d7e2b2f33da0540fc351d8. --- app/assets/composables/sprunjer.ts | 5 ++-- dist/composables/sprunjer.d.ts | 6 ++-- dist/sprunjer.cjs | 2 +- dist/sprunjer.js | 48 +++++++++++++++--------------- 4 files changed, 30 insertions(+), 31 deletions(-) diff --git a/app/assets/composables/sprunjer.ts b/app/assets/composables/sprunjer.ts index de13fa69..44f21d8d 100644 --- a/app/assets/composables/sprunjer.ts +++ b/app/assets/composables/sprunjer.ts @@ -6,7 +6,7 @@ interface AssociativeArray { } interface Sprunjer { - dataUrl: Ref + dataUrl: any size: Ref page: Ref totalPages: ComputedRef @@ -25,14 +25,13 @@ interface Sprunjer { } const useSprunjer = ( - defaultDataUrl: string, + dataUrl: any, defaultSorts: AssociativeArray = {}, defaultFilters: AssociativeArray = {}, defaultSize: number = 10, defaultPage: number = 0 ) => { // Sprunje parameters - const dataUrl = ref(defaultDataUrl) const size = ref(defaultSize) const page = ref(defaultPage) const sorts = ref(defaultSorts) diff --git a/dist/composables/sprunjer.d.ts b/dist/composables/sprunjer.d.ts index c826ccfe..1967e745 100644 --- a/dist/composables/sprunjer.d.ts +++ b/dist/composables/sprunjer.d.ts @@ -3,7 +3,7 @@ interface AssociativeArray { [key: string]: string | null; } interface Sprunjer { - dataUrl: Ref; + dataUrl: any; size: Ref; page: Ref; totalPages: ComputedRef; @@ -20,8 +20,8 @@ interface Sprunjer { toggleSort: (column: string) => void; downloadCsv: () => void; } -declare const useSprunjer: (defaultDataUrl: string, defaultSorts?: AssociativeArray, defaultFilters?: AssociativeArray, defaultSize?: number, defaultPage?: number) => { - dataUrl: Ref; +declare const useSprunjer: (dataUrl: any, defaultSorts?: AssociativeArray, defaultFilters?: AssociativeArray, defaultSize?: number, defaultPage?: number) => { + dataUrl: any; size: Ref; page: Ref; sorts: Ref; diff --git a/dist/sprunjer.cjs b/dist/sprunjer.cjs index ef67f84a..bf50e012 100644 --- a/dist/sprunjer.cjs +++ b/dist/sprunjer.cjs @@ -1 +1 @@ -"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),b=require("./axios-tuVKNgv9.cjs"),q=(v,f={},d={},p=10,m=0)=>{const l=e.ref(v),o=e.ref(p),r=e.ref(m),a=e.ref(f),c=e.ref(d),t=e.ref({}),s=e.ref(!1);async function i(){s.value=!0,b.axios.get(e.toValue(l),{params:{size:o.value,page:r.value,sorts:a.value,filters:c.value}}).then(u=>{t.value=u.data,s.value=!1}).catch(u=>{console.error(u)})}const g=e.computed(()=>Math.max(Math.ceil((t.value.count_filtered??0)/o.value)-1,0)),h=e.computed(()=>t.value.count??0),w=e.computed(()=>Math.min(r.value*o.value+1,t.value.count??0)),M=e.computed(()=>Math.min((r.value+1)*o.value,t.value.count??0)),S=e.computed(()=>t.value.count_filtered??0),y=e.computed(()=>t.value.rows??[]);function j(){console.log("Not yet implemented")}function x(u){let n;a.value[u]==="asc"?n="desc":a.value[u]==="desc"?n=null:n="asc",a.value[u]=n}return e.watchEffect(()=>{i()}),{dataUrl:l,size:o,page:r,sorts:a,filters:c,data:t,fetch:i,loading:s,downloadCsv:j,totalPages:g,countFiltered:S,count:h,rows:y,first:w,last:M,toggleSort:x}};exports.useSprunjer=q; +"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),x=require("./axios-tuVKNgv9.cjs"),b=(c,v={},f={},d=10,p=0)=>{const o=e.ref(d),r=e.ref(p),a=e.ref(v),l=e.ref(f),t=e.ref({}),s=e.ref(!1);async function i(){s.value=!0,x.axios.get(e.toValue(c),{params:{size:o.value,page:r.value,sorts:a.value,filters:l.value}}).then(u=>{t.value=u.data,s.value=!1}).catch(u=>{console.error(u)})}const m=e.computed(()=>Math.max(Math.ceil((t.value.count_filtered??0)/o.value)-1,0)),g=e.computed(()=>t.value.count??0),h=e.computed(()=>Math.min(r.value*o.value+1,t.value.count??0)),w=e.computed(()=>Math.min((r.value+1)*o.value,t.value.count??0)),M=e.computed(()=>t.value.count_filtered??0),S=e.computed(()=>t.value.rows??[]);function y(){console.log("Not yet implemented")}function j(u){let n;a.value[u]==="asc"?n="desc":a.value[u]==="desc"?n=null:n="asc",a.value[u]=n}return e.watchEffect(()=>{i()}),{dataUrl:c,size:o,page:r,sorts:a,filters:l,data:t,fetch:i,loading:s,downloadCsv:y,totalPages:m,countFiltered:M,count:g,rows:S,first:h,last:w,toggleSort:j}};exports.useSprunjer=b; diff --git a/dist/sprunjer.js b/dist/sprunjer.js index 1cfa5887..7f5654ee 100644 --- a/dist/sprunjer.js +++ b/dist/sprunjer.js @@ -1,13 +1,13 @@ -import { ref as a, computed as o, watchEffect as j, toValue as C } from "vue"; -import { a as E } from "./axios-CXDYiOMX.js"; -const O = (f, d = {}, m = {}, p = 10, g = 0) => { - const c = a(f), n = a(p), s = a(g), l = a(d), v = a(m), e = a({}), r = a(!1); +import { ref as a, computed as o, watchEffect as _, toValue as j } from "vue"; +import { a as C } from "./axios-CXDYiOMX.js"; +const N = (c, f = {}, d = {}, m = 10, p = 0) => { + const n = a(m), u = a(p), s = a(f), v = a(d), e = a({}), r = a(!1); async function i() { - r.value = !0, E.get(C(c), { + r.value = !0, C.get(j(c), { params: { size: n.value, - page: s.value, - sorts: l.value, + page: u.value, + sorts: s.value, filters: v.value } }).then((t) => { @@ -16,35 +16,35 @@ const O = (f, d = {}, m = {}, p = 10, g = 0) => { console.error(t); }); } - const h = o(() => Math.max(Math.ceil((e.value.count_filtered ?? 0) / n.value) - 1, 0)), w = o(() => e.value.count ?? 0), M = o(() => Math.min(s.value * n.value + 1, e.value.count ?? 0)), x = o(() => Math.min((s.value + 1) * n.value, e.value.count ?? 0)), y = o(() => e.value.count_filtered ?? 0), z = o(() => e.value.rows ?? []); - function S() { + const g = o(() => Math.max(Math.ceil((e.value.count_filtered ?? 0) / n.value) - 1, 0)), h = o(() => e.value.count ?? 0), w = o(() => Math.min(u.value * n.value + 1, e.value.count ?? 0)), M = o(() => Math.min((u.value + 1) * n.value, e.value.count ?? 0)), x = o(() => e.value.count_filtered ?? 0), y = o(() => e.value.rows ?? []); + function z() { console.log("Not yet implemented"); } - function _(t) { - let u; - l.value[t] === "asc" ? u = "desc" : l.value[t] === "desc" ? u = null : u = "asc", l.value[t] = u; + function S(t) { + let l; + s.value[t] === "asc" ? l = "desc" : s.value[t] === "desc" ? l = null : l = "asc", s.value[t] = l; } - return j(() => { + return _(() => { i(); }), { dataUrl: c, size: n, - page: s, - sorts: l, + page: u, + sorts: s, filters: v, data: e, fetch: i, loading: r, - downloadCsv: S, - totalPages: h, - countFiltered: y, - count: w, - rows: z, - first: M, - last: x, - toggleSort: _ + downloadCsv: z, + totalPages: g, + countFiltered: x, + count: h, + rows: y, + first: w, + last: M, + toggleSort: S }; }; export { - O as useSprunjer + N as useSprunjer };