@sumaris-net/ngx-components 1.23.1-rc3 → 1.23.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 +53 -67
- 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/esm2015/src/app/core/table/entities-table-datasource.class.js +10 -6
- package/esm2015/src/app/core/table/table.class.js +2 -1
- package/esm2015/src/app/shared/observables.js +44 -58
- package/fesm2015/sumaris-net.ngx-components.js +53 -62
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/shared/observables.d.ts +16 -18
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -1056,32 +1056,47 @@
|
|
|
1056
1056
|
function filterNotNil(obs) {
|
|
1057
1057
|
return obs.pipe(operators.filter(isNotNil));
|
|
1058
1058
|
}
|
|
1059
|
-
function firstNotNil(obs) {
|
|
1060
|
-
return obs.pipe(operators.first(isNotNil));
|
|
1061
|
-
}
|
|
1062
1059
|
function filterTrue(obs) {
|
|
1063
1060
|
return obs.pipe(operators.filter(function (v) { return v === true; }));
|
|
1064
1061
|
}
|
|
1065
|
-
function filterFalse(obs) {
|
|
1062
|
+
function filterFalse(obs, opts) {
|
|
1066
1063
|
return obs.pipe(operators.filter(function (v) { return v === false; }));
|
|
1067
1064
|
}
|
|
1065
|
+
function decorateForFirst(obs, opts) {
|
|
1066
|
+
// Set take until notifier
|
|
1067
|
+
var takeUntil$ = (opts === null || opts === void 0 ? void 0 : opts.stop) || ((opts === null || opts === void 0 ? void 0 : opts.timeout) && rxjs.timer(opts.timeout));
|
|
1068
|
+
if (takeUntil$) {
|
|
1069
|
+
// When stop, throw an error (useful when used with a toPromise())
|
|
1070
|
+
if (opts.stopError) {
|
|
1071
|
+
return rxjs.merge(obs.pipe(operators.takeUntil(takeUntil$)), takeUntil$
|
|
1072
|
+
.pipe(operators.map(function () {
|
|
1073
|
+
throw new Error(opts.timeout ? "Timeout " + opts.timeout + "ms" : "Stop");
|
|
1074
|
+
})));
|
|
1075
|
+
}
|
|
1076
|
+
// Add a takeUntil
|
|
1077
|
+
return obs.pipe(operators.takeUntil(takeUntil$));
|
|
1078
|
+
}
|
|
1079
|
+
return obs;
|
|
1080
|
+
}
|
|
1081
|
+
function firstNotNil(obs, opts) {
|
|
1082
|
+
return decorateForFirst(obs, opts).pipe(operators.first(isNotNil));
|
|
1083
|
+
}
|
|
1084
|
+
function firstTrue(obs, opts) {
|
|
1085
|
+
return decorateForFirst(obs, opts).pipe(operators.first(function (v) { return v === true; }), operators.map(function (_) { }) // Convert to void
|
|
1086
|
+
);
|
|
1087
|
+
}
|
|
1088
|
+
function firstFalse(obs, opts) {
|
|
1089
|
+
return decorateForFirst(obs, opts).pipe(operators.first(function (v) { return v === false; }), operators.map(function (_) { }) // Convert to void
|
|
1090
|
+
);
|
|
1091
|
+
}
|
|
1068
1092
|
function firstTruePromise(obs, opts) {
|
|
1069
|
-
|
|
1070
|
-
return obs.pipe(operators.first(function (v) { return v === true; }), operators.takeUntil(rxjs.timer(opts.timeout))).toPromise();
|
|
1071
|
-
}
|
|
1072
|
-
return obs.pipe(operators.first(function (v) { return v === true; })).toPromise();
|
|
1093
|
+
return firstTrue(obs, Object.assign({ stopError: true }, opts)).toPromise();
|
|
1073
1094
|
}
|
|
1074
1095
|
function firstFalsePromise(obs, opts) {
|
|
1075
|
-
|
|
1076
|
-
return obs.pipe(operators.first(function (v) { return v === false; }), operators.takeUntil(rxjs.timer(opts.timeout))).toPromise();
|
|
1077
|
-
}
|
|
1078
|
-
return obs.pipe(operators.first(function (v) { return v === false; })).toPromise();
|
|
1096
|
+
return firstFalse(obs, Object.assign({ stopError: true }, opts)).toPromise();
|
|
1079
1097
|
}
|
|
1080
1098
|
function firstNotNilPromise(obs, opts) {
|
|
1081
|
-
|
|
1082
|
-
return firstNotNil(obs).pipe(operators.takeUntil(rxjs.timer(opts.timeout))).toPromise();
|
|
1083
|
-
}
|
|
1084
|
-
return firstNotNil(obs).toPromise();
|
|
1099
|
+
return firstNotNil(obs, Object.assign({ stopError: true }, opts)).toPromise();
|
|
1085
1100
|
}
|
|
1086
1101
|
function chainPromises(defers) {
|
|
1087
1102
|
return (defers || []).reduce(function (previous, defer) {
|
|
@@ -1098,14 +1113,6 @@
|
|
|
1098
1113
|
.then(function (jobRes) { return finalResult.concat(jobRes); }); });
|
|
1099
1114
|
}, null);
|
|
1100
1115
|
}
|
|
1101
|
-
function firstTrue(obs) {
|
|
1102
|
-
return obs.pipe(operators.first(function (value) { return value === true; }), operators.map(function (_) { }) // Convert to void
|
|
1103
|
-
);
|
|
1104
|
-
}
|
|
1105
|
-
function firstFalse(obs) {
|
|
1106
|
-
return obs.pipe(operators.first(function (value) { return value === false; }), operators.map(function (_) { }) // Convert to void
|
|
1107
|
-
);
|
|
1108
|
-
}
|
|
1109
1116
|
/**
|
|
1110
1117
|
* Wait form a predicate return true. This need to implement AppFormUtils.waitWhilePending(), AppFormUtils.waitIdle()
|
|
1111
1118
|
* @param predicate
|
|
@@ -1113,7 +1120,7 @@
|
|
|
1113
1120
|
*/
|
|
1114
1121
|
function waitFor(predicate, opts) {
|
|
1115
1122
|
return __awaiter(this, void 0, void 0, function () {
|
|
1116
|
-
var period, dueTime, wait
|
|
1123
|
+
var period, dueTime, wait$;
|
|
1117
1124
|
return __generator(this, function (_a) {
|
|
1118
1125
|
switch (_a.label) {
|
|
1119
1126
|
case 0:
|
|
@@ -1126,15 +1133,7 @@
|
|
|
1126
1133
|
// For DEBUG :
|
|
1127
1134
|
//tap(() => console.debug("Waiting form idle...", form)),
|
|
1128
1135
|
operators.filter(function (_) { return predicate(); }), operators.map(function (_) { return true; }));
|
|
1129
|
-
|
|
1130
|
-
if (opts && opts.timeout) {
|
|
1131
|
-
$timeout = rxjs.timer(opts.timeout);
|
|
1132
|
-
wait$ = rxjs.merge(wait$.pipe(operators.takeUntil($timeout)), $timeout
|
|
1133
|
-
.pipe(operators.map(function () {
|
|
1134
|
-
throw new Error("Timeout waitIdle() - after " + opts.timeout + "ms");
|
|
1135
|
-
})));
|
|
1136
|
-
}
|
|
1137
|
-
return [4 /*yield*/, firstNotNilPromise(wait$)];
|
|
1136
|
+
return [4 /*yield*/, firstNotNilPromise(wait$, opts)];
|
|
1138
1137
|
case 1:
|
|
1139
1138
|
_a.sent();
|
|
1140
1139
|
return [2 /*return*/];
|
|
@@ -1143,37 +1142,19 @@
|
|
|
1143
1142
|
});
|
|
1144
1143
|
}
|
|
1145
1144
|
function waitForTrue(observable, opts) {
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
.pipe(operators.map(function () {
|
|
1155
|
-
throw new Error("Timeout ready() - after " + opts.timeout + "ms");
|
|
1156
|
-
})))
|
|
1157
|
-
.toPromise()];
|
|
1158
|
-
}
|
|
1159
|
-
// dueTime (without timeout)
|
|
1160
|
-
if (opts && opts.dueTime > 0) {
|
|
1161
|
-
return [2 /*return*/, rxjs.timer(opts.dueTime)
|
|
1162
|
-
.pipe(operators.switchMap(function () { return firstTrue(observable); }))
|
|
1163
|
-
.toPromise()];
|
|
1164
|
-
}
|
|
1165
|
-
return [2 /*return*/, firstTrue(observable).toPromise()];
|
|
1166
|
-
});
|
|
1167
|
-
});
|
|
1145
|
+
opts = Object.assign({ stopError: true }, opts);
|
|
1146
|
+
// dueTime (without timeout)
|
|
1147
|
+
if (opts && opts.dueTime > 0) {
|
|
1148
|
+
return rxjs.timer(opts.dueTime)
|
|
1149
|
+
.pipe(operators.switchMap(function () { return firstTrue(observable, opts); }))
|
|
1150
|
+
.toPromise();
|
|
1151
|
+
}
|
|
1152
|
+
return firstTrue(observable, opts).toPromise();
|
|
1168
1153
|
}
|
|
1169
1154
|
function waitForFalse(observable, opts) {
|
|
1170
|
-
return
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
// Inverse the logic
|
|
1174
|
-
observable.pipe(operators.map(function (v) { return v === false; })), opts)];
|
|
1175
|
-
});
|
|
1176
|
-
});
|
|
1155
|
+
return waitForTrue(
|
|
1156
|
+
// Inverse the logic
|
|
1157
|
+
observable.pipe(operators.map(function (v) { return v === false; })), opts);
|
|
1177
1158
|
}
|
|
1178
1159
|
|
|
1179
1160
|
function createPromiseEventEmitter() {
|
|
@@ -25826,7 +25807,7 @@
|
|
|
25826
25807
|
* @param config Additional configuration for table.
|
|
25827
25808
|
*/
|
|
25828
25809
|
function EntitiesTableDataSource(dataType, dataService, validatorService, options) {
|
|
25829
|
-
var _this = _super_1.call(this, [], dataType, validatorService, Object.assign({ keepOriginalDataAfterConfirm: false, readOnly: false, saveOnlyDirtyRows: false
|
|
25810
|
+
var _this = _super_1.call(this, [], dataType, validatorService, Object.assign({ keepOriginalDataAfterConfirm: false, readOnly: false, saveOnlyDirtyRows: false }, options)) || this;
|
|
25830
25811
|
_this.dataService = dataService;
|
|
25831
25812
|
_this._debug = false;
|
|
25832
25813
|
_this._creating = false;
|
|
@@ -26130,9 +26111,13 @@
|
|
|
26130
26111
|
case 2:
|
|
26131
26112
|
// Call service deletion
|
|
26132
26113
|
_b.sent();
|
|
26133
|
-
rowNotDeleted =
|
|
26134
|
-
.
|
|
26135
|
-
|
|
26114
|
+
rowNotDeleted = Object.getOwnPropertyNames(rowsById)
|
|
26115
|
+
.reduce(function (res, id) {
|
|
26116
|
+
var row = rowsById[id];
|
|
26117
|
+
var present = _this.getRow(+id) === row;
|
|
26118
|
+
return present ? res.concat(row) : res;
|
|
26119
|
+
}, []);
|
|
26120
|
+
//this.getRows().filter(row => rows.includes(row));
|
|
26136
26121
|
// Apply missing deletion
|
|
26137
26122
|
if (isNotEmptyArray(rowNotDeleted)) {
|
|
26138
26123
|
console.warn("[table-datasource] Force deletion of " + rowNotDeleted.length + " rows (Is service update the cache ?)");
|
|
@@ -26938,6 +26923,7 @@
|
|
|
26938
26923
|
// Stop event
|
|
26939
26924
|
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
|
26940
26925
|
// Confirmation edition or creation
|
|
26926
|
+
//const confirmed = this.dataSource.confirmEditCreate(row);
|
|
26941
26927
|
var confirmed = row.confirmEditCreate();
|
|
26942
26928
|
if (confirmed) {
|
|
26943
26929
|
// If edit finished, forget edited row
|