@sumaris-net/ngx-components 1.5.8 → 1.6.0
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 +68 -21
- 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/table.class.js +31 -6
- package/esm2015/src/app/shared/functions.js +2 -2
- package/esm2015/src/app/shared/observables.js +10 -3
- package/fesm2015/sumaris-net.ngx-components.js +61 -14
- 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/shared/observables.d.ts +2 -0
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -551,7 +551,7 @@
|
|
|
551
551
|
// Pagination (truncate if need)
|
|
552
552
|
var pageData = filteredItems;
|
|
553
553
|
if (opts) {
|
|
554
|
-
if (
|
|
554
|
+
if ((opts.offset || 0) > 0) {
|
|
555
555
|
pageData = pageData.slice(opts.offset);
|
|
556
556
|
}
|
|
557
557
|
if (isNotNil(opts.size) && pageData.length > opts.size) {
|
|
@@ -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)
|
|
@@ -24423,7 +24424,12 @@
|
|
|
24423
24424
|
rxjs.combineLatest([
|
|
24424
24425
|
_this.onStartEditingRow,
|
|
24425
24426
|
_this._destroy$
|
|
24426
|
-
])
|
|
24427
|
+
])
|
|
24428
|
+
// DEBUG
|
|
24429
|
+
//.pipe(
|
|
24430
|
+
// tap(() => console.debug('TODO stopping previous row listener'))
|
|
24431
|
+
//)
|
|
24432
|
+
), 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
24433
|
.subscribe(function () { return _this.markAsDirty(); }));
|
|
24428
24434
|
// Call datasource refresh, on each refresh events
|
|
24429
24435
|
this.registerSubscription(this.onRefresh
|
|
@@ -24892,8 +24898,10 @@
|
|
|
24892
24898
|
* @param opts Use interactive=false to avoid user interaction (e.g. user confirmation)
|
|
24893
24899
|
*/
|
|
24894
24900
|
AppTable.prototype.deleteRows = function (event, rows, opts) {
|
|
24901
|
+
var _a;
|
|
24895
24902
|
return __awaiter(this, void 0, void 0, function () {
|
|
24896
|
-
var canDelete, saved, rowsToDelete, deleteCount, err_2;
|
|
24903
|
+
var confirmed, canDelete, saved, rowsToDelete, deleteCount, err_2;
|
|
24904
|
+
var _this = this;
|
|
24897
24905
|
return __generator(this, function (_d) {
|
|
24898
24906
|
switch (_d.label) {
|
|
24899
24907
|
case 0:
|
|
@@ -24907,15 +24915,34 @@
|
|
|
24907
24915
|
return [2 /*return*/, 0];
|
|
24908
24916
|
if (this.loading || isEmptyArray(rows))
|
|
24909
24917
|
return [2 /*return*/, 0];
|
|
24918
|
+
// Make sure to keep newly created row
|
|
24919
|
+
if (((_a = this.editedRow) === null || _a === void 0 ? void 0 : _a.id) === -1 && this.editedRow.editing && !rows.includes(this.editedRow)) {
|
|
24920
|
+
confirmed = this.confirmEditCreate();
|
|
24921
|
+
if (!confirmed)
|
|
24922
|
+
return [2 /*return*/, 0]; // Cannot delete (e.g. edited row is invalid)
|
|
24923
|
+
}
|
|
24910
24924
|
return [4 /*yield*/, this.canDeleteRows(rows, opts)];
|
|
24911
24925
|
case 1:
|
|
24912
24926
|
canDelete = _d.sent();
|
|
24913
24927
|
if (!canDelete)
|
|
24914
24928
|
return [2 /*return*/, 0]; // Cannot delete
|
|
24915
24929
|
if (!this.saveBeforeDelete) return [3 /*break*/, 3];
|
|
24916
|
-
// Cancel invalid rows (because of save() will
|
|
24917
|
-
rows.
|
|
24918
|
-
|
|
24930
|
+
// Cancel invalid rows (because of save() will fail, if invalid rows exists)
|
|
24931
|
+
rows = rows.reduce(function (res, row) {
|
|
24932
|
+
if (row.validator && !row.validator.valid) {
|
|
24933
|
+
var deleted = row.id === -1;
|
|
24934
|
+
row.cancelOrDelete();
|
|
24935
|
+
// When deleted (= newly created row) : decrement counter
|
|
24936
|
+
if (deleted) {
|
|
24937
|
+
_this.visibleRowCount--;
|
|
24938
|
+
_this.totalRowCount--;
|
|
24939
|
+
return res;
|
|
24940
|
+
}
|
|
24941
|
+
}
|
|
24942
|
+
return res.concat(row);
|
|
24943
|
+
}, []);
|
|
24944
|
+
if (isEmptyArray(rows))
|
|
24945
|
+
return [2 /*return*/, 0];
|
|
24919
24946
|
return [4 /*yield*/, this.saveBeforeAction('delete')];
|
|
24920
24947
|
case 2:
|
|
24921
24948
|
saved = _d.sent();
|
|
@@ -24939,7 +24966,7 @@
|
|
|
24939
24966
|
return [4 /*yield*/, this._dataSource.deleteAll(rowsToDelete)];
|
|
24940
24967
|
case 5:
|
|
24941
24968
|
_d.sent();
|
|
24942
|
-
//
|
|
24969
|
+
// DO not update manually, because watchALl().subscribe() will update this count
|
|
24943
24970
|
//this.totalRowCount -= deleteCount;
|
|
24944
24971
|
//this.visibleRowCount -= deleteCount;
|
|
24945
24972
|
this.selection.clear();
|
|
@@ -25857,13 +25884,29 @@
|
|
|
25857
25884
|
this._subscription = new rxjs.Subscription();
|
|
25858
25885
|
this._enabled = false;
|
|
25859
25886
|
this._dirty = false;
|
|
25860
|
-
this._loading = true;
|
|
25861
25887
|
this._$ready = new rxjs.BehaviorSubject(false);
|
|
25888
|
+
this._$loading = new rxjs.BehaviorSubject(true);
|
|
25862
25889
|
this.debug = false;
|
|
25863
25890
|
this.submitted = false;
|
|
25864
25891
|
this.toolbar = null;
|
|
25865
25892
|
this.formButtonsBar = null;
|
|
25866
25893
|
}
|
|
25894
|
+
Object.defineProperty(AppEditor.prototype, "_loading", {
|
|
25895
|
+
/**
|
|
25896
|
+
* @deprecated
|
|
25897
|
+
*/
|
|
25898
|
+
get: function () {
|
|
25899
|
+
return this._$loading.value;
|
|
25900
|
+
},
|
|
25901
|
+
/**
|
|
25902
|
+
* @deprecated
|
|
25903
|
+
*/
|
|
25904
|
+
set: function (value) {
|
|
25905
|
+
this._$loading.next(value);
|
|
25906
|
+
},
|
|
25907
|
+
enumerable: false,
|
|
25908
|
+
configurable: true
|
|
25909
|
+
});
|
|
25867
25910
|
Object.defineProperty(AppEditor.prototype, "tables", {
|
|
25868
25911
|
get: function () {
|
|
25869
25912
|
return this._children && this._children.filter(function (c) { return c instanceof AppTable; });
|
|
@@ -25916,7 +25959,7 @@
|
|
|
25916
25959
|
Object.defineProperty(AppEditor.prototype, "loading", {
|
|
25917
25960
|
get: function () {
|
|
25918
25961
|
var _a;
|
|
25919
|
-
return this.
|
|
25962
|
+
return this._$loading.value || (((_a = this._children) === null || _a === void 0 ? void 0 : _a.findIndex(function (c) { return c.enabled && c.loading; })) !== -1) || false;
|
|
25920
25963
|
},
|
|
25921
25964
|
enumerable: false,
|
|
25922
25965
|
configurable: true
|
|
@@ -25962,6 +26005,8 @@
|
|
|
25962
26005
|
this._subscription.unsubscribe();
|
|
25963
26006
|
this._$ready.complete();
|
|
25964
26007
|
this._$ready.unsubscribe();
|
|
26008
|
+
this._$loading.complete();
|
|
26009
|
+
this._$loading.unsubscribe();
|
|
25965
26010
|
};
|
|
25966
26011
|
AppEditor.prototype.addChildForm = function (form) {
|
|
25967
26012
|
if (!form)
|
|
@@ -28726,9 +28771,11 @@
|
|
|
28726
28771
|
exports.filterNumberInput = filterNumberInput;
|
|
28727
28772
|
exports.filterTrue = filterTrue;
|
|
28728
28773
|
exports.firstArrayValue = firstArrayValue;
|
|
28774
|
+
exports.firstFalse = firstFalse;
|
|
28729
28775
|
exports.firstFalsePromise = firstFalsePromise;
|
|
28730
28776
|
exports.firstNotNil = firstNotNil;
|
|
28731
28777
|
exports.firstNotNilPromise = firstNotNilPromise;
|
|
28778
|
+
exports.firstTrue = firstTrue;
|
|
28732
28779
|
exports.firstTruePromise = firstTruePromise;
|
|
28733
28780
|
exports.focusInput = focusInput;
|
|
28734
28781
|
exports.focusNextInput = focusNextInput;
|