@sumaris-net/ngx-components 1.9.2 → 1.9.5
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 +231 -185
- 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/doc/changelog.md +8 -3
- package/esm2015/src/app/core/account/account.js +2 -2
- package/esm2015/src/app/core/form/entity-editor.class.js +18 -9
- package/esm2015/src/app/core/graphql/graphql.service.js +1 -3
- package/esm2015/src/app/core/register/confirm/confirm.js +2 -2
- package/esm2015/src/app/core/services/account.service.js +92 -63
- package/esm2015/src/app/core/table/table.class.js +4 -4
- package/esm2015/src/environments/environment.class.js +1 -1
- package/esm2015/src/environments/environment.js +8 -3
- package/fesm2015/sumaris-net.ngx-components.js +116 -75
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/core/form/entity-editor.class.d.ts +3 -2
- package/src/app/core/services/account.service.d.ts +10 -4
- package/src/environments/environment.class.d.ts +7 -1
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -10614,8 +10614,6 @@
|
|
|
10614
10614
|
defaultLocale: 'fr',
|
|
10615
10615
|
defaultLatLongFormat: 'DDMM',
|
|
10616
10616
|
apolloFetchPolicy: 'cache-first',
|
|
10617
|
-
// FIXME: GraphQL subscription never unsubscribe...
|
|
10618
|
-
listenRemoteChanges: false,
|
|
10619
10617
|
// FIXME: enable cache
|
|
10620
10618
|
persistCache: false,
|
|
10621
10619
|
// TODO: make this works
|
|
@@ -10668,6 +10666,13 @@
|
|
|
10668
10666
|
// username: 'admq2', password: 'q22006'
|
|
10669
10667
|
// Token auth (using Person.pubkey)
|
|
10670
10668
|
username: 'admin@sumaris.net', password: 'admin',
|
|
10669
|
+
},
|
|
10670
|
+
account: {
|
|
10671
|
+
enableListenChanges: true,
|
|
10672
|
+
listenIntervalInSecond: 30
|
|
10673
|
+
},
|
|
10674
|
+
entityEditor: {
|
|
10675
|
+
enableListenChanges: false
|
|
10671
10676
|
}
|
|
10672
10677
|
});
|
|
10673
10678
|
|
|
@@ -14913,8 +14918,6 @@
|
|
|
14913
14918
|
}
|
|
14914
14919
|
var headers = new i2$1.HttpHeaders()
|
|
14915
14920
|
.append('Authorization', authorization);
|
|
14916
|
-
//.append('X-App-Name', environment.name)
|
|
14917
|
-
//.append('X-App-Version', environment.version)
|
|
14918
14921
|
// Use the setContext method to set the HTTP headers.
|
|
14919
14922
|
operation.setContext(Object.assign(Object.assign({}, operation.getContext()), { headers: headers }));
|
|
14920
14923
|
// Call the next link in the middleware chain.
|
|
@@ -15443,7 +15446,7 @@
|
|
|
15443
15446
|
_this.onChange = new rxjs.Subject();
|
|
15444
15447
|
_this.onAuthTokenChange = new rxjs.Subject();
|
|
15445
15448
|
_this.onAuthBasicChange = new rxjs.Subject();
|
|
15446
|
-
_this.
|
|
15449
|
+
_this._listenChangesSubscription = null;
|
|
15447
15450
|
_this._cache = {
|
|
15448
15451
|
loaded: false,
|
|
15449
15452
|
keypair: null,
|
|
@@ -15456,6 +15459,7 @@
|
|
|
15456
15459
|
};
|
|
15457
15460
|
_this._$additionalFields = new rxjs.BehaviorSubject([]);
|
|
15458
15461
|
_this._tokenType$ = new rxjs.BehaviorSubject(undefined);
|
|
15462
|
+
_this._enableListenChanges = (!environment.account || environment.account.enableListenChanges !== false);
|
|
15459
15463
|
_this._debug = !environment.production;
|
|
15460
15464
|
if (_this._debug)
|
|
15461
15465
|
console.debug('[account-service] Creating service');
|
|
@@ -15699,6 +15703,9 @@
|
|
|
15699
15703
|
// Emit events
|
|
15700
15704
|
this.onLogin.next(this._data);
|
|
15701
15705
|
this.onChange.next(this._data);
|
|
15706
|
+
// Listen remote changes
|
|
15707
|
+
if (this._enableListenChanges)
|
|
15708
|
+
this.startListenChanges();
|
|
15702
15709
|
return [2 /*return*/, this._data];
|
|
15703
15710
|
case 6:
|
|
15704
15711
|
error_1 = _b.sent();
|
|
@@ -15853,13 +15860,16 @@
|
|
|
15853
15860
|
// Emit event to observers
|
|
15854
15861
|
this.onLogin.next(this._data);
|
|
15855
15862
|
this.onChange.next(this._data);
|
|
15863
|
+
if (this._enableListenChanges)
|
|
15864
|
+
this.startListenChanges();
|
|
15856
15865
|
return [2 /*return*/, this._data];
|
|
15857
15866
|
}
|
|
15858
15867
|
});
|
|
15859
15868
|
});
|
|
15860
15869
|
};
|
|
15861
|
-
AccountService.prototype.
|
|
15870
|
+
AccountService.prototype.reload = function () {
|
|
15862
15871
|
return __awaiter(this, void 0, void 0, function () {
|
|
15872
|
+
var now;
|
|
15863
15873
|
return __generator(this, function (_b) {
|
|
15864
15874
|
switch (_b.label) {
|
|
15865
15875
|
case 0:
|
|
@@ -15867,13 +15877,15 @@
|
|
|
15867
15877
|
throw new Error('User not logged');
|
|
15868
15878
|
if (this.network.offline)
|
|
15869
15879
|
throw new Error('Cannot check account in offline mode');
|
|
15880
|
+
now = Date.now();
|
|
15881
|
+
console.debug("[account] Reloading account...");
|
|
15870
15882
|
return [4 /*yield*/, this.loadData()];
|
|
15871
15883
|
case 1:
|
|
15872
15884
|
_b.sent();
|
|
15873
15885
|
return [4 /*yield*/, this.saveLocally()];
|
|
15874
15886
|
case 2:
|
|
15875
15887
|
_b.sent();
|
|
15876
|
-
console.debug(
|
|
15888
|
+
console.debug("[account] Reloading account [OK] in " + (Date.now() - now) + "ms");
|
|
15877
15889
|
// Emit login event to subscribers
|
|
15878
15890
|
this.onLogin.next(this._data);
|
|
15879
15891
|
this.onChange.next(this._data);
|
|
@@ -15970,7 +15982,7 @@
|
|
|
15970
15982
|
if (hadAuthBasic)
|
|
15971
15983
|
this.onAuthBasicChange.next(undefined);
|
|
15972
15984
|
this.onChange.next(undefined);
|
|
15973
|
-
this.
|
|
15985
|
+
this.stopListenChanges();
|
|
15974
15986
|
return [2 /*return*/];
|
|
15975
15987
|
}
|
|
15976
15988
|
});
|
|
@@ -16130,62 +16142,10 @@
|
|
|
16130
16142
|
});
|
|
16131
16143
|
});
|
|
16132
16144
|
};
|
|
16133
|
-
AccountService.prototype.
|
|
16134
|
-
|
|
16135
|
-
|
|
16136
|
-
|
|
16137
|
-
if (!this.started) {
|
|
16138
|
-
// Wait service ready, then loop
|
|
16139
|
-
return rxjs.from(this.ready())
|
|
16140
|
-
.pipe(operators.switchMap(function () { return _this.watch(); }));
|
|
16141
|
-
}
|
|
16142
|
-
this._stopWatching$.next(); // Stop previous listening
|
|
16143
|
-
console.debug('[account] [WS] Watching changes');
|
|
16144
|
-
return this.graphql.subscribe({
|
|
16145
|
-
query: AccountSubscriptions.listenChanges,
|
|
16146
|
-
variables: {
|
|
16147
|
-
interval: 10
|
|
16148
|
-
},
|
|
16149
|
-
error: {
|
|
16150
|
-
code: ErrorCodes$2.SUBSCRIBE_ACCOUNT_ERROR,
|
|
16151
|
-
message: 'ERROR.ACCOUNT.SUBSCRIBE_ACCOUNT_ERROR'
|
|
16152
|
-
}
|
|
16153
|
-
})
|
|
16154
|
-
.pipe(
|
|
16155
|
-
// Stop this pipe next time we call watch()
|
|
16156
|
-
operators.takeUntil(this._stopWatching$), operators.map(function (_b) {
|
|
16157
|
-
var data = _b.data;
|
|
16158
|
-
var _a;
|
|
16159
|
-
if (!data)
|
|
16160
|
-
return;
|
|
16161
|
-
var existingUpdateDate = toDateISOString((_a = _this._data) === null || _a === void 0 ? void 0 : _a.updateDate);
|
|
16162
|
-
if (existingUpdateDate === data.updateDate)
|
|
16163
|
-
return;
|
|
16164
|
-
console.debug("[account] [WS] Detected update on {" + data.updateDate + "}");
|
|
16165
|
-
return exports.Account.fromObject(data);
|
|
16166
|
-
}), operators.filter(isNotNil));
|
|
16167
|
-
};
|
|
16168
|
-
AccountService.prototype.listenChanges = function () {
|
|
16169
|
-
var self = this;
|
|
16170
|
-
var subscription = this.watch()
|
|
16171
|
-
.subscribe({
|
|
16172
|
-
next: function (data) { return self.refresh(); },
|
|
16173
|
-
error: function (err) {
|
|
16174
|
-
if (err && +err.code === ServerErrorCodes.NOT_FOUND) {
|
|
16175
|
-
console.info('[account] Account not exists anymore: force user to logout...', err);
|
|
16176
|
-
self.logout();
|
|
16177
|
-
}
|
|
16178
|
-
else if (err && +err.code === ServerErrorCodes.UNAUTHORIZED) {
|
|
16179
|
-
console.info('[account] Account not authorized: force user to logout...', err);
|
|
16180
|
-
self.logout();
|
|
16181
|
-
}
|
|
16182
|
-
else {
|
|
16183
|
-
console.warn('[account] [WS] Received error:', err);
|
|
16184
|
-
}
|
|
16185
|
-
}
|
|
16186
|
-
});
|
|
16187
|
-
subscription.add(function () { return console.debug('[account] [WS] Stop listening changes'); });
|
|
16188
|
-
return subscription;
|
|
16145
|
+
AccountService.prototype.listenChanges = function (opts) {
|
|
16146
|
+
if (this._enableListenChanges)
|
|
16147
|
+
return new rxjs.Subscription(); // Already started: skip
|
|
16148
|
+
return this.startListenChanges(opts);
|
|
16189
16149
|
};
|
|
16190
16150
|
Object.defineProperty(AccountService.prototype, "additionalFields", {
|
|
16191
16151
|
get: function () {
|
|
@@ -16215,6 +16175,7 @@
|
|
|
16215
16175
|
};
|
|
16216
16176
|
/* -- protected method -- */
|
|
16217
16177
|
AccountService.prototype.resetData = function () {
|
|
16178
|
+
this.stopListenChanges();
|
|
16218
16179
|
this._cache.loaded = false;
|
|
16219
16180
|
this._cache.keypair = null;
|
|
16220
16181
|
this._cache.authToken = null;
|
|
@@ -16365,6 +16326,8 @@
|
|
|
16365
16326
|
// Emit event
|
|
16366
16327
|
this.onLogin.next(this._data);
|
|
16367
16328
|
this.onChange.next(this._data);
|
|
16329
|
+
if (this._enableListenChanges)
|
|
16330
|
+
this.startListenChanges();
|
|
16368
16331
|
if (this._debug)
|
|
16369
16332
|
console.debug("[account] Account restoration [OK] {pubkey: " + pubkey.substr(0, 8) + "}, {profile: " + this._cache.mainProfile + "}");
|
|
16370
16333
|
return [2 /*return*/, account];
|
|
@@ -16614,6 +16577,79 @@
|
|
|
16614
16577
|
});
|
|
16615
16578
|
});
|
|
16616
16579
|
};
|
|
16580
|
+
AccountService.prototype.startListenChanges = function (opts) {
|
|
16581
|
+
var _this = this;
|
|
16582
|
+
if (this._listenChangesSubscription)
|
|
16583
|
+
this.stopListenChanges(); // Stop previous subscription
|
|
16584
|
+
if (this.network.offline)
|
|
16585
|
+
return new rxjs.Subscription(); // Offline: skip
|
|
16586
|
+
var subscription = this.watchChanges(opts)
|
|
16587
|
+
.subscribe({
|
|
16588
|
+
next: function (data) {
|
|
16589
|
+
console.debug("[account] Remote update detected at " + data.updateDate);
|
|
16590
|
+
_this.reload();
|
|
16591
|
+
},
|
|
16592
|
+
error: function (err) {
|
|
16593
|
+
if (err && +err.code === ServerErrorCodes.NOT_FOUND) {
|
|
16594
|
+
console.info('[account] [WS] Account not exists anymore: force user to logout...', err);
|
|
16595
|
+
_this.logout();
|
|
16596
|
+
}
|
|
16597
|
+
else if (err && +err.code === ServerErrorCodes.UNAUTHORIZED) {
|
|
16598
|
+
console.info('[account] [WS] Account not authorized: force user to logout...', err);
|
|
16599
|
+
_this.logout();
|
|
16600
|
+
}
|
|
16601
|
+
else {
|
|
16602
|
+
console.warn('[account] [WS] Received error:', err);
|
|
16603
|
+
}
|
|
16604
|
+
}
|
|
16605
|
+
});
|
|
16606
|
+
// Add close log
|
|
16607
|
+
subscription.add(function () { return console.debug("[account] Stop watching remote changes"); });
|
|
16608
|
+
this._listenChangesSubscription = subscription;
|
|
16609
|
+
// Make sure to use the stop function, when unsubscribe
|
|
16610
|
+
return new rxjs.Subscription(function () { return _this.stopListenChanges(); });
|
|
16611
|
+
};
|
|
16612
|
+
AccountService.prototype.stopListenChanges = function () {
|
|
16613
|
+
if (this._listenChangesSubscription) {
|
|
16614
|
+
this._listenChangesSubscription.unsubscribe();
|
|
16615
|
+
this._listenChangesSubscription = null;
|
|
16616
|
+
}
|
|
16617
|
+
};
|
|
16618
|
+
AccountService.prototype.watchChanges = function (opts) {
|
|
16619
|
+
var _this = this;
|
|
16620
|
+
var _a;
|
|
16621
|
+
if (!this.started) {
|
|
16622
|
+
// Wait service ready, then loop
|
|
16623
|
+
return rxjs.from(this.ready())
|
|
16624
|
+
.pipe(operators.switchMap(function () { return _this.watchChanges(opts); }));
|
|
16625
|
+
}
|
|
16626
|
+
if (!this._cache.pubkey)
|
|
16627
|
+
throw new Error('Not logged in');
|
|
16628
|
+
if (this.network.offline)
|
|
16629
|
+
throw new Error('Cannot watch account changes: network is offline.');
|
|
16630
|
+
var variables = {
|
|
16631
|
+
interval: Math.max(0, (opts === null || opts === void 0 ? void 0 : opts.intervalInSecond) || ((_a = this.environment.account) === null || _a === void 0 ? void 0 : _a.listenIntervalInSecond) || 0)
|
|
16632
|
+
};
|
|
16633
|
+
console.debug("[account] Watching remote changes, every " + variables.interval + "s");
|
|
16634
|
+
return this.graphql.subscribe({
|
|
16635
|
+
query: AccountSubscriptions.listenChanges,
|
|
16636
|
+
variables: variables,
|
|
16637
|
+
error: {
|
|
16638
|
+
code: ErrorCodes$2.SUBSCRIBE_ACCOUNT_ERROR,
|
|
16639
|
+
message: 'ERROR.ACCOUNT.SUBSCRIBE_ACCOUNT_ERROR'
|
|
16640
|
+
}
|
|
16641
|
+
}).pipe(operators.map(function (_b) {
|
|
16642
|
+
var data = _b.data;
|
|
16643
|
+
return data;
|
|
16644
|
+
}),
|
|
16645
|
+
// Keep only if newer
|
|
16646
|
+
operators.filter(function (data) {
|
|
16647
|
+
var _a;
|
|
16648
|
+
var currentUpdateDate = fromDateISOString((_a = _this._data) === null || _a === void 0 ? void 0 : _a.updateDate);
|
|
16649
|
+
var remoteUpdateDate = fromDateISOString(data === null || data === void 0 ? void 0 : data.updateDate);
|
|
16650
|
+
return (remoteUpdateDate && (!currentUpdateDate || !remoteUpdateDate.isSame(currentUpdateDate, 'millisecond')));
|
|
16651
|
+
}));
|
|
16652
|
+
};
|
|
16617
16653
|
AccountService.prototype.copyIdAndUpdateDate = function (source, target) {
|
|
16618
16654
|
if (!source)
|
|
16619
16655
|
return;
|
|
@@ -20903,7 +20939,7 @@
|
|
|
20903
20939
|
case 4:
|
|
20904
20940
|
confirmed = _a.sent();
|
|
20905
20941
|
if (!(confirmed && this.isLogin)) return [3 /*break*/, 6];
|
|
20906
|
-
return [4 /*yield*/, this.accountService.
|
|
20942
|
+
return [4 /*yield*/, this.accountService.reload()];
|
|
20907
20943
|
case 5:
|
|
20908
20944
|
_a.sent();
|
|
20909
20945
|
_a.label = 6;
|
|
@@ -21155,7 +21191,7 @@
|
|
|
21155
21191
|
return __generator(this, function (_b) {
|
|
21156
21192
|
this.disable();
|
|
21157
21193
|
this.markAsLoading();
|
|
21158
|
-
return [2 /*return*/, this.accountService.
|
|
21194
|
+
return [2 /*return*/, this.accountService.reload()];
|
|
21159
21195
|
});
|
|
21160
21196
|
});
|
|
21161
21197
|
};
|
|
@@ -25059,7 +25095,7 @@
|
|
|
25059
25095
|
rxjs.merge(
|
|
25060
25096
|
// Listen sort events
|
|
25061
25097
|
this.sort && this.sort.sortChange
|
|
25062
|
-
.pipe(operators.filter(function () { return !_this.sort.disabled; }), operators.mergeMap(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (
|
|
25098
|
+
.pipe(operators.filter(function () { return !_this.sort.disabled; }), operators.mergeMap(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_e) {
|
|
25063
25099
|
return [2 /*return*/, this.saveBeforeAction('sort')];
|
|
25064
25100
|
}); }); }), operators.filter(function (res) { return res === true; }),
|
|
25065
25101
|
// Save sort in settings
|
|
@@ -25070,7 +25106,7 @@
|
|
|
25070
25106
|
|| rxjs.EMPTY,
|
|
25071
25107
|
// Listen paginator events
|
|
25072
25108
|
this.paginator && this.paginator.page
|
|
25073
|
-
.pipe(operators.mergeMap(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (
|
|
25109
|
+
.pipe(operators.mergeMap(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_e) {
|
|
25074
25110
|
return [2 /*return*/, this.saveBeforeAction('sort')];
|
|
25075
25111
|
}); }); }), operators.filter(function (res) { return res === true; }),
|
|
25076
25112
|
// Save page size
|
|
@@ -25115,7 +25151,7 @@
|
|
|
25115
25151
|
};
|
|
25116
25152
|
AppTable.prototype.updateView = function (res, opts) {
|
|
25117
25153
|
return __awaiter(this, void 0, void 0, function () {
|
|
25118
|
-
return __generator(this, function (
|
|
25154
|
+
return __generator(this, function (_e) {
|
|
25119
25155
|
if (!res)
|
|
25120
25156
|
return [2 /*return*/]; // Skip (e.g error)
|
|
25121
25157
|
if (res && res.data) {
|
|
@@ -25224,8 +25260,8 @@
|
|
|
25224
25260
|
AppTable.prototype.editRowById = function (event, id, opts) {
|
|
25225
25261
|
return __awaiter(this, void 0, void 0, function () {
|
|
25226
25262
|
var row;
|
|
25227
|
-
return __generator(this, function (
|
|
25228
|
-
switch (
|
|
25263
|
+
return __generator(this, function (_e) {
|
|
25264
|
+
switch (_e.label) {
|
|
25229
25265
|
case 0:
|
|
25230
25266
|
if (id < 0)
|
|
25231
25267
|
return [2 /*return*/];
|
|
@@ -25235,9 +25271,9 @@
|
|
|
25235
25271
|
return [3 /*break*/, 3];
|
|
25236
25272
|
case 1: return [4 /*yield*/, this.dataSource.getRow(id)];
|
|
25237
25273
|
case 2:
|
|
25238
|
-
row =
|
|
25274
|
+
row = _e.sent();
|
|
25239
25275
|
this.editRow(event, row, opts);
|
|
25240
|
-
|
|
25276
|
+
_e.label = 3;
|
|
25241
25277
|
case 3: return [2 /*return*/];
|
|
25242
25278
|
}
|
|
25243
25279
|
});
|
|
@@ -25322,11 +25358,11 @@
|
|
|
25322
25358
|
return true;
|
|
25323
25359
|
};
|
|
25324
25360
|
AppTable.prototype.save = function (opts) {
|
|
25325
|
-
var _a, _b;
|
|
25361
|
+
var _a, _b, _c, _d;
|
|
25326
25362
|
return __awaiter(this, void 0, void 0, function () {
|
|
25327
25363
|
var previouslyEditedData, isOK, err_1;
|
|
25328
|
-
return __generator(this, function (
|
|
25329
|
-
switch (
|
|
25364
|
+
return __generator(this, function (_e) {
|
|
25365
|
+
switch (_e.label) {
|
|
25330
25366
|
case 0:
|
|
25331
25367
|
opts = Object.assign({ keepEditing: this.keepEditedRowOnSave }, opts);
|
|
25332
25368
|
if (this.readOnly) {
|
|
@@ -25334,27 +25370,27 @@
|
|
|
25334
25370
|
}
|
|
25335
25371
|
this.resetError();
|
|
25336
25372
|
// Keep edited row id (should be done BEFORE confirmEditCreate() )
|
|
25337
|
-
this.previouslyEditedRowId = opts.keepEditing && ((_a = this.editedRow) === null || _a === void 0 ? void 0 : _a.editing) ? this.editedRow.id : undefined;
|
|
25338
|
-
previouslyEditedData = isNotNil(this.previouslyEditedRowId) && this.editedRow.currentData || ((
|
|
25373
|
+
this.previouslyEditedRowId = opts.keepEditing && ((((_a = this.editedRow) === null || _a === void 0 ? void 0 : _a.editing) ? this.editedRow.id : undefined) || ((_b = this.singleSelectedRow) === null || _b === void 0 ? void 0 : _b.id));
|
|
25374
|
+
previouslyEditedData = isNotNil(this.previouslyEditedRowId) && ((_c = this.editedRow) === null || _c === void 0 ? void 0 : _c.currentData) || ((_d = this.singleSelectedRow) === null || _d === void 0 ? void 0 : _d.currentData);
|
|
25339
25375
|
if (!this.confirmEditCreate()) {
|
|
25340
25376
|
throw { code: ErrorCodes$2.TABLE_INVALID_ROW_ERROR, message: 'ERROR.TABLE_INVALID_ROW_ERROR' };
|
|
25341
25377
|
}
|
|
25342
25378
|
// Mark as saving
|
|
25343
25379
|
this.markAsSaving();
|
|
25344
|
-
|
|
25380
|
+
_e.label = 1;
|
|
25345
25381
|
case 1:
|
|
25346
|
-
|
|
25382
|
+
_e.trys.push([1, 3, 4, 7]);
|
|
25347
25383
|
// Calling service save()
|
|
25348
25384
|
if (this.debug)
|
|
25349
25385
|
console.debug('[table] Calling dataSource.save()...');
|
|
25350
25386
|
return [4 /*yield*/, this._dataSource.save()];
|
|
25351
25387
|
case 2:
|
|
25352
|
-
isOK =
|
|
25388
|
+
isOK = _e.sent();
|
|
25353
25389
|
if (isOK)
|
|
25354
25390
|
this.markAsPristine();
|
|
25355
25391
|
return [2 /*return*/, isOK];
|
|
25356
25392
|
case 3:
|
|
25357
|
-
err_1 =
|
|
25393
|
+
err_1 = _e.sent();
|
|
25358
25394
|
this.setError(err_1 && err_1.message || err_1);
|
|
25359
25395
|
throw err_1;
|
|
25360
25396
|
case 4:
|
|
@@ -25362,8 +25398,8 @@
|
|
|
25362
25398
|
if (!isNotNil(this.previouslyEditedRowId)) return [3 /*break*/, 6];
|
|
25363
25399
|
return [4 /*yield*/, this.selectRowByIdOrData(this.previouslyEditedRowId, previouslyEditedData)];
|
|
25364
25400
|
case 5:
|
|
25365
|
-
|
|
25366
|
-
|
|
25401
|
+
_e.sent();
|
|
25402
|
+
_e.label = 6;
|
|
25367
25403
|
case 6: return [7 /*endfinally*/];
|
|
25368
25404
|
case 7: return [2 /*return*/];
|
|
25369
25405
|
}
|
|
@@ -25388,8 +25424,8 @@
|
|
|
25388
25424
|
var _a;
|
|
25389
25425
|
return __awaiter(this, void 0, void 0, function () {
|
|
25390
25426
|
var newRow, json, newData_1;
|
|
25391
|
-
return __generator(this, function (
|
|
25392
|
-
switch (
|
|
25427
|
+
return __generator(this, function (_e) {
|
|
25428
|
+
switch (_e.label) {
|
|
25393
25429
|
case 0:
|
|
25394
25430
|
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
|
25395
25431
|
row = row || this.singleSelectedRow;
|
|
@@ -25398,7 +25434,7 @@
|
|
|
25398
25434
|
}
|
|
25399
25435
|
return [4 /*yield*/, this.addRowToTable(row.id + 1)];
|
|
25400
25436
|
case 1:
|
|
25401
|
-
newRow =
|
|
25437
|
+
newRow = _e.sent();
|
|
25402
25438
|
json = Object.assign(Object.assign({}, row.currentData), { id: null });
|
|
25403
25439
|
// Reset some properties (e.g. rankOrder, etc)
|
|
25404
25440
|
if (opts && opts.skipProperties) {
|
|
@@ -25437,8 +25473,8 @@
|
|
|
25437
25473
|
return __awaiter(this, void 0, void 0, function () {
|
|
25438
25474
|
var rows;
|
|
25439
25475
|
var _this = this;
|
|
25440
|
-
return __generator(this, function (
|
|
25441
|
-
switch (
|
|
25476
|
+
return __generator(this, function (_e) {
|
|
25477
|
+
switch (_e.label) {
|
|
25442
25478
|
case 0:
|
|
25443
25479
|
if (this.loading)
|
|
25444
25480
|
return [2 /*return*/];
|
|
@@ -25447,9 +25483,9 @@
|
|
|
25447
25483
|
return [3 /*break*/, 3];
|
|
25448
25484
|
case 1: return [4 /*yield*/, this._dataSource.getRows()];
|
|
25449
25485
|
case 2:
|
|
25450
|
-
rows =
|
|
25486
|
+
rows = _e.sent();
|
|
25451
25487
|
rows.forEach(function (row) { return _this.selection.select(row); });
|
|
25452
|
-
|
|
25488
|
+
_e.label = 3;
|
|
25453
25489
|
case 3: return [2 /*return*/];
|
|
25454
25490
|
}
|
|
25455
25491
|
});
|
|
@@ -25467,11 +25503,11 @@
|
|
|
25467
25503
|
AppTable.prototype.deleteRow = function (event, row, opts) {
|
|
25468
25504
|
return __awaiter(this, void 0, void 0, function () {
|
|
25469
25505
|
var deleteCount;
|
|
25470
|
-
return __generator(this, function (
|
|
25471
|
-
switch (
|
|
25506
|
+
return __generator(this, function (_e) {
|
|
25507
|
+
switch (_e.label) {
|
|
25472
25508
|
case 0: return [4 /*yield*/, this.deleteRows(event, [row], opts)];
|
|
25473
25509
|
case 1:
|
|
25474
|
-
deleteCount =
|
|
25510
|
+
deleteCount = _e.sent();
|
|
25475
25511
|
return [2 /*return*/, deleteCount === 1];
|
|
25476
25512
|
}
|
|
25477
25513
|
});
|
|
@@ -25488,8 +25524,8 @@
|
|
|
25488
25524
|
return __awaiter(this, void 0, void 0, function () {
|
|
25489
25525
|
var confirmed, canDelete, saved, rowsToDelete, deleteCount, err_2;
|
|
25490
25526
|
var _this = this;
|
|
25491
|
-
return __generator(this, function (
|
|
25492
|
-
switch (
|
|
25527
|
+
return __generator(this, function (_e) {
|
|
25528
|
+
switch (_e.label) {
|
|
25493
25529
|
case 0:
|
|
25494
25530
|
if (this.readOnly) {
|
|
25495
25531
|
throw { code: ErrorCodes$2.TABLE_READ_ONLY, message: 'ERROR.TABLE_READ_ONLY' };
|
|
@@ -25509,7 +25545,7 @@
|
|
|
25509
25545
|
}
|
|
25510
25546
|
return [4 /*yield*/, this.canDeleteRows(rows, opts)];
|
|
25511
25547
|
case 1:
|
|
25512
|
-
canDelete =
|
|
25548
|
+
canDelete = _e.sent();
|
|
25513
25549
|
if (!canDelete)
|
|
25514
25550
|
return [2 /*return*/, 0]; // Cannot delete
|
|
25515
25551
|
if (!this.saveBeforeDelete) return [3 /*break*/, 3];
|
|
@@ -25531,12 +25567,12 @@
|
|
|
25531
25567
|
return [2 /*return*/, 0];
|
|
25532
25568
|
return [4 /*yield*/, this.saveBeforeAction('delete')];
|
|
25533
25569
|
case 2:
|
|
25534
|
-
saved =
|
|
25570
|
+
saved = _e.sent();
|
|
25535
25571
|
if (!saved) {
|
|
25536
25572
|
// Stop if save cancelled or save failed
|
|
25537
25573
|
return [2 /*return*/];
|
|
25538
25574
|
}
|
|
25539
|
-
|
|
25575
|
+
_e.label = 3;
|
|
25540
25576
|
case 3:
|
|
25541
25577
|
if (this.debug)
|
|
25542
25578
|
console.debug('[table] Delete selection...');
|
|
@@ -25545,13 +25581,13 @@
|
|
|
25545
25581
|
// This is a workaround, need because row.delete() has async execution
|
|
25546
25582
|
// and index cache is updated with a delay)
|
|
25547
25583
|
.sort(function (a, b) { return a.id > b.id ? -1 : 1; });
|
|
25548
|
-
|
|
25584
|
+
_e.label = 4;
|
|
25549
25585
|
case 4:
|
|
25550
|
-
|
|
25586
|
+
_e.trys.push([4, 6, , 7]);
|
|
25551
25587
|
deleteCount = rowsToDelete.length;
|
|
25552
25588
|
return [4 /*yield*/, this._dataSource.deleteAll(rowsToDelete)];
|
|
25553
25589
|
case 5:
|
|
25554
|
-
|
|
25590
|
+
_e.sent();
|
|
25555
25591
|
// DO not update manually, because watchALl().subscribe() will update this count
|
|
25556
25592
|
//this.totalRowCount -= deleteCount;
|
|
25557
25593
|
//this.visibleRowCount -= deleteCount;
|
|
@@ -25562,7 +25598,7 @@
|
|
|
25562
25598
|
this.onAfterDeletedRows.next(rowsToDelete);
|
|
25563
25599
|
return [2 /*return*/, deleteCount];
|
|
25564
25600
|
case 6:
|
|
25565
|
-
err_2 =
|
|
25601
|
+
err_2 = _e.sent();
|
|
25566
25602
|
this.setError(err_2 && err_2.message || err_2);
|
|
25567
25603
|
throw err_2;
|
|
25568
25604
|
case 7: return [2 /*return*/];
|
|
@@ -25573,14 +25609,14 @@
|
|
|
25573
25609
|
AppTable.prototype.selectRowById = function (id) {
|
|
25574
25610
|
return __awaiter(this, void 0, void 0, function () {
|
|
25575
25611
|
var row;
|
|
25576
|
-
return __generator(this, function (
|
|
25577
|
-
switch (
|
|
25612
|
+
return __generator(this, function (_e) {
|
|
25613
|
+
switch (_e.label) {
|
|
25578
25614
|
case 0:
|
|
25579
25615
|
if (id === undefined)
|
|
25580
25616
|
return [2 /*return*/, false];
|
|
25581
25617
|
return [4 /*yield*/, this.waitIdle()];
|
|
25582
25618
|
case 1:
|
|
25583
|
-
|
|
25619
|
+
_e.sent();
|
|
25584
25620
|
row = this.dataSource.getRow(id);
|
|
25585
25621
|
return [2 /*return*/, this.clickRow(null, row)];
|
|
25586
25622
|
}
|
|
@@ -25595,17 +25631,17 @@
|
|
|
25595
25631
|
return __awaiter(this, void 0, void 0, function () {
|
|
25596
25632
|
var row;
|
|
25597
25633
|
var _this = this;
|
|
25598
|
-
return __generator(this, function (
|
|
25599
|
-
switch (
|
|
25634
|
+
return __generator(this, function (_e) {
|
|
25635
|
+
switch (_e.label) {
|
|
25600
25636
|
case 0:
|
|
25601
25637
|
if (data === undefined)
|
|
25602
25638
|
return [2 /*return*/, Promise.resolve(false)];
|
|
25603
25639
|
return [4 /*yield*/, this.waitIdle()];
|
|
25604
25640
|
case 1:
|
|
25605
|
-
|
|
25641
|
+
_e.sent();
|
|
25606
25642
|
return [4 /*yield*/, this.dataSource.getRows()];
|
|
25607
25643
|
case 2:
|
|
25608
|
-
row = ((
|
|
25644
|
+
row = ((_e.sent()) || [])
|
|
25609
25645
|
.find(function (row) { return _this.equals(row.currentData, data); });
|
|
25610
25646
|
return [2 /*return*/, row && this.clickRow(null, row)];
|
|
25611
25647
|
}
|
|
@@ -25647,11 +25683,11 @@
|
|
|
25647
25683
|
};
|
|
25648
25684
|
AppTable.prototype.ready = function () {
|
|
25649
25685
|
return __awaiter(this, void 0, void 0, function () {
|
|
25650
|
-
return __generator(this, function (
|
|
25651
|
-
switch (
|
|
25686
|
+
return __generator(this, function (_e) {
|
|
25687
|
+
switch (_e.label) {
|
|
25652
25688
|
case 0: return [4 /*yield*/, firstTruePromise(this.readySubject)];
|
|
25653
25689
|
case 1:
|
|
25654
|
-
|
|
25690
|
+
_e.sent();
|
|
25655
25691
|
return [2 /*return*/];
|
|
25656
25692
|
}
|
|
25657
25693
|
});
|
|
@@ -25659,11 +25695,11 @@
|
|
|
25659
25695
|
};
|
|
25660
25696
|
AppTable.prototype.waitIdle = function (opts) {
|
|
25661
25697
|
return __awaiter(this, void 0, void 0, function () {
|
|
25662
|
-
return __generator(this, function (
|
|
25663
|
-
switch (
|
|
25698
|
+
return __generator(this, function (_e) {
|
|
25699
|
+
switch (_e.label) {
|
|
25664
25700
|
case 0: return [4 /*yield*/, firstFalsePromise(this.loadingSubject)];
|
|
25665
25701
|
case 1:
|
|
25666
|
-
|
|
25702
|
+
_e.sent();
|
|
25667
25703
|
return [2 /*return*/];
|
|
25668
25704
|
}
|
|
25669
25705
|
});
|
|
@@ -25672,28 +25708,28 @@
|
|
|
25672
25708
|
AppTable.prototype.openSelectColumnsModal = function (event) {
|
|
25673
25709
|
return __awaiter(this, void 0, void 0, function () {
|
|
25674
25710
|
var columns, hasTopModal, modal, data, userColumns;
|
|
25675
|
-
return __generator(this, function (
|
|
25676
|
-
switch (
|
|
25711
|
+
return __generator(this, function (_e) {
|
|
25712
|
+
switch (_e.label) {
|
|
25677
25713
|
case 0:
|
|
25678
25714
|
columns = this.getCurrentColumns();
|
|
25679
25715
|
return [4 /*yield*/, this.modalCtrl.getTop()];
|
|
25680
25716
|
case 1:
|
|
25681
|
-
hasTopModal = !!(
|
|
25717
|
+
hasTopModal = !!(_e.sent());
|
|
25682
25718
|
return [4 /*yield*/, this.modalCtrl.create({
|
|
25683
25719
|
component: TableSelectColumnsComponent,
|
|
25684
25720
|
componentProps: { columns: columns },
|
|
25685
25721
|
cssClass: hasTopModal && 'stack-modal'
|
|
25686
25722
|
})];
|
|
25687
25723
|
case 2:
|
|
25688
|
-
modal =
|
|
25724
|
+
modal = _e.sent();
|
|
25689
25725
|
// Open the modal
|
|
25690
25726
|
return [4 /*yield*/, modal.present()];
|
|
25691
25727
|
case 3:
|
|
25692
25728
|
// Open the modal
|
|
25693
|
-
|
|
25729
|
+
_e.sent();
|
|
25694
25730
|
return [4 /*yield*/, modal.onDidDismiss()];
|
|
25695
25731
|
case 4:
|
|
25696
|
-
data = (
|
|
25732
|
+
data = (_e.sent()).data;
|
|
25697
25733
|
if (!data)
|
|
25698
25734
|
return [2 /*return*/]; // CANCELLED
|
|
25699
25735
|
userColumns = (data || []).filter(function (c) { return c.canHide === false || c.visible; }).map(function (c) { return c.name; }) || [];
|
|
@@ -25703,7 +25739,7 @@
|
|
|
25703
25739
|
return [4 /*yield*/, this.settings.savePageSetting(this.settingsId, userColumns, SETTINGS_DISPLAY_COLUMNS)];
|
|
25704
25740
|
case 5:
|
|
25705
25741
|
// Update user settings
|
|
25706
|
-
|
|
25742
|
+
_e.sent();
|
|
25707
25743
|
return [2 /*return*/];
|
|
25708
25744
|
}
|
|
25709
25745
|
});
|
|
@@ -25718,11 +25754,11 @@
|
|
|
25718
25754
|
// When target wait for a complete (e.g. IonRefresher)
|
|
25719
25755
|
if ((event === null || event === void 0 ? void 0 : event.target) && event.target.complete) {
|
|
25720
25756
|
setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
25721
|
-
return __generator(this, function (
|
|
25722
|
-
switch (
|
|
25757
|
+
return __generator(this, function (_e) {
|
|
25758
|
+
switch (_e.label) {
|
|
25723
25759
|
case 0: return [4 /*yield*/, this.waitIdle()];
|
|
25724
25760
|
case 1:
|
|
25725
|
-
|
|
25761
|
+
_e.sent();
|
|
25726
25762
|
event.target.complete();
|
|
25727
25763
|
return [2 /*return*/];
|
|
25728
25764
|
}
|
|
@@ -25807,33 +25843,33 @@
|
|
|
25807
25843
|
AppTable.prototype.selectRowByIdOrData = function (id, data) {
|
|
25808
25844
|
return __awaiter(this, void 0, void 0, function () {
|
|
25809
25845
|
var done, err_3;
|
|
25810
|
-
return __generator(this, function (
|
|
25811
|
-
switch (
|
|
25846
|
+
return __generator(this, function (_e) {
|
|
25847
|
+
switch (_e.label) {
|
|
25812
25848
|
case 0:
|
|
25813
25849
|
done = false;
|
|
25814
|
-
|
|
25850
|
+
_e.label = 1;
|
|
25815
25851
|
case 1:
|
|
25816
|
-
|
|
25852
|
+
_e.trys.push([1, 6, , 7]);
|
|
25817
25853
|
if (!(isNotNil(id) || id !== -1)) return [3 /*break*/, 3];
|
|
25818
25854
|
return [4 /*yield*/, this.selectRowById(id)];
|
|
25819
25855
|
case 2:
|
|
25820
|
-
done =
|
|
25856
|
+
done = _e.sent();
|
|
25821
25857
|
if (done)
|
|
25822
25858
|
return [2 /*return*/, true];
|
|
25823
25859
|
console.warn('[app-table] Save: Cannot reselect row by row.id: ', id);
|
|
25824
|
-
|
|
25860
|
+
_e.label = 3;
|
|
25825
25861
|
case 3:
|
|
25826
25862
|
if (!data) return [3 /*break*/, 5];
|
|
25827
25863
|
return [4 /*yield*/, this.selectRowByData(data)];
|
|
25828
25864
|
case 4:
|
|
25829
|
-
done =
|
|
25865
|
+
done = _e.sent();
|
|
25830
25866
|
if (done)
|
|
25831
25867
|
return [2 /*return*/, true];
|
|
25832
25868
|
console.warn('[app-table] Save: Cannot reselect row by data: ', data);
|
|
25833
|
-
|
|
25869
|
+
_e.label = 5;
|
|
25834
25870
|
case 5: return [2 /*return*/, false];
|
|
25835
25871
|
case 6:
|
|
25836
|
-
err_3 =
|
|
25872
|
+
err_3 = _e.sent();
|
|
25837
25873
|
// Log, but continue
|
|
25838
25874
|
console.error(err_3 && err_3.message || err_3);
|
|
25839
25875
|
return [2 /*return*/, false];
|
|
@@ -25856,23 +25892,23 @@
|
|
|
25856
25892
|
AppTable.prototype.canDeleteRows = function (rows, opts) {
|
|
25857
25893
|
return __awaiter(this, void 0, void 0, function () {
|
|
25858
25894
|
var canDelete, err_4;
|
|
25859
|
-
return __generator(this, function (
|
|
25860
|
-
switch (
|
|
25895
|
+
return __generator(this, function (_e) {
|
|
25896
|
+
switch (_e.label) {
|
|
25861
25897
|
case 0:
|
|
25862
25898
|
if (!(this.onBeforeDeleteRows.observers.length > 0)) return [3 /*break*/, 4];
|
|
25863
|
-
|
|
25899
|
+
_e.label = 1;
|
|
25864
25900
|
case 1:
|
|
25865
|
-
|
|
25901
|
+
_e.trys.push([1, 3, , 4]);
|
|
25866
25902
|
return [4 /*yield*/, emitPromiseEvent(this.onBeforeDeleteRows, 'canDelete', {
|
|
25867
25903
|
detail: { rows: rows }
|
|
25868
25904
|
})];
|
|
25869
25905
|
case 2:
|
|
25870
|
-
canDelete =
|
|
25906
|
+
canDelete = _e.sent();
|
|
25871
25907
|
if (!canDelete)
|
|
25872
25908
|
return [2 /*return*/, false];
|
|
25873
25909
|
return [3 /*break*/, 4];
|
|
25874
25910
|
case 3:
|
|
25875
|
-
err_4 =
|
|
25911
|
+
err_4 = _e.sent();
|
|
25876
25912
|
if (err_4 === 'CANCELLED')
|
|
25877
25913
|
return [2 /*return*/, false]; // User cancel
|
|
25878
25914
|
console.error('Error while checking if can delete rows', err_4);
|
|
@@ -25889,35 +25925,35 @@
|
|
|
25889
25925
|
};
|
|
25890
25926
|
AppTable.prototype.canCancelRows = function (rows, opts) {
|
|
25891
25927
|
return __awaiter(this, void 0, void 0, function () {
|
|
25892
|
-
var
|
|
25893
|
-
return __generator(this, function (
|
|
25894
|
-
switch (
|
|
25928
|
+
var _e, isCancel, err_5;
|
|
25929
|
+
return __generator(this, function (_f) {
|
|
25930
|
+
switch (_f.label) {
|
|
25895
25931
|
case 0:
|
|
25896
|
-
|
|
25897
|
-
if (
|
|
25932
|
+
_e = rows;
|
|
25933
|
+
if (_e) return [3 /*break*/, 2];
|
|
25898
25934
|
return [4 /*yield*/, this.dataSource.getRows()];
|
|
25899
25935
|
case 1:
|
|
25900
|
-
|
|
25901
|
-
|
|
25936
|
+
_e = (_f.sent()).filter(function (row) { var _a; return (_a = row.validator) === null || _a === void 0 ? void 0 : _a.dirty; });
|
|
25937
|
+
_f.label = 2;
|
|
25902
25938
|
case 2:
|
|
25903
25939
|
// Get dirty rows
|
|
25904
|
-
rows =
|
|
25940
|
+
rows = _e;
|
|
25905
25941
|
if (isEmptyArray(rows))
|
|
25906
25942
|
return [2 /*return*/, true]; // No dirty: OK
|
|
25907
25943
|
if (!(this.onBeforeCancelRows.observers.length > 0)) return [3 /*break*/, 6];
|
|
25908
|
-
|
|
25944
|
+
_f.label = 3;
|
|
25909
25945
|
case 3:
|
|
25910
|
-
|
|
25946
|
+
_f.trys.push([3, 5, , 6]);
|
|
25911
25947
|
return [4 /*yield*/, emitPromiseEvent(this.onBeforeCancelRows, 'canCancel', {
|
|
25912
25948
|
detail: { rows: rows }
|
|
25913
25949
|
})];
|
|
25914
25950
|
case 4:
|
|
25915
|
-
isCancel =
|
|
25951
|
+
isCancel = _f.sent();
|
|
25916
25952
|
if (!isCancel)
|
|
25917
25953
|
return [2 /*return*/, false];
|
|
25918
25954
|
return [3 /*break*/, 6];
|
|
25919
25955
|
case 5:
|
|
25920
|
-
err_5 =
|
|
25956
|
+
err_5 = _f.sent();
|
|
25921
25957
|
if (err_5 === 'CANCELLED')
|
|
25922
25958
|
return [2 /*return*/, false]; // User cancel
|
|
25923
25959
|
console.error('Error while checking if can cancel rows', err_5);
|
|
@@ -25935,8 +25971,8 @@
|
|
|
25935
25971
|
AppTable.prototype.saveBeforeAction = function (saveAction) {
|
|
25936
25972
|
return __awaiter(this, void 0, void 0, function () {
|
|
25937
25973
|
var save, confirmed, res, err_6, saved;
|
|
25938
|
-
return __generator(this, function (
|
|
25939
|
-
switch (
|
|
25974
|
+
return __generator(this, function (_e) {
|
|
25975
|
+
switch (_e.label) {
|
|
25940
25976
|
case 0:
|
|
25941
25977
|
if (!this.dirty) {
|
|
25942
25978
|
// Continue without save
|
|
@@ -25958,19 +25994,19 @@
|
|
|
25958
25994
|
confirmed = true;
|
|
25959
25995
|
if (!save) return [3 /*break*/, 4];
|
|
25960
25996
|
if (!(this.onBeforeSave.observers.length > 0)) return [3 /*break*/, 4];
|
|
25961
|
-
|
|
25997
|
+
_e.label = 1;
|
|
25962
25998
|
case 1:
|
|
25963
|
-
|
|
25999
|
+
_e.trys.push([1, 3, , 4]);
|
|
25964
26000
|
return [4 /*yield*/, emitPromiseEvent(this.onBeforeSave, 'beforeSave', {
|
|
25965
26001
|
detail: { action: saveAction, valid: this.valid }
|
|
25966
26002
|
})];
|
|
25967
26003
|
case 2:
|
|
25968
|
-
res =
|
|
26004
|
+
res = _e.sent();
|
|
25969
26005
|
confirmed = res.confirmed;
|
|
25970
26006
|
save = res.save;
|
|
25971
26007
|
return [3 /*break*/, 4];
|
|
25972
26008
|
case 3:
|
|
25973
|
-
err_6 =
|
|
26009
|
+
err_6 = _e.sent();
|
|
25974
26010
|
if (err_6 === 'CANCELLED')
|
|
25975
26011
|
return [2 /*return*/, false]; // User cancel
|
|
25976
26012
|
console.error('Error while checking if can delete rows', err_6);
|
|
@@ -25980,7 +26016,7 @@
|
|
|
25980
26016
|
if (!save) return [3 /*break*/, 6];
|
|
25981
26017
|
return [4 /*yield*/, this.save()];
|
|
25982
26018
|
case 5:
|
|
25983
|
-
saved =
|
|
26019
|
+
saved = _e.sent();
|
|
25984
26020
|
this.markAsDirty(); // Restore dirty flag
|
|
25985
26021
|
return [2 /*return*/, saved];
|
|
25986
26022
|
case 6: return [2 /*return*/, true]; // No save but continue action
|
|
@@ -25998,8 +26034,8 @@
|
|
|
25998
26034
|
*/
|
|
25999
26035
|
AppTable.prototype.openRow = function (id, row) {
|
|
26000
26036
|
return __awaiter(this, void 0, void 0, function () {
|
|
26001
|
-
return __generator(this, function (
|
|
26002
|
-
switch (
|
|
26037
|
+
return __generator(this, function (_e) {
|
|
26038
|
+
switch (_e.label) {
|
|
26003
26039
|
case 0:
|
|
26004
26040
|
if (!this.allowRowDetail) return [3 /*break*/, 2];
|
|
26005
26041
|
if (this.debug && this.dirty) {
|
|
@@ -26018,7 +26054,7 @@
|
|
|
26018
26054
|
relativeTo: this.route,
|
|
26019
26055
|
queryParams: {}
|
|
26020
26056
|
})];
|
|
26021
|
-
case 1: return [2 /*return*/,
|
|
26057
|
+
case 1: return [2 /*return*/, _e.sent()];
|
|
26022
26058
|
case 2: return [2 /*return*/, false];
|
|
26023
26059
|
}
|
|
26024
26060
|
});
|
|
@@ -26026,8 +26062,8 @@
|
|
|
26026
26062
|
};
|
|
26027
26063
|
AppTable.prototype.openNewRowDetail = function (event) {
|
|
26028
26064
|
return __awaiter(this, void 0, void 0, function () {
|
|
26029
|
-
return __generator(this, function (
|
|
26030
|
-
switch (
|
|
26065
|
+
return __generator(this, function (_e) {
|
|
26066
|
+
switch (_e.label) {
|
|
26031
26067
|
case 0:
|
|
26032
26068
|
if (!this.allowRowDetail)
|
|
26033
26069
|
return [2 /*return*/, false];
|
|
@@ -26038,7 +26074,7 @@
|
|
|
26038
26074
|
return [4 /*yield*/, this.router.navigate(['new'], {
|
|
26039
26075
|
relativeTo: this.route
|
|
26040
26076
|
})];
|
|
26041
|
-
case 1: return [2 /*return*/,
|
|
26077
|
+
case 1: return [2 /*return*/, _e.sent()];
|
|
26042
26078
|
}
|
|
26043
26079
|
});
|
|
26044
26080
|
});
|
|
@@ -26119,13 +26155,13 @@
|
|
|
26119
26155
|
};
|
|
26120
26156
|
AppTable.prototype.addRowToTable = function (insertAt) {
|
|
26121
26157
|
return __awaiter(this, void 0, void 0, function () {
|
|
26122
|
-
return __generator(this, function (
|
|
26123
|
-
switch (
|
|
26158
|
+
return __generator(this, function (_e) {
|
|
26159
|
+
switch (_e.label) {
|
|
26124
26160
|
case 0:
|
|
26125
26161
|
this.focusFirstColumn = true;
|
|
26126
26162
|
return [4 /*yield*/, this._dataSource.asyncCreateNew(insertAt)];
|
|
26127
26163
|
case 1:
|
|
26128
|
-
|
|
26164
|
+
_e.sent();
|
|
26129
26165
|
this.editedRow = this._dataSource.getRow(-1);
|
|
26130
26166
|
// Emit start editing event
|
|
26131
26167
|
this.onStartEditingRow.emit(this.editedRow);
|
|
@@ -26189,7 +26225,7 @@
|
|
|
26189
26225
|
};
|
|
26190
26226
|
AppTable.prototype.askDeleteConfirmation = function (event, rows) {
|
|
26191
26227
|
return __awaiter(this, void 0, void 0, function () {
|
|
26192
|
-
return __generator(this, function (
|
|
26228
|
+
return __generator(this, function (_e) {
|
|
26193
26229
|
if (this.undoableDeletion) {
|
|
26194
26230
|
// Special message, for undoable deletion
|
|
26195
26231
|
return [2 /*return*/, Alerts.askConfirmation((rows === null || rows === void 0 ? void 0 : rows.length) === 1 ? 'CONFIRM.DELETE_ROW' : 'CONFIRM.DELETE_ROWS', this.alertCtrl, this.translate, event)];
|
|
@@ -26201,21 +26237,21 @@
|
|
|
26201
26237
|
};
|
|
26202
26238
|
AppTable.prototype.askCancelConfirmation = function (event, rows) {
|
|
26203
26239
|
return __awaiter(this, void 0, void 0, function () {
|
|
26204
|
-
return __generator(this, function (
|
|
26240
|
+
return __generator(this, function (_e) {
|
|
26205
26241
|
return [2 /*return*/, Alerts.askConfirmation((rows === null || rows === void 0 ? void 0 : rows.length) === 1 ? 'CONFIRM.CANCEL_ROW' : 'CONFIRM.CANCEL_ROWS', this.alertCtrl, this.translate, event)];
|
|
26206
26242
|
});
|
|
26207
26243
|
});
|
|
26208
26244
|
};
|
|
26209
26245
|
AppTable.prototype.askRestoreConfirmation = function (event) {
|
|
26210
26246
|
return __awaiter(this, void 0, void 0, function () {
|
|
26211
|
-
return __generator(this, function (
|
|
26247
|
+
return __generator(this, function (_e) {
|
|
26212
26248
|
return [2 /*return*/, Alerts.askActionConfirmation(this.alertCtrl, this.translate, false, event)];
|
|
26213
26249
|
});
|
|
26214
26250
|
});
|
|
26215
26251
|
};
|
|
26216
26252
|
AppTable.prototype.showToast = function (opts) {
|
|
26217
26253
|
return __awaiter(this, void 0, void 0, function () {
|
|
26218
|
-
return __generator(this, function (
|
|
26254
|
+
return __generator(this, function (_e) {
|
|
26219
26255
|
if (!this.toastController)
|
|
26220
26256
|
throw new Error('Missing toastController in component\'s constructor');
|
|
26221
26257
|
return [2 /*return*/, Toasts.show(this.toastController, this.translate, opts)];
|
|
@@ -26310,14 +26346,14 @@
|
|
|
26310
26346
|
AppTable.prototype.checkIfPristine = function (opts) {
|
|
26311
26347
|
return __awaiter(this, void 0, void 0, function () {
|
|
26312
26348
|
var rows, pristine;
|
|
26313
|
-
return __generator(this, function (
|
|
26314
|
-
switch (
|
|
26349
|
+
return __generator(this, function (_e) {
|
|
26350
|
+
switch (_e.label) {
|
|
26315
26351
|
case 0:
|
|
26316
26352
|
if (!this.dirty)
|
|
26317
26353
|
return [2 /*return*/]; // Already pristine
|
|
26318
26354
|
return [4 /*yield*/, this._dataSource.getRows()];
|
|
26319
26355
|
case 1:
|
|
26320
|
-
rows =
|
|
26356
|
+
rows = _e.sent();
|
|
26321
26357
|
pristine = (rows || []).findIndex(function (row) { var _a; return (_a = row.validator) === null || _a === void 0 ? void 0 : _a.dirty; }) === -1;
|
|
26322
26358
|
if (pristine)
|
|
26323
26359
|
this.markAsPristine(opts);
|
|
@@ -27158,16 +27194,17 @@
|
|
|
27158
27194
|
var AppEntityEditor = /** @class */ (function (_super) {
|
|
27159
27195
|
__extends(AppEntityEditor, _super);
|
|
27160
27196
|
function AppEntityEditor(injector, dataType, dataService, options) {
|
|
27161
|
-
var _this =
|
|
27197
|
+
var _this = this;
|
|
27198
|
+
var _a;
|
|
27199
|
+
_this = _super.call(this, injector.get(i3.ActivatedRoute), injector.get(i3.Router), injector.get(i1$5.AlertController), injector.get(i1$2.TranslateService), options) || this;
|
|
27162
27200
|
_this.dataType = dataType;
|
|
27163
27201
|
_this.dataService = dataService;
|
|
27164
27202
|
_this.saving = false;
|
|
27165
|
-
_this.hasRemoteListener = false;
|
|
27166
27203
|
_this.$title = new rxjs.Subject();
|
|
27167
27204
|
_this.onUpdateView = new i0.EventEmitter();
|
|
27168
27205
|
options = Object.assign({
|
|
27169
27206
|
// Default options
|
|
27170
|
-
enableListenChanges: (injector.get(ENVIRONMENT).
|
|
27207
|
+
enableListenChanges: (((_a = injector.get(ENVIRONMENT).entityEditor) === null || _a === void 0 ? void 0 : _a.enableListenChanges) === true), pathIdAttribute: 'id', autoLoad: true, autoUpdateRoute: true, i18nPrefix: ''
|
|
27171
27208
|
}, options);
|
|
27172
27209
|
_this.settings = injector.get(LocalSettingsService);
|
|
27173
27210
|
_this.errorTranslator = injector.get(FormErrorTranslator);
|
|
@@ -27264,6 +27301,7 @@
|
|
|
27264
27301
|
};
|
|
27265
27302
|
AppEntityEditor.prototype.ngOnDestroy = function () {
|
|
27266
27303
|
_super.prototype.ngOnDestroy.call(this);
|
|
27304
|
+
this.listenRemoteSubscription = null; // already unsubscribe in the super function
|
|
27267
27305
|
this.$title.complete();
|
|
27268
27306
|
this.$title.unsubscribe();
|
|
27269
27307
|
this.onUpdateView.complete();
|
|
@@ -27360,11 +27398,10 @@
|
|
|
27360
27398
|
AppEntityEditor.prototype.startListenRemoteChanges = function () {
|
|
27361
27399
|
var _this = this;
|
|
27362
27400
|
// Skip if disable, or already listening
|
|
27363
|
-
if (this.
|
|
27401
|
+
if (this.listenRemoteSubscription || !this._enableListenChanges || this.isNewData)
|
|
27364
27402
|
return;
|
|
27365
27403
|
// Listen for changes on server
|
|
27366
|
-
this.
|
|
27367
|
-
this.registerSubscription(this.dataService.listenChanges(this.data.id)
|
|
27404
|
+
this.listenRemoteSubscription = this.dataService.listenChanges(this.data.id)
|
|
27368
27405
|
.pipe(operators.filter(isNotNil))
|
|
27369
27406
|
.subscribe(function (data) {
|
|
27370
27407
|
if (data.updateDate && data.updateDate.isAfter(_this.data.updateDate)) {
|
|
@@ -27378,8 +27415,16 @@
|
|
|
27378
27415
|
console.debug("[data-editor] Changes detected on server, at {" + data.updateDate + "}, but page is dirty: skip reloading.");
|
|
27379
27416
|
}
|
|
27380
27417
|
}
|
|
27381
|
-
})
|
|
27382
|
-
|
|
27418
|
+
});
|
|
27419
|
+
this.listenRemoteSubscription.add(function () { return _this.listenRemoteSubscription = null; });
|
|
27420
|
+
this.registerSubscription(this.listenRemoteSubscription);
|
|
27421
|
+
};
|
|
27422
|
+
AppEntityEditor.prototype.stopListenRemoteChanges = function () {
|
|
27423
|
+
if (this.listenRemoteSubscription) {
|
|
27424
|
+
this.unregisterSubscription(this.listenRemoteSubscription);
|
|
27425
|
+
this.listenRemoteSubscription.unsubscribe();
|
|
27426
|
+
this.listenRemoteSubscription = null;
|
|
27427
|
+
}
|
|
27383
27428
|
};
|
|
27384
27429
|
AppEntityEditor.prototype.updateView = function (data, opts) {
|
|
27385
27430
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -27575,7 +27620,7 @@
|
|
|
27575
27620
|
// Update the view (e.g metadata)
|
|
27576
27621
|
_b.sent();
|
|
27577
27622
|
// Subscribe to remote changes
|
|
27578
|
-
if (!this.
|
|
27623
|
+
if (!this.listenRemoteSubscription)
|
|
27579
27624
|
this.startListenRemoteChanges();
|
|
27580
27625
|
this.submitted = false;
|
|
27581
27626
|
return [2 /*return*/, true];
|
|
@@ -27773,6 +27818,7 @@
|
|
|
27773
27818
|
AppEntityEditor.prototype.unload = function () {
|
|
27774
27819
|
return __awaiter(this, void 0, void 0, function () {
|
|
27775
27820
|
return __generator(this, function (_b) {
|
|
27821
|
+
this.stopListenRemoteChanges();
|
|
27776
27822
|
this.form.reset();
|
|
27777
27823
|
this.registerForms();
|
|
27778
27824
|
this._dirty = false;
|