@sumaris-net/ngx-components 1.15.9 → 1.15.10
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 +27 -14
- 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 +4 -0
- package/esm2015/src/app/core/form/entity-editor.class.js +27 -15
- package/esm2015/src/app/core/services/base-entity-service.class.js +2 -1
- package/fesm2015/sumaris-net.ngx-components.js +26 -14
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/core/services/base-entity-service.class.d.ts +2 -1
- package/src/assets/i18n/en-US.json +3 -0
- package/src/assets/i18n/en.json +3 -0
- package/src/assets/i18n/fr.json +3 -2
|
@@ -24624,6 +24624,7 @@
|
|
|
24624
24624
|
console.debug(this._logPrefix + ("[WS] Listening for changes on " + this._logTypeName + " {" + id + "}..."));
|
|
24625
24625
|
return this.graphql.subscribe({
|
|
24626
24626
|
query: opts && opts.query || this.subscriptions.listenChanges,
|
|
24627
|
+
fetchPolicy: opts && opts.fetchPolicy || 'no-cache',
|
|
24627
24628
|
variables: variables,
|
|
24628
24629
|
error: {
|
|
24629
24630
|
code: ErrorCodes$2.SUBSCRIBE_DATA_ERROR,
|
|
@@ -27962,23 +27963,31 @@
|
|
|
27962
27963
|
AppEntityEditor.prototype.startListenRemoteChanges = function () {
|
|
27963
27964
|
var _this = this;
|
|
27964
27965
|
// Skip if disable, or already listening
|
|
27965
|
-
if (this._listenChangesSubscription || !this._enableListenChanges
|
|
27966
|
+
if (this._listenChangesSubscription || !this._enableListenChanges)
|
|
27967
|
+
return;
|
|
27968
|
+
// Skip if new or local data
|
|
27969
|
+
if (this.isNewData || EntityUtils.isLocal(this.data))
|
|
27966
27970
|
return;
|
|
27967
27971
|
// Listen for changes on server
|
|
27968
|
-
this._listenChangesSubscription = this.listenChanges(this.data.id, {
|
|
27972
|
+
this._listenChangesSubscription = this.listenChanges(this.data.id, {
|
|
27973
|
+
interval: this._listenIntervalInSeconds
|
|
27974
|
+
})
|
|
27969
27975
|
.pipe(operators.filter(isNotNil))
|
|
27970
27976
|
.subscribe(function (data) {
|
|
27971
|
-
|
|
27972
|
-
|
|
27973
|
-
|
|
27974
|
-
|
|
27975
|
-
|
|
27976
|
-
|
|
27977
|
-
|
|
27978
|
-
|
|
27979
|
-
|
|
27980
|
-
|
|
27981
|
-
|
|
27977
|
+
var isNewer = momentImported.isMoment(data.updateDate) && data.updateDate.isAfter(_this.data.updateDate);
|
|
27978
|
+
if (!isNewer)
|
|
27979
|
+
return; // Skip
|
|
27980
|
+
// Editor has no changes: reload
|
|
27981
|
+
if (!_this.dirty) {
|
|
27982
|
+
if (_this.debug)
|
|
27983
|
+
console.debug("[data-editor] Changes detected on server, at {" + data.updateDate + "}: reloading page...");
|
|
27984
|
+
_this.reload();
|
|
27985
|
+
}
|
|
27986
|
+
// Cannot reload: alert the user
|
|
27987
|
+
else {
|
|
27988
|
+
if (_this.debug)
|
|
27989
|
+
console.debug("[data-editor] Changes detected on server, at {" + data.updateDate + "}, but page is dirty: skip reloading.");
|
|
27990
|
+
_this.showToast({ message: 'ERROR.DATA_UPDATE_DATE_CHANGED', type: 'warning', showCloseButton: true });
|
|
27982
27991
|
}
|
|
27983
27992
|
});
|
|
27984
27993
|
this._listenChangesSubscription.add(function () { return _this._listenChangesSubscription = null; });
|
|
@@ -28517,7 +28526,11 @@
|
|
|
28517
28526
|
return parentUrl;
|
|
28518
28527
|
};
|
|
28519
28528
|
AppEntityEditor.prototype.listenChanges = function (id, opts) {
|
|
28520
|
-
return this.dataService.listenChanges(this.data.id,
|
|
28529
|
+
return this.dataService.listenChanges(this.data.id, Object.assign({
|
|
28530
|
+
// Make sure to skip cache, because NOT the full graph will be fetched by subscription
|
|
28531
|
+
// When a changes occur, we call reload() to force refetching the full graph
|
|
28532
|
+
fetchPolicy: 'no-cache'
|
|
28533
|
+
}, opts));
|
|
28521
28534
|
};
|
|
28522
28535
|
AppEntityEditor.prototype.markForCheck = function () {
|
|
28523
28536
|
this.cd.markForCheck();
|