@finema/core 2.37.0 → 2.38.0
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/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -21,6 +21,7 @@ export const usePageLoader = (loaderOptions) => {
|
|
|
21
21
|
const config = useCoreConfig();
|
|
22
22
|
const fetch = reactive({
|
|
23
23
|
status: ObjectHelper.createStatus(),
|
|
24
|
+
statusNextPage: ObjectHelper.createStatus(),
|
|
24
25
|
items: [],
|
|
25
26
|
options: initPageOptions({
|
|
26
27
|
limit: config.limit_per_page,
|
|
@@ -54,6 +55,7 @@ export const usePageLoader = (loaderOptions) => {
|
|
|
54
55
|
add.status = ObjectHelper.createStatus();
|
|
55
56
|
update.status = ObjectHelper.createStatus();
|
|
56
57
|
fetch.status = ObjectHelper.createStatus();
|
|
58
|
+
fetch.statusNextPage = ObjectHelper.createStatus();
|
|
57
59
|
find.item = null;
|
|
58
60
|
del.item = null;
|
|
59
61
|
update.item = null;
|
|
@@ -184,6 +186,35 @@ export const usePageLoader = (loaderOptions) => {
|
|
|
184
186
|
const fetchSearch = async (query = "", opts) => {
|
|
185
187
|
await fetchPage(1, query, opts);
|
|
186
188
|
};
|
|
189
|
+
const fetchNextPage = async (opts) => {
|
|
190
|
+
const {
|
|
191
|
+
page: _page,
|
|
192
|
+
...params
|
|
193
|
+
} = fetch.options?.request?.params || {};
|
|
194
|
+
await apiFetchHelper(
|
|
195
|
+
() => ({
|
|
196
|
+
status: fetch.status,
|
|
197
|
+
items: fetch.items,
|
|
198
|
+
options: fetch.options
|
|
199
|
+
}),
|
|
200
|
+
(data) => {
|
|
201
|
+
fetch.statusNextPage = data;
|
|
202
|
+
},
|
|
203
|
+
(data) => {
|
|
204
|
+
fetch.options = data;
|
|
205
|
+
},
|
|
206
|
+
(data) => {
|
|
207
|
+
fetch.items = [...fetch.items, ...data];
|
|
208
|
+
},
|
|
209
|
+
fetch.options.currentPage + 1,
|
|
210
|
+
fetch.options.search || "",
|
|
211
|
+
{
|
|
212
|
+
...loaderOptions,
|
|
213
|
+
params,
|
|
214
|
+
...opts
|
|
215
|
+
}
|
|
216
|
+
);
|
|
217
|
+
};
|
|
187
218
|
const fetchPageChange = async (page, opts) => {
|
|
188
219
|
const {
|
|
189
220
|
page: _page,
|
|
@@ -232,6 +263,7 @@ export const usePageLoader = (loaderOptions) => {
|
|
|
232
263
|
fetchPage,
|
|
233
264
|
fetchSearch,
|
|
234
265
|
fetchPageChange,
|
|
266
|
+
fetchNextPage,
|
|
235
267
|
fetchSetLoading,
|
|
236
268
|
findSetLoading,
|
|
237
269
|
findRun,
|
|
@@ -46,6 +46,7 @@ export interface IPageLoaderOptions<T> {
|
|
|
46
46
|
export interface IUsePageLoader<T> {
|
|
47
47
|
fetch: {
|
|
48
48
|
status: IStatus;
|
|
49
|
+
statusNextPage: IStatus;
|
|
49
50
|
items: T[];
|
|
50
51
|
options: IPageOptions;
|
|
51
52
|
};
|
|
@@ -72,6 +73,7 @@ export interface IUsePageLoader<T> {
|
|
|
72
73
|
};
|
|
73
74
|
fetchPage: (page?: number, query?: string, opts?: IPageFetchLoaderOptions) => Promise<void>;
|
|
74
75
|
fetchPageChange: (page: number, opts?: IPageFetchLoaderOptions) => Promise<void>;
|
|
76
|
+
fetchNextPage: (opts?: IPageFetchLoaderOptions) => Promise<void>;
|
|
75
77
|
fetchSearch: (query: string, opts?: IPageFetchLoaderOptions) => Promise<void>;
|
|
76
78
|
fetchSetLoading: () => void;
|
|
77
79
|
findSetLoading: () => void;
|