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