@sumaris-net/ngx-components 1.23.6 → 1.23.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 +97 -79
- package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
- package/esm2015/src/app/core/table/entities-table-datasource.class.js +2 -2
- package/esm2015/src/app/core/table/table.class.js +74 -64
- package/esm2015/src/app/core/table/testing/table.testing.js +2 -1
- package/fesm2015/sumaris-net.ngx-components.js +73 -62
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/core/table/table.class.d.ts +2 -1
- package/src/theme/_ngx-components.scss +5 -0
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -26105,7 +26105,7 @@
|
|
|
26105
26105
|
case 2:
|
|
26106
26106
|
// Call service deletion
|
|
26107
26107
|
_b.sent();
|
|
26108
|
-
rowNotDeleted = this.getRows().filter(rows.includes);
|
|
26108
|
+
rowNotDeleted = this.getRows().filter(function (row) { return rows.includes(row); });
|
|
26109
26109
|
if (isNotEmptyArray(rowNotDeleted)) {
|
|
26110
26110
|
console.warn("[table-datasource] Force deletion of " + rowNotDeleted.length + " rows! Please check that data service update the cache, after deletion");
|
|
26111
26111
|
rowNotDeleted
|
|
@@ -26688,47 +26688,11 @@
|
|
|
26688
26688
|
this.listenDatasourceLoading(this._dataSource);
|
|
26689
26689
|
};
|
|
26690
26690
|
AppTable.prototype.ngAfterViewInit = function () {
|
|
26691
|
-
|
|
26692
|
-
if (this.debug)
|
|
26693
|
-
|
|
26694
|
-
|
|
26695
|
-
|
|
26696
|
-
if (!_this.table) {
|
|
26697
|
-
console.warn("[table] Missing <mat-table> in the HTML template (after waiting 500ms)! Component: " + _this.constructor.name);
|
|
26698
|
-
}
|
|
26699
|
-
}, 500);
|
|
26700
|
-
}
|
|
26701
|
-
if (!this.displayedColumns)
|
|
26702
|
-
console.warn("[table] Missing 'displayedColumns'. Did you call super.ngOnInit() in component " + this.constructor.name + " ?");
|
|
26703
|
-
}
|
|
26704
|
-
rxjs.merge(
|
|
26705
|
-
// Listen sort events
|
|
26706
|
-
this.sort && this.sort.sortChange
|
|
26707
|
-
.pipe(operators.filter(function () { return !_this.sort.disabled; }), operators.mergeMap(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_e) {
|
|
26708
|
-
return [2 /*return*/, this.saveBeforeAction('sort')];
|
|
26709
|
-
}); }); }), operators.filter(function (res) { return res === true; }),
|
|
26710
|
-
// Save sort in settings
|
|
26711
|
-
operators.tap(function () {
|
|
26712
|
-
var value = [_this.sort.active, _this.sort.direction || 'asc'].join(':');
|
|
26713
|
-
_this.settings.savePageSetting(_this.settingsId, value, SETTINGS_SORTED_COLUMN);
|
|
26714
|
-
}))
|
|
26715
|
-
|| rxjs.EMPTY,
|
|
26716
|
-
// Listen paginator events
|
|
26717
|
-
this.paginator && this.paginator.page
|
|
26718
|
-
.pipe(operators.mergeMap(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_e) {
|
|
26719
|
-
return [2 /*return*/, this.saveBeforeAction('sort')];
|
|
26720
|
-
}); }); }), operators.filter(function (res) { return res === true; }),
|
|
26721
|
-
// Save page size
|
|
26722
|
-
operators.tap(function () { return _this.settings.savePageSetting(_this.settingsId, _this.paginator.pageSize, SETTINGS_PAGE_SIZE); })) || rxjs.EMPTY).subscribe(function (value) {
|
|
26723
|
-
_this.onSort.emit();
|
|
26724
|
-
_this.onRefresh.emit(value);
|
|
26725
|
-
});
|
|
26726
|
-
// If the user changes the sort order, reset back to the first page.
|
|
26727
|
-
if (this.sort && this.paginator) {
|
|
26728
|
-
this.registerSubscription(this.sort.sortChange
|
|
26729
|
-
.pipe(operators.filter(function () { return !_this.sort.disabled; }))
|
|
26730
|
-
.subscribe(function () { return _this.paginator.pageIndex = 0; }));
|
|
26731
|
-
}
|
|
26691
|
+
// Detect when super.ngOnInit() not call
|
|
26692
|
+
if (this.debug && !this.displayedColumns)
|
|
26693
|
+
console.warn("[table] Missing 'displayedColumns'. Did you call super.ngOnInit() in component " + this.constructor.name + " ?");
|
|
26694
|
+
// Start listening sort and paginator events
|
|
26695
|
+
this.listenSortAndPaginationEvents();
|
|
26732
26696
|
};
|
|
26733
26697
|
AppTable.prototype.ngOnDestroy = function () {
|
|
26734
26698
|
var _this = this;
|
|
@@ -26871,27 +26835,6 @@
|
|
|
26871
26835
|
this.editRowById(event, row.id + 1, { focusColumn: this.firstUserColumn });
|
|
26872
26836
|
return true;
|
|
26873
26837
|
};
|
|
26874
|
-
AppTable.prototype.editRowById = function (event, id, opts) {
|
|
26875
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
26876
|
-
var row;
|
|
26877
|
-
return __generator(this, function (_e) {
|
|
26878
|
-
switch (_e.label) {
|
|
26879
|
-
case 0:
|
|
26880
|
-
if (id < 0)
|
|
26881
|
-
return [2 /*return*/];
|
|
26882
|
-
if (!(id >= this.visibleRowCount)) return [3 /*break*/, 1];
|
|
26883
|
-
this.addRow(event, undefined, Object.assign(Object.assign({}, opts), { editing: true }));
|
|
26884
|
-
return [3 /*break*/, 3];
|
|
26885
|
-
case 1: return [4 /*yield*/, this.dataSource.getRow(id)];
|
|
26886
|
-
case 2:
|
|
26887
|
-
row = _e.sent();
|
|
26888
|
-
this.editRow(event, row, opts);
|
|
26889
|
-
_e.label = 3;
|
|
26890
|
-
case 3: return [2 /*return*/];
|
|
26891
|
-
}
|
|
26892
|
-
});
|
|
26893
|
-
});
|
|
26894
|
-
};
|
|
26895
26838
|
/**
|
|
26896
26839
|
* Confirm the creation of the given row, or if not specified the currently edited row
|
|
26897
26840
|
*
|
|
@@ -26907,7 +26850,6 @@
|
|
|
26907
26850
|
// Stop event
|
|
26908
26851
|
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
|
26909
26852
|
// Confirmation edition or creation
|
|
26910
|
-
//const confirmed = this.dataSource.confirmEditCreate(row);
|
|
26911
26853
|
var confirmed = row.confirmEditCreate();
|
|
26912
26854
|
if (confirmed) {
|
|
26913
26855
|
// If edit finished, forget edited row
|
|
@@ -27144,7 +27086,7 @@
|
|
|
27144
27086
|
AppTable.prototype.deleteRows = function (event, rows, opts) {
|
|
27145
27087
|
var _a;
|
|
27146
27088
|
return __awaiter(this, void 0, void 0, function () {
|
|
27147
|
-
var confirmed, canDelete,
|
|
27089
|
+
var confirmed, canDelete, tempRows, deletedRows, saved, err_2;
|
|
27148
27090
|
var _this = this;
|
|
27149
27091
|
return __generator(this, function (_e) {
|
|
27150
27092
|
switch (_e.label) {
|
|
@@ -27172,20 +27114,23 @@
|
|
|
27172
27114
|
canDelete = _e.sent();
|
|
27173
27115
|
if (!canDelete)
|
|
27174
27116
|
return [2 /*return*/, 0]; // Cannot delete
|
|
27175
|
-
|
|
27176
|
-
// This is a workaround, need because row.delete() has async execution
|
|
27177
|
-
// and index cache is updated with a delay
|
|
27178
|
-
rows = rows.slice()
|
|
27117
|
+
tempRows = rows.slice()
|
|
27179
27118
|
.sort(function (a, b) { return a.id > b.id ? -1 : 1; });
|
|
27119
|
+
deletedRows = [];
|
|
27180
27120
|
if (!this.saveBeforeDelete) return [3 /*break*/, 3];
|
|
27181
27121
|
// Exclude invalid rows (because of save() will fail, when exists some invalid rows)
|
|
27182
|
-
|
|
27122
|
+
tempRows = tempRows.filter(function (row) {
|
|
27183
27123
|
// Delete the row, if newly created row (id = -1), or if invalid and not editing (= not cancellable)
|
|
27184
27124
|
if (row.id === -1 || (!row.valid && !row.editing)) {
|
|
27125
|
+
if (_this.debug)
|
|
27126
|
+
console.debug("[table] Delete row #" + row.id);
|
|
27185
27127
|
row.delete();
|
|
27186
27128
|
_this.visibleRowCount--;
|
|
27187
27129
|
_this.totalRowCount--;
|
|
27188
|
-
|
|
27130
|
+
deletedRows.push(row);
|
|
27131
|
+
if (_this.editedRow === row)
|
|
27132
|
+
_this.editedRow = undefined;
|
|
27133
|
+
return false; // Exclude from the list to delete using the service
|
|
27189
27134
|
}
|
|
27190
27135
|
// Cancel the row (and mark as pristine), when not valid but in edition
|
|
27191
27136
|
else if (!row.valid && row.editing) {
|
|
@@ -27196,7 +27141,7 @@
|
|
|
27196
27141
|
}
|
|
27197
27142
|
return true;
|
|
27198
27143
|
});
|
|
27199
|
-
if (!
|
|
27144
|
+
if (!(deletedRows.length || tempRows.length)) return [3 /*break*/, 3];
|
|
27200
27145
|
return [4 /*yield*/, this.saveBeforeAction('delete')];
|
|
27201
27146
|
case 2:
|
|
27202
27147
|
saved = _e.sent();
|
|
@@ -27207,11 +27152,10 @@
|
|
|
27207
27152
|
_e.label = 3;
|
|
27208
27153
|
case 3:
|
|
27209
27154
|
_e.trys.push([3, 6, , 7]);
|
|
27210
|
-
|
|
27211
|
-
if (!deleteCount) return [3 /*break*/, 5];
|
|
27155
|
+
if (!tempRows.length) return [3 /*break*/, 5];
|
|
27212
27156
|
if (this.debug)
|
|
27213
|
-
console.debug(
|
|
27214
|
-
return [4 /*yield*/, this._dataSource.deleteAll(
|
|
27157
|
+
console.debug("[table] Delete " + tempRows.length + " rows...");
|
|
27158
|
+
return [4 /*yield*/, this._dataSource.deleteAll(tempRows)];
|
|
27215
27159
|
case 4:
|
|
27216
27160
|
_e.sent();
|
|
27217
27161
|
_e.label = 5;
|
|
@@ -27223,9 +27167,8 @@
|
|
|
27223
27167
|
this.editedRow = undefined;
|
|
27224
27168
|
this.markAsDirty({ emitEvent: false /*markForCheck() is called just after*/ });
|
|
27225
27169
|
this.markForCheck();
|
|
27226
|
-
|
|
27227
|
-
|
|
27228
|
-
return [2 /*return*/, deleteCount];
|
|
27170
|
+
this.onAfterDeletedRows.next(rows);
|
|
27171
|
+
return [2 /*return*/, rows.length];
|
|
27229
27172
|
case 6:
|
|
27230
27173
|
err_2 = _e.sent();
|
|
27231
27174
|
this.setError(err_2 && err_2.message || err_2);
|
|
@@ -27925,6 +27868,80 @@
|
|
|
27925
27868
|
this.markAsDirty(opts);
|
|
27926
27869
|
};
|
|
27927
27870
|
/* -- private method -- */
|
|
27871
|
+
AppTable.prototype.listenSortAndPaginationEvents = function () {
|
|
27872
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
27873
|
+
var _this = this;
|
|
27874
|
+
return __generator(this, function (_e) {
|
|
27875
|
+
switch (_e.label) {
|
|
27876
|
+
case 0:
|
|
27877
|
+
if (!!this.table) return [3 /*break*/, 2];
|
|
27878
|
+
// DEBUG only -- alert user that table not found in template
|
|
27879
|
+
if (this.debug) {
|
|
27880
|
+
setTimeout(function () { return !_this.table && console.warn("[table] Missing <mat-table> in the HTML template (after waiting 500ms)! Component: " + _this.constructor.name); }, 500);
|
|
27881
|
+
}
|
|
27882
|
+
// Make sure to wait the table
|
|
27883
|
+
return [4 /*yield*/, waitFor(function () { return !!_this.table; }, { stop: this.destroySubject })];
|
|
27884
|
+
case 1:
|
|
27885
|
+
// Make sure to wait the table
|
|
27886
|
+
_e.sent();
|
|
27887
|
+
_e.label = 2;
|
|
27888
|
+
case 2:
|
|
27889
|
+
this.registerSubscription(rxjs.merge(
|
|
27890
|
+
// Listen sort events
|
|
27891
|
+
this.sort && this.sort.sortChange
|
|
27892
|
+
.pipe(operators.filter(function () { return !_this.sort.disabled; }), operators.mergeMap(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_e) {
|
|
27893
|
+
return [2 /*return*/, this.saveBeforeAction('sort')];
|
|
27894
|
+
}); }); }), operators.filter(function (res) { return res === true; }),
|
|
27895
|
+
// Save sort in settings
|
|
27896
|
+
operators.tap(function () {
|
|
27897
|
+
var value = [_this.sort.active, _this.sort.direction || 'asc'].join(':');
|
|
27898
|
+
_this.settings.savePageSetting(_this.settingsId, value, SETTINGS_SORTED_COLUMN);
|
|
27899
|
+
}))
|
|
27900
|
+
|| rxjs.EMPTY,
|
|
27901
|
+
// Listen paginator events
|
|
27902
|
+
this.paginator && this.paginator.page
|
|
27903
|
+
.pipe(operators.mergeMap(function (event) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_e) {
|
|
27904
|
+
return [2 /*return*/, this.saveBeforeAction('sort')];
|
|
27905
|
+
}); }); }), operators.filter(function (res) { return res === true; }),
|
|
27906
|
+
// Save page size in settings
|
|
27907
|
+
operators.tap(function () { return _this.settings.savePageSetting(_this.settingsId, _this.paginator.pageSize, SETTINGS_PAGE_SIZE); })) || rxjs.EMPTY)
|
|
27908
|
+
// Refresh on any sort or paginator events
|
|
27909
|
+
.subscribe(function (value) {
|
|
27910
|
+
_this.onSort.emit(value);
|
|
27911
|
+
_this.onRefresh.emit(value);
|
|
27912
|
+
}));
|
|
27913
|
+
// If the user changes the sort order, reset back to the first page.
|
|
27914
|
+
if (this.sort && this.paginator) {
|
|
27915
|
+
this.registerSubscription(this.sort.sortChange
|
|
27916
|
+
.pipe(operators.filter(function () { return !_this.sort.disabled; }))
|
|
27917
|
+
.subscribe(function () { return _this.paginator.pageIndex = 0; }));
|
|
27918
|
+
}
|
|
27919
|
+
return [2 /*return*/];
|
|
27920
|
+
}
|
|
27921
|
+
});
|
|
27922
|
+
});
|
|
27923
|
+
};
|
|
27924
|
+
AppTable.prototype.editRowById = function (event, id, opts) {
|
|
27925
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
27926
|
+
var row;
|
|
27927
|
+
return __generator(this, function (_e) {
|
|
27928
|
+
switch (_e.label) {
|
|
27929
|
+
case 0:
|
|
27930
|
+
if (id < 0)
|
|
27931
|
+
return [2 /*return*/];
|
|
27932
|
+
if (!(id >= this.visibleRowCount)) return [3 /*break*/, 1];
|
|
27933
|
+
this.addRow(event, undefined, Object.assign(Object.assign({}, opts), { editing: true }));
|
|
27934
|
+
return [3 /*break*/, 3];
|
|
27935
|
+
case 1: return [4 /*yield*/, this.dataSource.getRow(id)];
|
|
27936
|
+
case 2:
|
|
27937
|
+
row = _e.sent();
|
|
27938
|
+
this.editRow(event, row, opts);
|
|
27939
|
+
_e.label = 3;
|
|
27940
|
+
case 3: return [2 /*return*/];
|
|
27941
|
+
}
|
|
27942
|
+
});
|
|
27943
|
+
});
|
|
27944
|
+
};
|
|
27928
27945
|
AppTable.prototype.setLoading = function (value, opts) {
|
|
27929
27946
|
if (this.loadingSubject.value !== value) {
|
|
27930
27947
|
this.loadingSubject.next(value);
|
|
@@ -33914,6 +33931,7 @@
|
|
|
33914
33931
|
this.data = this.generateData(0, TableTestPage.maxRowCount);
|
|
33915
33932
|
}
|
|
33916
33933
|
this.dataService.value = this.data;
|
|
33934
|
+
this.onRefresh.emit();
|
|
33917
33935
|
};
|
|
33918
33936
|
TableTestPage.prototype.fetchMore = function (event) {
|
|
33919
33937
|
return __awaiter(this, void 0, void 0, function () {
|