frappe-ui 0.0.42 → 0.0.43
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/package.json +1 -1
- package/src/utils/resources.js +19 -4
package/package.json
CHANGED
package/src/utils/resources.js
CHANGED
|
@@ -316,10 +316,12 @@ export function createListResource(options, vm, getResource) {
|
|
|
316
316
|
fields: options.fields,
|
|
317
317
|
filters: options.filters,
|
|
318
318
|
order_by: options.order_by,
|
|
319
|
-
start: options.start,
|
|
320
|
-
limit: options.limit,
|
|
319
|
+
start: options.start || 0,
|
|
320
|
+
limit: options.limit || 20,
|
|
321
321
|
originalData: null,
|
|
322
322
|
data: null,
|
|
323
|
+
next,
|
|
324
|
+
hasNextPage: true,
|
|
323
325
|
list: createResource(
|
|
324
326
|
{
|
|
325
327
|
method: 'frappe.client.get_list',
|
|
@@ -334,8 +336,15 @@ export function createListResource(options, vm, getResource) {
|
|
|
334
336
|
}
|
|
335
337
|
},
|
|
336
338
|
onSuccess(data) {
|
|
337
|
-
out.
|
|
338
|
-
|
|
339
|
+
if (data.length < out.limit) {
|
|
340
|
+
out.hasNextPage = false
|
|
341
|
+
}
|
|
342
|
+
if (!out.start || out.start == 0) {
|
|
343
|
+
out.originalData = data
|
|
344
|
+
} else if (out.start > 0) {
|
|
345
|
+
out.originalData = out.originalData.concat(data)
|
|
346
|
+
}
|
|
347
|
+
out.data = transform(out.originalData)
|
|
339
348
|
options.onSuccess?.call(vm, out.data)
|
|
340
349
|
},
|
|
341
350
|
onError: options.onError,
|
|
@@ -455,6 +464,7 @@ export function createListResource(options, vm, getResource) {
|
|
|
455
464
|
}
|
|
456
465
|
|
|
457
466
|
function reload() {
|
|
467
|
+
out.start = 0
|
|
458
468
|
return out.list.fetch()
|
|
459
469
|
}
|
|
460
470
|
|
|
@@ -465,6 +475,11 @@ export function createListResource(options, vm, getResource) {
|
|
|
465
475
|
out.data = data
|
|
466
476
|
}
|
|
467
477
|
|
|
478
|
+
function next() {
|
|
479
|
+
out.start = out.start + out.limit
|
|
480
|
+
out.list.fetch()
|
|
481
|
+
}
|
|
482
|
+
|
|
468
483
|
// fetch list
|
|
469
484
|
out.list.fetch()
|
|
470
485
|
|