@orchidui/core 1.8.1-100 → 1.8.1-102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DataTable/useDataTable.js +26 -25
- package/package.json +1 -1
@@ -1,18 +1,18 @@
|
|
1
|
-
import { ref as
|
1
|
+
import { ref as n } from "vue";
|
2
2
|
function I(m) {
|
3
|
-
const { id: L, name: w, localDb: _ } = m, B =
|
3
|
+
const { id: L, name: w, localDb: _ } = m, B = n(L), s = n(w), i = n(_), D = n([]), l = n([]), f = n({}), g = n({
|
4
4
|
total: 0,
|
5
5
|
last_page: 0
|
6
|
-
}),
|
7
|
-
let
|
6
|
+
}), y = n(!1);
|
7
|
+
let b = null;
|
8
8
|
const p = async () => {
|
9
|
-
|
10
|
-
let e = i.value.table(
|
9
|
+
y.value = !0, b && clearTimeout(b), b = setTimeout(async () => {
|
10
|
+
let e = i.value.table(s.value);
|
11
11
|
const t = C();
|
12
|
-
t.filter && Object.entries(t.filter).forEach(([c, o]) => {
|
12
|
+
console.log("local filter options :", t), t.filter && Object.entries(t.filter).forEach(([c, o]) => {
|
13
13
|
o && Array.isArray(o) ? e = e.filter((d) => {
|
14
14
|
const u = d[c];
|
15
|
-
return o.some((
|
15
|
+
return o.some((v) => typeof v == "string" && typeof u == "string" ? u.toLowerCase().includes(v.toLowerCase()) : u === v);
|
16
16
|
}) : o && typeof o == "string" ? e = e.filter((d) => {
|
17
17
|
const u = d[c];
|
18
18
|
return typeof u == "string" && u.toLowerCase().includes(o.toLowerCase());
|
@@ -21,34 +21,35 @@ function I(m) {
|
|
21
21
|
e = e.sortBy(c.column), c.direction === "desc" && (e = e.reverse());
|
22
22
|
});
|
23
23
|
const a = await e.toArray();
|
24
|
-
|
25
|
-
const
|
26
|
-
|
27
|
-
total:
|
24
|
+
D.value = a;
|
25
|
+
const r = await i.value.table(s.value).count();
|
26
|
+
g.value = {
|
27
|
+
total: r,
|
28
28
|
page: t.page,
|
29
29
|
per_page: t.per_page,
|
30
|
-
last_page: Math.ceil(
|
31
|
-
},
|
30
|
+
last_page: Math.ceil(r / t.per_page)
|
31
|
+
}, y.value = !1;
|
32
32
|
}, 300);
|
33
33
|
}, C = () => {
|
34
34
|
const e = {}, t = ["columnEdit", "page", "per_page"];
|
35
|
-
return Object.entries(f.value).forEach(([a,
|
36
|
-
!t.includes(a) &&
|
35
|
+
return Object.entries(f.value).forEach(([a, r]) => {
|
36
|
+
!t.includes(a) && r !== void 0 && r !== null && r !== "" && (e[a] = r);
|
37
37
|
}), {
|
38
38
|
filter: e,
|
39
39
|
sortBy: l.value,
|
40
40
|
page: f.value.page,
|
41
|
-
per_page: f.value.per_page
|
41
|
+
per_page: f.value.per_page,
|
42
|
+
pagination: g.value
|
42
43
|
};
|
43
44
|
};
|
44
45
|
return {
|
45
46
|
// State
|
46
47
|
sortBy: l,
|
47
|
-
localData:
|
48
|
+
localData: D,
|
48
49
|
dataTableId: B,
|
49
|
-
dbTablename:
|
50
|
-
paginationData:
|
51
|
-
isLoading:
|
50
|
+
dbTablename: s,
|
51
|
+
paginationData: g,
|
52
|
+
isLoading: y,
|
52
53
|
// Methods
|
53
54
|
toggleSort: (e) => {
|
54
55
|
const t = l.value.find((a) => a.column === e);
|
@@ -57,16 +58,16 @@ function I(m) {
|
|
57
58
|
) : l.value = l.value.filter((a) => a.column !== e) : l.value = [...l.value, { column: e, direction: "asc" }], p();
|
58
59
|
},
|
59
60
|
bulkPutLocalData: async (e) => {
|
60
|
-
await i.value.table(
|
61
|
+
await i.value.table(s.value).bulkPut(e);
|
61
62
|
},
|
62
63
|
bulkDeleteLocalData: async (e) => {
|
63
|
-
await i.value.table(
|
64
|
+
await i.value.table(s.value).bulkDelete(e);
|
64
65
|
},
|
65
66
|
getLocalDataUpdatedAt: async () => {
|
66
|
-
const e = await i.value.table(
|
67
|
+
const e = await i.value.table(s.value).orderBy("updated_at").reverse().limit(1).first();
|
67
68
|
return e == null ? void 0 : e.updated_at;
|
68
69
|
},
|
69
|
-
getLocalDataIds: async () => await i.value.table(
|
70
|
+
getLocalDataIds: async () => await i.value.table(s.value).toCollection().primaryKeys(),
|
70
71
|
syncLocalData: p,
|
71
72
|
// Setters
|
72
73
|
setFilter: (e) => {
|