@sumaris-net/ngx-components 0.13.10 → 0.13.14
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 +81 -39
- package/bundles/ngx-sumaris-components.umd.js.map +1 -1
- package/bundles/ngx-sumaris-components.umd.min.js +2 -2
- package/bundles/ngx-sumaris-components.umd.min.js.map +1 -1
- package/esm2015/src/app/core/services/base-entity-service.class.js +24 -1
- package/esm2015/src/app/core/services/model/entity.model.js +2 -2
- package/esm2015/src/app/core/table/entities-table-datasource.class.js +5 -1
- package/esm2015/src/app/core/table/table.class.js +11 -6
- package/esm2015/src/app/shared/material/autocomplete/material.autocomplete.js +2 -2
- package/fesm2015/ngx-sumaris-components.js +39 -7
- 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/services/base-entity-service.class.d.ts +2 -0
|
@@ -1346,7 +1346,7 @@
|
|
|
1346
1346
|
}
|
|
1347
1347
|
}),
|
|
1348
1348
|
// Filter if not enough character
|
|
1349
|
-
operators.filter(function (value) { return value
|
|
1349
|
+
operators.filter(function (value) { return value.length >= _this.suggestLengthThreshold; }),
|
|
1350
1350
|
// Wait a debounce time
|
|
1351
1351
|
operators.debounceTime(this.debounceTime)),
|
|
1352
1352
|
// Object set: use it (no distinctUntilChanged() pipe need)
|
|
@@ -8525,7 +8525,7 @@
|
|
|
8525
8525
|
}
|
|
8526
8526
|
Entity.prototype.clone = function (opts) {
|
|
8527
8527
|
var target = new this.constructor();
|
|
8528
|
-
this.copy(target);
|
|
8528
|
+
this.copy(target, opts);
|
|
8529
8529
|
return target;
|
|
8530
8530
|
};
|
|
8531
8531
|
Entity.prototype.copy = function (target, opts) {
|
|
@@ -21755,8 +21755,8 @@
|
|
|
21755
21755
|
fetchPolicy: opts && opts.fetchPolicy || undefined,
|
|
21756
21756
|
error: { code: ErrorCodes.LOAD_DATA_ERROR, message: 'REFERENTIAL.ERROR.LOAD_DATA_ERROR' }
|
|
21757
21757
|
})
|
|
21758
|
-
.pipe(operators.map(function (
|
|
21759
|
-
var data =
|
|
21758
|
+
.pipe(operators.map(function (_b) {
|
|
21759
|
+
var data = _b.data;
|
|
21760
21760
|
return (!opts || opts.toEntity !== false)
|
|
21761
21761
|
? (data && _this.fromObject(data))
|
|
21762
21762
|
: data;
|
|
@@ -21765,8 +21765,8 @@
|
|
|
21765
21765
|
BaseEntityService.prototype.load = function (id, opts) {
|
|
21766
21766
|
return __awaiter(this, void 0, void 0, function () {
|
|
21767
21767
|
var query, data;
|
|
21768
|
-
return __generator(this, function (
|
|
21769
|
-
switch (
|
|
21768
|
+
return __generator(this, function (_b) {
|
|
21769
|
+
switch (_b.label) {
|
|
21770
21770
|
case 0:
|
|
21771
21771
|
if (this._debug)
|
|
21772
21772
|
console.debug(this._logPrefix + ("Loading " + this._logTypeName + " {" + id + "}..."));
|
|
@@ -21778,7 +21778,7 @@
|
|
|
21778
21778
|
error: { code: ErrorCodes.LOAD_DATA_ERROR, message: 'REFERENTIAL.ERROR.LOAD_DATA_ERROR' }
|
|
21779
21779
|
})];
|
|
21780
21780
|
case 1:
|
|
21781
|
-
data = (
|
|
21781
|
+
data = (_b.sent()).data;
|
|
21782
21782
|
// Convert to entity
|
|
21783
21783
|
return [2 /*return*/, (!opts || opts.toEntity !== false)
|
|
21784
21784
|
? (data && this.fromObject(data))
|
|
@@ -21814,8 +21814,8 @@
|
|
|
21814
21814
|
error: { code: ErrorCodes.LOAD_DATA_ERROR, message: 'REFERENTIAL.ERROR.LOAD_DATA_ERROR' },
|
|
21815
21815
|
fetchPolicy: opts && opts.fetchPolicy || undefined
|
|
21816
21816
|
})
|
|
21817
|
-
.pipe(operators.map(function (
|
|
21818
|
-
var data =
|
|
21817
|
+
.pipe(operators.map(function (_b) {
|
|
21818
|
+
var data = _b.data, total = _b.total;
|
|
21819
21819
|
// Convert to entity (if need)
|
|
21820
21820
|
var entities = (!opts || opts.toEntity !== false)
|
|
21821
21821
|
? (data || []).map(function (json) { return _this.fromObject(json); })
|
|
@@ -21829,10 +21829,10 @@
|
|
|
21829
21829
|
};
|
|
21830
21830
|
BaseEntityService.prototype.loadAll = function (offset, size, sortBy, sortDirection, filter, opts) {
|
|
21831
21831
|
return __awaiter(this, void 0, void 0, function () {
|
|
21832
|
-
var debug, variables, now, withTotal, query,
|
|
21832
|
+
var debug, variables, now, withTotal, query, _b, data, total, entities, res, nextOffset_1;
|
|
21833
21833
|
var _this = this;
|
|
21834
|
-
return __generator(this, function (
|
|
21835
|
-
switch (
|
|
21834
|
+
return __generator(this, function (_c) {
|
|
21835
|
+
switch (_c.label) {
|
|
21836
21836
|
case 0:
|
|
21837
21837
|
debug = this._debug && (!opts || opts.debug !== false);
|
|
21838
21838
|
filter = this.asFilter(filter);
|
|
@@ -21857,7 +21857,7 @@
|
|
|
21857
21857
|
fetchPolicy: opts && opts.fetchPolicy || 'network-only'
|
|
21858
21858
|
})];
|
|
21859
21859
|
case 1:
|
|
21860
|
-
|
|
21860
|
+
_b = _c.sent(), data = _b.data, total = _b.total;
|
|
21861
21861
|
entities = (!opts || opts.toEntity !== false) ?
|
|
21862
21862
|
(data || []).map(function (json) { return _this.fromObject(json); }) :
|
|
21863
21863
|
(data || []);
|
|
@@ -21879,12 +21879,44 @@
|
|
|
21879
21879
|
});
|
|
21880
21880
|
});
|
|
21881
21881
|
};
|
|
21882
|
+
BaseEntityService.prototype.countAll = function (filter, opts) {
|
|
21883
|
+
var _a;
|
|
21884
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
21885
|
+
var res;
|
|
21886
|
+
return __generator(this, function (_b) {
|
|
21887
|
+
switch (_b.label) {
|
|
21888
|
+
case 0:
|
|
21889
|
+
if (!!this.queries.countAll) return [3 /*break*/, 2];
|
|
21890
|
+
// Fail if no loadAll (cannot count)
|
|
21891
|
+
if (!this.queries.loadAllWithTotal)
|
|
21892
|
+
throw new Error('Not implemented');
|
|
21893
|
+
return [4 /*yield*/, this.loadAll(0, 1, null, null, filter, { withTotal: true })];
|
|
21894
|
+
case 1:
|
|
21895
|
+
// Use loadAll query, with size = 0;
|
|
21896
|
+
return [2 /*return*/, ((_a = (_b.sent())) === null || _a === void 0 ? void 0 : _a.total) || 0];
|
|
21897
|
+
case 2:
|
|
21898
|
+
filter = this.asFilter(filter);
|
|
21899
|
+
return [4 /*yield*/, this.graphql.query({
|
|
21900
|
+
query: this.queries.countAll,
|
|
21901
|
+
variables: {
|
|
21902
|
+
filter: filter && filter.asPodObject()
|
|
21903
|
+
},
|
|
21904
|
+
error: { code: ErrorCodes.LOAD_DATA_ERROR, message: 'ERROR.COUNT_DATA_ERROR' },
|
|
21905
|
+
fetchPolicy: opts && opts.fetchPolicy || 'network-only'
|
|
21906
|
+
})];
|
|
21907
|
+
case 3:
|
|
21908
|
+
res = _b.sent();
|
|
21909
|
+
return [2 /*return*/, res.total];
|
|
21910
|
+
}
|
|
21911
|
+
});
|
|
21912
|
+
});
|
|
21913
|
+
};
|
|
21882
21914
|
BaseEntityService.prototype.saveAll = function (entities, opts) {
|
|
21883
21915
|
return __awaiter(this, void 0, void 0, function () {
|
|
21884
21916
|
var hasNewEntities, json, now;
|
|
21885
21917
|
var _this = this;
|
|
21886
|
-
return __generator(this, function (
|
|
21887
|
-
switch (
|
|
21918
|
+
return __generator(this, function (_b) {
|
|
21919
|
+
switch (_b.label) {
|
|
21888
21920
|
case 0:
|
|
21889
21921
|
if (isEmptyArray(entities))
|
|
21890
21922
|
return [2 /*return*/, entities]; // Nothing to save: skip
|
|
@@ -21912,8 +21944,8 @@
|
|
|
21912
21944
|
data: json
|
|
21913
21945
|
},
|
|
21914
21946
|
error: { code: ErrorCodes.SAVE_DATA_ERROR, message: 'ERROR.SAVE_DATA_ERROR' },
|
|
21915
|
-
update: function (proxy,
|
|
21916
|
-
var data =
|
|
21947
|
+
update: function (proxy, _b) {
|
|
21948
|
+
var data = _b.data;
|
|
21917
21949
|
var savedEntities = data && data.data;
|
|
21918
21950
|
if (savedEntities) {
|
|
21919
21951
|
// Update entities (id and update date)
|
|
@@ -21937,7 +21969,7 @@
|
|
|
21937
21969
|
}
|
|
21938
21970
|
})];
|
|
21939
21971
|
case 1:
|
|
21940
|
-
|
|
21972
|
+
_b.sent();
|
|
21941
21973
|
return [2 /*return*/, entities];
|
|
21942
21974
|
}
|
|
21943
21975
|
});
|
|
@@ -21953,15 +21985,15 @@
|
|
|
21953
21985
|
return __awaiter(this, void 0, void 0, function () {
|
|
21954
21986
|
var data, json, isNew, now;
|
|
21955
21987
|
var _this = this;
|
|
21956
|
-
return __generator(this, function (
|
|
21957
|
-
switch (
|
|
21988
|
+
return __generator(this, function (_b) {
|
|
21989
|
+
switch (_b.label) {
|
|
21958
21990
|
case 0:
|
|
21959
21991
|
if (!!this.mutations.save) return [3 /*break*/, 2];
|
|
21960
21992
|
if (!this.mutations.saveAll)
|
|
21961
21993
|
throw new Error('Not implemented');
|
|
21962
21994
|
return [4 /*yield*/, this.saveAll([entity], opts)];
|
|
21963
21995
|
case 1:
|
|
21964
|
-
data =
|
|
21996
|
+
data = _b.sent();
|
|
21965
21997
|
return [2 /*return*/, data && data[0]];
|
|
21966
21998
|
case 2:
|
|
21967
21999
|
// Fill default properties
|
|
@@ -21979,8 +22011,8 @@
|
|
|
21979
22011
|
data: json
|
|
21980
22012
|
},
|
|
21981
22013
|
error: { code: ErrorCodes.SAVE_DATA_ERROR, message: 'ERROR.SAVE_DATA_ERROR' },
|
|
21982
|
-
update: function (cache,
|
|
21983
|
-
var data =
|
|
22014
|
+
update: function (cache, _b) {
|
|
22015
|
+
var data = _b.data;
|
|
21984
22016
|
// Update entity
|
|
21985
22017
|
var savedEntity = data && data.data;
|
|
21986
22018
|
_this.copyIdAndUpdateDate(savedEntity, entity);
|
|
@@ -21999,7 +22031,7 @@
|
|
|
21999
22031
|
}
|
|
22000
22032
|
})];
|
|
22001
22033
|
case 3:
|
|
22002
|
-
|
|
22034
|
+
_b.sent();
|
|
22003
22035
|
return [2 /*return*/, entity];
|
|
22004
22036
|
}
|
|
22005
22037
|
});
|
|
@@ -22012,8 +22044,8 @@
|
|
|
22012
22044
|
return __awaiter(this, void 0, void 0, function () {
|
|
22013
22045
|
var ids, now;
|
|
22014
22046
|
var _this = this;
|
|
22015
|
-
return __generator(this, function (
|
|
22016
|
-
switch (
|
|
22047
|
+
return __generator(this, function (_b) {
|
|
22048
|
+
switch (_b.label) {
|
|
22017
22049
|
case 0:
|
|
22018
22050
|
if (!this.mutations.deleteAll) {
|
|
22019
22051
|
if (!this.mutations.delete)
|
|
@@ -22053,7 +22085,7 @@
|
|
|
22053
22085
|
}
|
|
22054
22086
|
})];
|
|
22055
22087
|
case 1:
|
|
22056
|
-
|
|
22088
|
+
_b.sent();
|
|
22057
22089
|
return [2 /*return*/];
|
|
22058
22090
|
}
|
|
22059
22091
|
});
|
|
@@ -22066,15 +22098,15 @@
|
|
|
22066
22098
|
return __awaiter(this, void 0, void 0, function () {
|
|
22067
22099
|
var data, id, now;
|
|
22068
22100
|
var _this = this;
|
|
22069
|
-
return __generator(this, function (
|
|
22070
|
-
switch (
|
|
22101
|
+
return __generator(this, function (_b) {
|
|
22102
|
+
switch (_b.label) {
|
|
22071
22103
|
case 0:
|
|
22072
22104
|
if (!!this.mutations.delete) return [3 /*break*/, 2];
|
|
22073
22105
|
if (!this.mutations.deleteAll)
|
|
22074
22106
|
throw new Error('Not implemented');
|
|
22075
22107
|
return [4 /*yield*/, this.deleteAll([entity], opts)];
|
|
22076
22108
|
case 1:
|
|
22077
|
-
data =
|
|
22109
|
+
data = _b.sent();
|
|
22078
22110
|
return [2 /*return*/, data && data[0]];
|
|
22079
22111
|
case 2:
|
|
22080
22112
|
// Nothing to save: skip
|
|
@@ -22106,7 +22138,7 @@
|
|
|
22106
22138
|
}
|
|
22107
22139
|
})];
|
|
22108
22140
|
case 3:
|
|
22109
|
-
|
|
22141
|
+
_b.sent();
|
|
22110
22142
|
return [2 /*return*/];
|
|
22111
22143
|
}
|
|
22112
22144
|
});
|
|
@@ -22132,8 +22164,8 @@
|
|
|
22132
22164
|
message: 'ERROR.SUBSCRIBE_DATA_ERROR'
|
|
22133
22165
|
}
|
|
22134
22166
|
})
|
|
22135
|
-
.pipe(operators.map(function (
|
|
22136
|
-
var data =
|
|
22167
|
+
.pipe(operators.map(function (_b) {
|
|
22168
|
+
var data = _b.data;
|
|
22137
22169
|
var entity = (!opts || opts.toEntity !== false) ? data && _this.fromObject(data) : data;
|
|
22138
22170
|
if (entity && _this._debug)
|
|
22139
22171
|
console.debug(_this._logPrefix + ("[WS] Received changes on " + _this._logTypeName + " {" + id + "}"), entity);
|
|
@@ -22444,6 +22476,10 @@
|
|
|
22444
22476
|
};
|
|
22445
22477
|
EntitiesTableDataSource.prototype.delete = function (id) {
|
|
22446
22478
|
var _this = this;
|
|
22479
|
+
// If new row: not need to propagate to the dataService
|
|
22480
|
+
if (id === -1) {
|
|
22481
|
+
return _super_1.prototype.delete.call(this, id);
|
|
22482
|
+
}
|
|
22447
22483
|
var row = this.getRow(id);
|
|
22448
22484
|
if (!row) {
|
|
22449
22485
|
console.error("[table-datasource] Row to delete with id=" + id + " not found");
|
|
@@ -23444,6 +23480,10 @@
|
|
|
23444
23480
|
canDelete = _d.sent();
|
|
23445
23481
|
if (!canDelete)
|
|
23446
23482
|
return [2 /*return*/, 0]; // Cannot delete
|
|
23483
|
+
if (!this.saveBeforeDelete) return [3 /*break*/, 3];
|
|
23484
|
+
// Cancel invalid rows (because of save() will failed if there is invalid rows)
|
|
23485
|
+
rows.filter(function (row) { var _a; return !((_a = row.validator) === null || _a === void 0 ? void 0 : _a.valid); })
|
|
23486
|
+
.forEach(function (row) { return row.cancelOrDelete(); });
|
|
23447
23487
|
return [4 /*yield*/, this.saveBeforeAction('delete')];
|
|
23448
23488
|
case 2:
|
|
23449
23489
|
saved = _d.sent();
|
|
@@ -23451,6 +23491,8 @@
|
|
|
23451
23491
|
// Stop if save cancelled or save failed
|
|
23452
23492
|
return [2 /*return*/];
|
|
23453
23493
|
}
|
|
23494
|
+
_d.label = 3;
|
|
23495
|
+
case 3:
|
|
23454
23496
|
if (this.debug)
|
|
23455
23497
|
console.debug('[table] Delete selection...');
|
|
23456
23498
|
rowsToDelete = rows.slice()
|
|
@@ -23458,12 +23500,12 @@
|
|
|
23458
23500
|
// This is a workaround, need because row.delete() has async execution
|
|
23459
23501
|
// and index cache is updated with a delay)
|
|
23460
23502
|
.sort(function (a, b) { return a.id > b.id ? -1 : 1; });
|
|
23461
|
-
_d.label =
|
|
23462
|
-
case
|
|
23463
|
-
_d.trys.push([
|
|
23503
|
+
_d.label = 4;
|
|
23504
|
+
case 4:
|
|
23505
|
+
_d.trys.push([4, 6, , 7]);
|
|
23464
23506
|
deleteCount = rowsToDelete.length;
|
|
23465
23507
|
return [4 /*yield*/, this._dataSource.deleteAll(rowsToDelete)];
|
|
23466
|
-
case
|
|
23508
|
+
case 5:
|
|
23467
23509
|
_d.sent();
|
|
23468
23510
|
// Not need to update manually, because watchALl().subscribe() will update this count
|
|
23469
23511
|
//this.totalRowCount -= deleteCount;
|
|
@@ -23474,11 +23516,11 @@
|
|
|
23474
23516
|
this.markForCheck();
|
|
23475
23517
|
this.onAfterDeletedRows.next(rowsToDelete);
|
|
23476
23518
|
return [2 /*return*/, deleteCount];
|
|
23477
|
-
case
|
|
23519
|
+
case 6:
|
|
23478
23520
|
err_2 = _d.sent();
|
|
23479
23521
|
this.setError(err_2 && err_2.message || err_2);
|
|
23480
23522
|
throw err_2;
|
|
23481
|
-
case
|
|
23523
|
+
case 7: return [2 /*return*/];
|
|
23482
23524
|
}
|
|
23483
23525
|
});
|
|
23484
23526
|
});
|