@lavalogic/scoria 0.38.15 → 0.38.16
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.
|
@@ -131,6 +131,14 @@ export declare class CustomRemoteRepository<TRow extends object> extends TableDa
|
|
|
131
131
|
readonly setFilterMode: (id: string, mode: FilterMode | undefined) => void;
|
|
132
132
|
readonly filterBy: (id: string, value: unknown) => void;
|
|
133
133
|
readonly resetFilters: () => void;
|
|
134
|
+
/**
|
|
135
|
+
* Reset the current page to page 1 without touching `pageSize`. Used
|
|
136
|
+
* by every filter-mutation entrypoint so a fresh filter never leaves
|
|
137
|
+
* the user stranded on a page index that no longer exists once the
|
|
138
|
+
* remote re-query returns a smaller result set. Mirror of the helper
|
|
139
|
+
* on `BuiltInRemoteRepository`.
|
|
140
|
+
*/
|
|
141
|
+
private resetToFirstPage;
|
|
134
142
|
/** Jumps to the given 1-based page number, clamped at >= 1. */
|
|
135
143
|
readonly setPage: (page: number) => void;
|
|
136
144
|
/** Advances to the next page. */
|
|
@@ -403,6 +403,7 @@ export class CustomRemoteRepository extends TableDataRepository {
|
|
|
403
403
|
else {
|
|
404
404
|
this._filterModes.set(id, mode);
|
|
405
405
|
}
|
|
406
|
+
this.resetToFirstPage();
|
|
406
407
|
void this.reload();
|
|
407
408
|
};
|
|
408
409
|
filterBy = (id, value) => {
|
|
@@ -423,12 +424,34 @@ export class CustomRemoteRepository extends TableDataRepository {
|
|
|
423
424
|
}
|
|
424
425
|
}
|
|
425
426
|
this._filtering = next;
|
|
427
|
+
// Any filter change should drop the user back on page 1; otherwise
|
|
428
|
+
// when typing in a filter while on page 2+ the new (smaller) result
|
|
429
|
+
// set leaves the pagination on an out-of-range page index. The user
|
|
430
|
+
// then sees "1 row" in the footer but the body is blank because
|
|
431
|
+
// the request still asks for `page=3` of a 1-page result set.
|
|
432
|
+
this.resetToFirstPage();
|
|
426
433
|
void this.reload();
|
|
427
434
|
};
|
|
428
435
|
resetFilters = () => {
|
|
429
436
|
this._filtering = [];
|
|
437
|
+
this.resetToFirstPage();
|
|
430
438
|
void this.reload();
|
|
431
439
|
};
|
|
440
|
+
/**
|
|
441
|
+
* Reset the current page to page 1 without touching `pageSize`. Used
|
|
442
|
+
* by every filter-mutation entrypoint so a fresh filter never leaves
|
|
443
|
+
* the user stranded on a page index that no longer exists once the
|
|
444
|
+
* remote re-query returns a smaller result set. Mirror of the helper
|
|
445
|
+
* on `BuiltInRemoteRepository`.
|
|
446
|
+
*/
|
|
447
|
+
resetToFirstPage() {
|
|
448
|
+
if (this.paginationState.pageIndex !== 0) {
|
|
449
|
+
this.paginationState = {
|
|
450
|
+
...this.paginationState,
|
|
451
|
+
pageIndex: 0,
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
}
|
|
432
455
|
/** Jumps to the given 1-based page number, clamped at >= 1. */
|
|
433
456
|
setPage = (page) => {
|
|
434
457
|
this.paginationState = {
|