@sumaris-net/ngx-components 1.23.0-rc3 → 1.23.0-rc6
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 +97 -73
- 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/form/form-buttons-bar.component.js +2 -2
- package/esm2015/src/app/core/table/entities-table-datasource.class.js +38 -15
- package/esm2015/src/app/core/table/testing/table.testing.js +4 -4
- package/esm2015/src/app/shared/services/memory-entity-service.class.js +39 -43
- package/fesm2015/sumaris-net.ngx-components.js +74 -56
- 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 +22 -10
- package/src/app/shared/services/memory-entity-service.class.d.ts +2 -5
- package/src/theme/_ngx-components.scss +11 -0
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -20829,7 +20829,7 @@
|
|
|
20829
20829
|
_this.debug = false;
|
|
20830
20830
|
_this.dirty = false;
|
|
20831
20831
|
_this._saving = false;
|
|
20832
|
-
_this.
|
|
20832
|
+
_this.dataSubject = new rxjs.BehaviorSubject(null);
|
|
20833
20833
|
options = Object.assign({ onSort: _this.sort }, options);
|
|
20834
20834
|
_this._sortFn = options.onSort;
|
|
20835
20835
|
_this._onLoad = options.onLoad;
|
|
@@ -20850,7 +20850,7 @@
|
|
|
20850
20850
|
}
|
|
20851
20851
|
Object.defineProperty(InMemoryEntitiesService.prototype, "value", {
|
|
20852
20852
|
get: function () {
|
|
20853
|
-
return this.
|
|
20853
|
+
return this.dataSubject.getValue();
|
|
20854
20854
|
},
|
|
20855
20855
|
set: function (data) {
|
|
20856
20856
|
this.setValue(data);
|
|
@@ -20861,56 +20861,49 @@
|
|
|
20861
20861
|
InMemoryEntitiesService.prototype.ngOnDestroy = function () {
|
|
20862
20862
|
if (this.debug)
|
|
20863
20863
|
console.debug('[memory-data-service] Destroying...');
|
|
20864
|
-
this.
|
|
20865
|
-
this.
|
|
20864
|
+
this.dataSubject.complete();
|
|
20865
|
+
this.dataSubject.unsubscribe();
|
|
20866
20866
|
};
|
|
20867
|
-
InMemoryEntitiesService.prototype.setValue = function (data
|
|
20868
|
-
if (this.
|
|
20867
|
+
InMemoryEntitiesService.prototype.setValue = function (data) {
|
|
20868
|
+
if (this.dataSubject.value !== data) {
|
|
20869
20869
|
this._hiddenData = [];
|
|
20870
|
-
this.data
|
|
20871
|
-
// Send to observers
|
|
20872
|
-
if (!opts || opts.emitEvent !== false) {
|
|
20873
|
-
this._onChange.next(true);
|
|
20874
|
-
}
|
|
20870
|
+
this.dataSubject.next(data);
|
|
20875
20871
|
}
|
|
20876
20872
|
this.dirty = false;
|
|
20877
20873
|
};
|
|
20878
20874
|
InMemoryEntitiesService.prototype.loadAll = function (offset, size, sortBy, sortDirection, filter, opts) {
|
|
20879
20875
|
return __awaiter(this, void 0, void 0, function () {
|
|
20880
|
-
var excludedDataByFilter, excludedDataByPagination, data, total, res, nextOffset_1;
|
|
20876
|
+
var originalData, excludedDataByFilter, excludedDataByPagination, data, total, res, nextOffset_1;
|
|
20881
20877
|
var _this = this;
|
|
20882
20878
|
return __generator(this, function (_b) {
|
|
20883
20879
|
switch (_b.label) {
|
|
20884
20880
|
case 0:
|
|
20885
20881
|
offset = offset >= 0 ? offset : 0;
|
|
20886
20882
|
size = size >= 0 ? size : -1;
|
|
20887
|
-
|
|
20888
|
-
|
|
20889
|
-
|
|
20883
|
+
originalData = this.dataSubject.value;
|
|
20884
|
+
if (isNil(originalData)) {
|
|
20885
|
+
console.warn('[memory-data-service] Cannot load all: no value set. Will return empty result');
|
|
20886
|
+
}
|
|
20887
|
+
if (!this._saving) return [3 /*break*/, 2];
|
|
20888
|
+
return [4 /*yield*/, waitFor(function () { return !_this._saving; })];
|
|
20890
20889
|
case 1:
|
|
20891
20890
|
_b.sent();
|
|
20892
20891
|
_b.label = 2;
|
|
20893
20892
|
case 2:
|
|
20894
|
-
if (!this._saving) return [3 /*break*/, 4];
|
|
20895
|
-
return [4 /*yield*/, waitFor(function () { return !_this._saving; })];
|
|
20896
|
-
case 3:
|
|
20897
|
-
_b.sent();
|
|
20898
|
-
_b.label = 4;
|
|
20899
|
-
case 4:
|
|
20900
20893
|
excludedDataByFilter = [];
|
|
20901
|
-
_b.label =
|
|
20902
|
-
case
|
|
20903
|
-
_b.trys.push([
|
|
20904
|
-
if (
|
|
20894
|
+
_b.label = 3;
|
|
20895
|
+
case 3:
|
|
20896
|
+
_b.trys.push([3, , 6, 7]);
|
|
20897
|
+
if (isEmptyArray(originalData)) {
|
|
20905
20898
|
return [2 /*return*/, { data: [], total: 0 }];
|
|
20906
20899
|
}
|
|
20907
|
-
data = this._sortFn(
|
|
20908
|
-
if (!this._onLoad) return [3 /*break*/,
|
|
20900
|
+
data = this._sortFn(originalData, sortBy, sortDirection);
|
|
20901
|
+
if (!this._onLoad) return [3 /*break*/, 5];
|
|
20909
20902
|
return [4 /*yield*/, this._onLoad(data)];
|
|
20910
|
-
case
|
|
20903
|
+
case 4:
|
|
20911
20904
|
data = _b.sent();
|
|
20912
|
-
_b.label =
|
|
20913
|
-
case
|
|
20905
|
+
_b.label = 5;
|
|
20906
|
+
case 5:
|
|
20914
20907
|
// Apply filter (will update hiddenData)
|
|
20915
20908
|
data = this.filter(data, filter, excludedDataByFilter);
|
|
20916
20909
|
total = data.length;
|
|
@@ -20927,16 +20920,16 @@
|
|
|
20927
20920
|
data = [];
|
|
20928
20921
|
}
|
|
20929
20922
|
else {
|
|
20930
|
-
excludedDataByPagination = (size > 0 && ((offset + size) < data.length))
|
|
20923
|
+
excludedDataByPagination = (size > 0 && ((offset + size) < data.length))
|
|
20931
20924
|
// Slice using limit to size
|
|
20932
|
-
data.slice(0, offset - 1).concat(data.slice(offset + size))
|
|
20925
|
+
? data.slice(0, offset - 1).concat(data.slice(offset + size))
|
|
20933
20926
|
// Slice without limit
|
|
20934
|
-
data.slice(0, offset - 1);
|
|
20935
|
-
data = (size > 0 && ((offset + size) < data.length))
|
|
20927
|
+
: data.slice(0, offset - 1);
|
|
20928
|
+
data = (size > 0 && ((offset + size) < data.length))
|
|
20936
20929
|
// Slice using limit to size
|
|
20937
|
-
data.slice(offset, offset + size)
|
|
20930
|
+
? data.slice(offset, offset + size)
|
|
20938
20931
|
// Slice without limit
|
|
20939
|
-
data.slice(offset);
|
|
20932
|
+
: data.slice(offset);
|
|
20940
20933
|
}
|
|
20941
20934
|
}
|
|
20942
20935
|
// Apply a limit
|
|
@@ -20950,7 +20943,7 @@
|
|
|
20950
20943
|
}
|
|
20951
20944
|
// /!\ If already observed, then always create a copy of the original array
|
|
20952
20945
|
// Because datasource will only update if the array changed
|
|
20953
|
-
if (data ===
|
|
20946
|
+
if (data === originalData) {
|
|
20954
20947
|
data = data.slice();
|
|
20955
20948
|
}
|
|
20956
20949
|
res = { data: data, total: total };
|
|
@@ -20967,13 +20960,13 @@
|
|
|
20967
20960
|
}); };
|
|
20968
20961
|
}
|
|
20969
20962
|
return [2 /*return*/, res];
|
|
20970
|
-
case
|
|
20963
|
+
case 6:
|
|
20971
20964
|
// Remember hidden data
|
|
20972
20965
|
if (offset === 0) {
|
|
20973
20966
|
this._hiddenData = !excludedDataByPagination ? excludedDataByFilter : excludedDataByFilter.concat.apply(excludedDataByFilter, __spread(excludedDataByPagination));
|
|
20974
20967
|
}
|
|
20975
20968
|
return [7 /*endfinally*/];
|
|
20976
|
-
case
|
|
20969
|
+
case 7: return [2 /*return*/];
|
|
20977
20970
|
}
|
|
20978
20971
|
});
|
|
20979
20972
|
});
|
|
@@ -20982,11 +20975,10 @@
|
|
|
20982
20975
|
var _this = this;
|
|
20983
20976
|
offset = offset >= 0 ? offset : 0;
|
|
20984
20977
|
size = size >= 0 ? size : -1;
|
|
20985
|
-
|
|
20986
|
-
|
|
20987
|
-
|
|
20988
|
-
return
|
|
20989
|
-
.pipe(operators.filter(isNotNil), operators.mergeMap(function (_) { return _this.loadAll(offset, size, sortBy, sortDirection, filterData, options); }));
|
|
20978
|
+
return this.dataSubject
|
|
20979
|
+
.pipe(
|
|
20980
|
+
// Warn if waiting value to be set
|
|
20981
|
+
operators.tap(function (data) { return !data && console.warn('[memory-data-service] Waiting value to be set...'); }), operators.filter(isNotNil), operators.mergeMap(function (_) { return _this.loadAll(offset, size, sortBy, sortDirection, filterData, options); }));
|
|
20990
20982
|
};
|
|
20991
20983
|
InMemoryEntitiesService.prototype.saveAll = function (data, options) {
|
|
20992
20984
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -20994,7 +20986,7 @@
|
|
|
20994
20986
|
return __generator(this, function (_c) {
|
|
20995
20987
|
switch (_c.label) {
|
|
20996
20988
|
case 0:
|
|
20997
|
-
if (!this.
|
|
20989
|
+
if (!this.dataSubject.value)
|
|
20998
20990
|
throw new Error('[memory-service] Could not save, because value not set');
|
|
20999
20991
|
this.markAsSaving();
|
|
21000
20992
|
_c.label = 1;
|
|
@@ -21017,9 +21009,9 @@
|
|
|
21017
21009
|
data = _b;
|
|
21018
21010
|
_c.label = 5;
|
|
21019
21011
|
case 5:
|
|
21020
|
-
this.data
|
|
21012
|
+
this.dataSubject.next(data);
|
|
21021
21013
|
this.dirty = true;
|
|
21022
|
-
return [2 /*return*/,
|
|
21014
|
+
return [2 /*return*/, data];
|
|
21023
21015
|
case 6:
|
|
21024
21016
|
this.markAsSaved();
|
|
21025
21017
|
return [7 /*endfinally*/];
|
|
@@ -21030,20 +21022,21 @@
|
|
|
21030
21022
|
};
|
|
21031
21023
|
InMemoryEntitiesService.prototype.deleteAll = function (dataToRemove, options) {
|
|
21032
21024
|
return __awaiter(this, void 0, void 0, function () {
|
|
21033
|
-
var updatedData, deleteCount;
|
|
21025
|
+
var data, updatedData, deleteCount;
|
|
21034
21026
|
var _this = this;
|
|
21035
21027
|
return __generator(this, function (_b) {
|
|
21036
|
-
|
|
21028
|
+
data = this.dataSubject.value;
|
|
21029
|
+
if (!data)
|
|
21037
21030
|
throw new Error('[memory-service] Could not delete, because value not set');
|
|
21038
|
-
updatedData =
|
|
21031
|
+
updatedData = data.filter(function (entity) {
|
|
21039
21032
|
var removed = dataToRemove.findIndex(function (entityToRemove) { return _this.equals(entityToRemove, entity); }) !== -1;
|
|
21040
21033
|
return !removed;
|
|
21041
21034
|
});
|
|
21042
|
-
deleteCount =
|
|
21035
|
+
deleteCount = data.length - updatedData.length;
|
|
21043
21036
|
if (deleteCount > 0) {
|
|
21044
|
-
|
|
21037
|
+
data = updatedData;
|
|
21045
21038
|
this.dirty = true;
|
|
21046
|
-
this.
|
|
21039
|
+
this.dataSubject.next(data);
|
|
21047
21040
|
}
|
|
21048
21041
|
return [2 /*return*/];
|
|
21049
21042
|
});
|
|
@@ -21073,7 +21066,7 @@
|
|
|
21073
21066
|
*/
|
|
21074
21067
|
get: function () {
|
|
21075
21068
|
var _a;
|
|
21076
|
-
return (((_a = this.
|
|
21069
|
+
return (((_a = this.dataSubject.value) === null || _a === void 0 ? void 0 : _a.length) || 0);
|
|
21077
21070
|
},
|
|
21078
21071
|
enumerable: false,
|
|
21079
21072
|
configurable: true
|
|
@@ -21104,9 +21097,8 @@
|
|
|
21104
21097
|
return data;
|
|
21105
21098
|
};
|
|
21106
21099
|
InMemoryEntitiesService.prototype.connect = function () {
|
|
21107
|
-
|
|
21108
|
-
|
|
21109
|
-
var data = _this.data || [];
|
|
21100
|
+
return this.dataSubject.pipe(operators.map(function (data) {
|
|
21101
|
+
data = data || [];
|
|
21110
21102
|
var total = data.length;
|
|
21111
21103
|
return { data: data, total: total };
|
|
21112
21104
|
}));
|
|
@@ -22903,7 +22895,7 @@
|
|
|
22903
22895
|
FormButtonsBarComponent.decorators = [
|
|
22904
22896
|
{ type: i0.Component, args: [{
|
|
22905
22897
|
selector: 'app-form-buttons-bar',
|
|
22906
|
-
template: "\n<ion-toolbar [class]=\"classList\">\n <ion-row class=\"ion-no-padding\" nowrap>\n <!-- show menu button -->\n <ion-col size=\"auto\" class=\"hidden-xs hidden-sm\">\n <ion-menu-toggle>\n <button\n mat-icon-button\n color=\"accent\"\n [title]=\"'COMMON.BTN_SHOW_MENU' | translate\"\n (click)=\"menu.toggleSplitPaneWhen()\">\n <mat-icon><span>»</span></mat-icon>\n </button>\n </ion-menu-toggle>\n </ion-col>\n\n <ion-col>\n <ng-content></ng-content>\n </ion-col>\n\n <ion-col size=\"auto\">\n\n <ng-content select=\"[slot=end]\"></ng-content>\n\n <!-- close (go back) -->\n <ion-button fill=\"clear\" color=\"dark\" (click)=\"onBack.emit($event)\"\n (keyup.enter)=\"onBack.emit($event)\"\n *ngIf=\"onBack.observers | isNotEmptyArray\">\n <ion-label translate>COMMON.BTN_CLOSE</ion-label>\n </ion-button>\n\n <!-- reload -->\n <ion-button fill=\"clear\" color=\"dark\" (click)=\"onCancel.emit($event)\"\n (keyup.enter)=\"onCancel.emit($event)\"\n [disabled]=\"disabledCancel\">\n <ion-icon slot=\"start\" name=\"refresh\"></ion-icon>\n <ion-label translate>COMMON.BTN_RESET</ion-label>\n </ion-button>\n\n <!-- next -->\n <ion-button fill=\"solid\" (click)=\"onNext.emit($event)\" (keyup.enter)=\"onNext.emit($event)\" *ngIf=\"onNext.observers | isNotEmptyArray\">\n <ion-label translate>COMMON.BTN_NEXT</ion-label>\n <ion-icon slot=\"end\" name=\"arrow-forward\"></ion-icon>\n </ion-button>\n\n <!-- save -->\n <ion-button [fill]=\"disabled ? 'clear' : 'solid'\"\n (click)=\"onSave.emit($event)\"\n (keyup.enter)=\"onSave.emit($event)\" color=\"danger\"\n [disabled]=\"disabled\">\n <ion-label [innerHTML]=\"'COMMON.BTN_SAVE_WITH_SHORTCUT'|translate\" [title]=\"'COMMON.BTN_SAVE_WITH_SHORTCUT_HELP'|translate\"></ion-label>\n </ion-button>\n </ion-col>\n </ion-row>\n</ion-toolbar>\n",
|
|
22898
|
+
template: "\n<ion-toolbar [class]=\"classList\">\n <ion-row class=\"ion-no-padding\" nowrap>\n <!-- show menu button -->\n <ion-col size=\"auto\" class=\"hidden-xs hidden-sm\">\n <ion-menu-toggle>\n <button\n mat-icon-button\n color=\"accent\"\n [title]=\"'COMMON.BTN_SHOW_MENU' | translate\"\n (click)=\"menu.toggleSplitPaneWhen()\">\n <mat-icon><span>»</span></mat-icon>\n </button>\n </ion-menu-toggle>\n </ion-col>\n\n <ion-col class=\"app-form-buttons-bar-content\">\n <ng-content></ng-content>\n </ion-col>\n\n <ion-col size=\"auto\">\n\n <ng-content select=\"[slot=end]\"></ng-content>\n\n <!-- close (go back) -->\n <ion-button fill=\"clear\" color=\"dark\" (click)=\"onBack.emit($event)\"\n (keyup.enter)=\"onBack.emit($event)\"\n *ngIf=\"onBack.observers | isNotEmptyArray\">\n <ion-label translate>COMMON.BTN_CLOSE</ion-label>\n </ion-button>\n\n <!-- reload -->\n <ion-button fill=\"clear\" color=\"dark\" (click)=\"onCancel.emit($event)\"\n (keyup.enter)=\"onCancel.emit($event)\"\n [disabled]=\"disabledCancel\">\n <ion-icon slot=\"start\" name=\"refresh\"></ion-icon>\n <ion-label translate>COMMON.BTN_RESET</ion-label>\n </ion-button>\n\n <!-- next -->\n <ion-button fill=\"solid\" (click)=\"onNext.emit($event)\" (keyup.enter)=\"onNext.emit($event)\" *ngIf=\"onNext.observers | isNotEmptyArray\">\n <ion-label translate>COMMON.BTN_NEXT</ion-label>\n <ion-icon slot=\"end\" name=\"arrow-forward\"></ion-icon>\n </ion-button>\n\n <!-- save -->\n <ion-button [fill]=\"disabled ? 'clear' : 'solid'\"\n (click)=\"onSave.emit($event)\"\n (keyup.enter)=\"onSave.emit($event)\" color=\"danger\"\n [disabled]=\"disabled\">\n <ion-label [innerHTML]=\"'COMMON.BTN_SAVE_WITH_SHORTCUT'|translate\" [title]=\"'COMMON.BTN_SAVE_WITH_SHORTCUT_HELP'|translate\"></ion-label>\n </ion-button>\n </ion-col>\n </ion-row>\n</ion-toolbar>\n",
|
|
22907
22899
|
providers: [
|
|
22908
22900
|
{ provide: FormButtonsBarToken, useExisting: FormButtonsBarComponent }
|
|
22909
22901
|
],
|
|
@@ -25825,8 +25817,9 @@
|
|
|
25825
25817
|
* @param config Additional configuration for table.
|
|
25826
25818
|
*/
|
|
25827
25819
|
function EntitiesTableDataSource(dataType, dataService, validatorService, options) {
|
|
25828
|
-
var _this = _super_1.call(this, [], dataType, validatorService, Object.assign({
|
|
25820
|
+
var _this = _super_1.call(this, [], dataType, validatorService, Object.assign({ keepOriginalDataAfterConfirm: false, readOnly: false, saveOnlyDirtyRows: false, dataServiceOptions: {} }, options)) || this;
|
|
25829
25821
|
_this.dataService = dataService;
|
|
25822
|
+
_this._debug = false;
|
|
25830
25823
|
_this._creating = false;
|
|
25831
25824
|
_this._saving = false;
|
|
25832
25825
|
_this._stopWatching$ = new rxjs.Subject();
|
|
@@ -25834,18 +25827,47 @@
|
|
|
25834
25827
|
_this._fetchMoreFn = null;
|
|
25835
25828
|
_this.loadingSubject = new rxjs.BehaviorSubject(undefined);
|
|
25836
25829
|
_this._entityName = removeEnd((new dataType()).__typename || 'UnknownVO', 'VO');
|
|
25830
|
+
_this._debug = (options === null || options === void 0 ? void 0 : options.suppressErrors) === false && !environment.production;
|
|
25837
25831
|
return _this;
|
|
25838
25832
|
}
|
|
25839
25833
|
Object.defineProperty(EntitiesTableDataSource.prototype, "serviceOptions", {
|
|
25834
|
+
/**
|
|
25835
|
+
* @deprecated Use watchAllOptions or saveAllOptions
|
|
25836
|
+
*/
|
|
25840
25837
|
get: function () {
|
|
25841
|
-
return this.config.dataServiceOptions
|
|
25838
|
+
return this.config.dataServiceOptions
|
|
25839
|
+
|| Object.assign(Object.assign({}, this.watchAllOptions), this.saveAllOptions);
|
|
25842
25840
|
},
|
|
25841
|
+
/**
|
|
25842
|
+
* @deprecated Use watchAllOptions or saveAllOptions
|
|
25843
|
+
*/
|
|
25843
25844
|
set: function (value) {
|
|
25845
|
+
console.warn('dataSource.serviceOptions is deprecated! Please use \'watchAllOptions\' or \'saveAllOptions\' instead');
|
|
25844
25846
|
this.config.dataServiceOptions = value;
|
|
25845
25847
|
},
|
|
25846
25848
|
enumerable: false,
|
|
25847
25849
|
configurable: true
|
|
25848
25850
|
});
|
|
25851
|
+
Object.defineProperty(EntitiesTableDataSource.prototype, "watchAllOptions", {
|
|
25852
|
+
get: function () {
|
|
25853
|
+
return this.config.watchAllOptions;
|
|
25854
|
+
},
|
|
25855
|
+
set: function (value) {
|
|
25856
|
+
this.config.watchAllOptions = value;
|
|
25857
|
+
},
|
|
25858
|
+
enumerable: false,
|
|
25859
|
+
configurable: true
|
|
25860
|
+
});
|
|
25861
|
+
Object.defineProperty(EntitiesTableDataSource.prototype, "saveAllOptions", {
|
|
25862
|
+
get: function () {
|
|
25863
|
+
return this.config.saveAllOptions;
|
|
25864
|
+
},
|
|
25865
|
+
set: function (value) {
|
|
25866
|
+
this.config.saveAllOptions = value;
|
|
25867
|
+
},
|
|
25868
|
+
enumerable: false,
|
|
25869
|
+
configurable: true
|
|
25870
|
+
});
|
|
25849
25871
|
Object.defineProperty(EntitiesTableDataSource.prototype, "loaded", {
|
|
25850
25872
|
get: function () {
|
|
25851
25873
|
return this.loadingSubject.value === false; // Should be false when undefined (initial state)
|
|
@@ -25911,8 +25933,8 @@
|
|
|
25911
25933
|
return __generator(this, function (_b) {
|
|
25912
25934
|
switch (_b.label) {
|
|
25913
25935
|
case 0:
|
|
25914
|
-
if (
|
|
25915
|
-
console.error('[table-datasource] Enable to save, because
|
|
25936
|
+
if (this.config.readOnly) {
|
|
25937
|
+
console.error('[table-datasource] Enable to save, because config.readOnly=true');
|
|
25916
25938
|
return [2 /*return*/, false];
|
|
25917
25939
|
}
|
|
25918
25940
|
// Saving twice (should never occur)
|
|
@@ -25922,18 +25944,18 @@
|
|
|
25922
25944
|
}
|
|
25923
25945
|
this._saving = true;
|
|
25924
25946
|
this.markAsLoading();
|
|
25925
|
-
onlyDirtyRows =
|
|
25947
|
+
onlyDirtyRows = this.config.saveOnlyDirtyRows;
|
|
25926
25948
|
_b.label = 1;
|
|
25927
25949
|
case 1:
|
|
25928
25950
|
_b.trys.push([1, 3, 4, 5]);
|
|
25929
|
-
if (this.
|
|
25930
|
-
console.debug("[table-datasource] Saving " + this._entityName + " rows... {
|
|
25951
|
+
if (this._debug)
|
|
25952
|
+
console.debug("[table-datasource] Saving " + this._entityName + " rows... {onlyDirtyRows: " + onlyDirtyRows + "}");
|
|
25931
25953
|
rows = this.getRows();
|
|
25932
25954
|
invalidRows = rows.filter(function (row) { return row.editing && !row.confirmEditCreate(); });
|
|
25933
25955
|
// Cannot finish some rows: error
|
|
25934
25956
|
if (invalidRows.length) {
|
|
25935
25957
|
// log errors
|
|
25936
|
-
if (this.
|
|
25958
|
+
if (this._debug)
|
|
25937
25959
|
invalidRows.forEach(function (row) { return AppTableUtils.logRowErrors(row, "[table-datasource] " + _this._entityName + " row #" + row.id); });
|
|
25938
25960
|
// Stop with an error
|
|
25939
25961
|
throw { code: ErrorCodes.TABLE_INVALID_ROW_ERROR, message: 'ERROR.TABLE_INVALID_ROW_ERROR' };
|
|
@@ -25961,23 +25983,23 @@
|
|
|
25961
25983
|
}
|
|
25962
25984
|
// If no data to save: exit
|
|
25963
25985
|
if (onlyDirtyRows && !dataToSave_1.length) {
|
|
25964
|
-
if (this.
|
|
25986
|
+
if (this._debug)
|
|
25965
25987
|
console.debug("[table-datasource] No " + this._entityName + " data to save. Skip");
|
|
25966
25988
|
return [2 /*return*/, false];
|
|
25967
25989
|
}
|
|
25968
|
-
if (this.
|
|
25990
|
+
if (this._debug)
|
|
25969
25991
|
console.debug("[table-datasource] Asking service to save this " + this._entityName + " data:", dataToSave_1);
|
|
25970
25992
|
return [4 /*yield*/, this.dataService.saveAll(dataToSave_1, this.serviceOptions)];
|
|
25971
25993
|
case 2:
|
|
25972
25994
|
_b.sent();
|
|
25973
|
-
if (this.
|
|
25995
|
+
if (this._debug)
|
|
25974
25996
|
console.debug("[table-datasource] Saving " + this._entityName + " data [OK]");
|
|
25975
25997
|
// 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)
|
|
25976
25998
|
this.updateDatasource(data, { emitEvent: false });
|
|
25977
25999
|
return [2 /*return*/, true];
|
|
25978
26000
|
case 3:
|
|
25979
26001
|
error_1 = _b.sent();
|
|
25980
|
-
if (this.
|
|
26002
|
+
if (this._debug)
|
|
25981
26003
|
console.error('[table-datasource] Error while saving: ' + error_1 && error_1.message || error_1);
|
|
25982
26004
|
throw error_1;
|
|
25983
26005
|
case 4:
|
|
@@ -25990,7 +26012,7 @@
|
|
|
25990
26012
|
});
|
|
25991
26013
|
};
|
|
25992
26014
|
EntitiesTableDataSource.prototype.updateDatasource = function (data, opts) {
|
|
25993
|
-
if (this.
|
|
26015
|
+
if (this._debug)
|
|
25994
26016
|
console.debug("[table-datasource] Updating datasource with data:", data);
|
|
25995
26017
|
_super_1.prototype.updateDatasource.call(this, data, opts);
|
|
25996
26018
|
if (!opts || opts.emitEvent !== false) {
|
|
@@ -33906,8 +33928,7 @@
|
|
|
33906
33928
|
if (isNil(this.data)) {
|
|
33907
33929
|
this.data = this.generateData(0, TableTestPage.maxRowCount);
|
|
33908
33930
|
}
|
|
33909
|
-
this.dataService.
|
|
33910
|
-
this.onRefresh.emit();
|
|
33931
|
+
this.dataService.value = this.data;
|
|
33911
33932
|
};
|
|
33912
33933
|
TableTestPage.prototype.fetchMore = function (event) {
|
|
33913
33934
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -33920,9 +33941,12 @@
|
|
|
33920
33941
|
case 1:
|
|
33921
33942
|
fetched = _a.sent();
|
|
33922
33943
|
if (!(fetched && (event === null || event === void 0 ? void 0 : event.target) && event.target.complete)) return [3 /*break*/, 3];
|
|
33944
|
+
// Wait end of load
|
|
33923
33945
|
return [4 /*yield*/, this.waitIdle()];
|
|
33924
33946
|
case 2:
|
|
33947
|
+
// Wait end of load
|
|
33925
33948
|
_a.sent();
|
|
33949
|
+
// Mark target event as completed (e.g. IonRefresher)
|
|
33926
33950
|
event.target.complete();
|
|
33927
33951
|
_a.label = 3;
|
|
33928
33952
|
case 3: return [2 /*return*/];
|