@sumaris-net/ngx-components 0.18.11 → 0.18.16
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/ngx-sumaris-components.umd.js +171 -102
- package/bundles/ngx-sumaris-components.umd.js.map +1 -1
- package/bundles/ngx-sumaris-components.umd.min.js +1 -1
- package/bundles/ngx-sumaris-components.umd.min.js.map +1 -1
- package/esm2015/src/app/core/services/model/entity.model.js +2 -1
- package/esm2015/src/app/core/table/memory-table.class.js +4 -1
- package/esm2015/src/app/core/table/table.class.js +77 -46
- package/esm2015/src/app/shared/services/memory-entity-service.class.js +88 -67
- package/fesm2015/ngx-sumaris-components.js +166 -111
- package/fesm2015/ngx-sumaris-components.js.map +1 -1
- package/ngx-sumaris-components.metadata.json +1 -1
- package/package.json +1 -1
- package/src/app/core/table/memory-table.class.d.ts +1 -0
- package/src/app/core/table/table.class.d.ts +21 -10
- package/src/app/shared/services/memory-entity-service.class.d.ts +4 -1
|
@@ -8689,6 +8689,7 @@
|
|
|
8689
8689
|
return !obj || obj[checkedAttribute] === null || obj[checkedAttribute] === undefined;
|
|
8690
8690
|
};
|
|
8691
8691
|
EntityUtils.equals = function (o1, o2, checkAttribute) {
|
|
8692
|
+
checkAttribute = checkAttribute || 'id';
|
|
8692
8693
|
return (o1 === o2) || (isNil(o1) && isNil(o2)) || (o1 && o2 && o1[checkAttribute] === o2[checkAttribute]);
|
|
8693
8694
|
};
|
|
8694
8695
|
EntityUtils.getPropertyByPath = function (obj, path) {
|
|
@@ -16279,6 +16280,7 @@
|
|
|
16279
16280
|
_this.filterType = filterType;
|
|
16280
16281
|
_this.debug = false;
|
|
16281
16282
|
_this.dirty = false;
|
|
16283
|
+
_this._saving = false;
|
|
16282
16284
|
_this._onChange = new rxjs.BehaviorSubject(true);
|
|
16283
16285
|
options = Object.assign({ onSort: _this.sort, equals: _this.equals }, options);
|
|
16284
16286
|
_this._sortFn = options.onSort;
|
|
@@ -16302,7 +16304,6 @@
|
|
|
16302
16304
|
get: function () {
|
|
16303
16305
|
return this.data;
|
|
16304
16306
|
},
|
|
16305
|
-
// TODO add test see sub-batches.modal.ts onLoadData & _hiddenData
|
|
16306
16307
|
set: function (data) {
|
|
16307
16308
|
this.setValue(data);
|
|
16308
16309
|
},
|
|
@@ -16334,53 +16335,54 @@
|
|
|
16334
16335
|
console.warn('[memory-data-service] Waiting value to be set...');
|
|
16335
16336
|
}
|
|
16336
16337
|
return this._onChange
|
|
16337
|
-
.pipe(operators.filter(isNotNil), operators.mergeMap(function (_) { return __awaiter(_this, void 0, void 0, function () {
|
|
16338
|
-
var data, promiseOrData, _a, total
|
|
16339
|
-
|
|
16340
|
-
|
|
16341
|
-
switch (_f.label) {
|
|
16338
|
+
.pipe(operators.filter(isNotNil), operators.mergeMap(function (_) { return waitFor(function () { return !_this._saving; }); }), operators.mergeMap(function (_) { return __awaiter(_this, void 0, void 0, function () {
|
|
16339
|
+
var excludedDataByFilter, excludedDataByPagination, data, promiseOrData, _a, total;
|
|
16340
|
+
return __generator(this, function (_b) {
|
|
16341
|
+
switch (_b.label) {
|
|
16342
16342
|
case 0:
|
|
16343
|
-
|
|
16343
|
+
excludedDataByFilter = [];
|
|
16344
|
+
_b.label = 1;
|
|
16345
|
+
case 1:
|
|
16346
|
+
_b.trys.push([1, , 6, 7]);
|
|
16344
16347
|
if (isEmptyArray(this.data)) {
|
|
16345
16348
|
return [2 /*return*/, { data: [], total: 0 }];
|
|
16346
16349
|
}
|
|
16347
16350
|
data = this._sortFn(this.data || [], sortBy, sortDirection);
|
|
16348
|
-
if (!this._onLoad) return [3 /*break*/,
|
|
16351
|
+
if (!this._onLoad) return [3 /*break*/, 5];
|
|
16349
16352
|
promiseOrData = this._onLoad(data);
|
|
16350
|
-
if (!((promiseOrData instanceof Promise))) return [3 /*break*/,
|
|
16353
|
+
if (!((promiseOrData instanceof Promise))) return [3 /*break*/, 3];
|
|
16351
16354
|
return [4 /*yield*/, promiseOrData];
|
|
16352
|
-
case 1:
|
|
16353
|
-
_a = _f.sent();
|
|
16354
|
-
return [3 /*break*/, 3];
|
|
16355
16355
|
case 2:
|
|
16356
|
-
_a =
|
|
16357
|
-
|
|
16356
|
+
_a = _b.sent();
|
|
16357
|
+
return [3 /*break*/, 4];
|
|
16358
16358
|
case 3:
|
|
16359
|
-
|
|
16360
|
-
|
|
16359
|
+
_a = promiseOrData;
|
|
16360
|
+
_b.label = 4;
|
|
16361
16361
|
case 4:
|
|
16362
|
+
data = _a;
|
|
16363
|
+
_b.label = 5;
|
|
16364
|
+
case 5:
|
|
16362
16365
|
// Apply filter (will update hiddenData)
|
|
16363
|
-
data = this.filter(data, filterData,
|
|
16366
|
+
data = this.filter(data, filterData, excludedDataByFilter);
|
|
16364
16367
|
total = data.length;
|
|
16365
16368
|
// If page size=0 (e.g. only need total)
|
|
16366
16369
|
if (size === 0) {
|
|
16367
|
-
|
|
16370
|
+
excludedDataByPagination = data;
|
|
16368
16371
|
return [2 /*return*/, { data: [], total: total }];
|
|
16369
16372
|
}
|
|
16370
16373
|
// Slice in a page (using offset and size)
|
|
16371
16374
|
if (offset > 0) {
|
|
16372
16375
|
// Offset after the end: no result
|
|
16373
16376
|
if (offset >= data.length) {
|
|
16374
|
-
|
|
16377
|
+
excludedDataByPagination = data;
|
|
16375
16378
|
data = [];
|
|
16376
16379
|
}
|
|
16377
16380
|
else {
|
|
16378
|
-
|
|
16381
|
+
excludedDataByPagination = (size > 0 && ((offset + size) < data.length)) ?
|
|
16379
16382
|
// Slice using limit to size
|
|
16380
16383
|
data.slice(0, offset - 1).concat(data.slice(offset + size)) :
|
|
16381
16384
|
// Slice without limit
|
|
16382
16385
|
data.slice(0, offset - 1);
|
|
16383
|
-
(_d = this._hiddenData).push.apply(_d, __spread(hiddenData));
|
|
16384
16386
|
data = (size > 0 && ((offset + size) < data.length)) ?
|
|
16385
16387
|
// Slice using limit to size
|
|
16386
16388
|
data.slice(offset, offset + size) :
|
|
@@ -16390,7 +16392,7 @@
|
|
|
16390
16392
|
}
|
|
16391
16393
|
// Apply a limit
|
|
16392
16394
|
else if (size > 0) {
|
|
16393
|
-
|
|
16395
|
+
excludedDataByPagination = data.slice(size);
|
|
16394
16396
|
data = data.slice(0, size);
|
|
16395
16397
|
}
|
|
16396
16398
|
// No limit:
|
|
@@ -16400,9 +16402,14 @@
|
|
|
16400
16402
|
// /!\ If already observed, then always create a copy of the original array
|
|
16401
16403
|
// Because datasource will only update if the array changed
|
|
16402
16404
|
if (data === this.data) {
|
|
16403
|
-
data = data.slice(
|
|
16405
|
+
data = data.slice();
|
|
16404
16406
|
}
|
|
16405
16407
|
return [2 /*return*/, { data: data, total: total }];
|
|
16408
|
+
case 6:
|
|
16409
|
+
// Remember hidden data
|
|
16410
|
+
this._hiddenData = !excludedDataByPagination ? excludedDataByFilter : excludedDataByFilter.concat.apply(excludedDataByFilter, __spread(excludedDataByPagination));
|
|
16411
|
+
return [7 /*endfinally*/];
|
|
16412
|
+
case 7: return [2 /*return*/];
|
|
16406
16413
|
}
|
|
16407
16414
|
});
|
|
16408
16415
|
}); }));
|
|
@@ -16415,26 +16422,34 @@
|
|
|
16415
16422
|
case 0:
|
|
16416
16423
|
if (!this.data)
|
|
16417
16424
|
throw new Error('[memory-service] Could not save, because value not set');
|
|
16425
|
+
this.markAsSaving();
|
|
16426
|
+
_b.label = 1;
|
|
16427
|
+
case 1:
|
|
16428
|
+
_b.trys.push([1, , 6, 7]);
|
|
16418
16429
|
// Restore hidden data
|
|
16419
16430
|
if (isNotEmptyArray(this._hiddenData))
|
|
16420
|
-
data = data.concat(this._hiddenData);
|
|
16421
|
-
if (!this._onSaveFn) return [3 /*break*/,
|
|
16431
|
+
data = data.concat.apply(data, __spread(this._hiddenData));
|
|
16432
|
+
if (!this._onSaveFn) return [3 /*break*/, 5];
|
|
16422
16433
|
res = this._onSaveFn(data);
|
|
16423
|
-
if (!((res instanceof Promise))) return [3 /*break*/,
|
|
16434
|
+
if (!((res instanceof Promise))) return [3 /*break*/, 3];
|
|
16424
16435
|
return [4 /*yield*/, res];
|
|
16425
|
-
case 1:
|
|
16426
|
-
_a = _b.sent();
|
|
16427
|
-
return [3 /*break*/, 3];
|
|
16428
16436
|
case 2:
|
|
16429
|
-
_a =
|
|
16430
|
-
|
|
16437
|
+
_a = _b.sent();
|
|
16438
|
+
return [3 /*break*/, 4];
|
|
16431
16439
|
case 3:
|
|
16432
|
-
|
|
16440
|
+
_a = res;
|
|
16433
16441
|
_b.label = 4;
|
|
16434
16442
|
case 4:
|
|
16443
|
+
data = _a;
|
|
16444
|
+
_b.label = 5;
|
|
16445
|
+
case 5:
|
|
16435
16446
|
this.data = data;
|
|
16436
16447
|
this.dirty = true;
|
|
16437
16448
|
return [2 /*return*/, this.data];
|
|
16449
|
+
case 6:
|
|
16450
|
+
this.markAsSaved();
|
|
16451
|
+
return [7 /*endfinally*/];
|
|
16452
|
+
case 7: return [2 /*return*/];
|
|
16438
16453
|
}
|
|
16439
16454
|
});
|
|
16440
16455
|
});
|
|
@@ -16447,8 +16462,8 @@
|
|
|
16447
16462
|
if (!this.data)
|
|
16448
16463
|
throw new Error('[memory-service] Could not delete, because value not set');
|
|
16449
16464
|
updatedData = this.data.filter(function (entity) {
|
|
16450
|
-
var
|
|
16451
|
-
return !
|
|
16465
|
+
var removed = dataToRemove.findIndex(function (entityToRemove) { return _this.equals(entityToRemove, entity); }) !== -1;
|
|
16466
|
+
return !removed;
|
|
16452
16467
|
});
|
|
16453
16468
|
deleteCount = this.data.length - updatedData.length;
|
|
16454
16469
|
if (deleteCount > 0) {
|
|
@@ -16472,6 +16487,11 @@
|
|
|
16472
16487
|
InMemoryEntitiesService.prototype.addSortByReplacement = function (source, target) {
|
|
16473
16488
|
this._sortByReplacement[source] = target;
|
|
16474
16489
|
};
|
|
16490
|
+
InMemoryEntitiesService.prototype.equals = function (d1, d2) {
|
|
16491
|
+
if (this._equalsFn)
|
|
16492
|
+
return this._equalsFn(d1, d2);
|
|
16493
|
+
return d1 && d1.equals ? d1.equals(d2) : EntityUtils.equals(d1, d2, 'id');
|
|
16494
|
+
};
|
|
16475
16495
|
/* -- protected methods -- */
|
|
16476
16496
|
InMemoryEntitiesService.prototype.filter = function (data, _filter, hiddenData) {
|
|
16477
16497
|
// if filter is DataFilter instance, use its test function
|
|
@@ -16497,8 +16517,11 @@
|
|
|
16497
16517
|
return { data: data, total: total };
|
|
16498
16518
|
}));
|
|
16499
16519
|
};
|
|
16500
|
-
InMemoryEntitiesService.prototype.
|
|
16501
|
-
|
|
16520
|
+
InMemoryEntitiesService.prototype.markAsSaving = function () {
|
|
16521
|
+
this._saving = true;
|
|
16522
|
+
};
|
|
16523
|
+
InMemoryEntitiesService.prototype.markAsSaved = function () {
|
|
16524
|
+
this._saving = false;
|
|
16502
16525
|
};
|
|
16503
16526
|
return InMemoryEntitiesService;
|
|
16504
16527
|
}(EntitiesService));
|
|
@@ -23049,7 +23072,7 @@
|
|
|
23049
23072
|
}
|
|
23050
23073
|
};
|
|
23051
23074
|
AppTable.prototype.markAsUntouched = function (opts) {
|
|
23052
|
-
if (this.dirtySubject.value !== false || (this.editedRow && this.editedRow.id !== this.
|
|
23075
|
+
if (this.dirtySubject.value !== false || (this.editedRow && this.editedRow.id !== this.previouslyEditedRowId)) {
|
|
23053
23076
|
// Cancel the current editing row only if editing and if it was not previously saved
|
|
23054
23077
|
this.dirtySubject.next(false);
|
|
23055
23078
|
if (this.editedRow && this.editedRow.editing) {
|
|
@@ -23060,7 +23083,7 @@
|
|
|
23060
23083
|
this.markForCheck();
|
|
23061
23084
|
}
|
|
23062
23085
|
}
|
|
23063
|
-
this.
|
|
23086
|
+
this.previouslyEditedRowId = undefined;
|
|
23064
23087
|
};
|
|
23065
23088
|
/**
|
|
23066
23089
|
* @deprecated prefer to use markAllAsTouched()
|
|
@@ -23526,7 +23549,7 @@
|
|
|
23526
23549
|
AppTable.prototype.save = function (opts) {
|
|
23527
23550
|
var _a, _b;
|
|
23528
23551
|
return __awaiter(this, void 0, void 0, function () {
|
|
23529
|
-
var isOK, err_1;
|
|
23552
|
+
var previouslyEditedData, isOK, err_1;
|
|
23530
23553
|
return __generator(this, function (_d) {
|
|
23531
23554
|
switch (_d.label) {
|
|
23532
23555
|
case 0:
|
|
@@ -23536,7 +23559,8 @@
|
|
|
23536
23559
|
}
|
|
23537
23560
|
this.resetError();
|
|
23538
23561
|
// Keep edited row id (should be done BEFORE confirmEditCreate() )
|
|
23539
|
-
this.
|
|
23562
|
+
this.previouslyEditedRowId = opts.keepEditing && ((_a = this.editedRow) === null || _a === void 0 ? void 0 : _a.editing) ? this.editedRow.id : undefined;
|
|
23563
|
+
previouslyEditedData = isNotNil(this.previouslyEditedRowId) && this.editedRow.currentData || ((_b = this.singleSelectedRow) === null || _b === void 0 ? void 0 : _b.currentData);
|
|
23540
23564
|
if (!this.confirmEditCreate()) {
|
|
23541
23565
|
throw { code: ErrorCodes$2.TABLE_INVALID_ROW_ERROR, message: 'ERROR.TABLE_INVALID_ROW_ERROR' };
|
|
23542
23566
|
}
|
|
@@ -23544,7 +23568,7 @@
|
|
|
23544
23568
|
this.markAsSaving();
|
|
23545
23569
|
_d.label = 1;
|
|
23546
23570
|
case 1:
|
|
23547
|
-
_d.trys.push([1, 3, 4,
|
|
23571
|
+
_d.trys.push([1, 3, 4, 7]);
|
|
23548
23572
|
// Calling service save()
|
|
23549
23573
|
if (this.debug)
|
|
23550
23574
|
console.debug('[table] Calling dataSource.save()...');
|
|
@@ -23560,18 +23584,13 @@
|
|
|
23560
23584
|
throw err_1;
|
|
23561
23585
|
case 4:
|
|
23562
23586
|
this.markAsSaved();
|
|
23563
|
-
|
|
23564
|
-
|
|
23565
|
-
|
|
23566
|
-
|
|
23567
|
-
|
|
23568
|
-
|
|
23569
|
-
|
|
23570
|
-
this.selectRowByData((_b = this.singleSelectedRow) === null || _b === void 0 ? void 0 : _b.currentData);
|
|
23571
|
-
}
|
|
23572
|
-
}
|
|
23573
|
-
return [7 /*endfinally*/];
|
|
23574
|
-
case 5: return [2 /*return*/];
|
|
23587
|
+
if (!isNotNil(this.previouslyEditedRowId)) return [3 /*break*/, 6];
|
|
23588
|
+
return [4 /*yield*/, this.selectRowByIdOrData(this.previouslyEditedRowId, previouslyEditedData)];
|
|
23589
|
+
case 5:
|
|
23590
|
+
_d.sent();
|
|
23591
|
+
_d.label = 6;
|
|
23592
|
+
case 6: return [7 /*endfinally*/];
|
|
23593
|
+
case 7: return [2 /*return*/];
|
|
23575
23594
|
}
|
|
23576
23595
|
});
|
|
23577
23596
|
});
|
|
@@ -23755,39 +23774,26 @@
|
|
|
23755
23774
|
});
|
|
23756
23775
|
});
|
|
23757
23776
|
};
|
|
23758
|
-
AppTable.prototype.editRow = function (event, row, opts) {
|
|
23759
|
-
if (!this._enabled)
|
|
23760
|
-
return false;
|
|
23761
|
-
if (this.editedRow === row)
|
|
23762
|
-
return true; // Already the edited row
|
|
23763
|
-
if (event === null || event === void 0 ? void 0 : event.defaultPrevented)
|
|
23764
|
-
return false;
|
|
23765
|
-
if (!this.confirmEditCreate()) {
|
|
23766
|
-
return false;
|
|
23767
|
-
}
|
|
23768
|
-
if (!row.editing && !this.loading) {
|
|
23769
|
-
this._focusColumn = opts && opts.focusColumn || this._focusColumn;
|
|
23770
|
-
this._dataSource.startEdit(row);
|
|
23771
|
-
}
|
|
23772
|
-
this.editedRow = row;
|
|
23773
|
-
this.onStartEditingRow.emit(row);
|
|
23774
|
-
return true;
|
|
23775
|
-
};
|
|
23776
23777
|
AppTable.prototype.selectRowById = function (id) {
|
|
23777
23778
|
var _this = this;
|
|
23778
23779
|
if (id === undefined)
|
|
23779
|
-
return;
|
|
23780
|
-
this.dataSource.waitIdle()
|
|
23780
|
+
return Promise.resolve(false);
|
|
23781
|
+
return this.dataSource.waitIdle()
|
|
23781
23782
|
.then(function () { return _this.dataSource.getRow(id); })
|
|
23782
|
-
.then(function (row) { return _this.clickRow(null, row); });
|
|
23783
|
+
.then(function (row) { return row && _this.clickRow(null, row); });
|
|
23783
23784
|
};
|
|
23785
|
+
/**
|
|
23786
|
+
* Try to select row by data. Will use dataEquals() (that call EntityUtils.equals()) to find same row's data
|
|
23787
|
+
* @param data
|
|
23788
|
+
*/
|
|
23784
23789
|
AppTable.prototype.selectRowByData = function (data) {
|
|
23785
23790
|
var _this = this;
|
|
23786
23791
|
if (data === undefined)
|
|
23787
|
-
return;
|
|
23788
|
-
this.dataSource.waitIdle()
|
|
23792
|
+
return Promise.resolve(false);
|
|
23793
|
+
return this.dataSource.waitIdle()
|
|
23789
23794
|
.then(function () { return _this.dataSource.getRows(); })
|
|
23790
|
-
.then(function (rows) {
|
|
23795
|
+
.then(function (rows) { return rows.find(function (row) { return _this.equals(row.currentData, data); }); })
|
|
23796
|
+
.then(function (row) { return row && _this.clickRow(null, row); });
|
|
23791
23797
|
};
|
|
23792
23798
|
AppTable.prototype.clickRow = function (event, row) {
|
|
23793
23799
|
var _this = this;
|
|
@@ -23805,8 +23811,6 @@
|
|
|
23805
23811
|
return true; // Already in edition
|
|
23806
23812
|
if (event === null || event === void 0 ? void 0 : event.defaultPrevented)
|
|
23807
23813
|
return false; // Cancelled by event
|
|
23808
|
-
if (this.loading)
|
|
23809
|
-
return false; // Already busy
|
|
23810
23814
|
// Open the detail page (if not inline editing)
|
|
23811
23815
|
if (!this.inlineEdition) {
|
|
23812
23816
|
if (this.dirty && this.debug) {
|
|
@@ -23819,10 +23823,10 @@
|
|
|
23819
23823
|
// No ID defined: unable to open details
|
|
23820
23824
|
if (isNil(row.currentData.id)) {
|
|
23821
23825
|
console.warn('[table] Opening row details, but missing currentData.id!');
|
|
23822
|
-
|
|
23826
|
+
return false;
|
|
23823
23827
|
}
|
|
23824
23828
|
this.markAsLoading();
|
|
23825
|
-
this.
|
|
23829
|
+
this.openRowDetail(row.currentData.id, row)
|
|
23826
23830
|
.then(function () { return _this.markAsLoaded(); });
|
|
23827
23831
|
return true;
|
|
23828
23832
|
}
|
|
@@ -23933,8 +23937,70 @@
|
|
|
23933
23937
|
}
|
|
23934
23938
|
}
|
|
23935
23939
|
};
|
|
23940
|
+
/* -- protected method -- */
|
|
23941
|
+
AppTable.prototype.editRow = function (event, row, opts) {
|
|
23942
|
+
if (!this._enabled)
|
|
23943
|
+
return false;
|
|
23944
|
+
if (this.editedRow === row)
|
|
23945
|
+
return true; // Already the edited row
|
|
23946
|
+
if (event === null || event === void 0 ? void 0 : event.defaultPrevented)
|
|
23947
|
+
return false;
|
|
23948
|
+
if (!this.confirmEditCreate()) {
|
|
23949
|
+
return false;
|
|
23950
|
+
}
|
|
23951
|
+
if (!row.editing && !this.loading) {
|
|
23952
|
+
this._focusColumn = opts && opts.focusColumn || this._focusColumn;
|
|
23953
|
+
this._dataSource.startEdit(row);
|
|
23954
|
+
}
|
|
23955
|
+
this.editedRow = row;
|
|
23956
|
+
this.onStartEditingRow.emit(row);
|
|
23957
|
+
return true;
|
|
23958
|
+
};
|
|
23959
|
+
/**
|
|
23960
|
+
* Try to select row, by row.id, or by data. WIll use EntityUtils.equals()
|
|
23961
|
+
* @param id
|
|
23962
|
+
* @param data
|
|
23963
|
+
* @protected
|
|
23964
|
+
*/
|
|
23965
|
+
AppTable.prototype.selectRowByIdOrData = function (id, data) {
|
|
23966
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
23967
|
+
var done, err_3;
|
|
23968
|
+
return __generator(this, function (_d) {
|
|
23969
|
+
switch (_d.label) {
|
|
23970
|
+
case 0:
|
|
23971
|
+
done = false;
|
|
23972
|
+
_d.label = 1;
|
|
23973
|
+
case 1:
|
|
23974
|
+
_d.trys.push([1, 6, , 7]);
|
|
23975
|
+
if (!(isNotNil(id) || id !== -1)) return [3 /*break*/, 3];
|
|
23976
|
+
return [4 /*yield*/, this.selectRowById(id)];
|
|
23977
|
+
case 2:
|
|
23978
|
+
done = _d.sent();
|
|
23979
|
+
if (done)
|
|
23980
|
+
return [2 /*return*/, true];
|
|
23981
|
+
console.warn('[app-table] Save: Cannot reselect row by row.id: ', id);
|
|
23982
|
+
_d.label = 3;
|
|
23983
|
+
case 3:
|
|
23984
|
+
if (!data) return [3 /*break*/, 5];
|
|
23985
|
+
return [4 /*yield*/, this.selectRowByData(data)];
|
|
23986
|
+
case 4:
|
|
23987
|
+
done = _d.sent();
|
|
23988
|
+
if (done)
|
|
23989
|
+
return [2 /*return*/, true];
|
|
23990
|
+
console.warn('[app-table] Save: Cannot reselect row by data: ', data);
|
|
23991
|
+
_d.label = 5;
|
|
23992
|
+
case 5: return [2 /*return*/, false];
|
|
23993
|
+
case 6:
|
|
23994
|
+
err_3 = _d.sent();
|
|
23995
|
+
// Log, but continue
|
|
23996
|
+
console.error(err_3 && err_3.message || err_3);
|
|
23997
|
+
return [2 /*return*/, false];
|
|
23998
|
+
case 7: return [2 /*return*/];
|
|
23999
|
+
}
|
|
24000
|
+
});
|
|
24001
|
+
});
|
|
24002
|
+
};
|
|
23936
24003
|
Object.defineProperty(AppTable.prototype, "singleSelectedRow", {
|
|
23937
|
-
/* -- protected method -- */
|
|
23938
24004
|
/**
|
|
23939
24005
|
* return the selected row if unique in selection
|
|
23940
24006
|
*/
|
|
@@ -23947,7 +24013,7 @@
|
|
|
23947
24013
|
});
|
|
23948
24014
|
AppTable.prototype.canDeleteRows = function (rows, opts) {
|
|
23949
24015
|
return __awaiter(this, void 0, void 0, function () {
|
|
23950
|
-
var canDelete,
|
|
24016
|
+
var canDelete, err_4;
|
|
23951
24017
|
return __generator(this, function (_d) {
|
|
23952
24018
|
switch (_d.label) {
|
|
23953
24019
|
case 0:
|
|
@@ -23964,11 +24030,11 @@
|
|
|
23964
24030
|
return [2 /*return*/, false];
|
|
23965
24031
|
return [3 /*break*/, 4];
|
|
23966
24032
|
case 3:
|
|
23967
|
-
|
|
23968
|
-
if (
|
|
24033
|
+
err_4 = _d.sent();
|
|
24034
|
+
if (err_4 === 'CANCELLED')
|
|
23969
24035
|
return [2 /*return*/, false]; // User cancel
|
|
23970
|
-
console.error('Error while checking if can delete rows',
|
|
23971
|
-
throw
|
|
24036
|
+
console.error('Error while checking if can delete rows', err_4);
|
|
24037
|
+
throw err_4;
|
|
23972
24038
|
case 4:
|
|
23973
24039
|
// Ask user confirmation
|
|
23974
24040
|
if (this.confirmBeforeDelete && (!opts || opts.interactive !== false)) {
|
|
@@ -23981,7 +24047,7 @@
|
|
|
23981
24047
|
};
|
|
23982
24048
|
AppTable.prototype.canCancelRows = function (rows, opts) {
|
|
23983
24049
|
return __awaiter(this, void 0, void 0, function () {
|
|
23984
|
-
var _d, isCancel,
|
|
24050
|
+
var _d, isCancel, err_5;
|
|
23985
24051
|
return __generator(this, function (_e) {
|
|
23986
24052
|
switch (_e.label) {
|
|
23987
24053
|
case 0:
|
|
@@ -24009,11 +24075,11 @@
|
|
|
24009
24075
|
return [2 /*return*/, false];
|
|
24010
24076
|
return [3 /*break*/, 6];
|
|
24011
24077
|
case 5:
|
|
24012
|
-
|
|
24013
|
-
if (
|
|
24078
|
+
err_5 = _e.sent();
|
|
24079
|
+
if (err_5 === 'CANCELLED')
|
|
24014
24080
|
return [2 /*return*/, false]; // User cancel
|
|
24015
|
-
console.error('Error while checking if can cancel rows',
|
|
24016
|
-
throw
|
|
24081
|
+
console.error('Error while checking if can cancel rows', err_5);
|
|
24082
|
+
throw err_5;
|
|
24017
24083
|
case 6:
|
|
24018
24084
|
// Ask user confirmation
|
|
24019
24085
|
if (this.confirmBeforeCancel && (!opts || opts.interactive !== false)) {
|
|
@@ -24026,7 +24092,7 @@
|
|
|
24026
24092
|
};
|
|
24027
24093
|
AppTable.prototype.saveBeforeAction = function (saveAction) {
|
|
24028
24094
|
return __awaiter(this, void 0, void 0, function () {
|
|
24029
|
-
var save, confirmed, res,
|
|
24095
|
+
var save, confirmed, res, err_6, saved;
|
|
24030
24096
|
return __generator(this, function (_d) {
|
|
24031
24097
|
switch (_d.label) {
|
|
24032
24098
|
case 0:
|
|
@@ -24062,11 +24128,11 @@
|
|
|
24062
24128
|
save = res.save;
|
|
24063
24129
|
return [3 /*break*/, 4];
|
|
24064
24130
|
case 3:
|
|
24065
|
-
|
|
24066
|
-
if (
|
|
24131
|
+
err_6 = _d.sent();
|
|
24132
|
+
if (err_6 === 'CANCELLED')
|
|
24067
24133
|
return [2 /*return*/, false]; // User cancel
|
|
24068
|
-
console.error('Error while checking if can delete rows',
|
|
24069
|
-
throw
|
|
24134
|
+
console.error('Error while checking if can delete rows', err_6);
|
|
24135
|
+
throw err_6;
|
|
24070
24136
|
case 4:
|
|
24071
24137
|
if (!confirmed) return [3 /*break*/, 7];
|
|
24072
24138
|
if (!save) return [3 /*break*/, 6];
|
|
@@ -24081,7 +24147,7 @@
|
|
|
24081
24147
|
});
|
|
24082
24148
|
});
|
|
24083
24149
|
};
|
|
24084
|
-
AppTable.prototype.
|
|
24150
|
+
AppTable.prototype.openRowDetail = function (id, row) {
|
|
24085
24151
|
return __awaiter(this, void 0, void 0, function () {
|
|
24086
24152
|
return __generator(this, function (_d) {
|
|
24087
24153
|
switch (_d.label) {
|
|
@@ -24352,12 +24418,12 @@
|
|
|
24352
24418
|
* Compare data equality (default by id)
|
|
24353
24419
|
* Can be overridden to add additional properties to compare
|
|
24354
24420
|
*
|
|
24355
|
-
* @param
|
|
24356
|
-
* @param
|
|
24421
|
+
* @param d1
|
|
24422
|
+
* @param d2
|
|
24357
24423
|
* @protected
|
|
24358
24424
|
*/
|
|
24359
|
-
AppTable.prototype.
|
|
24360
|
-
return EntityUtils.equals(
|
|
24425
|
+
AppTable.prototype.equals = function (d1, d2) {
|
|
24426
|
+
return EntityUtils.equals(d1, d2, 'id');
|
|
24361
24427
|
};
|
|
24362
24428
|
/* -- private method -- */
|
|
24363
24429
|
AppTable.prototype.setLoading = function (value, opts) {
|
|
@@ -26046,6 +26112,9 @@
|
|
|
26046
26112
|
this.onRefresh.emit();
|
|
26047
26113
|
}
|
|
26048
26114
|
};
|
|
26115
|
+
AppInMemoryTable.prototype.equals = function (t1, t2) {
|
|
26116
|
+
return this.memoryDataService.equals(t1, t2);
|
|
26117
|
+
};
|
|
26049
26118
|
return AppInMemoryTable;
|
|
26050
26119
|
}(AppTable));
|
|
26051
26120
|
AppInMemoryTable.decorators = [
|