@sumaris-net/ngx-components 1.5.9 → 1.6.1
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 +107 -22
- package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js +2 -2
- package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
- package/doc/changelog.md +4 -0
- package/esm2015/src/app/core/form/editor.class.js +17 -3
- package/esm2015/src/app/core/form/form.class.js +6 -5
- package/esm2015/src/app/core/table/entities-table-datasource.class.js +29 -1
- package/esm2015/src/app/core/table/table.class.js +26 -9
- package/esm2015/src/app/shared/observables.js +10 -3
- package/fesm2015/sumaris-net.ngx-components.js +83 -16
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/core/form/editor.class.d.ts +9 -1
- package/src/app/core/table/entities-table-datasource.class.d.ts +6 -1
- package/src/app/shared/observables.d.ts +2 -0
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -1117,6 +1117,14 @@
|
|
|
1117
1117
|
.then(function (jobRes) { return finalResult.concat(jobRes); }); });
|
|
1118
1118
|
}, null);
|
|
1119
1119
|
}
|
|
1120
|
+
function firstTrue(obs) {
|
|
1121
|
+
return obs.pipe(operators.first(function (v) { return v === true; }), operators.map(function (_) { }) // Convert to void
|
|
1122
|
+
);
|
|
1123
|
+
}
|
|
1124
|
+
function firstFalse(obs) {
|
|
1125
|
+
return obs.pipe(operators.first(function (v) { return v === false; }), operators.map(function (_) { }) // Convert to void
|
|
1126
|
+
);
|
|
1127
|
+
}
|
|
1120
1128
|
/**
|
|
1121
1129
|
* Wait form a predicate return true. This need to implement AppFormUtils.waitWhilePending(), AppFormUtils.waitIdle()
|
|
1122
1130
|
* @param predicate
|
|
@@ -1157,8 +1165,7 @@
|
|
|
1157
1165
|
return __awaiter(this, void 0, void 0, function () {
|
|
1158
1166
|
var firstTrueObservable, $timeout;
|
|
1159
1167
|
return __generator(this, function (_a) {
|
|
1160
|
-
firstTrueObservable = observable
|
|
1161
|
-
);
|
|
1168
|
+
firstTrueObservable = firstTrue(observable);
|
|
1162
1169
|
// Timeout (+ dueTime)
|
|
1163
1170
|
if (opts && opts.timeout > 0) {
|
|
1164
1171
|
$timeout = rxjs.timer(opts.timeout);
|
|
@@ -19531,6 +19538,9 @@
|
|
|
19531
19538
|
this.onSubmit.complete();
|
|
19532
19539
|
this.onSubmit.unsubscribe();
|
|
19533
19540
|
this._$ready.complete();
|
|
19541
|
+
this._$ready.unsubscribe();
|
|
19542
|
+
this._$loading.complete();
|
|
19543
|
+
this._$loading.unsubscribe();
|
|
19534
19544
|
};
|
|
19535
19545
|
AppForm.prototype.cancel = function () {
|
|
19536
19546
|
this.onCancel.emit();
|
|
@@ -19636,16 +19646,7 @@
|
|
|
19636
19646
|
* @param opts
|
|
19637
19647
|
*/
|
|
19638
19648
|
AppForm.prototype.ready = function (opts) {
|
|
19639
|
-
return
|
|
19640
|
-
return __generator(this, function (_b) {
|
|
19641
|
-
switch (_b.label) {
|
|
19642
|
-
case 0: return [4 /*yield*/, firstTruePromise(this._$ready)];
|
|
19643
|
-
case 1:
|
|
19644
|
-
_b.sent();
|
|
19645
|
-
return [2 /*return*/];
|
|
19646
|
-
}
|
|
19647
|
-
});
|
|
19648
|
-
});
|
|
19649
|
+
return waitForTrue(this._$ready, opts);
|
|
19649
19650
|
};
|
|
19650
19651
|
/**
|
|
19651
19652
|
* Wait form is idle (not loading)
|
|
@@ -23672,6 +23673,7 @@
|
|
|
23672
23673
|
_this._useValidator = false;
|
|
23673
23674
|
_this._stopWatching$ = new rxjs.Subject();
|
|
23674
23675
|
_this._editingRowCount = 0;
|
|
23676
|
+
_this._fetchMoreFn = null;
|
|
23675
23677
|
_this.loadingSubject = new rxjs.BehaviorSubject(undefined);
|
|
23676
23678
|
_this._options = Object.assign({ dataServiceOptions: {}, debug: config && config.suppressErrors === false, keepOriginalDataAfterConfirm: false }, config);
|
|
23677
23679
|
_this._useValidator = isNotNil(validatorService);
|
|
@@ -23722,6 +23724,7 @@
|
|
|
23722
23724
|
var _this = this;
|
|
23723
23725
|
this._stopWatching$.next();
|
|
23724
23726
|
this._editingRowCount = 0;
|
|
23727
|
+
this._fetchMoreFn = null;
|
|
23725
23728
|
this.markAsLoading();
|
|
23726
23729
|
return this.dataService.watchAll(offset, size, sortBy, sortDirection, filter, this.serviceOptions)
|
|
23727
23730
|
.pipe(
|
|
@@ -23735,6 +23738,7 @@
|
|
|
23735
23738
|
}
|
|
23736
23739
|
else {
|
|
23737
23740
|
_this.updateDatasource((res.data || []));
|
|
23741
|
+
_this._fetchMoreFn = res.fetchMore;
|
|
23738
23742
|
}
|
|
23739
23743
|
return res;
|
|
23740
23744
|
}));
|
|
@@ -23985,6 +23989,49 @@
|
|
|
23985
23989
|
});
|
|
23986
23990
|
});
|
|
23987
23991
|
};
|
|
23992
|
+
EntitiesTableDataSource.prototype.getData = function () {
|
|
23993
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
23994
|
+
var rows;
|
|
23995
|
+
return __generator(this, function (_a) {
|
|
23996
|
+
switch (_a.label) {
|
|
23997
|
+
case 0: return [4 /*yield*/, this.getRows()];
|
|
23998
|
+
case 1:
|
|
23999
|
+
rows = _a.sent();
|
|
24000
|
+
return [2 /*return*/, this.getDataFromRows(rows)];
|
|
24001
|
+
}
|
|
24002
|
+
});
|
|
24003
|
+
});
|
|
24004
|
+
};
|
|
24005
|
+
EntitiesTableDataSource.prototype.fetchMore = function (opts) {
|
|
24006
|
+
var _super = Object.create(null, {
|
|
24007
|
+
updateDatasource: { get: function () { return _super_1.prototype.updateDatasource; } }
|
|
24008
|
+
});
|
|
24009
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
24010
|
+
var res, existingData;
|
|
24011
|
+
return __generator(this, function (_a) {
|
|
24012
|
+
switch (_a.label) {
|
|
24013
|
+
case 0:
|
|
24014
|
+
if (!this._fetchMoreFn)
|
|
24015
|
+
return [2 /*return*/];
|
|
24016
|
+
if (this._editingRowCount > 0) {
|
|
24017
|
+
console.warn('Cannot fetch more because still editing row');
|
|
24018
|
+
return [2 /*return*/];
|
|
24019
|
+
}
|
|
24020
|
+
return [4 /*yield*/, this._fetchMoreFn()];
|
|
24021
|
+
case 1:
|
|
24022
|
+
res = _a.sent();
|
|
24023
|
+
if (isNotEmptyArray(res === null || res === void 0 ? void 0 : res.data))
|
|
24024
|
+
return [2 /*return*/];
|
|
24025
|
+
return [4 /*yield*/, this.getData()];
|
|
24026
|
+
case 2:
|
|
24027
|
+
existingData = _a.sent();
|
|
24028
|
+
_super.updateDatasource.call(this, existingData.concat.apply(existingData, __spread(res.data)), opts);
|
|
24029
|
+
this._fetchMoreFn = res.fetchMore;
|
|
24030
|
+
return [2 /*return*/];
|
|
24031
|
+
}
|
|
24032
|
+
});
|
|
24033
|
+
});
|
|
24034
|
+
};
|
|
23988
24035
|
/* -- protected method -- */
|
|
23989
24036
|
EntitiesTableDataSource.prototype.markAsLoading = function () {
|
|
23990
24037
|
if (this.loadingSubject.value !== true) {
|
|
@@ -24423,7 +24470,12 @@
|
|
|
24423
24470
|
rxjs.combineLatest([
|
|
24424
24471
|
_this.onStartEditingRow,
|
|
24425
24472
|
_this._destroy$
|
|
24426
|
-
])
|
|
24473
|
+
])
|
|
24474
|
+
// DEBUG
|
|
24475
|
+
//.pipe(
|
|
24476
|
+
// tap(() => console.debug('TODO stopping previous row listener'))
|
|
24477
|
+
//)
|
|
24478
|
+
), operators.map(function () { var _a; return (_a = row.validator) === null || _a === void 0 ? void 0 : _a.dirty; }), operators.filter(function (dirty) { return dirty === true; }), operators.first()); }))
|
|
24427
24479
|
.subscribe(function () { return _this.markAsDirty(); }));
|
|
24428
24480
|
// Call datasource refresh, on each refresh events
|
|
24429
24481
|
this.registerSubscription(this.onRefresh
|
|
@@ -24895,6 +24947,7 @@
|
|
|
24895
24947
|
var _a;
|
|
24896
24948
|
return __awaiter(this, void 0, void 0, function () {
|
|
24897
24949
|
var confirmed, canDelete, saved, rowsToDelete, deleteCount, err_2;
|
|
24950
|
+
var _this = this;
|
|
24898
24951
|
return __generator(this, function (_d) {
|
|
24899
24952
|
switch (_d.label) {
|
|
24900
24953
|
case 0:
|
|
@@ -24920,9 +24973,22 @@
|
|
|
24920
24973
|
if (!canDelete)
|
|
24921
24974
|
return [2 /*return*/, 0]; // Cannot delete
|
|
24922
24975
|
if (!this.saveBeforeDelete) return [3 /*break*/, 3];
|
|
24923
|
-
// Cancel invalid rows (because of save() will
|
|
24924
|
-
rows.
|
|
24925
|
-
|
|
24976
|
+
// Cancel invalid rows (because of save() will fail, if invalid rows exists)
|
|
24977
|
+
rows = rows.reduce(function (res, row) {
|
|
24978
|
+
if (row.validator && !row.validator.valid) {
|
|
24979
|
+
var deleted = row.id === -1;
|
|
24980
|
+
row.cancelOrDelete();
|
|
24981
|
+
// When deleted (= newly created row) : decrement counter
|
|
24982
|
+
if (deleted) {
|
|
24983
|
+
_this.visibleRowCount--;
|
|
24984
|
+
_this.totalRowCount--;
|
|
24985
|
+
return res;
|
|
24986
|
+
}
|
|
24987
|
+
}
|
|
24988
|
+
return res.concat(row);
|
|
24989
|
+
}, []);
|
|
24990
|
+
if (isEmptyArray(rows))
|
|
24991
|
+
return [2 /*return*/, 0];
|
|
24926
24992
|
return [4 /*yield*/, this.saveBeforeAction('delete')];
|
|
24927
24993
|
case 2:
|
|
24928
24994
|
saved = _d.sent();
|
|
@@ -24946,10 +25012,9 @@
|
|
|
24946
25012
|
return [4 /*yield*/, this._dataSource.deleteAll(rowsToDelete)];
|
|
24947
25013
|
case 5:
|
|
24948
25014
|
_d.sent();
|
|
24949
|
-
//
|
|
24950
|
-
//
|
|
24951
|
-
this.
|
|
24952
|
-
this.visibleRowCount -= deleteCount;
|
|
25015
|
+
// DO not update manually, because watchALl().subscribe() will update this count
|
|
25016
|
+
//this.totalRowCount -= deleteCount;
|
|
25017
|
+
//this.visibleRowCount -= deleteCount;
|
|
24953
25018
|
this.selection.clear();
|
|
24954
25019
|
this.editedRow = undefined;
|
|
24955
25020
|
this.markAsDirty({ emitEvent: false /*markForCheck() is called just after*/ });
|
|
@@ -25865,13 +25930,29 @@
|
|
|
25865
25930
|
this._subscription = new rxjs.Subscription();
|
|
25866
25931
|
this._enabled = false;
|
|
25867
25932
|
this._dirty = false;
|
|
25868
|
-
this._loading = true;
|
|
25869
25933
|
this._$ready = new rxjs.BehaviorSubject(false);
|
|
25934
|
+
this._$loading = new rxjs.BehaviorSubject(true);
|
|
25870
25935
|
this.debug = false;
|
|
25871
25936
|
this.submitted = false;
|
|
25872
25937
|
this.toolbar = null;
|
|
25873
25938
|
this.formButtonsBar = null;
|
|
25874
25939
|
}
|
|
25940
|
+
Object.defineProperty(AppEditor.prototype, "_loading", {
|
|
25941
|
+
/**
|
|
25942
|
+
* @deprecated
|
|
25943
|
+
*/
|
|
25944
|
+
get: function () {
|
|
25945
|
+
return this._$loading.value;
|
|
25946
|
+
},
|
|
25947
|
+
/**
|
|
25948
|
+
* @deprecated
|
|
25949
|
+
*/
|
|
25950
|
+
set: function (value) {
|
|
25951
|
+
this._$loading.next(value);
|
|
25952
|
+
},
|
|
25953
|
+
enumerable: false,
|
|
25954
|
+
configurable: true
|
|
25955
|
+
});
|
|
25875
25956
|
Object.defineProperty(AppEditor.prototype, "tables", {
|
|
25876
25957
|
get: function () {
|
|
25877
25958
|
return this._children && this._children.filter(function (c) { return c instanceof AppTable; });
|
|
@@ -25924,7 +26005,7 @@
|
|
|
25924
26005
|
Object.defineProperty(AppEditor.prototype, "loading", {
|
|
25925
26006
|
get: function () {
|
|
25926
26007
|
var _a;
|
|
25927
|
-
return this.
|
|
26008
|
+
return this._$loading.value || (((_a = this._children) === null || _a === void 0 ? void 0 : _a.findIndex(function (c) { return c.enabled && c.loading; })) !== -1) || false;
|
|
25928
26009
|
},
|
|
25929
26010
|
enumerable: false,
|
|
25930
26011
|
configurable: true
|
|
@@ -25970,6 +26051,8 @@
|
|
|
25970
26051
|
this._subscription.unsubscribe();
|
|
25971
26052
|
this._$ready.complete();
|
|
25972
26053
|
this._$ready.unsubscribe();
|
|
26054
|
+
this._$loading.complete();
|
|
26055
|
+
this._$loading.unsubscribe();
|
|
25973
26056
|
};
|
|
25974
26057
|
AppEditor.prototype.addChildForm = function (form) {
|
|
25975
26058
|
if (!form)
|
|
@@ -28734,9 +28817,11 @@
|
|
|
28734
28817
|
exports.filterNumberInput = filterNumberInput;
|
|
28735
28818
|
exports.filterTrue = filterTrue;
|
|
28736
28819
|
exports.firstArrayValue = firstArrayValue;
|
|
28820
|
+
exports.firstFalse = firstFalse;
|
|
28737
28821
|
exports.firstFalsePromise = firstFalsePromise;
|
|
28738
28822
|
exports.firstNotNil = firstNotNil;
|
|
28739
28823
|
exports.firstNotNilPromise = firstNotNilPromise;
|
|
28824
|
+
exports.firstTrue = firstTrue;
|
|
28740
28825
|
exports.firstTruePromise = firstTruePromise;
|
|
28741
28826
|
exports.focusInput = focusInput;
|
|
28742
28827
|
exports.focusNextInput = focusNextInput;
|