@sumaris-net/ngx-components 1.20.0-rc2 → 1.20.0-rc5
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 +173 -105
- 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 +36 -15
- package/esm2015/src/app/core/table/table.class.js +92 -87
- package/fesm2015/sumaris-net.ngx-components.js +126 -100
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/core/table/entities-table-datasource.class.d.ts +6 -2
- package/src/app/core/table/table.class.d.ts +2 -2
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -21603,6 +21603,10 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
21603
21603
|
get loading() {
|
|
21604
21604
|
return this.loadingSubject.value !== false; // Should be true when undefined (initial state)
|
|
21605
21605
|
}
|
|
21606
|
+
connect(collectionViewer) {
|
|
21607
|
+
// DEBUG console.debug("[entities-datasource] connect");
|
|
21608
|
+
return super.connect(collectionViewer);
|
|
21609
|
+
}
|
|
21606
21610
|
disconnect(collectionViewer) {
|
|
21607
21611
|
super.disconnect(collectionViewer);
|
|
21608
21612
|
this._stopWatching$.next();
|
|
@@ -21880,7 +21884,7 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
21880
21884
|
getRows() {
|
|
21881
21885
|
return this.rowsSubject.toPromise();
|
|
21882
21886
|
}
|
|
21883
|
-
|
|
21887
|
+
createNew(insertAt) {
|
|
21884
21888
|
const _super = Object.create(null, {
|
|
21885
21889
|
createNew: { get: () => super.createNew }
|
|
21886
21890
|
});
|
|
@@ -21888,22 +21892,39 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
21888
21892
|
if (this._creating)
|
|
21889
21893
|
return; // Avoid multiple call (should never occur)
|
|
21890
21894
|
this._creating = true;
|
|
21891
|
-
_super.createNew.call(this, insertAt);
|
|
21892
|
-
|
|
21893
|
-
|
|
21894
|
-
|
|
21895
|
-
|
|
21896
|
-
|
|
21897
|
-
|
|
21898
|
-
|
|
21899
|
-
|
|
21900
|
-
catch (err) {
|
|
21901
|
-
console.error(err && err.message || err, err);
|
|
21902
|
-
}
|
|
21895
|
+
const done = yield _super.createNew.call(this, insertAt);
|
|
21896
|
+
if (done && this.config.onRowCreated) {
|
|
21897
|
+
const row = this.getRow(-1);
|
|
21898
|
+
try {
|
|
21899
|
+
yield this.config.onRowCreated(row);
|
|
21900
|
+
}
|
|
21901
|
+
catch (err) {
|
|
21902
|
+
console.error(err && err.message || err, err);
|
|
21903
|
+
// Continue
|
|
21903
21904
|
}
|
|
21904
21905
|
}
|
|
21905
|
-
|
|
21906
|
+
if (done)
|
|
21907
|
+
this._editingRowCount++;
|
|
21906
21908
|
this._creating = false;
|
|
21909
|
+
return done;
|
|
21910
|
+
});
|
|
21911
|
+
}
|
|
21912
|
+
createRowValidator() {
|
|
21913
|
+
const _super = Object.create(null, {
|
|
21914
|
+
createRowValidator: { get: () => super.createRowValidator }
|
|
21915
|
+
});
|
|
21916
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21917
|
+
const validator = yield _super.createRowValidator.call(this);
|
|
21918
|
+
if (validator && this.config.onRowValidator) {
|
|
21919
|
+
try {
|
|
21920
|
+
yield this.config.onRowValidator(validator);
|
|
21921
|
+
}
|
|
21922
|
+
catch (err) {
|
|
21923
|
+
console.error(err && err.message || err, err);
|
|
21924
|
+
// Continue
|
|
21925
|
+
}
|
|
21926
|
+
}
|
|
21927
|
+
return validator;
|
|
21907
21928
|
});
|
|
21908
21929
|
}
|
|
21909
21930
|
getData() {
|
|
@@ -22471,13 +22492,15 @@ class AppTable {
|
|
|
22471
22492
|
return true;
|
|
22472
22493
|
}
|
|
22473
22494
|
confirmAndForward(event, row) {
|
|
22474
|
-
|
|
22475
|
-
|
|
22476
|
-
|
|
22477
|
-
|
|
22478
|
-
|
|
22479
|
-
|
|
22480
|
-
|
|
22495
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22496
|
+
row = row || this.editedRow;
|
|
22497
|
+
const done = yield this.confirmEditCreate(event, row);
|
|
22498
|
+
if (done) {
|
|
22499
|
+
// Edit next row
|
|
22500
|
+
this.editRowById(event, row.id + 1, { focusColumn: this.firstUserColumn });
|
|
22501
|
+
}
|
|
22502
|
+
return done;
|
|
22503
|
+
});
|
|
22481
22504
|
}
|
|
22482
22505
|
editRowById(event, id, opts) {
|
|
22483
22506
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -22501,48 +22524,44 @@ class AppTable {
|
|
|
22501
22524
|
*/
|
|
22502
22525
|
confirmEditCreate(event, row) {
|
|
22503
22526
|
var _a;
|
|
22504
|
-
|
|
22505
|
-
|
|
22506
|
-
|
|
22507
|
-
|
|
22508
|
-
|
|
22509
|
-
|
|
22510
|
-
|
|
22511
|
-
|
|
22512
|
-
|
|
22513
|
-
|
|
22514
|
-
this.editedRow
|
|
22515
|
-
|
|
22516
|
-
|
|
22517
|
-
|
|
22518
|
-
|
|
22519
|
-
|
|
22520
|
-
|
|
22521
|
-
|
|
22522
|
-
|
|
22523
|
-
|
|
22524
|
-
|
|
22525
|
-
|
|
22526
|
-
|
|
22527
|
-
|
|
22528
|
-
|
|
22529
|
-
|
|
22530
|
-
|
|
22531
|
-
|
|
22532
|
-
|
|
22533
|
-
|
|
22534
|
-
|
|
22535
|
-
|
|
22536
|
-
|
|
22537
|
-
|
|
22538
|
-
|
|
22539
|
-
// Compute row error, and propagate to table's error
|
|
22540
|
-
if (this.propagateRowError) {
|
|
22541
|
-
const error = this.getRowError(row);
|
|
22542
|
-
this.setError(error);
|
|
22527
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22528
|
+
row = row || this.editedRow;
|
|
22529
|
+
if (!row || !row.editing)
|
|
22530
|
+
return true; // no row to confirm
|
|
22531
|
+
// Stop event
|
|
22532
|
+
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
|
22533
|
+
// Confirmation edition or creation
|
|
22534
|
+
const done = yield row.confirmEditCreate();
|
|
22535
|
+
if (done) {
|
|
22536
|
+
// If edit finished, forget edited row
|
|
22537
|
+
if (row === this.editedRow) {
|
|
22538
|
+
this.editedRow = undefined;
|
|
22539
|
+
}
|
|
22540
|
+
// Mark table as dirty (if row is dirty)
|
|
22541
|
+
if ((_a = row.validator) === null || _a === void 0 ? void 0 : _a.dirty) {
|
|
22542
|
+
this.markAsDirty({ emitEvent: false /* because of resetError() */ });
|
|
22543
|
+
}
|
|
22544
|
+
// Clear error
|
|
22545
|
+
this.resetError();
|
|
22546
|
+
// Emit the confirm event
|
|
22547
|
+
this.onConfirmEditCreateRow.next(row);
|
|
22548
|
+
}
|
|
22549
|
+
else if (row.validator) {
|
|
22550
|
+
// NOT confirmed = row has error
|
|
22551
|
+
if (this.debug) {
|
|
22552
|
+
console.warn('[table] Cannot confirm row, because invalid');
|
|
22553
|
+
AppFormUtils.logFormErrors(row.validator, '[table] ');
|
|
22554
|
+
}
|
|
22555
|
+
// fix: mark all controls as touched to show errors
|
|
22556
|
+
row.validator.markAllAsTouched();
|
|
22557
|
+
// Compute row error, and propagate to table's error
|
|
22558
|
+
if (this.propagateRowError) {
|
|
22559
|
+
const error = this.getRowError(row);
|
|
22560
|
+
this.setError(error);
|
|
22561
|
+
}
|
|
22543
22562
|
}
|
|
22544
|
-
|
|
22545
|
-
|
|
22563
|
+
return done;
|
|
22564
|
+
});
|
|
22546
22565
|
}
|
|
22547
22566
|
cancelOrDelete(event, row, opts) {
|
|
22548
22567
|
// Delete new row
|
|
@@ -23242,7 +23261,9 @@ class AppTable {
|
|
|
23242
23261
|
addRowToTable(insertAt) {
|
|
23243
23262
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23244
23263
|
this.focusFirstColumn = true;
|
|
23245
|
-
yield this._dataSource.
|
|
23264
|
+
const done = yield this._dataSource.createNew(insertAt);
|
|
23265
|
+
if (!done)
|
|
23266
|
+
return undefined;
|
|
23246
23267
|
this.editedRow = this._dataSource.getRow(-1);
|
|
23247
23268
|
// Emit start editing event
|
|
23248
23269
|
this.onStartEditingRow.emit(this.editedRow);
|
|
@@ -23373,53 +23394,58 @@ class AppTable {
|
|
|
23373
23394
|
}
|
|
23374
23395
|
}
|
|
23375
23396
|
deleteNewRow(event, row) {
|
|
23376
|
-
|
|
23377
|
-
|
|
23378
|
-
|
|
23379
|
-
|
|
23380
|
-
|
|
23381
|
-
|
|
23382
|
-
|
|
23383
|
-
|
|
23384
|
-
|
|
23385
|
-
|
|
23397
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23398
|
+
if (row.id !== -1)
|
|
23399
|
+
throw new Error('Row must have id = -1');
|
|
23400
|
+
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
|
23401
|
+
this.selection.clear();
|
|
23402
|
+
this.editedRow = undefined; // unselect row
|
|
23403
|
+
const done = yield this._dataSource.cancelOrDelete(row);
|
|
23404
|
+
if (done) {
|
|
23405
|
+
this.onCancelOrDeleteRow.next(row);
|
|
23406
|
+
this.resetError();
|
|
23407
|
+
this.totalRowCount--;
|
|
23408
|
+
this.visibleRowCount--;
|
|
23409
|
+
}
|
|
23410
|
+
return done;
|
|
23411
|
+
});
|
|
23386
23412
|
}
|
|
23387
23413
|
deleteExistingRow(event, row, opts) {
|
|
23388
23414
|
// Make sure row will be cancelled, and NOT deleted
|
|
23389
23415
|
if (row.id === -1)
|
|
23390
23416
|
throw new Error('Row must have an id');
|
|
23391
23417
|
if (event === null || event === void 0 ? void 0 : event.defaultPrevented)
|
|
23392
|
-
return
|
|
23418
|
+
return Promise.resolve(false); // SKip
|
|
23393
23419
|
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
23394
|
-
this.deleteRow(null, row, opts);
|
|
23420
|
+
return this.deleteRow(null, row, opts);
|
|
23395
23421
|
}
|
|
23396
23422
|
cancelExistingRow(event, row, opts) {
|
|
23397
23423
|
var _a;
|
|
23398
|
-
|
|
23399
|
-
|
|
23400
|
-
|
|
23401
|
-
|
|
23402
|
-
|
|
23403
|
-
|
|
23404
|
-
|
|
23405
|
-
|
|
23406
|
-
.
|
|
23407
|
-
// If confirmed
|
|
23408
|
-
if (confirm)
|
|
23409
|
-
|
|
23410
|
-
}
|
|
23411
|
-
|
|
23412
|
-
|
|
23413
|
-
|
|
23414
|
-
|
|
23415
|
-
|
|
23416
|
-
|
|
23417
|
-
|
|
23418
|
-
|
|
23419
|
-
|
|
23420
|
-
|
|
23421
|
-
|
|
23422
|
-
}
|
|
23424
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23425
|
+
// Make sure row will be cancelled, and NOT deleted
|
|
23426
|
+
if (row.id === -1 || !row.editing)
|
|
23427
|
+
throw new Error('Row cannot be canceling, but only deleting');
|
|
23428
|
+
const confirmed = (!opts || opts.interactive !== false);
|
|
23429
|
+
// Ask user confirmation, if cancel
|
|
23430
|
+
if (!confirmed && ((_a = row.validator) === null || _a === void 0 ? void 0 : _a.dirty) && (this.confirmBeforeCancel || this.onBeforeCancelRows.observers.length > 0)) {
|
|
23431
|
+
event.stopPropagation();
|
|
23432
|
+
const confirm = yield this.canCancelRows([row], opts);
|
|
23433
|
+
// If not confirmed: stop
|
|
23434
|
+
if (!confirm)
|
|
23435
|
+
return false;
|
|
23436
|
+
}
|
|
23437
|
+
const keepEditing = row.editing && (!opts || opts.keepEditing !== false);
|
|
23438
|
+
this.editedRow = undefined; // unselect row
|
|
23439
|
+
this._dataSource.cancelOrDelete(row);
|
|
23440
|
+
this.onCancelOrDeleteRow.next(row);
|
|
23441
|
+
// Mark row as pristine
|
|
23442
|
+
this.checkIfRowPristine(row);
|
|
23443
|
+
// Restore editing state
|
|
23444
|
+
if (keepEditing) {
|
|
23445
|
+
this.editRow(undefined, row);
|
|
23446
|
+
}
|
|
23447
|
+
return true;
|
|
23448
|
+
});
|
|
23423
23449
|
}
|
|
23424
23450
|
checkIfRowPristine(row, opts) {
|
|
23425
23451
|
var _a, _b;
|