@sumaris-net/ngx-components 1.20.0-rc1 → 1.20.0-rc4
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 +218 -131
- 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 +3 -0
- package/esm2015/src/app/core/table/entities-table-datasource.class.js +67 -38
- package/esm2015/src/app/core/table/table.class.js +92 -87
- package/fesm2015/sumaris-net.ngx-components.js +157 -123
- 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
|
@@ -24961,6 +24961,10 @@
|
|
|
24961
24961
|
enumerable: false,
|
|
24962
24962
|
configurable: true
|
|
24963
24963
|
});
|
|
24964
|
+
EntitiesTableDataSource.prototype.connect = function (collectionViewer) {
|
|
24965
|
+
// DEBUG console.debug("[entities-datasource] connect");
|
|
24966
|
+
return _super_1.prototype.connect.call(this, collectionViewer);
|
|
24967
|
+
};
|
|
24964
24968
|
EntitiesTableDataSource.prototype.disconnect = function (collectionViewer) {
|
|
24965
24969
|
_super_1.prototype.disconnect.call(this, collectionViewer);
|
|
24966
24970
|
this._stopWatching$.next();
|
|
@@ -25270,68 +25274,116 @@
|
|
|
25270
25274
|
});
|
|
25271
25275
|
};
|
|
25272
25276
|
EntitiesTableDataSource.prototype.deleteAll = function (rows) {
|
|
25273
|
-
var
|
|
25274
|
-
|
|
25275
|
-
|
|
25276
|
-
|
|
25277
|
-
|
|
25278
|
-
|
|
25279
|
-
|
|
25280
|
-
|
|
25281
|
-
|
|
25282
|
-
|
|
25283
|
-
|
|
25284
|
-
|
|
25285
|
-
|
|
25286
|
-
|
|
25287
|
-
|
|
25288
|
-
|
|
25289
|
-
|
|
25290
|
-
|
|
25291
|
-
|
|
25292
|
-
|
|
25293
|
-
|
|
25294
|
-
|
|
25295
|
-
|
|
25296
|
-
|
|
25297
|
-
|
|
25277
|
+
var _super = Object.create(null, {
|
|
25278
|
+
delete: { get: function () { return _super_1.prototype.delete; } }
|
|
25279
|
+
});
|
|
25280
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
25281
|
+
var data, rowsById, self, rowNotDeleted, err_2;
|
|
25282
|
+
var _this = this;
|
|
25283
|
+
return __generator(this, function (_a) {
|
|
25284
|
+
switch (_a.label) {
|
|
25285
|
+
case 0:
|
|
25286
|
+
this.markAsLoading();
|
|
25287
|
+
data = this.getDataFromRows(rows);
|
|
25288
|
+
rowsById = rows.reduce(function (res, row) {
|
|
25289
|
+
res[row.id] = row;
|
|
25290
|
+
return res;
|
|
25291
|
+
}, {});
|
|
25292
|
+
self = this;
|
|
25293
|
+
_a.label = 1;
|
|
25294
|
+
case 1:
|
|
25295
|
+
_a.trys.push([1, 5, 6, 7]);
|
|
25296
|
+
return [4 /*yield*/, this.dataService.deleteAll(data, this.serviceOptions)];
|
|
25297
|
+
case 2:
|
|
25298
|
+
_a.sent();
|
|
25299
|
+
rowNotDeleted = Object.getOwnPropertyNames(rowsById).reduce(function (res, id) {
|
|
25300
|
+
var row = rowsById[id];
|
|
25301
|
+
var present = self.getRow(+id) === row;
|
|
25302
|
+
return present ? res.concat(row) : res;
|
|
25303
|
+
}, []).sort(function (a, b) { return a.id > b.id ? -1 : 1; });
|
|
25304
|
+
if (!isNotEmptyArray(rowNotDeleted)) return [3 /*break*/, 4];
|
|
25305
|
+
console.warn("[table-datasource] Force deletion of " + rowNotDeleted.length + " rows (Is service applying deletion to observable ?)");
|
|
25306
|
+
return [4 /*yield*/, Promise.all(rowNotDeleted.map(function (r) { return _super.delete.call(_this, r.id); }))];
|
|
25307
|
+
case 3:
|
|
25308
|
+
_a.sent();
|
|
25309
|
+
_a.label = 4;
|
|
25310
|
+
case 4: return [3 /*break*/, 7];
|
|
25311
|
+
case 5:
|
|
25312
|
+
err_2 = _a.sent();
|
|
25313
|
+
this.handleErrorPromise(err_2);
|
|
25314
|
+
return [3 /*break*/, 7];
|
|
25315
|
+
case 6:
|
|
25316
|
+
this.markAsLoaded();
|
|
25317
|
+
return [7 /*endfinally*/];
|
|
25318
|
+
case 7: return [2 /*return*/];
|
|
25319
|
+
}
|
|
25320
|
+
});
|
|
25298
25321
|
});
|
|
25299
25322
|
};
|
|
25300
25323
|
EntitiesTableDataSource.prototype.getRows = function () {
|
|
25301
25324
|
return this.rowsSubject.toPromise();
|
|
25302
25325
|
};
|
|
25303
|
-
EntitiesTableDataSource.prototype.
|
|
25326
|
+
EntitiesTableDataSource.prototype.createNew = function (insertAt) {
|
|
25304
25327
|
var _super = Object.create(null, {
|
|
25305
25328
|
createNew: { get: function () { return _super_1.prototype.createNew; } }
|
|
25306
25329
|
});
|
|
25307
25330
|
return __awaiter(this, void 0, void 0, function () {
|
|
25308
|
-
var
|
|
25331
|
+
var done, row, err_3;
|
|
25309
25332
|
return __generator(this, function (_a) {
|
|
25310
25333
|
switch (_a.label) {
|
|
25311
25334
|
case 0:
|
|
25312
25335
|
if (this._creating)
|
|
25313
25336
|
return [2 /*return*/]; // Avoid multiple call (should never occur)
|
|
25314
25337
|
this._creating = true;
|
|
25315
|
-
_super.createNew.call(this, insertAt);
|
|
25316
|
-
row = this.getRow(-1);
|
|
25317
|
-
if (!(row && this.config.onRowCreated)) return [3 /*break*/, 4];
|
|
25318
|
-
res = this.config.onRowCreated(row);
|
|
25319
|
-
if (!(res instanceof Promise)) return [3 /*break*/, 4];
|
|
25320
|
-
_a.label = 1;
|
|
25338
|
+
return [4 /*yield*/, _super.createNew.call(this, insertAt)];
|
|
25321
25339
|
case 1:
|
|
25322
|
-
_a.
|
|
25323
|
-
return [
|
|
25340
|
+
done = _a.sent();
|
|
25341
|
+
if (!(done && this.config.onRowCreated)) return [3 /*break*/, 5];
|
|
25342
|
+
row = this.getRow(-1);
|
|
25343
|
+
_a.label = 2;
|
|
25324
25344
|
case 2:
|
|
25325
|
-
_a.
|
|
25326
|
-
return [
|
|
25345
|
+
_a.trys.push([2, 4, , 5]);
|
|
25346
|
+
return [4 /*yield*/, this.config.onRowCreated(row)];
|
|
25327
25347
|
case 3:
|
|
25328
|
-
|
|
25329
|
-
|
|
25330
|
-
return [3 /*break*/, 4];
|
|
25348
|
+
_a.sent();
|
|
25349
|
+
return [3 /*break*/, 5];
|
|
25331
25350
|
case 4:
|
|
25332
|
-
|
|
25351
|
+
err_3 = _a.sent();
|
|
25352
|
+
console.error(err_3 && err_3.message || err_3, err_3);
|
|
25353
|
+
return [3 /*break*/, 5];
|
|
25354
|
+
case 5:
|
|
25355
|
+
if (done)
|
|
25356
|
+
this._editingRowCount++;
|
|
25333
25357
|
this._creating = false;
|
|
25334
|
-
return [2 /*return
|
|
25358
|
+
return [2 /*return*/, done];
|
|
25359
|
+
}
|
|
25360
|
+
});
|
|
25361
|
+
});
|
|
25362
|
+
};
|
|
25363
|
+
EntitiesTableDataSource.prototype.createRowValidator = function () {
|
|
25364
|
+
var _super = Object.create(null, {
|
|
25365
|
+
createRowValidator: { get: function () { return _super_1.prototype.createRowValidator; } }
|
|
25366
|
+
});
|
|
25367
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
25368
|
+
var validator, err_4;
|
|
25369
|
+
return __generator(this, function (_a) {
|
|
25370
|
+
switch (_a.label) {
|
|
25371
|
+
case 0: return [4 /*yield*/, _super.createRowValidator.call(this)];
|
|
25372
|
+
case 1:
|
|
25373
|
+
validator = _a.sent();
|
|
25374
|
+
if (!(validator && this.config.onRowValidator)) return [3 /*break*/, 5];
|
|
25375
|
+
_a.label = 2;
|
|
25376
|
+
case 2:
|
|
25377
|
+
_a.trys.push([2, 4, , 5]);
|
|
25378
|
+
return [4 /*yield*/, this.config.onRowValidator(validator)];
|
|
25379
|
+
case 3:
|
|
25380
|
+
_a.sent();
|
|
25381
|
+
return [3 /*break*/, 5];
|
|
25382
|
+
case 4:
|
|
25383
|
+
err_4 = _a.sent();
|
|
25384
|
+
console.error(err_4 && err_4.message || err_4, err_4);
|
|
25385
|
+
return [3 /*break*/, 5];
|
|
25386
|
+
case 5: return [2 /*return*/, validator];
|
|
25335
25387
|
}
|
|
25336
25388
|
});
|
|
25337
25389
|
});
|
|
@@ -26021,13 +26073,23 @@
|
|
|
26021
26073
|
return true;
|
|
26022
26074
|
};
|
|
26023
26075
|
AppTable.prototype.confirmAndForward = function (event, row) {
|
|
26024
|
-
|
|
26025
|
-
|
|
26026
|
-
return
|
|
26027
|
-
|
|
26028
|
-
|
|
26029
|
-
|
|
26030
|
-
|
|
26076
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
26077
|
+
var done;
|
|
26078
|
+
return __generator(this, function (_e) {
|
|
26079
|
+
switch (_e.label) {
|
|
26080
|
+
case 0:
|
|
26081
|
+
row = row || this.editedRow;
|
|
26082
|
+
return [4 /*yield*/, this.confirmEditCreate(event, row)];
|
|
26083
|
+
case 1:
|
|
26084
|
+
done = _e.sent();
|
|
26085
|
+
if (done) {
|
|
26086
|
+
// Edit next row
|
|
26087
|
+
this.editRowById(event, row.id + 1, { focusColumn: this.firstUserColumn });
|
|
26088
|
+
}
|
|
26089
|
+
return [2 /*return*/, done];
|
|
26090
|
+
}
|
|
26091
|
+
});
|
|
26092
|
+
});
|
|
26031
26093
|
};
|
|
26032
26094
|
AppTable.prototype.editRowById = function (event, id, opts) {
|
|
26033
26095
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -26058,50 +26120,52 @@
|
|
|
26058
26120
|
* @param row
|
|
26059
26121
|
*/
|
|
26060
26122
|
AppTable.prototype.confirmEditCreate = function (event, row) {
|
|
26061
|
-
var _this = this;
|
|
26062
26123
|
var _a;
|
|
26063
|
-
|
|
26064
|
-
|
|
26065
|
-
return
|
|
26066
|
-
|
|
26067
|
-
|
|
26068
|
-
|
|
26069
|
-
|
|
26070
|
-
|
|
26071
|
-
|
|
26072
|
-
|
|
26073
|
-
|
|
26074
|
-
|
|
26075
|
-
|
|
26076
|
-
|
|
26077
|
-
|
|
26078
|
-
|
|
26079
|
-
|
|
26080
|
-
|
|
26081
|
-
|
|
26082
|
-
|
|
26083
|
-
|
|
26084
|
-
|
|
26085
|
-
|
|
26086
|
-
|
|
26087
|
-
|
|
26088
|
-
|
|
26089
|
-
|
|
26090
|
-
|
|
26091
|
-
|
|
26092
|
-
|
|
26093
|
-
|
|
26094
|
-
|
|
26095
|
-
|
|
26096
|
-
|
|
26097
|
-
|
|
26098
|
-
|
|
26099
|
-
|
|
26100
|
-
|
|
26101
|
-
|
|
26102
|
-
|
|
26103
|
-
|
|
26104
|
-
|
|
26124
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
26125
|
+
var done, error;
|
|
26126
|
+
return __generator(this, function (_e) {
|
|
26127
|
+
switch (_e.label) {
|
|
26128
|
+
case 0:
|
|
26129
|
+
row = row || this.editedRow;
|
|
26130
|
+
if (!row || !row.editing)
|
|
26131
|
+
return [2 /*return*/, true]; // no row to confirm
|
|
26132
|
+
// Stop event
|
|
26133
|
+
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
|
26134
|
+
return [4 /*yield*/, row.confirmEditCreate()];
|
|
26135
|
+
case 1:
|
|
26136
|
+
done = _e.sent();
|
|
26137
|
+
if (done) {
|
|
26138
|
+
// If edit finished, forget edited row
|
|
26139
|
+
if (row === this.editedRow) {
|
|
26140
|
+
this.editedRow = undefined;
|
|
26141
|
+
}
|
|
26142
|
+
// Mark table as dirty (if row is dirty)
|
|
26143
|
+
if ((_a = row.validator) === null || _a === void 0 ? void 0 : _a.dirty) {
|
|
26144
|
+
this.markAsDirty({ emitEvent: false /* because of resetError() */ });
|
|
26145
|
+
}
|
|
26146
|
+
// Clear error
|
|
26147
|
+
this.resetError();
|
|
26148
|
+
// Emit the confirm event
|
|
26149
|
+
this.onConfirmEditCreateRow.next(row);
|
|
26150
|
+
}
|
|
26151
|
+
else if (row.validator) {
|
|
26152
|
+
// NOT confirmed = row has error
|
|
26153
|
+
if (this.debug) {
|
|
26154
|
+
console.warn('[table] Cannot confirm row, because invalid');
|
|
26155
|
+
AppFormUtils.logFormErrors(row.validator, '[table] ');
|
|
26156
|
+
}
|
|
26157
|
+
// fix: mark all controls as touched to show errors
|
|
26158
|
+
row.validator.markAllAsTouched();
|
|
26159
|
+
// Compute row error, and propagate to table's error
|
|
26160
|
+
if (this.propagateRowError) {
|
|
26161
|
+
error = this.getRowError(row);
|
|
26162
|
+
this.setError(error);
|
|
26163
|
+
}
|
|
26164
|
+
}
|
|
26165
|
+
return [2 /*return*/, done];
|
|
26166
|
+
}
|
|
26167
|
+
});
|
|
26168
|
+
});
|
|
26105
26169
|
};
|
|
26106
26170
|
AppTable.prototype.cancelOrDelete = function (event, row, opts) {
|
|
26107
26171
|
// Delete new row
|
|
@@ -26961,13 +27025,16 @@
|
|
|
26961
27025
|
};
|
|
26962
27026
|
AppTable.prototype.addRowToTable = function (insertAt) {
|
|
26963
27027
|
return __awaiter(this, void 0, void 0, function () {
|
|
27028
|
+
var done;
|
|
26964
27029
|
return __generator(this, function (_e) {
|
|
26965
27030
|
switch (_e.label) {
|
|
26966
27031
|
case 0:
|
|
26967
27032
|
this.focusFirstColumn = true;
|
|
26968
|
-
return [4 /*yield*/, this._dataSource.
|
|
27033
|
+
return [4 /*yield*/, this._dataSource.createNew(insertAt)];
|
|
26969
27034
|
case 1:
|
|
26970
|
-
_e.sent();
|
|
27035
|
+
done = _e.sent();
|
|
27036
|
+
if (!done)
|
|
27037
|
+
return [2 /*return*/, undefined];
|
|
26971
27038
|
this.editedRow = this._dataSource.getRow(-1);
|
|
26972
27039
|
// Emit start editing event
|
|
26973
27040
|
this.onStartEditingRow.emit(this.editedRow);
|
|
@@ -27109,54 +27176,74 @@
|
|
|
27109
27176
|
}
|
|
27110
27177
|
};
|
|
27111
27178
|
AppTable.prototype.deleteNewRow = function (event, row) {
|
|
27112
|
-
|
|
27113
|
-
|
|
27114
|
-
|
|
27115
|
-
|
|
27116
|
-
|
|
27117
|
-
|
|
27118
|
-
|
|
27119
|
-
|
|
27120
|
-
|
|
27121
|
-
|
|
27179
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
27180
|
+
var done;
|
|
27181
|
+
return __generator(this, function (_e) {
|
|
27182
|
+
switch (_e.label) {
|
|
27183
|
+
case 0:
|
|
27184
|
+
if (row.id !== -1)
|
|
27185
|
+
throw new Error('Row must have id = -1');
|
|
27186
|
+
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
|
27187
|
+
this.selection.clear();
|
|
27188
|
+
this.editedRow = undefined; // unselect row
|
|
27189
|
+
return [4 /*yield*/, this._dataSource.cancelOrDelete(row)];
|
|
27190
|
+
case 1:
|
|
27191
|
+
done = _e.sent();
|
|
27192
|
+
if (done) {
|
|
27193
|
+
this.onCancelOrDeleteRow.next(row);
|
|
27194
|
+
this.resetError();
|
|
27195
|
+
this.totalRowCount--;
|
|
27196
|
+
this.visibleRowCount--;
|
|
27197
|
+
}
|
|
27198
|
+
return [2 /*return*/, done];
|
|
27199
|
+
}
|
|
27200
|
+
});
|
|
27201
|
+
});
|
|
27122
27202
|
};
|
|
27123
27203
|
AppTable.prototype.deleteExistingRow = function (event, row, opts) {
|
|
27124
27204
|
// Make sure row will be cancelled, and NOT deleted
|
|
27125
27205
|
if (row.id === -1)
|
|
27126
27206
|
throw new Error('Row must have an id');
|
|
27127
27207
|
if (event === null || event === void 0 ? void 0 : event.defaultPrevented)
|
|
27128
|
-
return
|
|
27208
|
+
return Promise.resolve(false); // SKip
|
|
27129
27209
|
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
27130
|
-
this.deleteRow(null, row, opts);
|
|
27210
|
+
return this.deleteRow(null, row, opts);
|
|
27131
27211
|
};
|
|
27132
27212
|
AppTable.prototype.cancelExistingRow = function (event, row, opts) {
|
|
27133
|
-
var _this = this;
|
|
27134
27213
|
var _a;
|
|
27135
|
-
|
|
27136
|
-
|
|
27137
|
-
|
|
27138
|
-
|
|
27139
|
-
|
|
27140
|
-
|
|
27141
|
-
|
|
27142
|
-
|
|
27143
|
-
|
|
27144
|
-
|
|
27145
|
-
|
|
27146
|
-
|
|
27214
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
27215
|
+
var confirmed, confirm, keepEditing;
|
|
27216
|
+
return __generator(this, function (_e) {
|
|
27217
|
+
switch (_e.label) {
|
|
27218
|
+
case 0:
|
|
27219
|
+
// Make sure row will be cancelled, and NOT deleted
|
|
27220
|
+
if (row.id === -1 || !row.editing)
|
|
27221
|
+
throw new Error('Row cannot be canceling, but only deleting');
|
|
27222
|
+
confirmed = (!opts || opts.interactive !== false);
|
|
27223
|
+
if (!(!confirmed && ((_a = row.validator) === null || _a === void 0 ? void 0 : _a.dirty) && (this.confirmBeforeCancel || this.onBeforeCancelRows.observers.length > 0))) return [3 /*break*/, 2];
|
|
27224
|
+
event.stopPropagation();
|
|
27225
|
+
return [4 /*yield*/, this.canCancelRows([row], opts)];
|
|
27226
|
+
case 1:
|
|
27227
|
+
confirm = _e.sent();
|
|
27228
|
+
// If not confirmed: stop
|
|
27229
|
+
if (!confirm)
|
|
27230
|
+
return [2 /*return*/, false];
|
|
27231
|
+
_e.label = 2;
|
|
27232
|
+
case 2:
|
|
27233
|
+
keepEditing = row.editing && (!opts || opts.keepEditing !== false);
|
|
27234
|
+
this.editedRow = undefined; // unselect row
|
|
27235
|
+
this._dataSource.cancelOrDelete(row);
|
|
27236
|
+
this.onCancelOrDeleteRow.next(row);
|
|
27237
|
+
// Mark row as pristine
|
|
27238
|
+
this.checkIfRowPristine(row);
|
|
27239
|
+
// Restore editing state
|
|
27240
|
+
if (keepEditing) {
|
|
27241
|
+
this.editRow(undefined, row);
|
|
27242
|
+
}
|
|
27243
|
+
return [2 /*return*/, true];
|
|
27244
|
+
}
|
|
27147
27245
|
});
|
|
27148
|
-
|
|
27149
|
-
}
|
|
27150
|
-
var keepEditing = row.editing && (!opts || opts.keepEditing !== false);
|
|
27151
|
-
this.editedRow = undefined; // unselect row
|
|
27152
|
-
this._dataSource.cancelOrDelete(row);
|
|
27153
|
-
this.onCancelOrDeleteRow.next(row);
|
|
27154
|
-
// Mark row as pristine
|
|
27155
|
-
this.checkIfRowPristine(row);
|
|
27156
|
-
// Restore editing state
|
|
27157
|
-
if (keepEditing) {
|
|
27158
|
-
this.editRow(undefined, row);
|
|
27159
|
-
}
|
|
27246
|
+
});
|
|
27160
27247
|
};
|
|
27161
27248
|
AppTable.prototype.checkIfRowPristine = function (row, opts) {
|
|
27162
27249
|
var _a, _b;
|