@sumaris-net/ngx-components 1.0.6 → 1.0.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 +93 -46
- 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 +1 -0
- package/esm2015/src/app/core/form/entity-editor.class.js +1 -1
- package/esm2015/src/app/core/graphql/graphql.service.js +5 -2
- package/esm2015/src/app/core/services/account.service.js +9 -8
- package/esm2015/src/app/core/services/local-settings.service.js +5 -3
- package/esm2015/src/app/shared/pipes/form.pipes.js +56 -5
- package/esm2015/src/app/shared/pipes/translate-context.pipe.js +7 -28
- package/esm2015/src/app/shared/shared-routing.module.js +21 -11
- package/fesm2015/sumaris-net.ngx-components.js +93 -48
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/shared/pipes/form.pipes.d.ts +14 -3
- package/src/app/shared/pipes/translate-context.pipe.d.ts +2 -7
- package/src/app/shared/shared-routing.module.d.ts +7 -0
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -2945,39 +2945,19 @@
|
|
|
2945
2945
|
]; };
|
|
2946
2946
|
|
|
2947
2947
|
var TranslateContextPipe = /** @class */ (function () {
|
|
2948
|
-
function TranslateContextPipe(translate
|
|
2948
|
+
function TranslateContextPipe(translate) {
|
|
2949
2949
|
this.translate = translate;
|
|
2950
|
-
this._ref = _ref;
|
|
2951
|
-
this.value = '';
|
|
2952
|
-
this.lastKey = null;
|
|
2953
|
-
this.lastSuffix = null;
|
|
2954
|
-
this.lastParams = [];
|
|
2955
2950
|
}
|
|
2956
2951
|
TranslateContextPipe.prototype.transform = function (query) {
|
|
2957
2952
|
var params = [];
|
|
2958
2953
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2959
2954
|
params[_i - 1] = arguments[_i];
|
|
2960
2955
|
}
|
|
2961
|
-
if (!query || !query.length)
|
|
2956
|
+
if (!query || !query.length)
|
|
2962
2957
|
return query;
|
|
2963
|
-
}
|
|
2964
2958
|
var suffix = params && params.length ? params[0] : '';
|
|
2965
2959
|
params = suffix && params.slice(1);
|
|
2966
|
-
|
|
2967
|
-
if (equalsOrNil(query, this.lastKey)
|
|
2968
|
-
&& equals(suffix, this.lastSuffix)
|
|
2969
|
-
&& equals(params, this.lastParams)) {
|
|
2970
|
-
return this.value;
|
|
2971
|
-
}
|
|
2972
|
-
// store the query, in case it changes
|
|
2973
|
-
this.lastKey = query;
|
|
2974
|
-
// store the params, in case they change
|
|
2975
|
-
this.lastParams = params;
|
|
2976
|
-
// store the params, in case they change
|
|
2977
|
-
this.lastSuffix = suffix;
|
|
2978
|
-
// set the value
|
|
2979
|
-
this.value = this.translate.instant(query, suffix, params);
|
|
2980
|
-
return this.value;
|
|
2960
|
+
return this.translate.instant(query, suffix, params);
|
|
2981
2961
|
};
|
|
2982
2962
|
return TranslateContextPipe;
|
|
2983
2963
|
}());
|
|
@@ -2988,8 +2968,7 @@
|
|
|
2988
2968
|
},] }
|
|
2989
2969
|
];
|
|
2990
2970
|
TranslateContextPipe.ctorParameters = function () { return [
|
|
2991
|
-
{ type: TranslateContextService }
|
|
2992
|
-
{ type: i0.ChangeDetectorRef }
|
|
2971
|
+
{ type: TranslateContextService }
|
|
2993
2972
|
]; };
|
|
2994
2973
|
var TranslatablePipe = /** @class */ (function () {
|
|
2995
2974
|
function TranslatablePipe() {
|
|
@@ -4216,21 +4195,72 @@
|
|
|
4216
4195
|
]; };
|
|
4217
4196
|
|
|
4218
4197
|
var FormErrorTranslatePipe = /** @class */ (function () {
|
|
4219
|
-
function FormErrorTranslatePipe(adapter) {
|
|
4198
|
+
function FormErrorTranslatePipe(adapter, _ref) {
|
|
4220
4199
|
this.adapter = adapter;
|
|
4200
|
+
this._ref = _ref;
|
|
4201
|
+
this.value = '';
|
|
4202
|
+
this._lastForm = null;
|
|
4203
|
+
this._lastOptions = null;
|
|
4221
4204
|
}
|
|
4222
4205
|
FormErrorTranslatePipe.prototype.transform = function (form, opts) {
|
|
4223
|
-
|
|
4206
|
+
var _this = this;
|
|
4207
|
+
if (!form) {
|
|
4208
|
+
this._dispose();
|
|
4209
|
+
return '';
|
|
4210
|
+
}
|
|
4211
|
+
// if we ask another time for the same form and opts, return the last value
|
|
4212
|
+
if (form === this._lastForm && equals(opts, this._lastOptions)) {
|
|
4213
|
+
return this.value;
|
|
4214
|
+
}
|
|
4215
|
+
// store the query, in case it changes
|
|
4216
|
+
this._lastForm = form;
|
|
4217
|
+
// store the params, in case they change
|
|
4218
|
+
this._lastOptions = opts;
|
|
4219
|
+
// set the value
|
|
4220
|
+
this._updateValue(form, opts);
|
|
4221
|
+
// if there is a subscription to onLangChange, clean it
|
|
4222
|
+
this._dispose();
|
|
4223
|
+
// subscribe to onTranslationChange event, in case the translations change
|
|
4224
|
+
if (!this._onFormStatusChange) {
|
|
4225
|
+
this._onFormStatusChange = form.statusChanges.subscribe(function (status) {
|
|
4226
|
+
_this._updateValue(form, opts, status);
|
|
4227
|
+
});
|
|
4228
|
+
}
|
|
4229
|
+
return this.value;
|
|
4230
|
+
};
|
|
4231
|
+
FormErrorTranslatePipe.prototype.ngOnDestroy = function () {
|
|
4232
|
+
this._dispose();
|
|
4233
|
+
};
|
|
4234
|
+
FormErrorTranslatePipe.prototype._updateValue = function (form, opts, status) {
|
|
4235
|
+
if (status === 'INVALID' || form.invalid) {
|
|
4236
|
+
this.value = this.adapter.translateErrors(form, opts);
|
|
4237
|
+
this._ref.markForCheck();
|
|
4238
|
+
}
|
|
4239
|
+
else if (this.value !== undefined) {
|
|
4240
|
+
this.value = undefined;
|
|
4241
|
+
this._ref.markForCheck();
|
|
4242
|
+
}
|
|
4243
|
+
};
|
|
4244
|
+
/**
|
|
4245
|
+
* Clean any existing subscription to change events
|
|
4246
|
+
*/
|
|
4247
|
+
FormErrorTranslatePipe.prototype._dispose = function () {
|
|
4248
|
+
if (typeof this._onFormStatusChange !== 'undefined') {
|
|
4249
|
+
this._onFormStatusChange.unsubscribe();
|
|
4250
|
+
this._onFormStatusChange = undefined;
|
|
4251
|
+
}
|
|
4224
4252
|
};
|
|
4225
4253
|
return FormErrorTranslatePipe;
|
|
4226
4254
|
}());
|
|
4227
4255
|
FormErrorTranslatePipe.decorators = [
|
|
4228
4256
|
{ type: i0.Pipe, args: [{
|
|
4229
4257
|
name: 'translateFormError',
|
|
4258
|
+
pure: false
|
|
4230
4259
|
},] }
|
|
4231
4260
|
];
|
|
4232
4261
|
FormErrorTranslatePipe.ctorParameters = function () { return [
|
|
4233
|
-
{ type: FormErrorTranslator }
|
|
4262
|
+
{ type: FormErrorTranslator },
|
|
4263
|
+
{ type: i0.ChangeDetectorRef }
|
|
4234
4264
|
]; };
|
|
4235
4265
|
|
|
4236
4266
|
var SharedPipesModule = /** @class */ (function () {
|
|
@@ -10843,7 +10873,7 @@
|
|
|
10843
10873
|
case 2:
|
|
10844
10874
|
data = Object.assign(Object.assign({}, this._data), settings);
|
|
10845
10875
|
if (equals(data, this._data))
|
|
10846
|
-
return [2 /*return*/]; //
|
|
10876
|
+
return [2 /*return*/]; // Skip if no changes
|
|
10847
10877
|
this._data = data;
|
|
10848
10878
|
if (!(opts && opts.persistImmediate)) return [3 /*break*/, 4];
|
|
10849
10879
|
return [4 /*yield*/, this.persistLocally(true)];
|
|
@@ -10924,9 +10954,11 @@
|
|
|
10924
10954
|
if (!feature)
|
|
10925
10955
|
return; // Not found
|
|
10926
10956
|
if (typeof feature === 'string') {
|
|
10957
|
+
var lastSyncDate = feature.substring(featurePrefix.length);
|
|
10958
|
+
console.debug("[" + featureName + "] Last synchronization date: " + lastSyncDate);
|
|
10927
10959
|
return {
|
|
10928
10960
|
name: featureName,
|
|
10929
|
-
lastSyncDate:
|
|
10961
|
+
lastSyncDate: lastSyncDate
|
|
10930
10962
|
};
|
|
10931
10963
|
}
|
|
10932
10964
|
return feature;
|
|
@@ -14511,7 +14543,10 @@
|
|
|
14511
14543
|
var message = err && err.message || err;
|
|
14512
14544
|
if (typeof message === 'string' && message.trim().indexOf('{"code":') === 0) {
|
|
14513
14545
|
try {
|
|
14514
|
-
error = JSON.parse(
|
|
14546
|
+
error = JSON.parse(message
|
|
14547
|
+
// Remove special characters before parsing (e.g. SQL errors from an Oracle database)
|
|
14548
|
+
.replace('\n', ' ')
|
|
14549
|
+
.replace('\r', ''));
|
|
14515
14550
|
}
|
|
14516
14551
|
catch (parseError) {
|
|
14517
14552
|
console.error('Unable to parse error as JSON: ', parseError);
|
|
@@ -14786,7 +14821,7 @@
|
|
|
14786
14821
|
settings: core.gql(templateObject_2$4 || (templateObject_2$4 = __makeTemplateObject(["fragment UserSettingsFragment on UserSettingsVO {\n id\n locale\n latLongFormat\n content\n nonce\n updateDate\n __typename\n }"], ["fragment UserSettingsFragment on UserSettingsVO {\n id\n locale\n latLongFormat\n content\n nonce\n updateDate\n __typename\n }"])))
|
|
14787
14822
|
};
|
|
14788
14823
|
// Load account query
|
|
14789
|
-
var LoadQuery$1 = core.gql(templateObject_3$3 || (templateObject_3$3 = __makeTemplateObject(["\n query Account {\n data: account {\n ...AccountFragment\n }\n }\n ", "\n"], ["\n query Account {\n data: account {\n ...AccountFragment\n }\n }\n ", "\n"])), Fragments$1.account);
|
|
14824
|
+
var LoadQuery$1 = core.gql(templateObject_3$3 || (templateObject_3$3 = __makeTemplateObject(["\n query Account {\n data: account {\n ...AccountFragment\n }\n }\n ", "\n ", "\n"], ["\n query Account {\n data: account {\n ...AccountFragment\n }\n }\n ", "\n ", "\n"])), Fragments$1.account, Fragments$1.settings);
|
|
14790
14825
|
// Check email query
|
|
14791
14826
|
var IsEmailExistsQuery = core.gql(templateObject_4$3 || (templateObject_4$3 = __makeTemplateObject(["\n query IsEmailExists($email: String, $hash: String){\n isEmailExists(email: $email, hash: $hash)\n }\n"], ["\n query IsEmailExists($email: String, $hash: String){\n isEmailExists(email: $email, hash: $hash)\n }\n"])));
|
|
14792
14827
|
// Save (create or update) account mutation
|
|
@@ -14803,7 +14838,9 @@
|
|
|
14803
14838
|
var AuthQuery = core.gql(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n query Auth($token: String){\n authenticate(token: $token)\n }\n"], ["\n query Auth($token: String){\n authenticate(token: $token)\n }\n"])));
|
|
14804
14839
|
// New auth challenge query
|
|
14805
14840
|
var AuthChallengeQuery = core.gql(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n query AuthChallenge{\n authChallenge{\n challenge\n pubkey\n signature\n }\n }\n"], ["\n query AuthChallenge{\n authChallenge{\n challenge\n pubkey\n signature\n }\n }\n"])));
|
|
14806
|
-
var
|
|
14841
|
+
var AccountSubscriptions = {
|
|
14842
|
+
listenChanges: core.gql(templateObject_12 || (templateObject_12 = __makeTemplateObject(["subscription updateAccount($interval: Int){\n data: updateAccount(interval: $interval) {\n id\n updateDate\n }\n }"], ["subscription updateAccount($interval: Int){\n data: updateAccount(interval: $interval) {\n id\n updateDate\n }\n }"])))
|
|
14843
|
+
};
|
|
14807
14844
|
var AccountService = /** @class */ (function (_super) {
|
|
14808
14845
|
__extends(AccountService, _super);
|
|
14809
14846
|
function AccountService(cryptoService, network, graphql, settings, storage, file, environment) {
|
|
@@ -15510,9 +15547,9 @@
|
|
|
15510
15547
|
if (!this._cache.pubkey)
|
|
15511
15548
|
return rxjs.Subscription.EMPTY;
|
|
15512
15549
|
var self = this;
|
|
15513
|
-
console.debug('[account] [WS] Listening
|
|
15550
|
+
console.debug('[account] [WS] Listening changes');
|
|
15514
15551
|
var subscription = this.graphql.subscribe({
|
|
15515
|
-
query:
|
|
15552
|
+
query: AccountSubscriptions.listenChanges,
|
|
15516
15553
|
variables: {
|
|
15517
15554
|
interval: 10
|
|
15518
15555
|
},
|
|
@@ -15571,7 +15608,7 @@
|
|
|
15571
15608
|
}
|
|
15572
15609
|
});
|
|
15573
15610
|
// Add log when closing WS
|
|
15574
|
-
subscription.add(function () { return console.debug('[account] [WS] Stop listening
|
|
15611
|
+
subscription.add(function () { return console.debug('[account] [WS] Stop listening changes'); });
|
|
15575
15612
|
return subscription;
|
|
15576
15613
|
};
|
|
15577
15614
|
Object.defineProperty(AccountService.prototype, "additionalFields", {
|
|
@@ -17666,20 +17703,30 @@
|
|
|
17666
17703
|
function CustomReuseStrategy() {
|
|
17667
17704
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
17668
17705
|
}
|
|
17706
|
+
/**
|
|
17707
|
+
* Force to reuse the route when:
|
|
17708
|
+
* - path change from [/new] -> [/:id]
|
|
17709
|
+
* - or path change from [/new] -> [/new?id=:id]
|
|
17710
|
+
* @param future
|
|
17711
|
+
* @param curr
|
|
17712
|
+
*/
|
|
17669
17713
|
CustomReuseStrategy.prototype.shouldReuseRoute = function (future, curr) {
|
|
17670
17714
|
var result = _super.prototype.shouldReuseRoute.call(this, future, curr);
|
|
17671
|
-
//
|
|
17672
|
-
// - path change from [/new] -> [/:id]
|
|
17673
|
-
// - or path change from [/new] -> [/new?id=:id]
|
|
17715
|
+
// Is sam route config
|
|
17674
17716
|
if (!result && future.routeConfig && future.routeConfig === curr.routeConfig) {
|
|
17717
|
+
// Read the parameter name, where id is stored
|
|
17675
17718
|
var pathIdParam = future.routeConfig.data && future.routeConfig.data.pathIdParam || 'id';
|
|
17676
|
-
|
|
17677
|
-
|
|
17678
|
-
|
|
17679
|
-
|
|
17680
|
-
|
|
17681
|
-
|
|
17682
|
-
|
|
17719
|
+
// Read the current route id
|
|
17720
|
+
var currId = curr.params[pathIdParam] === 'new'
|
|
17721
|
+
? (curr.queryParams[pathIdParam] || curr.queryParams['id'] || 'new') // e.g. path like '/new/?id=<ID>'
|
|
17722
|
+
: curr.params[pathIdParam]; // e.g. path like '/<ID>'
|
|
17723
|
+
// Read the future route id
|
|
17724
|
+
var futureId = future.params[pathIdParam] === 'new'
|
|
17725
|
+
? (future.queryParams[pathIdParam] || future.queryParams['id'] || 'new') // e.g. path like '/new/?id=<ID>'
|
|
17726
|
+
: future.params[pathIdParam]; // e.g. path like '/<ID>'
|
|
17727
|
+
// Reuse if same ID, but never when 'new' expected
|
|
17728
|
+
return futureId !== 'new' && currId !== 'new'
|
|
17729
|
+
&& futureId === currId;
|
|
17683
17730
|
}
|
|
17684
17731
|
return result;
|
|
17685
17732
|
};
|