@firestitch/list 9.12.3 → 9.12.4
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/app/classes/pagination-controller.d.ts +10 -6
- package/bundles/firestitch-list.umd.js +73 -59
- package/bundles/firestitch-list.umd.js.map +1 -1
- package/bundles/firestitch-list.umd.min.js +1 -1
- package/bundles/firestitch-list.umd.min.js.map +1 -1
- package/esm2015/app/classes/list-controller.js +14 -4
- package/esm2015/app/classes/pagination-controller.js +40 -40
- package/esm5/app/classes/list-controller.js +14 -4
- package/esm5/app/classes/pagination-controller.js +62 -60
- package/fesm2015/firestitch-list.js +52 -40
- package/fesm2015/firestitch-list.js.map +1 -1
- package/fesm5/firestitch-list.js +74 -60
- package/fesm5/firestitch-list.js.map +1 -1
- package/firestitch-list.metadata.json +1 -1
- package/package.json +1 -1
package/fesm5/firestitch-list.js
CHANGED
|
@@ -18,7 +18,7 @@ import { FsPrompt, FsPromptModule } from '@firestitch/prompt';
|
|
|
18
18
|
import { FsFileModule } from '@firestitch/file';
|
|
19
19
|
import { isString, isObject, isBoolean, isNumber, isFunction, get, cloneDeep, mergeWith, random, merge as merge$1 } from 'lodash-es';
|
|
20
20
|
import { Subject, BehaviorSubject, Observable, merge, from, combineLatest, of } from 'rxjs';
|
|
21
|
-
import { takeUntil, tap, take, map, debounceTime, switchMap, mapTo, catchError,
|
|
21
|
+
import { takeUntil, tap, distinctUntilChanged, take, map, debounceTime, switchMap, mapTo, catchError, shareReplay, skip, filter } from 'rxjs/operators';
|
|
22
22
|
import { SelectionDialog } from '@firestitch/selection';
|
|
23
23
|
import { getNormalizedPath } from '@firestitch/common';
|
|
24
24
|
import { DrawerRef } from '@firestitch/drawer';
|
|
@@ -1423,27 +1423,24 @@ var PaginationStrategy;
|
|
|
1423
1423
|
PaginationStrategy["None"] = "none";
|
|
1424
1424
|
})(PaginationStrategy || (PaginationStrategy = {}));
|
|
1425
1425
|
|
|
1426
|
-
var PaginationController = /** @class */ (function (
|
|
1427
|
-
__extends(PaginationController, _super);
|
|
1426
|
+
var PaginationController = /** @class */ (function () {
|
|
1428
1427
|
function PaginationController() {
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
_this.offset = 0;
|
|
1428
|
+
this.limit = 25;
|
|
1429
|
+
this.manual = false;
|
|
1430
|
+
this.page = 1; // Active page
|
|
1431
|
+
this.offset = 0;
|
|
1434
1432
|
// public pagesArray = [];
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
return _this;
|
|
1433
|
+
this.displayed = 0;
|
|
1434
|
+
this._pages$ = new BehaviorSubject(0); // Total pages
|
|
1435
|
+
this._strategy = PaginationStrategy.None;
|
|
1436
|
+
this._removedRows = 0;
|
|
1437
|
+
this._pageChanged$ = new Subject();
|
|
1438
|
+
this._pageReset$ = new Subject();
|
|
1439
|
+
this._onDestroy$ = new Subject();
|
|
1440
|
+
this._loadMoreEnabled = false;
|
|
1441
|
+
this._infinityScrollEnabled = false;
|
|
1442
|
+
this._loadMoreText = 'Load More';
|
|
1443
|
+
this._limits = [10, 25, 50, 100, 200];
|
|
1447
1444
|
}
|
|
1448
1445
|
Object.defineProperty(PaginationController.prototype, "pages", {
|
|
1449
1446
|
get: function () {
|
|
@@ -1458,7 +1455,8 @@ var PaginationController = /** @class */ (function (_super) {
|
|
|
1458
1455
|
});
|
|
1459
1456
|
Object.defineProperty(PaginationController.prototype, "pages$", {
|
|
1460
1457
|
get: function () {
|
|
1461
|
-
return this._pages
|
|
1458
|
+
return this._pages$
|
|
1459
|
+
.pipe(distinctUntilChanged());
|
|
1462
1460
|
},
|
|
1463
1461
|
enumerable: true,
|
|
1464
1462
|
configurable: true
|
|
@@ -1529,6 +1527,22 @@ var PaginationController = /** @class */ (function (_super) {
|
|
|
1529
1527
|
enumerable: true,
|
|
1530
1528
|
configurable: true
|
|
1531
1529
|
});
|
|
1530
|
+
Object.defineProperty(PaginationController.prototype, "loadMoreQuery", {
|
|
1531
|
+
get: function () {
|
|
1532
|
+
switch (this.strategy) {
|
|
1533
|
+
case PaginationStrategy.Page:
|
|
1534
|
+
return this.query;
|
|
1535
|
+
case PaginationStrategy.Offset:
|
|
1536
|
+
var query = this.queryOffsetStrategy;
|
|
1537
|
+
query.limit = query.offset + query.limit;
|
|
1538
|
+
query.offset = 0;
|
|
1539
|
+
return query;
|
|
1540
|
+
}
|
|
1541
|
+
return {};
|
|
1542
|
+
},
|
|
1543
|
+
enumerable: true,
|
|
1544
|
+
configurable: true
|
|
1545
|
+
});
|
|
1532
1546
|
Object.defineProperty(PaginationController.prototype, "queryPageStrategy", {
|
|
1533
1547
|
/**
|
|
1534
1548
|
* Query for Page Strategy
|
|
@@ -1691,12 +1705,6 @@ var PaginationController = /** @class */ (function (_super) {
|
|
|
1691
1705
|
enumerable: true,
|
|
1692
1706
|
configurable: true
|
|
1693
1707
|
});
|
|
1694
|
-
PaginationController.prototype._fromJSON = function (value) {
|
|
1695
|
-
_super.prototype._fromJSON.call(this, value);
|
|
1696
|
-
if (!value.limit) {
|
|
1697
|
-
this.limit = 25;
|
|
1698
|
-
}
|
|
1699
|
-
};
|
|
1700
1708
|
PaginationController.prototype.initWithConfig = function (config, loadMore, infinityScrollEnabled) {
|
|
1701
1709
|
if (infinityScrollEnabled === void 0) { infinityScrollEnabled = false; }
|
|
1702
1710
|
if (config) {
|
|
@@ -1706,12 +1714,12 @@ var PaginationController = /** @class */ (function (_super) {
|
|
|
1706
1714
|
if (config.limit) {
|
|
1707
1715
|
this.limit = config.limit;
|
|
1708
1716
|
}
|
|
1709
|
-
if (loadMore) {
|
|
1710
|
-
this.setLoadMore(loadMore);
|
|
1711
|
-
}
|
|
1712
|
-
this._infinityScrollEnabled = infinityScrollEnabled;
|
|
1713
1717
|
this.strategy = config.strategy;
|
|
1714
1718
|
}
|
|
1719
|
+
if (loadMore) {
|
|
1720
|
+
this.setLoadMore(loadMore);
|
|
1721
|
+
}
|
|
1722
|
+
this._infinityScrollEnabled = infinityScrollEnabled;
|
|
1715
1723
|
};
|
|
1716
1724
|
Object.defineProperty(PaginationController.prototype, "_hasPrevPagePageStrategy", {
|
|
1717
1725
|
/**
|
|
@@ -1756,15 +1764,15 @@ var PaginationController = /** @class */ (function (_super) {
|
|
|
1756
1764
|
/**
|
|
1757
1765
|
* Update paging config and all related fields
|
|
1758
1766
|
* @param config
|
|
1759
|
-
* @param
|
|
1760
|
-
* @param
|
|
1767
|
+
* @param displayedRecords
|
|
1768
|
+
* @param loadMoreOperation
|
|
1761
1769
|
*/
|
|
1762
|
-
PaginationController.prototype.updatePaging = function (config,
|
|
1763
|
-
if (
|
|
1764
|
-
if (
|
|
1765
|
-
if (!
|
|
1766
|
-
this.
|
|
1767
|
-
this.displayed =
|
|
1770
|
+
PaginationController.prototype.updatePaging = function (config, displayedRecords, loadMoreOperation) {
|
|
1771
|
+
if (displayedRecords === void 0) { displayedRecords = 0; }
|
|
1772
|
+
if (loadMoreOperation === void 0) { loadMoreOperation = false; }
|
|
1773
|
+
if (!loadMoreOperation) {
|
|
1774
|
+
this._fromParams(config);
|
|
1775
|
+
this.displayed = displayedRecords;
|
|
1768
1776
|
}
|
|
1769
1777
|
else {
|
|
1770
1778
|
this.records = config.records;
|
|
@@ -1951,6 +1959,19 @@ var PaginationController = /** @class */ (function (_super) {
|
|
|
1951
1959
|
this._onDestroy$.next();
|
|
1952
1960
|
this._onDestroy$.complete();
|
|
1953
1961
|
};
|
|
1962
|
+
/**
|
|
1963
|
+
* Update paging state
|
|
1964
|
+
* @param params
|
|
1965
|
+
*/
|
|
1966
|
+
PaginationController.prototype._fromParams = function (params) {
|
|
1967
|
+
var _a;
|
|
1968
|
+
if (!this.loadMoreEnabled) {
|
|
1969
|
+
this.limit = (_a = params.limit, (_a !== null && _a !== void 0 ? _a : 25));
|
|
1970
|
+
}
|
|
1971
|
+
this.records = params.records;
|
|
1972
|
+
this.manual = params.manual;
|
|
1973
|
+
this.pages = params.pages || 0;
|
|
1974
|
+
};
|
|
1954
1975
|
/**
|
|
1955
1976
|
* Calc and update offset
|
|
1956
1977
|
*/
|
|
@@ -1963,25 +1984,8 @@ var PaginationController = /** @class */ (function (_super) {
|
|
|
1963
1984
|
PaginationController.prototype.updateTotalPages = function () {
|
|
1964
1985
|
this.pages = Math.ceil(this.records / this.limit);
|
|
1965
1986
|
};
|
|
1966
|
-
__decorate([
|
|
1967
|
-
Alias(),
|
|
1968
|
-
__metadata("design:type", Object)
|
|
1969
|
-
], PaginationController.prototype, "limit", void 0);
|
|
1970
|
-
__decorate([
|
|
1971
|
-
Alias(),
|
|
1972
|
-
__metadata("design:type", Number)
|
|
1973
|
-
], PaginationController.prototype, "records", void 0);
|
|
1974
|
-
__decorate([
|
|
1975
|
-
Alias(),
|
|
1976
|
-
__metadata("design:type", Object)
|
|
1977
|
-
], PaginationController.prototype, "manual", void 0);
|
|
1978
|
-
__decorate([
|
|
1979
|
-
Alias('pages'),
|
|
1980
|
-
__metadata("design:type", Number),
|
|
1981
|
-
__metadata("design:paramtypes", [Number])
|
|
1982
|
-
], PaginationController.prototype, "pages", null);
|
|
1983
1987
|
return PaginationController;
|
|
1984
|
-
}(
|
|
1988
|
+
}());
|
|
1985
1989
|
|
|
1986
1990
|
var SelectionChangeType;
|
|
1987
1991
|
(function (SelectionChangeType) {
|
|
@@ -3201,9 +3205,18 @@ var List = /** @class */ (function (_super) {
|
|
|
3201
3205
|
var _a;
|
|
3202
3206
|
(_a = _this.selection) === null || _a === void 0 ? void 0 : _a.closeSelectionDialog();
|
|
3203
3207
|
}), map(function (params) {
|
|
3204
|
-
var query =
|
|
3205
|
-
|
|
3206
|
-
|
|
3208
|
+
var query = Object.assign({}, _this.filtersQuery);
|
|
3209
|
+
if (_this.paging.hasOffsetStrategy && params && params.loadOffset) {
|
|
3210
|
+
query = Object.assign(query, _this.paging.loadDeletedOffsetQuery);
|
|
3211
|
+
}
|
|
3212
|
+
else {
|
|
3213
|
+
if (_this.initialFetch && _this.paging.loadMoreEnabled) {
|
|
3214
|
+
query = Object.assign(query, _this.paging.loadMoreQuery);
|
|
3215
|
+
}
|
|
3216
|
+
else {
|
|
3217
|
+
query = Object.assign(query, _this.paging.query);
|
|
3218
|
+
}
|
|
3219
|
+
}
|
|
3207
3220
|
if (_this.sorting.sortingColumn) {
|
|
3208
3221
|
Object.assign(query, {
|
|
3209
3222
|
order: _this.sorting.sortingColumn.name + "," + _this.sorting.sortingColumn.direction
|
|
@@ -3230,6 +3243,7 @@ var List = /** @class */ (function (_super) {
|
|
|
3230
3243
|
return source$;
|
|
3231
3244
|
}), takeUntil(this.onDestroy$))
|
|
3232
3245
|
.subscribe(function (response) {
|
|
3246
|
+
_this.initialFetch = false;
|
|
3233
3247
|
_this.completeFetch(response);
|
|
3234
3248
|
});
|
|
3235
3249
|
};
|