@sumaris-net/ngx-components 1.7.4 → 1.8.2-rc2
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 +124 -112
- 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/doc/changelog.md +6 -1
- package/esm2015/src/app/core/form/entity-editor.class.js +5 -1
- package/esm2015/src/app/core/services/base-entity-service.class.js +4 -1
- package/esm2015/src/app/core/services/config.service.js +11 -4
- package/esm2015/src/app/core/table/table.class.js +4 -4
- package/esm2015/src/app/shared/services/entity-service.class.js +1 -1
- package/fesm2015/sumaris-net.ngx-components.js +17 -5
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/core/form/entity-editor.class.d.ts +1 -1
- package/src/app/core/services/base-entity-service.class.d.ts +1 -0
- package/src/app/core/services/config.service.d.ts +4 -1
- package/src/app/shared/services/entity-service.class.d.ts +1 -0
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -16867,7 +16867,7 @@
|
|
|
16867
16867
|
var APP_CONFIG_OPTIONS = new i0.InjectionToken('defaultOptions');
|
|
16868
16868
|
var ConfigService = /** @class */ (function (_super) {
|
|
16869
16869
|
__extends(ConfigService, _super);
|
|
16870
|
-
function ConfigService(platform, graphql, storage, network, file, toastController, translate, environment, defaultOptionsMap) {
|
|
16870
|
+
function ConfigService(platform, graphql, storage, network, file, toastController, translate, accountService, environment, defaultOptionsMap) {
|
|
16871
16871
|
var _this = _super.call(this, graphql, environment) || this;
|
|
16872
16872
|
_this.platform = platform;
|
|
16873
16873
|
_this.graphql = graphql;
|
|
@@ -16876,6 +16876,7 @@
|
|
|
16876
16876
|
_this.file = file;
|
|
16877
16877
|
_this.toastController = toastController;
|
|
16878
16878
|
_this.translate = translate;
|
|
16879
|
+
_this.accountService = accountService;
|
|
16879
16880
|
_this.environment = environment;
|
|
16880
16881
|
_this.$data = new rxjs.BehaviorSubject(null);
|
|
16881
16882
|
_this._debug = !environment.production;
|
|
@@ -16946,6 +16947,9 @@
|
|
|
16946
16947
|
});
|
|
16947
16948
|
});
|
|
16948
16949
|
};
|
|
16950
|
+
ConfigService.prototype.canUserWrite = function (data, opts) {
|
|
16951
|
+
return this.accountService.isAdmin();
|
|
16952
|
+
};
|
|
16949
16953
|
/**
|
|
16950
16954
|
* Save a configuration
|
|
16951
16955
|
*
|
|
@@ -17224,7 +17228,7 @@
|
|
|
17224
17228
|
};
|
|
17225
17229
|
return ConfigService;
|
|
17226
17230
|
}(BaseGraphqlService));
|
|
17227
|
-
ConfigService.ɵprov = i0.ɵɵdefineInjectable({ factory: function ConfigService_Factory() { return new ConfigService(i0.ɵɵinject(i1$5.Platform), i0.ɵɵinject(GraphqlService), i0.ɵɵinject(i3$2.Storage), i0.ɵɵinject(NetworkService), i0.ɵɵinject(FileService), i0.ɵɵinject(i1$5.ToastController), i0.ɵɵinject(i1$2.TranslateService), i0.ɵɵinject(ENVIRONMENT), i0.ɵɵinject(APP_CONFIG_OPTIONS, 8)); }, token: ConfigService, providedIn: "root" });
|
|
17231
|
+
ConfigService.ɵprov = i0.ɵɵdefineInjectable({ factory: function ConfigService_Factory() { return new ConfigService(i0.ɵɵinject(i1$5.Platform), i0.ɵɵinject(GraphqlService), i0.ɵɵinject(i3$2.Storage), i0.ɵɵinject(NetworkService), i0.ɵɵinject(FileService), i0.ɵɵinject(i1$5.ToastController), i0.ɵɵinject(i1$2.TranslateService), i0.ɵɵinject(AccountService), i0.ɵɵinject(ENVIRONMENT), i0.ɵɵinject(APP_CONFIG_OPTIONS, 8)); }, token: ConfigService, providedIn: "root" });
|
|
17228
17232
|
ConfigService.decorators = [
|
|
17229
17233
|
{ type: i0.Injectable, args: [{
|
|
17230
17234
|
providedIn: 'root',
|
|
@@ -17239,6 +17243,7 @@
|
|
|
17239
17243
|
{ type: FileService },
|
|
17240
17244
|
{ type: i1$5.ToastController },
|
|
17241
17245
|
{ type: i1$2.TranslateService },
|
|
17246
|
+
{ type: AccountService },
|
|
17242
17247
|
{ type: undefined, decorators: [{ type: i0.Inject, args: [ENVIRONMENT,] }] },
|
|
17243
17248
|
{ type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [APP_CONFIG_OPTIONS,] }] }
|
|
17244
17249
|
]; };
|
|
@@ -23796,6 +23801,9 @@
|
|
|
23796
23801
|
});
|
|
23797
23802
|
});
|
|
23798
23803
|
};
|
|
23804
|
+
BaseEntityService.prototype.canUserWrite = function (data, opts) {
|
|
23805
|
+
return !!data;
|
|
23806
|
+
};
|
|
23799
23807
|
BaseEntityService.prototype.saveAll = function (entities, opts) {
|
|
23800
23808
|
return __awaiter(this, void 0, void 0, function () {
|
|
23801
23809
|
var hasNewEntities, json, now;
|
|
@@ -25009,7 +25017,7 @@
|
|
|
25009
25017
|
rxjs.merge(
|
|
25010
25018
|
// Listen sort events
|
|
25011
25019
|
this.sort && this.sort.sortChange
|
|
25012
|
-
.pipe(operators.filter(function () { return !_this.sort.disabled; }), operators.mergeMap(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (
|
|
25020
|
+
.pipe(operators.filter(function () { return !_this.sort.disabled; }), operators.mergeMap(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_e) {
|
|
25013
25021
|
return [2 /*return*/, this.saveBeforeAction('sort')];
|
|
25014
25022
|
}); }); }), operators.filter(function (res) { return res === true; }),
|
|
25015
25023
|
// Save sort in settings
|
|
@@ -25020,7 +25028,7 @@
|
|
|
25020
25028
|
|| rxjs.EMPTY,
|
|
25021
25029
|
// Listen paginator events
|
|
25022
25030
|
this.paginator && this.paginator.page
|
|
25023
|
-
.pipe(operators.mergeMap(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (
|
|
25031
|
+
.pipe(operators.mergeMap(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_e) {
|
|
25024
25032
|
return [2 /*return*/, this.saveBeforeAction('sort')];
|
|
25025
25033
|
}); }); }), operators.filter(function (res) { return res === true; }),
|
|
25026
25034
|
// Save page size
|
|
@@ -25065,7 +25073,7 @@
|
|
|
25065
25073
|
};
|
|
25066
25074
|
AppTable.prototype.updateView = function (res, opts) {
|
|
25067
25075
|
return __awaiter(this, void 0, void 0, function () {
|
|
25068
|
-
return __generator(this, function (
|
|
25076
|
+
return __generator(this, function (_e) {
|
|
25069
25077
|
if (!res)
|
|
25070
25078
|
return [2 /*return*/]; // Skip (e.g error)
|
|
25071
25079
|
if (res && res.data) {
|
|
@@ -25174,8 +25182,8 @@
|
|
|
25174
25182
|
AppTable.prototype.editRowById = function (event, id, opts) {
|
|
25175
25183
|
return __awaiter(this, void 0, void 0, function () {
|
|
25176
25184
|
var row;
|
|
25177
|
-
return __generator(this, function (
|
|
25178
|
-
switch (
|
|
25185
|
+
return __generator(this, function (_e) {
|
|
25186
|
+
switch (_e.label) {
|
|
25179
25187
|
case 0:
|
|
25180
25188
|
if (id < 0)
|
|
25181
25189
|
return [2 /*return*/];
|
|
@@ -25185,9 +25193,9 @@
|
|
|
25185
25193
|
return [3 /*break*/, 3];
|
|
25186
25194
|
case 1: return [4 /*yield*/, this.dataSource.getRow(id)];
|
|
25187
25195
|
case 2:
|
|
25188
|
-
row =
|
|
25196
|
+
row = _e.sent();
|
|
25189
25197
|
this.editRow(event, row, opts);
|
|
25190
|
-
|
|
25198
|
+
_e.label = 3;
|
|
25191
25199
|
case 3: return [2 /*return*/];
|
|
25192
25200
|
}
|
|
25193
25201
|
});
|
|
@@ -25272,11 +25280,11 @@
|
|
|
25272
25280
|
return true;
|
|
25273
25281
|
};
|
|
25274
25282
|
AppTable.prototype.save = function (opts) {
|
|
25275
|
-
var _a, _b;
|
|
25283
|
+
var _a, _b, _c, _d;
|
|
25276
25284
|
return __awaiter(this, void 0, void 0, function () {
|
|
25277
25285
|
var previouslyEditedData, isOK, err_1;
|
|
25278
|
-
return __generator(this, function (
|
|
25279
|
-
switch (
|
|
25286
|
+
return __generator(this, function (_e) {
|
|
25287
|
+
switch (_e.label) {
|
|
25280
25288
|
case 0:
|
|
25281
25289
|
opts = Object.assign({ keepEditing: this.keepEditedRowOnSave }, opts);
|
|
25282
25290
|
if (this.readOnly) {
|
|
@@ -25284,27 +25292,27 @@
|
|
|
25284
25292
|
}
|
|
25285
25293
|
this.resetError();
|
|
25286
25294
|
// Keep edited row id (should be done BEFORE confirmEditCreate() )
|
|
25287
|
-
this.previouslyEditedRowId = opts.keepEditing && ((_a = this.editedRow) === null || _a === void 0 ? void 0 : _a.editing) ? this.editedRow.id : undefined;
|
|
25288
|
-
previouslyEditedData = isNotNil(this.previouslyEditedRowId) && this.editedRow.currentData || ((
|
|
25295
|
+
this.previouslyEditedRowId = opts.keepEditing && ((((_a = this.editedRow) === null || _a === void 0 ? void 0 : _a.editing) ? this.editedRow.id : undefined) || ((_b = this.singleSelectedRow) === null || _b === void 0 ? void 0 : _b.id));
|
|
25296
|
+
previouslyEditedData = isNotNil(this.previouslyEditedRowId) && ((_c = this.editedRow) === null || _c === void 0 ? void 0 : _c.currentData) || ((_d = this.singleSelectedRow) === null || _d === void 0 ? void 0 : _d.currentData);
|
|
25289
25297
|
if (!this.confirmEditCreate()) {
|
|
25290
25298
|
throw { code: ErrorCodes.TABLE_INVALID_ROW_ERROR, message: 'ERROR.TABLE_INVALID_ROW_ERROR' };
|
|
25291
25299
|
}
|
|
25292
25300
|
// Mark as saving
|
|
25293
25301
|
this.markAsSaving();
|
|
25294
|
-
|
|
25302
|
+
_e.label = 1;
|
|
25295
25303
|
case 1:
|
|
25296
|
-
|
|
25304
|
+
_e.trys.push([1, 3, 4, 7]);
|
|
25297
25305
|
// Calling service save()
|
|
25298
25306
|
if (this.debug)
|
|
25299
25307
|
console.debug('[table] Calling dataSource.save()...');
|
|
25300
25308
|
return [4 /*yield*/, this._dataSource.save()];
|
|
25301
25309
|
case 2:
|
|
25302
|
-
isOK =
|
|
25310
|
+
isOK = _e.sent();
|
|
25303
25311
|
if (isOK)
|
|
25304
25312
|
this.markAsPristine();
|
|
25305
25313
|
return [2 /*return*/, isOK];
|
|
25306
25314
|
case 3:
|
|
25307
|
-
err_1 =
|
|
25315
|
+
err_1 = _e.sent();
|
|
25308
25316
|
this.setError(err_1 && err_1.message || err_1);
|
|
25309
25317
|
throw err_1;
|
|
25310
25318
|
case 4:
|
|
@@ -25312,8 +25320,8 @@
|
|
|
25312
25320
|
if (!isNotNil(this.previouslyEditedRowId)) return [3 /*break*/, 6];
|
|
25313
25321
|
return [4 /*yield*/, this.selectRowByIdOrData(this.previouslyEditedRowId, previouslyEditedData)];
|
|
25314
25322
|
case 5:
|
|
25315
|
-
|
|
25316
|
-
|
|
25323
|
+
_e.sent();
|
|
25324
|
+
_e.label = 6;
|
|
25317
25325
|
case 6: return [7 /*endfinally*/];
|
|
25318
25326
|
case 7: return [2 /*return*/];
|
|
25319
25327
|
}
|
|
@@ -25338,8 +25346,8 @@
|
|
|
25338
25346
|
var _a;
|
|
25339
25347
|
return __awaiter(this, void 0, void 0, function () {
|
|
25340
25348
|
var newRow, json, newData_1;
|
|
25341
|
-
return __generator(this, function (
|
|
25342
|
-
switch (
|
|
25349
|
+
return __generator(this, function (_e) {
|
|
25350
|
+
switch (_e.label) {
|
|
25343
25351
|
case 0:
|
|
25344
25352
|
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
|
25345
25353
|
row = row || this.singleSelectedRow;
|
|
@@ -25348,7 +25356,7 @@
|
|
|
25348
25356
|
}
|
|
25349
25357
|
return [4 /*yield*/, this.addRowToTable(row.id + 1)];
|
|
25350
25358
|
case 1:
|
|
25351
|
-
newRow =
|
|
25359
|
+
newRow = _e.sent();
|
|
25352
25360
|
json = Object.assign(Object.assign({}, row.currentData), { id: null });
|
|
25353
25361
|
// Reset some properties (e.g. rankOrder, etc)
|
|
25354
25362
|
if (opts && opts.skipProperties) {
|
|
@@ -25387,8 +25395,8 @@
|
|
|
25387
25395
|
return __awaiter(this, void 0, void 0, function () {
|
|
25388
25396
|
var rows;
|
|
25389
25397
|
var _this = this;
|
|
25390
|
-
return __generator(this, function (
|
|
25391
|
-
switch (
|
|
25398
|
+
return __generator(this, function (_e) {
|
|
25399
|
+
switch (_e.label) {
|
|
25392
25400
|
case 0:
|
|
25393
25401
|
if (this.loading)
|
|
25394
25402
|
return [2 /*return*/];
|
|
@@ -25397,9 +25405,9 @@
|
|
|
25397
25405
|
return [3 /*break*/, 3];
|
|
25398
25406
|
case 1: return [4 /*yield*/, this._dataSource.getRows()];
|
|
25399
25407
|
case 2:
|
|
25400
|
-
rows =
|
|
25408
|
+
rows = _e.sent();
|
|
25401
25409
|
rows.forEach(function (row) { return _this.selection.select(row); });
|
|
25402
|
-
|
|
25410
|
+
_e.label = 3;
|
|
25403
25411
|
case 3: return [2 /*return*/];
|
|
25404
25412
|
}
|
|
25405
25413
|
});
|
|
@@ -25417,11 +25425,11 @@
|
|
|
25417
25425
|
AppTable.prototype.deleteRow = function (event, row, opts) {
|
|
25418
25426
|
return __awaiter(this, void 0, void 0, function () {
|
|
25419
25427
|
var deleteCount;
|
|
25420
|
-
return __generator(this, function (
|
|
25421
|
-
switch (
|
|
25428
|
+
return __generator(this, function (_e) {
|
|
25429
|
+
switch (_e.label) {
|
|
25422
25430
|
case 0: return [4 /*yield*/, this.deleteRows(event, [row], opts)];
|
|
25423
25431
|
case 1:
|
|
25424
|
-
deleteCount =
|
|
25432
|
+
deleteCount = _e.sent();
|
|
25425
25433
|
return [2 /*return*/, deleteCount === 1];
|
|
25426
25434
|
}
|
|
25427
25435
|
});
|
|
@@ -25438,8 +25446,8 @@
|
|
|
25438
25446
|
return __awaiter(this, void 0, void 0, function () {
|
|
25439
25447
|
var confirmed, canDelete, saved, rowsToDelete, deleteCount, err_2;
|
|
25440
25448
|
var _this = this;
|
|
25441
|
-
return __generator(this, function (
|
|
25442
|
-
switch (
|
|
25449
|
+
return __generator(this, function (_e) {
|
|
25450
|
+
switch (_e.label) {
|
|
25443
25451
|
case 0:
|
|
25444
25452
|
if (this.readOnly) {
|
|
25445
25453
|
throw { code: ErrorCodes.TABLE_READ_ONLY, message: 'ERROR.TABLE_READ_ONLY' };
|
|
@@ -25459,7 +25467,7 @@
|
|
|
25459
25467
|
}
|
|
25460
25468
|
return [4 /*yield*/, this.canDeleteRows(rows, opts)];
|
|
25461
25469
|
case 1:
|
|
25462
|
-
canDelete =
|
|
25470
|
+
canDelete = _e.sent();
|
|
25463
25471
|
if (!canDelete)
|
|
25464
25472
|
return [2 /*return*/, 0]; // Cannot delete
|
|
25465
25473
|
if (!this.saveBeforeDelete) return [3 /*break*/, 3];
|
|
@@ -25481,12 +25489,12 @@
|
|
|
25481
25489
|
return [2 /*return*/, 0];
|
|
25482
25490
|
return [4 /*yield*/, this.saveBeforeAction('delete')];
|
|
25483
25491
|
case 2:
|
|
25484
|
-
saved =
|
|
25492
|
+
saved = _e.sent();
|
|
25485
25493
|
if (!saved) {
|
|
25486
25494
|
// Stop if save cancelled or save failed
|
|
25487
25495
|
return [2 /*return*/];
|
|
25488
25496
|
}
|
|
25489
|
-
|
|
25497
|
+
_e.label = 3;
|
|
25490
25498
|
case 3:
|
|
25491
25499
|
if (this.debug)
|
|
25492
25500
|
console.debug('[table] Delete selection...');
|
|
@@ -25495,13 +25503,13 @@
|
|
|
25495
25503
|
// This is a workaround, need because row.delete() has async execution
|
|
25496
25504
|
// and index cache is updated with a delay)
|
|
25497
25505
|
.sort(function (a, b) { return a.id > b.id ? -1 : 1; });
|
|
25498
|
-
|
|
25506
|
+
_e.label = 4;
|
|
25499
25507
|
case 4:
|
|
25500
|
-
|
|
25508
|
+
_e.trys.push([4, 6, , 7]);
|
|
25501
25509
|
deleteCount = rowsToDelete.length;
|
|
25502
25510
|
return [4 /*yield*/, this._dataSource.deleteAll(rowsToDelete)];
|
|
25503
25511
|
case 5:
|
|
25504
|
-
|
|
25512
|
+
_e.sent();
|
|
25505
25513
|
// DO not update manually, because watchALl().subscribe() will update this count
|
|
25506
25514
|
//this.totalRowCount -= deleteCount;
|
|
25507
25515
|
//this.visibleRowCount -= deleteCount;
|
|
@@ -25512,7 +25520,7 @@
|
|
|
25512
25520
|
this.onAfterDeletedRows.next(rowsToDelete);
|
|
25513
25521
|
return [2 /*return*/, deleteCount];
|
|
25514
25522
|
case 6:
|
|
25515
|
-
err_2 =
|
|
25523
|
+
err_2 = _e.sent();
|
|
25516
25524
|
this.setError(err_2 && err_2.message || err_2);
|
|
25517
25525
|
throw err_2;
|
|
25518
25526
|
case 7: return [2 /*return*/];
|
|
@@ -25523,14 +25531,14 @@
|
|
|
25523
25531
|
AppTable.prototype.selectRowById = function (id) {
|
|
25524
25532
|
return __awaiter(this, void 0, void 0, function () {
|
|
25525
25533
|
var row;
|
|
25526
|
-
return __generator(this, function (
|
|
25527
|
-
switch (
|
|
25534
|
+
return __generator(this, function (_e) {
|
|
25535
|
+
switch (_e.label) {
|
|
25528
25536
|
case 0:
|
|
25529
25537
|
if (id === undefined)
|
|
25530
25538
|
return [2 /*return*/, false];
|
|
25531
25539
|
return [4 /*yield*/, this.waitIdle()];
|
|
25532
25540
|
case 1:
|
|
25533
|
-
|
|
25541
|
+
_e.sent();
|
|
25534
25542
|
row = this.dataSource.getRow(id);
|
|
25535
25543
|
return [2 /*return*/, this.clickRow(null, row)];
|
|
25536
25544
|
}
|
|
@@ -25545,17 +25553,17 @@
|
|
|
25545
25553
|
return __awaiter(this, void 0, void 0, function () {
|
|
25546
25554
|
var row;
|
|
25547
25555
|
var _this = this;
|
|
25548
|
-
return __generator(this, function (
|
|
25549
|
-
switch (
|
|
25556
|
+
return __generator(this, function (_e) {
|
|
25557
|
+
switch (_e.label) {
|
|
25550
25558
|
case 0:
|
|
25551
25559
|
if (data === undefined)
|
|
25552
25560
|
return [2 /*return*/, Promise.resolve(false)];
|
|
25553
25561
|
return [4 /*yield*/, this.waitIdle()];
|
|
25554
25562
|
case 1:
|
|
25555
|
-
|
|
25563
|
+
_e.sent();
|
|
25556
25564
|
return [4 /*yield*/, this.dataSource.getRows()];
|
|
25557
25565
|
case 2:
|
|
25558
|
-
row = ((
|
|
25566
|
+
row = ((_e.sent()) || [])
|
|
25559
25567
|
.find(function (row) { return _this.equals(row.currentData, data); });
|
|
25560
25568
|
return [2 /*return*/, row && this.clickRow(null, row)];
|
|
25561
25569
|
}
|
|
@@ -25597,11 +25605,11 @@
|
|
|
25597
25605
|
};
|
|
25598
25606
|
AppTable.prototype.ready = function () {
|
|
25599
25607
|
return __awaiter(this, void 0, void 0, function () {
|
|
25600
|
-
return __generator(this, function (
|
|
25601
|
-
switch (
|
|
25608
|
+
return __generator(this, function (_e) {
|
|
25609
|
+
switch (_e.label) {
|
|
25602
25610
|
case 0: return [4 /*yield*/, firstTruePromise(this.readySubject)];
|
|
25603
25611
|
case 1:
|
|
25604
|
-
|
|
25612
|
+
_e.sent();
|
|
25605
25613
|
return [2 /*return*/];
|
|
25606
25614
|
}
|
|
25607
25615
|
});
|
|
@@ -25609,11 +25617,11 @@
|
|
|
25609
25617
|
};
|
|
25610
25618
|
AppTable.prototype.waitIdle = function (opts) {
|
|
25611
25619
|
return __awaiter(this, void 0, void 0, function () {
|
|
25612
|
-
return __generator(this, function (
|
|
25613
|
-
switch (
|
|
25620
|
+
return __generator(this, function (_e) {
|
|
25621
|
+
switch (_e.label) {
|
|
25614
25622
|
case 0: return [4 /*yield*/, firstFalsePromise(this.loadingSubject)];
|
|
25615
25623
|
case 1:
|
|
25616
|
-
|
|
25624
|
+
_e.sent();
|
|
25617
25625
|
return [2 /*return*/];
|
|
25618
25626
|
}
|
|
25619
25627
|
});
|
|
@@ -25622,28 +25630,28 @@
|
|
|
25622
25630
|
AppTable.prototype.openSelectColumnsModal = function (event) {
|
|
25623
25631
|
return __awaiter(this, void 0, void 0, function () {
|
|
25624
25632
|
var columns, hasTopModal, modal, data, userColumns;
|
|
25625
|
-
return __generator(this, function (
|
|
25626
|
-
switch (
|
|
25633
|
+
return __generator(this, function (_e) {
|
|
25634
|
+
switch (_e.label) {
|
|
25627
25635
|
case 0:
|
|
25628
25636
|
columns = this.getCurrentColumns();
|
|
25629
25637
|
return [4 /*yield*/, this.modalCtrl.getTop()];
|
|
25630
25638
|
case 1:
|
|
25631
|
-
hasTopModal = !!(
|
|
25639
|
+
hasTopModal = !!(_e.sent());
|
|
25632
25640
|
return [4 /*yield*/, this.modalCtrl.create({
|
|
25633
25641
|
component: TableSelectColumnsComponent,
|
|
25634
25642
|
componentProps: { columns: columns },
|
|
25635
25643
|
cssClass: hasTopModal && 'stack-modal'
|
|
25636
25644
|
})];
|
|
25637
25645
|
case 2:
|
|
25638
|
-
modal =
|
|
25646
|
+
modal = _e.sent();
|
|
25639
25647
|
// Open the modal
|
|
25640
25648
|
return [4 /*yield*/, modal.present()];
|
|
25641
25649
|
case 3:
|
|
25642
25650
|
// Open the modal
|
|
25643
|
-
|
|
25651
|
+
_e.sent();
|
|
25644
25652
|
return [4 /*yield*/, modal.onDidDismiss()];
|
|
25645
25653
|
case 4:
|
|
25646
|
-
data = (
|
|
25654
|
+
data = (_e.sent()).data;
|
|
25647
25655
|
if (!data)
|
|
25648
25656
|
return [2 /*return*/]; // CANCELLED
|
|
25649
25657
|
userColumns = (data || []).filter(function (c) { return c.canHide === false || c.visible; }).map(function (c) { return c.name; }) || [];
|
|
@@ -25653,7 +25661,7 @@
|
|
|
25653
25661
|
return [4 /*yield*/, this.settings.savePageSetting(this.settingsId, userColumns, SETTINGS_DISPLAY_COLUMNS)];
|
|
25654
25662
|
case 5:
|
|
25655
25663
|
// Update user settings
|
|
25656
|
-
|
|
25664
|
+
_e.sent();
|
|
25657
25665
|
return [2 /*return*/];
|
|
25658
25666
|
}
|
|
25659
25667
|
});
|
|
@@ -25668,11 +25676,11 @@
|
|
|
25668
25676
|
// When target wait for a complete (e.g. IonRefresher)
|
|
25669
25677
|
if ((event === null || event === void 0 ? void 0 : event.target) && event.target.complete) {
|
|
25670
25678
|
setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
25671
|
-
return __generator(this, function (
|
|
25672
|
-
switch (
|
|
25679
|
+
return __generator(this, function (_e) {
|
|
25680
|
+
switch (_e.label) {
|
|
25673
25681
|
case 0: return [4 /*yield*/, this.waitIdle()];
|
|
25674
25682
|
case 1:
|
|
25675
|
-
|
|
25683
|
+
_e.sent();
|
|
25676
25684
|
event.target.complete();
|
|
25677
25685
|
return [2 /*return*/];
|
|
25678
25686
|
}
|
|
@@ -25757,33 +25765,33 @@
|
|
|
25757
25765
|
AppTable.prototype.selectRowByIdOrData = function (id, data) {
|
|
25758
25766
|
return __awaiter(this, void 0, void 0, function () {
|
|
25759
25767
|
var done, err_3;
|
|
25760
|
-
return __generator(this, function (
|
|
25761
|
-
switch (
|
|
25768
|
+
return __generator(this, function (_e) {
|
|
25769
|
+
switch (_e.label) {
|
|
25762
25770
|
case 0:
|
|
25763
25771
|
done = false;
|
|
25764
|
-
|
|
25772
|
+
_e.label = 1;
|
|
25765
25773
|
case 1:
|
|
25766
|
-
|
|
25774
|
+
_e.trys.push([1, 6, , 7]);
|
|
25767
25775
|
if (!(isNotNil(id) || id !== -1)) return [3 /*break*/, 3];
|
|
25768
25776
|
return [4 /*yield*/, this.selectRowById(id)];
|
|
25769
25777
|
case 2:
|
|
25770
|
-
done =
|
|
25778
|
+
done = _e.sent();
|
|
25771
25779
|
if (done)
|
|
25772
25780
|
return [2 /*return*/, true];
|
|
25773
25781
|
console.warn('[app-table] Save: Cannot reselect row by row.id: ', id);
|
|
25774
|
-
|
|
25782
|
+
_e.label = 3;
|
|
25775
25783
|
case 3:
|
|
25776
25784
|
if (!data) return [3 /*break*/, 5];
|
|
25777
25785
|
return [4 /*yield*/, this.selectRowByData(data)];
|
|
25778
25786
|
case 4:
|
|
25779
|
-
done =
|
|
25787
|
+
done = _e.sent();
|
|
25780
25788
|
if (done)
|
|
25781
25789
|
return [2 /*return*/, true];
|
|
25782
25790
|
console.warn('[app-table] Save: Cannot reselect row by data: ', data);
|
|
25783
|
-
|
|
25791
|
+
_e.label = 5;
|
|
25784
25792
|
case 5: return [2 /*return*/, false];
|
|
25785
25793
|
case 6:
|
|
25786
|
-
err_3 =
|
|
25794
|
+
err_3 = _e.sent();
|
|
25787
25795
|
// Log, but continue
|
|
25788
25796
|
console.error(err_3 && err_3.message || err_3);
|
|
25789
25797
|
return [2 /*return*/, false];
|
|
@@ -25806,23 +25814,23 @@
|
|
|
25806
25814
|
AppTable.prototype.canDeleteRows = function (rows, opts) {
|
|
25807
25815
|
return __awaiter(this, void 0, void 0, function () {
|
|
25808
25816
|
var canDelete, err_4;
|
|
25809
|
-
return __generator(this, function (
|
|
25810
|
-
switch (
|
|
25817
|
+
return __generator(this, function (_e) {
|
|
25818
|
+
switch (_e.label) {
|
|
25811
25819
|
case 0:
|
|
25812
25820
|
if (!(this.onBeforeDeleteRows.observers.length > 0)) return [3 /*break*/, 4];
|
|
25813
|
-
|
|
25821
|
+
_e.label = 1;
|
|
25814
25822
|
case 1:
|
|
25815
|
-
|
|
25823
|
+
_e.trys.push([1, 3, , 4]);
|
|
25816
25824
|
return [4 /*yield*/, emitPromiseEvent(this.onBeforeDeleteRows, 'canDelete', {
|
|
25817
25825
|
detail: { rows: rows }
|
|
25818
25826
|
})];
|
|
25819
25827
|
case 2:
|
|
25820
|
-
canDelete =
|
|
25828
|
+
canDelete = _e.sent();
|
|
25821
25829
|
if (!canDelete)
|
|
25822
25830
|
return [2 /*return*/, false];
|
|
25823
25831
|
return [3 /*break*/, 4];
|
|
25824
25832
|
case 3:
|
|
25825
|
-
err_4 =
|
|
25833
|
+
err_4 = _e.sent();
|
|
25826
25834
|
if (err_4 === 'CANCELLED')
|
|
25827
25835
|
return [2 /*return*/, false]; // User cancel
|
|
25828
25836
|
console.error('Error while checking if can delete rows', err_4);
|
|
@@ -25839,35 +25847,35 @@
|
|
|
25839
25847
|
};
|
|
25840
25848
|
AppTable.prototype.canCancelRows = function (rows, opts) {
|
|
25841
25849
|
return __awaiter(this, void 0, void 0, function () {
|
|
25842
|
-
var
|
|
25843
|
-
return __generator(this, function (
|
|
25844
|
-
switch (
|
|
25850
|
+
var _e, isCancel, err_5;
|
|
25851
|
+
return __generator(this, function (_f) {
|
|
25852
|
+
switch (_f.label) {
|
|
25845
25853
|
case 0:
|
|
25846
|
-
|
|
25847
|
-
if (
|
|
25854
|
+
_e = rows;
|
|
25855
|
+
if (_e) return [3 /*break*/, 2];
|
|
25848
25856
|
return [4 /*yield*/, this.dataSource.getRows()];
|
|
25849
25857
|
case 1:
|
|
25850
|
-
|
|
25851
|
-
|
|
25858
|
+
_e = (_f.sent()).filter(function (row) { var _a; return (_a = row.validator) === null || _a === void 0 ? void 0 : _a.dirty; });
|
|
25859
|
+
_f.label = 2;
|
|
25852
25860
|
case 2:
|
|
25853
25861
|
// Get dirty rows
|
|
25854
|
-
rows =
|
|
25862
|
+
rows = _e;
|
|
25855
25863
|
if (isEmptyArray(rows))
|
|
25856
25864
|
return [2 /*return*/, true]; // No dirty: OK
|
|
25857
25865
|
if (!(this.onBeforeCancelRows.observers.length > 0)) return [3 /*break*/, 6];
|
|
25858
|
-
|
|
25866
|
+
_f.label = 3;
|
|
25859
25867
|
case 3:
|
|
25860
|
-
|
|
25868
|
+
_f.trys.push([3, 5, , 6]);
|
|
25861
25869
|
return [4 /*yield*/, emitPromiseEvent(this.onBeforeCancelRows, 'canCancel', {
|
|
25862
25870
|
detail: { rows: rows }
|
|
25863
25871
|
})];
|
|
25864
25872
|
case 4:
|
|
25865
|
-
isCancel =
|
|
25873
|
+
isCancel = _f.sent();
|
|
25866
25874
|
if (!isCancel)
|
|
25867
25875
|
return [2 /*return*/, false];
|
|
25868
25876
|
return [3 /*break*/, 6];
|
|
25869
25877
|
case 5:
|
|
25870
|
-
err_5 =
|
|
25878
|
+
err_5 = _f.sent();
|
|
25871
25879
|
if (err_5 === 'CANCELLED')
|
|
25872
25880
|
return [2 /*return*/, false]; // User cancel
|
|
25873
25881
|
console.error('Error while checking if can cancel rows', err_5);
|
|
@@ -25885,8 +25893,8 @@
|
|
|
25885
25893
|
AppTable.prototype.saveBeforeAction = function (saveAction) {
|
|
25886
25894
|
return __awaiter(this, void 0, void 0, function () {
|
|
25887
25895
|
var save, confirmed, res, err_6, saved;
|
|
25888
|
-
return __generator(this, function (
|
|
25889
|
-
switch (
|
|
25896
|
+
return __generator(this, function (_e) {
|
|
25897
|
+
switch (_e.label) {
|
|
25890
25898
|
case 0:
|
|
25891
25899
|
if (!this.dirty) {
|
|
25892
25900
|
// Continue without save
|
|
@@ -25908,19 +25916,19 @@
|
|
|
25908
25916
|
confirmed = true;
|
|
25909
25917
|
if (!save) return [3 /*break*/, 4];
|
|
25910
25918
|
if (!(this.onBeforeSave.observers.length > 0)) return [3 /*break*/, 4];
|
|
25911
|
-
|
|
25919
|
+
_e.label = 1;
|
|
25912
25920
|
case 1:
|
|
25913
|
-
|
|
25921
|
+
_e.trys.push([1, 3, , 4]);
|
|
25914
25922
|
return [4 /*yield*/, emitPromiseEvent(this.onBeforeSave, 'beforeSave', {
|
|
25915
25923
|
detail: { action: saveAction, valid: this.valid }
|
|
25916
25924
|
})];
|
|
25917
25925
|
case 2:
|
|
25918
|
-
res =
|
|
25926
|
+
res = _e.sent();
|
|
25919
25927
|
confirmed = res.confirmed;
|
|
25920
25928
|
save = res.save;
|
|
25921
25929
|
return [3 /*break*/, 4];
|
|
25922
25930
|
case 3:
|
|
25923
|
-
err_6 =
|
|
25931
|
+
err_6 = _e.sent();
|
|
25924
25932
|
if (err_6 === 'CANCELLED')
|
|
25925
25933
|
return [2 /*return*/, false]; // User cancel
|
|
25926
25934
|
console.error('Error while checking if can delete rows', err_6);
|
|
@@ -25930,7 +25938,7 @@
|
|
|
25930
25938
|
if (!save) return [3 /*break*/, 6];
|
|
25931
25939
|
return [4 /*yield*/, this.save()];
|
|
25932
25940
|
case 5:
|
|
25933
|
-
saved =
|
|
25941
|
+
saved = _e.sent();
|
|
25934
25942
|
this.markAsDirty(); // Restore dirty flag
|
|
25935
25943
|
return [2 /*return*/, saved];
|
|
25936
25944
|
case 6: return [2 /*return*/, true]; // No save but continue action
|
|
@@ -25948,8 +25956,8 @@
|
|
|
25948
25956
|
*/
|
|
25949
25957
|
AppTable.prototype.openRow = function (id, row) {
|
|
25950
25958
|
return __awaiter(this, void 0, void 0, function () {
|
|
25951
|
-
return __generator(this, function (
|
|
25952
|
-
switch (
|
|
25959
|
+
return __generator(this, function (_e) {
|
|
25960
|
+
switch (_e.label) {
|
|
25953
25961
|
case 0:
|
|
25954
25962
|
if (!this.allowRowDetail) return [3 /*break*/, 2];
|
|
25955
25963
|
if (this.debug && this.dirty) {
|
|
@@ -25968,7 +25976,7 @@
|
|
|
25968
25976
|
relativeTo: this.route,
|
|
25969
25977
|
queryParams: {}
|
|
25970
25978
|
})];
|
|
25971
|
-
case 1: return [2 /*return*/,
|
|
25979
|
+
case 1: return [2 /*return*/, _e.sent()];
|
|
25972
25980
|
case 2: return [2 /*return*/, false];
|
|
25973
25981
|
}
|
|
25974
25982
|
});
|
|
@@ -25976,8 +25984,8 @@
|
|
|
25976
25984
|
};
|
|
25977
25985
|
AppTable.prototype.openNewRowDetail = function (event) {
|
|
25978
25986
|
return __awaiter(this, void 0, void 0, function () {
|
|
25979
|
-
return __generator(this, function (
|
|
25980
|
-
switch (
|
|
25987
|
+
return __generator(this, function (_e) {
|
|
25988
|
+
switch (_e.label) {
|
|
25981
25989
|
case 0:
|
|
25982
25990
|
if (!this.allowRowDetail)
|
|
25983
25991
|
return [2 /*return*/, false];
|
|
@@ -25988,7 +25996,7 @@
|
|
|
25988
25996
|
return [4 /*yield*/, this.router.navigate(['new'], {
|
|
25989
25997
|
relativeTo: this.route
|
|
25990
25998
|
})];
|
|
25991
|
-
case 1: return [2 /*return*/,
|
|
25999
|
+
case 1: return [2 /*return*/, _e.sent()];
|
|
25992
26000
|
}
|
|
25993
26001
|
});
|
|
25994
26002
|
});
|
|
@@ -26066,13 +26074,13 @@
|
|
|
26066
26074
|
};
|
|
26067
26075
|
AppTable.prototype.addRowToTable = function (insertAt) {
|
|
26068
26076
|
return __awaiter(this, void 0, void 0, function () {
|
|
26069
|
-
return __generator(this, function (
|
|
26070
|
-
switch (
|
|
26077
|
+
return __generator(this, function (_e) {
|
|
26078
|
+
switch (_e.label) {
|
|
26071
26079
|
case 0:
|
|
26072
26080
|
this.focusFirstColumn = true;
|
|
26073
26081
|
return [4 /*yield*/, this._dataSource.asyncCreateNew(insertAt)];
|
|
26074
26082
|
case 1:
|
|
26075
|
-
|
|
26083
|
+
_e.sent();
|
|
26076
26084
|
this.editedRow = this._dataSource.getRow(-1);
|
|
26077
26085
|
// Emit start editing event
|
|
26078
26086
|
this.onStartEditingRow.emit(this.editedRow);
|
|
@@ -26136,7 +26144,7 @@
|
|
|
26136
26144
|
};
|
|
26137
26145
|
AppTable.prototype.askDeleteConfirmation = function (event, rows) {
|
|
26138
26146
|
return __awaiter(this, void 0, void 0, function () {
|
|
26139
|
-
return __generator(this, function (
|
|
26147
|
+
return __generator(this, function (_e) {
|
|
26140
26148
|
if (this.undoableDeletion) {
|
|
26141
26149
|
// Special message, for undoable deletion
|
|
26142
26150
|
return [2 /*return*/, Alerts.askConfirmation((rows === null || rows === void 0 ? void 0 : rows.length) === 1 ? 'CONFIRM.DELETE_ROW' : 'CONFIRM.DELETE_ROWS', this.alertCtrl, this.translate, event)];
|
|
@@ -26148,21 +26156,21 @@
|
|
|
26148
26156
|
};
|
|
26149
26157
|
AppTable.prototype.askCancelConfirmation = function (event, rows) {
|
|
26150
26158
|
return __awaiter(this, void 0, void 0, function () {
|
|
26151
|
-
return __generator(this, function (
|
|
26159
|
+
return __generator(this, function (_e) {
|
|
26152
26160
|
return [2 /*return*/, Alerts.askConfirmation((rows === null || rows === void 0 ? void 0 : rows.length) === 1 ? 'CONFIRM.CANCEL_ROW' : 'CONFIRM.CANCEL_ROWS', this.alertCtrl, this.translate, event)];
|
|
26153
26161
|
});
|
|
26154
26162
|
});
|
|
26155
26163
|
};
|
|
26156
26164
|
AppTable.prototype.askRestoreConfirmation = function (event) {
|
|
26157
26165
|
return __awaiter(this, void 0, void 0, function () {
|
|
26158
|
-
return __generator(this, function (
|
|
26166
|
+
return __generator(this, function (_e) {
|
|
26159
26167
|
return [2 /*return*/, Alerts.askActionConfirmation(this.alertCtrl, this.translate, false, event)];
|
|
26160
26168
|
});
|
|
26161
26169
|
});
|
|
26162
26170
|
};
|
|
26163
26171
|
AppTable.prototype.showToast = function (opts) {
|
|
26164
26172
|
return __awaiter(this, void 0, void 0, function () {
|
|
26165
|
-
return __generator(this, function (
|
|
26173
|
+
return __generator(this, function (_e) {
|
|
26166
26174
|
if (!this.toastController)
|
|
26167
26175
|
throw new Error('Missing toastController in component\'s constructor');
|
|
26168
26176
|
return [2 /*return*/, Toasts.show(this.toastController, this.translate, opts)];
|
|
@@ -26257,14 +26265,14 @@
|
|
|
26257
26265
|
AppTable.prototype.checkIfPristine = function (opts) {
|
|
26258
26266
|
return __awaiter(this, void 0, void 0, function () {
|
|
26259
26267
|
var rows, pristine;
|
|
26260
|
-
return __generator(this, function (
|
|
26261
|
-
switch (
|
|
26268
|
+
return __generator(this, function (_e) {
|
|
26269
|
+
switch (_e.label) {
|
|
26262
26270
|
case 0:
|
|
26263
26271
|
if (!this.dirty)
|
|
26264
26272
|
return [2 /*return*/]; // Already pristine
|
|
26265
26273
|
return [4 /*yield*/, this._dataSource.getRows()];
|
|
26266
26274
|
case 1:
|
|
26267
|
-
rows =
|
|
26275
|
+
rows = _e.sent();
|
|
26268
26276
|
pristine = (rows || []).findIndex(function (row) { var _a; return (_a = row.validator) === null || _a === void 0 ? void 0 : _a.dirty; }) === -1;
|
|
26269
26277
|
if (pristine)
|
|
26270
26278
|
this.markAsPristine(opts);
|
|
@@ -27710,6 +27718,10 @@
|
|
|
27710
27718
|
if (!opts || opts.emitEvent !== false)
|
|
27711
27719
|
this.markForCheck();
|
|
27712
27720
|
};
|
|
27721
|
+
/* -- public abstract methods (to override) -- */
|
|
27722
|
+
AppEntityEditor.prototype.canUserWrite = function (data, opts) {
|
|
27723
|
+
return this.dataService.canUserWrite(data, opts);
|
|
27724
|
+
};
|
|
27713
27725
|
/* -- protected methods -- */
|
|
27714
27726
|
/**
|
|
27715
27727
|
* Return undefined to keep same tab
|