@sumaris-net/ngx-components 1.0.5 → 1.0.9
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 +82 -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/form.utils.js +1 -1
- package/esm2015/src/app/core/graphql/graphql.service.js +5 -2
- package/esm2015/src/app/core/services/account.service.js +17 -17
- 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/fesm2015/sumaris-net.ngx-components.js +81 -47
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/core/form/form.utils.d.ts +4 -4
- package/src/app/shared/pipes/form.pipes.d.ts +14 -3
- package/src/app/shared/pipes/translate-context.pipe.d.ts +2 -7
- 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 (isNotNilOrBlank(this.value)) {
|
|
4240
|
+
this.value = '';
|
|
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", {
|
|
@@ -15821,23 +15858,23 @@
|
|
|
15821
15858
|
};
|
|
15822
15859
|
AccountService.prototype.saveLocalSettingsRemotely = function (source) {
|
|
15823
15860
|
return __awaiter(this, void 0, void 0, function () {
|
|
15824
|
-
var account, settings,
|
|
15861
|
+
var account, settings, changed;
|
|
15825
15862
|
return __generator(this, function (_b) {
|
|
15826
15863
|
switch (_b.label) {
|
|
15827
15864
|
case 0:
|
|
15828
|
-
if (!source || !this.isLogin())
|
|
15865
|
+
if (!source || !this.isLogin() || source.accountInheritance === false)
|
|
15829
15866
|
return [2 /*return*/]; // Skip
|
|
15830
15867
|
account = this.account;
|
|
15831
15868
|
settings = exports.UserSettings.fromObject(account.settings) || new exports.UserSettings();
|
|
15832
|
-
|
|
15833
|
-
if (!
|
|
15834
|
-
|
|
15835
|
-
|
|
15869
|
+
changed = settings.merge(source, ['locale', 'latLongFormat', 'properties']);
|
|
15870
|
+
if (!changed)
|
|
15871
|
+
return [2 /*return*/]; // Skip if unchanged
|
|
15872
|
+
// Save remotely
|
|
15873
|
+
this.account.settings = settings;
|
|
15836
15874
|
return [4 /*yield*/, this.saveSettingsRemotely(settings)];
|
|
15837
15875
|
case 1:
|
|
15838
15876
|
_b.sent();
|
|
15839
|
-
|
|
15840
|
-
case 2: return [2 /*return*/];
|
|
15877
|
+
return [2 /*return*/];
|
|
15841
15878
|
}
|
|
15842
15879
|
});
|
|
15843
15880
|
});
|
|
@@ -15923,9 +15960,8 @@
|
|
|
15923
15960
|
if (this._debug)
|
|
15924
15961
|
console.debug("[account] Settings remotely saved in " + (Date.now() - now) + "ms");
|
|
15925
15962
|
// Save into account
|
|
15926
|
-
if (this.account)
|
|
15963
|
+
if (this.account)
|
|
15927
15964
|
this.account.settings = settings;
|
|
15928
|
-
}
|
|
15929
15965
|
return [2 /*return*/];
|
|
15930
15966
|
}
|
|
15931
15967
|
});
|