@sumaris-net/ngx-components 1.23.17 → 1.23.19
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 +33 -30
- 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/services/base-entity-service.class.js +5 -6
- package/esm2015/src/app/core/services/network.service.js +1 -1
- package/esm2015/src/app/core/table/entities-table-datasource.class.js +25 -23
- package/esm2015/src/app/core/table/table.class.js +6 -4
- package/fesm2015/sumaris-net.ngx-components.js +33 -30
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -22410,15 +22410,15 @@ class BaseEntityService extends BaseGraphqlService {
|
|
|
22410
22410
|
console.warn(`${this.constructor.name}.listenChanges() not implemented yet. Will empty observable`);
|
|
22411
22411
|
return of();
|
|
22412
22412
|
}
|
|
22413
|
-
const variables = opts
|
|
22413
|
+
const variables = (opts === null || opts === void 0 ? void 0 : opts.variables) || {
|
|
22414
22414
|
id,
|
|
22415
22415
|
interval: toNumber(opts && opts.interval, 0) // no timer by default
|
|
22416
22416
|
};
|
|
22417
22417
|
if (this._debug)
|
|
22418
22418
|
console.debug(this._logPrefix + `[WS] Listening for changes on ${this._logTypeName} {${id}}...`);
|
|
22419
22419
|
return this.graphql.subscribe({
|
|
22420
|
-
query: opts
|
|
22421
|
-
fetchPolicy: opts
|
|
22420
|
+
query: (opts === null || opts === void 0 ? void 0 : opts.query) || this.subscriptions.listenChanges,
|
|
22421
|
+
fetchPolicy: (opts === null || opts === void 0 ? void 0 : opts.fetchPolicy) || 'no-cache',
|
|
22422
22422
|
variables,
|
|
22423
22423
|
error: {
|
|
22424
22424
|
code: ErrorCodes.SUBSCRIBE_DATA_ERROR,
|
|
@@ -22427,8 +22427,7 @@ class BaseEntityService extends BaseGraphqlService {
|
|
|
22427
22427
|
})
|
|
22428
22428
|
.pipe(map(({ data }) => {
|
|
22429
22429
|
const entity = (!opts || opts.toEntity !== false) ? data && this.fromObject(data) : data;
|
|
22430
|
-
if (entity && this._debug)
|
|
22431
|
-
console.debug(this._logPrefix + `[WS] Received changes on ${this._logTypeName} {${id}}`, entity);
|
|
22430
|
+
//if (entity && this._debug) console.debug(this._logPrefix + `[WS] Received changes on ${this._logTypeName} {${id}}`, entity);
|
|
22432
22431
|
// TODO: missing = deleted ?
|
|
22433
22432
|
if (!entity)
|
|
22434
22433
|
console.warn(this._logPrefix + `[WS] Received deletion on ${this._logTypeName} {${id}} - TODO check implementation`);
|
|
@@ -22573,7 +22572,8 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
22573
22572
|
*/
|
|
22574
22573
|
close() {
|
|
22575
22574
|
if (!this._stopWatchSubject.closed) {
|
|
22576
|
-
|
|
22575
|
+
if (this._debug)
|
|
22576
|
+
console.debug('[entities-table-datasource] Closing...');
|
|
22577
22577
|
this._stopWatchSubject.next();
|
|
22578
22578
|
this._stopWatchSubject.complete();
|
|
22579
22579
|
this._stopWatchSubject.unsubscribe();
|
|
@@ -22588,10 +22588,10 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
22588
22588
|
return this.dataService.watchAll(offset, size, sortBy, sortDirection, filter, this.serviceOptions)
|
|
22589
22589
|
.pipe(catchError(err => this.handleError(err, 'ERROR.LOAD_DATA_ERROR')), map((res) => {
|
|
22590
22590
|
if (this._saving) {
|
|
22591
|
-
console.info(`[table-datasource] Received ${this._entityName} data (from service), but still saving: skip`);
|
|
22591
|
+
console.info(`[entities-table-datasource] Received ${this._entityName} data (from service), but still saving: skip`);
|
|
22592
22592
|
}
|
|
22593
22593
|
else if (this.hasSomeEditingRow()) {
|
|
22594
|
-
console.warn(`[table-datasource] Received ${this._entityName} data, while some row still editing: skip; Please check save() implementation in the table!`);
|
|
22594
|
+
console.warn(`[entities-table-datasource] Received ${this._entityName} data, while some row still editing: skip; Please check save() implementation in the table!`);
|
|
22595
22595
|
}
|
|
22596
22596
|
else {
|
|
22597
22597
|
this.updateDatasource((res.data || []));
|
|
@@ -22609,22 +22609,22 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
22609
22609
|
// Avoid to update dataSourceSubject, when not need
|
|
22610
22610
|
if ((_a = this.datasourceSubject.observers) === null || _a === void 0 ? void 0 : _a.length) {
|
|
22611
22611
|
if (!this.config.suppressErrors)
|
|
22612
|
-
console.warn('[table-datasource] Update datasource subject. Please prefer using \'rowsSubject\' instead of \'datasourceSubject\'');
|
|
22612
|
+
console.warn('[entities-table-datasource] Update datasource subject. Please prefer using \'rowsSubject\' instead of \'datasourceSubject\'');
|
|
22613
22613
|
super.updateDatasourceFromRows(rows);
|
|
22614
22614
|
}
|
|
22615
22615
|
else {
|
|
22616
|
-
console.debug('[table-datasource] Skipping datasourceSubject update (not used yet).');
|
|
22616
|
+
console.debug('[entities-table-datasource] Skipping datasourceSubject update (not used yet).');
|
|
22617
22617
|
}
|
|
22618
22618
|
}
|
|
22619
22619
|
save() {
|
|
22620
22620
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22621
22621
|
if (this.config.readOnly) {
|
|
22622
|
-
console.error('[table-datasource] Enable to save, because config.readOnly=true');
|
|
22622
|
+
console.error('[entities-table-datasource] Enable to save, because config.readOnly=true');
|
|
22623
22623
|
return false;
|
|
22624
22624
|
}
|
|
22625
22625
|
// Saving twice (should never occur)
|
|
22626
22626
|
if (this._saving) {
|
|
22627
|
-
console.warn(`[table-datasource] Trying to save ${this._entityName} rows twice. Skip`);
|
|
22627
|
+
console.warn(`[entities-table-datasource] Trying to save ${this._entityName} rows twice. Skip`);
|
|
22628
22628
|
return false;
|
|
22629
22629
|
}
|
|
22630
22630
|
this._saving = true;
|
|
@@ -22632,7 +22632,7 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
22632
22632
|
const onlyDirtyRows = this.config.saveOnlyDirtyRows;
|
|
22633
22633
|
try {
|
|
22634
22634
|
if (this._debug)
|
|
22635
|
-
console.debug(`[table-datasource] Saving ${this._entityName} rows... {onlyDirtyRows: ${onlyDirtyRows}}`);
|
|
22635
|
+
console.debug(`[entities-table-datasource] Saving ${this._entityName} rows... {onlyDirtyRows: ${onlyDirtyRows}}`);
|
|
22636
22636
|
// Get all rows
|
|
22637
22637
|
const rows = this.getRows();
|
|
22638
22638
|
// Finish editing all rows
|
|
@@ -22641,7 +22641,7 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
22641
22641
|
if (invalidRows.length) {
|
|
22642
22642
|
// log errors
|
|
22643
22643
|
if (this._debug)
|
|
22644
|
-
invalidRows.forEach(row => AppTableUtils.logRowErrors(row, `[table-datasource] ${this._entityName} row #${row.id}`));
|
|
22644
|
+
invalidRows.forEach(row => AppTableUtils.logRowErrors(row, `[entities-table-datasource] ${this._entityName} row #${row.id}`));
|
|
22645
22645
|
// Stop with an error
|
|
22646
22646
|
throw { code: ErrorCodes.TABLE_INVALID_ROW_ERROR, message: 'ERROR.TABLE_INVALID_ROW_ERROR' };
|
|
22647
22647
|
}
|
|
@@ -22669,21 +22669,21 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
22669
22669
|
// If no data to save: exit
|
|
22670
22670
|
if (onlyDirtyRows && !dataToSave.length) {
|
|
22671
22671
|
if (this._debug)
|
|
22672
|
-
console.debug(`[table-datasource] No ${this._entityName} data to save. Skip`);
|
|
22672
|
+
console.debug(`[entities-table-datasource] No ${this._entityName} data to save. Skip`);
|
|
22673
22673
|
return false;
|
|
22674
22674
|
}
|
|
22675
22675
|
if (this._debug)
|
|
22676
|
-
console.debug(`[table-datasource] Asking service to save this ${this._entityName} data:`, dataToSave);
|
|
22676
|
+
console.debug(`[entities-table-datasource] Asking service to save this ${this._entityName} data:`, dataToSave);
|
|
22677
22677
|
yield this.dataService.saveAll(dataToSave, this.serviceOptions);
|
|
22678
22678
|
if (this._debug)
|
|
22679
|
-
console.debug(`[table-datasource] Saving ${this._entityName} data [OK]`);
|
|
22679
|
+
console.debug(`[entities-table-datasource] Saving ${this._entityName} data [OK]`);
|
|
22680
22680
|
// LP 23/03/2021: update datasource is necessary but can be changed to a refetch() on QueryRef (must be created and registered in GraphqlService.watchQuery)
|
|
22681
22681
|
this.updateDatasource(data, { emitEvent: false });
|
|
22682
22682
|
return true;
|
|
22683
22683
|
}
|
|
22684
22684
|
catch (error) {
|
|
22685
22685
|
if (this._debug)
|
|
22686
|
-
console.error('[table-datasource] Error while saving: ' + error && error.message || error);
|
|
22686
|
+
console.error('[entities-table-datasource] Error while saving: ' + error && error.message || error);
|
|
22687
22687
|
throw error;
|
|
22688
22688
|
}
|
|
22689
22689
|
finally {
|
|
@@ -22694,7 +22694,7 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
22694
22694
|
}
|
|
22695
22695
|
updateDatasource(data, opts) {
|
|
22696
22696
|
if (this._debug)
|
|
22697
|
-
console.debug(`[table-datasource] Updating datasource with data:`, data);
|
|
22697
|
+
console.debug(`[entities-table-datasource] Updating datasource with data:`, data);
|
|
22698
22698
|
super.updateDatasource(data, opts);
|
|
22699
22699
|
if (!opts || opts.emitEvent !== false) {
|
|
22700
22700
|
this.markAsLoaded();
|
|
@@ -22706,7 +22706,8 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
22706
22706
|
return super.connect(collectionViewer);
|
|
22707
22707
|
}
|
|
22708
22708
|
disconnect(collectionViewer) {
|
|
22709
|
-
|
|
22709
|
+
if (this._debug)
|
|
22710
|
+
console.debug('[entities-table-datasource] Disconnecting...');
|
|
22710
22711
|
super.disconnect(collectionViewer);
|
|
22711
22712
|
this.close();
|
|
22712
22713
|
}
|
|
@@ -22720,7 +22721,7 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
22720
22721
|
if (!super.confirmCreate(row))
|
|
22721
22722
|
return false;
|
|
22722
22723
|
if (row.editing && row.validator) {
|
|
22723
|
-
console.warn('[table-datasource] Row still has {editing: true} after confirmCreate()! Force editing to false');
|
|
22724
|
+
console.warn('[entities-table-datasource] Row still has {editing: true} after confirmCreate()! Force editing to false');
|
|
22724
22725
|
row.validator.disable({ onlySelf: true, emitEvent: false });
|
|
22725
22726
|
}
|
|
22726
22727
|
return true;
|
|
@@ -22729,7 +22730,7 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
22729
22730
|
if (!super.confirmEdit(row))
|
|
22730
22731
|
return false;
|
|
22731
22732
|
if (row.editing && row.validator) {
|
|
22732
|
-
console.warn('[table-datasource] Row still has {editing: true} after confirmEdit()! Force editing to false');
|
|
22733
|
+
console.warn('[entities-table-datasource] Row still has {editing: true} after confirmEdit()! Force editing to false');
|
|
22733
22734
|
row.validator.disable({ onlySelf: true, emitEvent: false });
|
|
22734
22735
|
}
|
|
22735
22736
|
return true;
|
|
@@ -22738,19 +22739,19 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
22738
22739
|
if (!super.startEdit(row))
|
|
22739
22740
|
return false;
|
|
22740
22741
|
if (!row.editing && row.validator) {
|
|
22741
|
-
console.warn('[table-datasource] Row still has {editing: false} after startEdit()! Force editing');
|
|
22742
|
+
console.warn('[entities-table-datasource] Row still has {editing: false} after startEdit()! Force editing');
|
|
22742
22743
|
row.validator.enable({ onlySelf: true, emitEvent: false });
|
|
22743
22744
|
}
|
|
22744
22745
|
}
|
|
22745
22746
|
handleError(error, message) {
|
|
22746
22747
|
const errorMsg = error && error.message || error;
|
|
22747
|
-
console.error(`[table-datasource] Service ${this._entityName} sent error: ${errorMsg}`, error);
|
|
22748
|
+
console.error(`[entities-table-datasource] Service ${this._entityName} sent error: ${errorMsg}`, error);
|
|
22748
22749
|
this.markAsLoaded();
|
|
22749
22750
|
throw new Error(message || errorMsg);
|
|
22750
22751
|
}
|
|
22751
22752
|
handleServiceError(error) {
|
|
22752
22753
|
const errorMsg = error && error.message || error;
|
|
22753
|
-
console.error(`[table-datasource] Service ${this._entityName} sent error: ${errorMsg}`, error);
|
|
22754
|
+
console.error(`[entities-table-datasource] Service ${this._entityName} sent error: ${errorMsg}`, error);
|
|
22754
22755
|
this.markAsLoaded();
|
|
22755
22756
|
throw error;
|
|
22756
22757
|
}
|
|
@@ -22761,7 +22762,7 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
22761
22762
|
}
|
|
22762
22763
|
const row = this.getRow(id);
|
|
22763
22764
|
if (!row) {
|
|
22764
|
-
console.error(`[table-datasource] Row to delete with id=${id} not found`);
|
|
22765
|
+
console.error(`[entities-table-datasource] Row to delete with id=${id} not found`);
|
|
22765
22766
|
return;
|
|
22766
22767
|
}
|
|
22767
22768
|
this.markAsLoading();
|
|
@@ -22792,7 +22793,7 @@ class EntitiesTableDataSource extends TableDataSource {
|
|
|
22792
22793
|
// In this case, apply missing deletion using the super.delete() function
|
|
22793
22794
|
const rowNotDeleted = this.getRows().filter(row => rows.includes(row));
|
|
22794
22795
|
if (isNotEmptyArray(rowNotDeleted)) {
|
|
22795
|
-
console.warn(`[table-datasource] Force deletion of ${rowNotDeleted.length} rows! Please check that data service update the cache, after deletion`);
|
|
22796
|
+
console.warn(`[entities-table-datasource] Force deletion of ${rowNotDeleted.length} rows! Please check that data service update the cache, after deletion`);
|
|
22796
22797
|
rowNotDeleted
|
|
22797
22798
|
// Start at the end
|
|
22798
22799
|
.sort((a, b) => a.id > b.id ? -1 : 1)
|
|
@@ -23637,8 +23638,10 @@ class AppTable {
|
|
|
23637
23638
|
if (this.saveBeforeDelete) {
|
|
23638
23639
|
// Exclude invalid rows (because of save() will fail, when exists some invalid rows)
|
|
23639
23640
|
tempRows = tempRows.filter(row => {
|
|
23640
|
-
// Delete the row
|
|
23641
|
-
if (
|
|
23641
|
+
// Delete the row :
|
|
23642
|
+
// - if newly created row (id = -1),
|
|
23643
|
+
// - or if invalid and not editing (= not cancellable)
|
|
23644
|
+
if (row.id === -1 || (!row.editing && row.invalid)) {
|
|
23642
23645
|
if (this.debug)
|
|
23643
23646
|
console.debug(`[table] Delete row #${row.id}`);
|
|
23644
23647
|
row.delete();
|
|
@@ -23650,7 +23653,7 @@ class AppTable {
|
|
|
23650
23653
|
return false; // Exclude from the list to delete using the service
|
|
23651
23654
|
}
|
|
23652
23655
|
// Cancel the row (and mark as pristine), when not valid but in edition
|
|
23653
|
-
else if (
|
|
23656
|
+
else if (row.editing && !row.valid) {
|
|
23654
23657
|
row.cancel();
|
|
23655
23658
|
// Mark row as pristine (if possible)
|
|
23656
23659
|
this.checkIfRowPristine(row, { emitEvent: false, onlySelf: true /*avoid propagation to table*/ });
|