@sumaris-net/ngx-components 1.23.1-rc5 → 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.
@@ -1056,32 +1056,47 @@
1056
1056
  function filterNotNil(obs) {
1057
1057
  return obs.pipe(operators.filter(isNotNil));
1058
1058
  }
1059
- function firstNotNil(obs, opts) {
1060
- if ((opts === null || opts === void 0 ? void 0 : opts.timeout) > 0) {
1061
- obs.pipe(operators.takeUntil(rxjs.timer(opts.timeout)), operators.first(isNotNil));
1062
- }
1063
- return obs.pipe(operators.first(isNotNil));
1064
- }
1065
1059
  function filterTrue(obs) {
1066
1060
  return obs.pipe(operators.filter(function (v) { return v === true; }));
1067
1061
  }
1068
- function filterFalse(obs) {
1062
+ function filterFalse(obs, opts) {
1069
1063
  return obs.pipe(operators.filter(function (v) { return v === false; }));
1070
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
+ }
1071
1092
  function firstTruePromise(obs, opts) {
1072
- if ((opts === null || opts === void 0 ? void 0 : opts.timeout) > 0) {
1073
- return obs.pipe(operators.takeUntil(rxjs.timer(opts.timeout)), operators.first(function (v) { return v === true; })).toPromise();
1074
- }
1075
- return obs.pipe(operators.first(function (v) { return v === true; })).toPromise();
1093
+ return firstTrue(obs, Object.assign({ stopError: true }, opts)).toPromise();
1076
1094
  }
1077
1095
  function firstFalsePromise(obs, opts) {
1078
- if ((opts === null || opts === void 0 ? void 0 : opts.timeout) > 0) {
1079
- return obs.pipe(operators.takeUntil(rxjs.timer(opts.timeout)), operators.first(function (v) { return v === false; })).toPromise();
1080
- }
1081
- return obs.pipe(operators.first(function (v) { return v === false; })).toPromise();
1096
+ return firstFalse(obs, Object.assign({ stopError: true }, opts)).toPromise();
1082
1097
  }
1083
1098
  function firstNotNilPromise(obs, opts) {
1084
- return firstNotNil(obs, opts).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$, $timeout;
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
- // Add timeout
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
- return __awaiter(this, void 0, void 0, function () {
1147
- var $timeout;
1148
- return __generator(this, function (_a) {
1149
- // Timeout (+ dueTime)
1150
- if (opts && opts.timeout > 0) {
1151
- $timeout = rxjs.timer(opts.timeout);
1152
- return [2 /*return*/, rxjs.merge(rxjs.timer(opts.dueTime || 0)
1153
- .pipe(operators.switchMap(function () { return firstTrue(observable); }), operators.takeUntil($timeout)), $timeout
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 __awaiter(this, void 0, void 0, function () {
1171
- return __generator(this, function (_a) {
1172
- return [2 /*return*/, waitForTrue(
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() {
@@ -26130,7 +26111,13 @@
26130
26111
  case 2:
26131
26112
  // Call service deletion
26132
26113
  _b.sent();
26133
- rowNotDeleted = this.getRows().filter(function (row) { return rows.includes(row); });
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));
26134
26121
  // Apply missing deletion
26135
26122
  if (isNotEmptyArray(rowNotDeleted)) {
26136
26123
  console.warn("[table-datasource] Force deletion of " + rowNotDeleted.length + " rows (Is service update the cache ?)");
@@ -26936,6 +26923,7 @@
26936
26923
  // Stop event
26937
26924
  event === null || event === void 0 ? void 0 : event.stopPropagation();
26938
26925
  // Confirmation edition or creation
26926
+ //const confirmed = this.dataSource.confirmEditCreate(row);
26939
26927
  var confirmed = row.confirmEditCreate();
26940
26928
  if (confirmed) {
26941
26929
  // If edit finished, forget edited row