@sumaris-net/ngx-components 1.5.5 → 1.5.9
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/bundles/sumaris-net.ngx-components.umd.js +42 -26
- package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js +2 -2
- package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
- package/doc/changelog.md +1 -1
- package/esm2015/src/app/core/table/table.class.js +12 -4
- package/esm2015/src/app/shared/functions.js +28 -20
- package/fesm2015/sumaris-net.ngx-components.js +39 -23
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/shared/functions.d.ts +1 -0
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -523,48 +523,56 @@
|
|
|
523
523
|
return { data: [], total: 0 };
|
|
524
524
|
}
|
|
525
525
|
// Filter items
|
|
526
|
-
var
|
|
526
|
+
var filteredItems = items;
|
|
527
527
|
if (isNotNilOrBlank(value)) {
|
|
528
528
|
// If wildcard, search using regexp
|
|
529
529
|
if (value.indexOf('*') !== -1) {
|
|
530
530
|
value = value.replace('*', '.*');
|
|
531
|
-
|
|
531
|
+
filteredItems = filteredItems.filter(function (v) { return keys.findIndex(function (key) { return matchUpperCase(getPropertyByPathAsString(v, key), value); }) !== -1; });
|
|
532
532
|
}
|
|
533
533
|
// Else (no wildcard), search using startsWith
|
|
534
534
|
else {
|
|
535
|
-
|
|
535
|
+
filteredItems = filteredItems.filter(function (v) { return keys.findIndex(function (key) { return startsWithUpperCase(getPropertyByPathAsString(v, key), value); }) !== -1; });
|
|
536
536
|
}
|
|
537
537
|
}
|
|
538
538
|
// Exclude ids
|
|
539
539
|
if (isNotEmptyArray(opts === null || opts === void 0 ? void 0 : opts.excludedIds)) {
|
|
540
|
-
|
|
541
|
-
}
|
|
542
|
-
// Sort
|
|
543
|
-
if (
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
540
|
+
filteredItems = filteredItems.filter(function (v) { return !opts.excludedIds.includes(+v['id']); });
|
|
541
|
+
}
|
|
542
|
+
// Sort
|
|
543
|
+
if (!opts || opts.skipSort !== true) {
|
|
544
|
+
// Make to copy input items, before sorting (if not yet already done)
|
|
545
|
+
if (filteredItems === items)
|
|
546
|
+
filteredItems = filteredItems.slice();
|
|
547
|
+
// Sort by keys
|
|
548
|
+
filteredItems.sort(propertiesPathComparator(keys));
|
|
549
|
+
}
|
|
550
|
+
var total = filteredItems.length || 0;
|
|
551
|
+
// Pagination (truncate if need)
|
|
552
|
+
var pageData = filteredItems;
|
|
548
553
|
if (opts) {
|
|
549
|
-
if (
|
|
550
|
-
|
|
554
|
+
if ((opts.offset || 0) > 0) {
|
|
555
|
+
pageData = pageData.slice(opts.offset);
|
|
551
556
|
}
|
|
552
|
-
if (isNotNil(opts.size) &&
|
|
553
|
-
|
|
557
|
+
if (isNotNil(opts.size) && pageData.length > opts.size) {
|
|
558
|
+
pageData = pageData.slice(0, opts.size);
|
|
554
559
|
}
|
|
555
560
|
}
|
|
556
|
-
var
|
|
557
|
-
data:
|
|
561
|
+
var result = {
|
|
562
|
+
data: pageData,
|
|
558
563
|
total: total
|
|
559
564
|
};
|
|
560
565
|
// Add fetch more capability, if total was fetched
|
|
561
|
-
var nextOffset = (opts && opts.offset || 0) +
|
|
566
|
+
var nextOffset = (opts && opts.offset || 0) + pageData.length;
|
|
562
567
|
if (nextOffset < total) {
|
|
563
|
-
|
|
564
|
-
return
|
|
565
|
-
|
|
568
|
+
result.fetchMore = function (_) { return __awaiter(_this, void 0, void 0, function () {
|
|
569
|
+
return __generator(this, function (_a) {
|
|
570
|
+
return [2 /*return*/, suggestFromArray(filteredItems, undefined /*OPTIMISATION: already applied*/, Object.assign(Object.assign({}, opts), { offset: nextOffset, skipSort: true, excludedIds: undefined // OPTIMISATION: already filtered
|
|
571
|
+
}))];
|
|
572
|
+
});
|
|
573
|
+
}); };
|
|
566
574
|
}
|
|
567
|
-
return
|
|
575
|
+
return result;
|
|
568
576
|
}
|
|
569
577
|
function suggestFromStringArray(values, value, options) {
|
|
570
578
|
value = (typeof value === 'string' && value !== '*') && value.toUpperCase() || undefined;
|
|
@@ -24884,8 +24892,9 @@
|
|
|
24884
24892
|
* @param opts Use interactive=false to avoid user interaction (e.g. user confirmation)
|
|
24885
24893
|
*/
|
|
24886
24894
|
AppTable.prototype.deleteRows = function (event, rows, opts) {
|
|
24895
|
+
var _a;
|
|
24887
24896
|
return __awaiter(this, void 0, void 0, function () {
|
|
24888
|
-
var canDelete, saved, rowsToDelete, deleteCount, err_2;
|
|
24897
|
+
var confirmed, canDelete, saved, rowsToDelete, deleteCount, err_2;
|
|
24889
24898
|
return __generator(this, function (_d) {
|
|
24890
24899
|
switch (_d.label) {
|
|
24891
24900
|
case 0:
|
|
@@ -24899,6 +24908,12 @@
|
|
|
24899
24908
|
return [2 /*return*/, 0];
|
|
24900
24909
|
if (this.loading || isEmptyArray(rows))
|
|
24901
24910
|
return [2 /*return*/, 0];
|
|
24911
|
+
// Make sure to keep newly created row
|
|
24912
|
+
if (((_a = this.editedRow) === null || _a === void 0 ? void 0 : _a.id) === -1 && this.editedRow.editing && !rows.includes(this.editedRow)) {
|
|
24913
|
+
confirmed = this.confirmEditCreate();
|
|
24914
|
+
if (!confirmed)
|
|
24915
|
+
return [2 /*return*/, 0]; // Cannot delete (e.g. edited row is invalid)
|
|
24916
|
+
}
|
|
24902
24917
|
return [4 /*yield*/, this.canDeleteRows(rows, opts)];
|
|
24903
24918
|
case 1:
|
|
24904
24919
|
canDelete = _d.sent();
|
|
@@ -24931,9 +24946,10 @@
|
|
|
24931
24946
|
return [4 /*yield*/, this._dataSource.deleteAll(rowsToDelete)];
|
|
24932
24947
|
case 5:
|
|
24933
24948
|
_d.sent();
|
|
24934
|
-
//
|
|
24935
|
-
//
|
|
24936
|
-
|
|
24949
|
+
// Update manually, even if watchALl().subscribe() will update this count,
|
|
24950
|
+
// because of memory data service (see issue #
|
|
24951
|
+
this.totalRowCount -= deleteCount;
|
|
24952
|
+
this.visibleRowCount -= deleteCount;
|
|
24937
24953
|
this.selection.clear();
|
|
24938
24954
|
this.editedRow = undefined;
|
|
24939
24955
|
this.markAsDirty({ emitEvent: false /*markForCheck() is called just after*/ });
|