@masterteam/client-components 0.0.86 → 0.0.87
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.
|
@@ -559,8 +559,6 @@ class ClientListStateService {
|
|
|
559
559
|
existing.areaType !== item.areaType) {
|
|
560
560
|
return item;
|
|
561
561
|
}
|
|
562
|
-
const keepPaging = existing.config.isPaginated === item.config.isPaginated &&
|
|
563
|
-
existing.take === item.take;
|
|
564
562
|
return {
|
|
565
563
|
...item,
|
|
566
564
|
loading: existing.loading,
|
|
@@ -571,7 +569,12 @@ class ClientListStateService {
|
|
|
571
569
|
columns: existing.columns,
|
|
572
570
|
rows: existing.rows,
|
|
573
571
|
cards: existing.cards,
|
|
574
|
-
|
|
572
|
+
// Paging is settled by the caller, which compared the incoming config
|
|
573
|
+
// against the previous one. Re-deciding it here — with only the two
|
|
574
|
+
// states and no view of what changed in the config — is what used to
|
|
575
|
+
// drop the user's page whenever their rows-per-page differed from the
|
|
576
|
+
// configured default.
|
|
577
|
+
skip: item.skip,
|
|
575
578
|
take: item.take,
|
|
576
579
|
expanded: existing.expanded,
|
|
577
580
|
dashboardData: existing.dashboardData,
|
|
@@ -1941,6 +1944,40 @@ function toScalar(value) {
|
|
|
1941
1944
|
item['displayName']);
|
|
1942
1945
|
}
|
|
1943
1946
|
|
|
1947
|
+
/**
|
|
1948
|
+
* Whether the offset a list is currently sitting on still describes the same
|
|
1949
|
+
* result set, i.e. this reconfigure changed nothing about what gets fetched.
|
|
1950
|
+
*
|
|
1951
|
+
* Hosts rebuild the `configurations` array from a `computed()`, so *any*
|
|
1952
|
+
* unrelated state change — a permission refresh after a write, a language
|
|
1953
|
+
* switch, a re-rendered header template — hands the list a brand new array
|
|
1954
|
+
* with identical content. That must not move the user off their page, and
|
|
1955
|
+
* must not cost a request.
|
|
1956
|
+
*
|
|
1957
|
+
* The page size is compared **as configured**, never as currently applied. The
|
|
1958
|
+
* table owns its rows-per-page: the user picks it from the paginator and
|
|
1959
|
+
* `mt-table` restores a persisted value, and either of those legitimately
|
|
1960
|
+
* leaves the runtime `take` different from the configured one. Reading that
|
|
1961
|
+
* difference as drift to correct is what used to reset the paginator and
|
|
1962
|
+
* refetch page 1 on every reconfigure.
|
|
1963
|
+
*/
|
|
1964
|
+
function preservesPaging(existing, areaType, next) {
|
|
1965
|
+
if (!existing ||
|
|
1966
|
+
existing.type !== 'form' ||
|
|
1967
|
+
existing.areaType !== areaType ||
|
|
1968
|
+
next.type !== 'form') {
|
|
1969
|
+
return false;
|
|
1970
|
+
}
|
|
1971
|
+
const current = existing.config;
|
|
1972
|
+
return (current.isPaginated === next.isPaginated &&
|
|
1973
|
+
current.take === next.take &&
|
|
1974
|
+
current.contextKey === next.contextKey &&
|
|
1975
|
+
serializeFilters(current.filters) === serializeFilters(next.filters));
|
|
1976
|
+
}
|
|
1977
|
+
function serializeFilters(filters) {
|
|
1978
|
+
return JSON.stringify(filters ?? []);
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1944
1981
|
const DEFAULT_AREA_TYPE = 'table';
|
|
1945
1982
|
const DEFAULT_MODE = 'auto';
|
|
1946
1983
|
const DEFAULT_TYPE = 'form';
|
|
@@ -2546,6 +2583,10 @@ class ClientList {
|
|
|
2546
2583
|
const key = config.key ?? this.createItemKey(config, index);
|
|
2547
2584
|
const existing = previousItems[key];
|
|
2548
2585
|
const normalizedConfig = this.toNormalizedConfig(config, type, areaType, mode, isPaginated, take, showHeader, collapseEnabled, layout);
|
|
2586
|
+
// Paging is runtime state, not config state: it survives a reconfigure
|
|
2587
|
+
// that changed nothing about the fetch, and the *applied* page size
|
|
2588
|
+
// (the user's rows-per-page choice) is carried forward with it.
|
|
2589
|
+
const keepsPaging = preservesPaging(existing, areaType, normalizedConfig);
|
|
2549
2590
|
if (isInformative) {
|
|
2550
2591
|
return {
|
|
2551
2592
|
key,
|
|
@@ -2581,12 +2622,13 @@ class ClientList {
|
|
|
2581
2622
|
columns: [],
|
|
2582
2623
|
rows: [],
|
|
2583
2624
|
cards: [],
|
|
2584
|
-
//
|
|
2585
|
-
//
|
|
2586
|
-
// the
|
|
2587
|
-
//
|
|
2588
|
-
|
|
2589
|
-
|
|
2625
|
+
// For infinite scroll `skip` is the next offset into the loaded
|
|
2626
|
+
// set, so it travels with that set: kept while the fetch is
|
|
2627
|
+
// unchanged (the cards themselves are kept too, by
|
|
2628
|
+
// `mergeItemState`), and restarted at 0 the moment the fetch
|
|
2629
|
+
// changes and the loaded set stops meaning anything.
|
|
2630
|
+
skip: keepsPaging ? existing.skip : 0,
|
|
2631
|
+
take: keepsPaging ? existing.take : take,
|
|
2590
2632
|
expanded: existing?.expanded ?? config.collapse?.expandedByDefault ?? true,
|
|
2591
2633
|
dashboardData: null,
|
|
2592
2634
|
rawData: existing?.rawData ?? null,
|
|
@@ -2605,12 +2647,8 @@ class ClientList {
|
|
|
2605
2647
|
columns: [],
|
|
2606
2648
|
rows: [],
|
|
2607
2649
|
cards: [],
|
|
2608
|
-
skip: existing
|
|
2609
|
-
|
|
2610
|
-
existing.take === take
|
|
2611
|
-
? existing.skip
|
|
2612
|
-
: 0,
|
|
2613
|
-
take,
|
|
2650
|
+
skip: keepsPaging ? existing.skip : 0,
|
|
2651
|
+
take: keepsPaging ? existing.take : take,
|
|
2614
2652
|
expanded: existing?.expanded ?? config.collapse?.expandedByDefault ?? true,
|
|
2615
2653
|
dashboardData: null,
|
|
2616
2654
|
rawData: existing?.rawData ?? null,
|