@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
|
@@ -2509,35 +2509,15 @@ TranslateContextService.ctorParameters = () => [
|
|
|
2509
2509
|
];
|
|
2510
2510
|
|
|
2511
2511
|
class TranslateContextPipe {
|
|
2512
|
-
constructor(translate
|
|
2512
|
+
constructor(translate) {
|
|
2513
2513
|
this.translate = translate;
|
|
2514
|
-
this._ref = _ref;
|
|
2515
|
-
this.value = '';
|
|
2516
|
-
this.lastKey = null;
|
|
2517
|
-
this.lastSuffix = null;
|
|
2518
|
-
this.lastParams = [];
|
|
2519
2514
|
}
|
|
2520
2515
|
transform(query, ...params) {
|
|
2521
|
-
if (!query || !query.length)
|
|
2516
|
+
if (!query || !query.length)
|
|
2522
2517
|
return query;
|
|
2523
|
-
}
|
|
2524
2518
|
const suffix = params && params.length ? params[0] : '';
|
|
2525
2519
|
params = suffix && params.slice(1);
|
|
2526
|
-
|
|
2527
|
-
if (equalsOrNil(query, this.lastKey)
|
|
2528
|
-
&& equals(suffix, this.lastSuffix)
|
|
2529
|
-
&& equals(params, this.lastParams)) {
|
|
2530
|
-
return this.value;
|
|
2531
|
-
}
|
|
2532
|
-
// store the query, in case it changes
|
|
2533
|
-
this.lastKey = query;
|
|
2534
|
-
// store the params, in case they change
|
|
2535
|
-
this.lastParams = params;
|
|
2536
|
-
// store the params, in case they change
|
|
2537
|
-
this.lastSuffix = suffix;
|
|
2538
|
-
// set the value
|
|
2539
|
-
this.value = this.translate.instant(query, suffix, params);
|
|
2540
|
-
return this.value;
|
|
2520
|
+
return this.translate.instant(query, suffix, params);
|
|
2541
2521
|
}
|
|
2542
2522
|
}
|
|
2543
2523
|
TranslateContextPipe.decorators = [
|
|
@@ -2547,8 +2527,7 @@ TranslateContextPipe.decorators = [
|
|
|
2547
2527
|
},] }
|
|
2548
2528
|
];
|
|
2549
2529
|
TranslateContextPipe.ctorParameters = () => [
|
|
2550
|
-
{ type: TranslateContextService }
|
|
2551
|
-
{ type: ChangeDetectorRef }
|
|
2530
|
+
{ type: TranslateContextService }
|
|
2552
2531
|
];
|
|
2553
2532
|
class TranslatablePipe {
|
|
2554
2533
|
transform(value) {
|
|
@@ -3675,20 +3654,70 @@ FormErrorTranslator.ctorParameters = () => [
|
|
|
3675
3654
|
];
|
|
3676
3655
|
|
|
3677
3656
|
class FormErrorTranslatePipe {
|
|
3678
|
-
constructor(adapter) {
|
|
3657
|
+
constructor(adapter, _ref) {
|
|
3679
3658
|
this.adapter = adapter;
|
|
3659
|
+
this._ref = _ref;
|
|
3660
|
+
this.value = '';
|
|
3661
|
+
this._lastForm = null;
|
|
3662
|
+
this._lastOptions = null;
|
|
3680
3663
|
}
|
|
3681
3664
|
transform(form, opts) {
|
|
3682
|
-
|
|
3665
|
+
if (!form) {
|
|
3666
|
+
this._dispose();
|
|
3667
|
+
return '';
|
|
3668
|
+
}
|
|
3669
|
+
// if we ask another time for the same form and opts, return the last value
|
|
3670
|
+
if (form === this._lastForm && equals(opts, this._lastOptions)) {
|
|
3671
|
+
return this.value;
|
|
3672
|
+
}
|
|
3673
|
+
// store the query, in case it changes
|
|
3674
|
+
this._lastForm = form;
|
|
3675
|
+
// store the params, in case they change
|
|
3676
|
+
this._lastOptions = opts;
|
|
3677
|
+
// set the value
|
|
3678
|
+
this._updateValue(form, opts);
|
|
3679
|
+
// if there is a subscription to onLangChange, clean it
|
|
3680
|
+
this._dispose();
|
|
3681
|
+
// subscribe to onTranslationChange event, in case the translations change
|
|
3682
|
+
if (!this._onFormStatusChange) {
|
|
3683
|
+
this._onFormStatusChange = form.statusChanges.subscribe((status) => {
|
|
3684
|
+
this._updateValue(form, opts, status);
|
|
3685
|
+
});
|
|
3686
|
+
}
|
|
3687
|
+
return this.value;
|
|
3688
|
+
}
|
|
3689
|
+
ngOnDestroy() {
|
|
3690
|
+
this._dispose();
|
|
3691
|
+
}
|
|
3692
|
+
_updateValue(form, opts, status) {
|
|
3693
|
+
if (status === 'INVALID' || form.invalid) {
|
|
3694
|
+
this.value = this.adapter.translateErrors(form, opts);
|
|
3695
|
+
this._ref.markForCheck();
|
|
3696
|
+
}
|
|
3697
|
+
else if (this.value !== undefined) {
|
|
3698
|
+
this.value = undefined;
|
|
3699
|
+
this._ref.markForCheck();
|
|
3700
|
+
}
|
|
3701
|
+
}
|
|
3702
|
+
/**
|
|
3703
|
+
* Clean any existing subscription to change events
|
|
3704
|
+
*/
|
|
3705
|
+
_dispose() {
|
|
3706
|
+
if (typeof this._onFormStatusChange !== 'undefined') {
|
|
3707
|
+
this._onFormStatusChange.unsubscribe();
|
|
3708
|
+
this._onFormStatusChange = undefined;
|
|
3709
|
+
}
|
|
3683
3710
|
}
|
|
3684
3711
|
}
|
|
3685
3712
|
FormErrorTranslatePipe.decorators = [
|
|
3686
3713
|
{ type: Pipe, args: [{
|
|
3687
3714
|
name: 'translateFormError',
|
|
3715
|
+
pure: false
|
|
3688
3716
|
},] }
|
|
3689
3717
|
];
|
|
3690
3718
|
FormErrorTranslatePipe.ctorParameters = () => [
|
|
3691
|
-
{ type: FormErrorTranslator }
|
|
3719
|
+
{ type: FormErrorTranslator },
|
|
3720
|
+
{ type: ChangeDetectorRef }
|
|
3692
3721
|
];
|
|
3693
3722
|
|
|
3694
3723
|
class SharedPipesModule {
|
|
@@ -9579,7 +9608,7 @@ class LocalSettingsService extends StartableService {
|
|
|
9579
9608
|
yield this.ready();
|
|
9580
9609
|
const data = Object.assign(Object.assign({}, this._data), settings);
|
|
9581
9610
|
if (equals(data, this._data))
|
|
9582
|
-
return; //
|
|
9611
|
+
return; // Skip if no changes
|
|
9583
9612
|
this._data = data;
|
|
9584
9613
|
// Save locally
|
|
9585
9614
|
if (opts && opts.persistImmediate) {
|
|
@@ -9642,9 +9671,11 @@ class LocalSettingsService extends StartableService {
|
|
|
9642
9671
|
if (!feature)
|
|
9643
9672
|
return; // Not found
|
|
9644
9673
|
if (typeof feature === 'string') {
|
|
9674
|
+
const lastSyncDate = feature.substring(featurePrefix.length);
|
|
9675
|
+
console.debug(`[${featureName}] Last synchronization date: ${lastSyncDate}`);
|
|
9645
9676
|
return {
|
|
9646
9677
|
name: featureName,
|
|
9647
|
-
lastSyncDate
|
|
9678
|
+
lastSyncDate
|
|
9648
9679
|
};
|
|
9649
9680
|
}
|
|
9650
9681
|
return feature;
|
|
@@ -12642,7 +12673,10 @@ class GraphqlService extends StartableService {
|
|
|
12642
12673
|
const message = err && err.message || err;
|
|
12643
12674
|
if (typeof message === 'string' && message.trim().indexOf('{"code":') === 0) {
|
|
12644
12675
|
try {
|
|
12645
|
-
error = JSON.parse(
|
|
12676
|
+
error = JSON.parse(message
|
|
12677
|
+
// Remove special characters before parsing (e.g. SQL errors from an Oracle database)
|
|
12678
|
+
.replace('\n', ' ')
|
|
12679
|
+
.replace('\r', ''));
|
|
12646
12680
|
}
|
|
12647
12681
|
catch (parseError) {
|
|
12648
12682
|
console.error('Unable to parse error as JSON: ', parseError);
|
|
@@ -12931,6 +12965,7 @@ const LoadQuery$1 = gql `
|
|
|
12931
12965
|
}
|
|
12932
12966
|
}
|
|
12933
12967
|
${Fragments$1.account}
|
|
12968
|
+
${Fragments$1.settings}
|
|
12934
12969
|
`;
|
|
12935
12970
|
// Check email query
|
|
12936
12971
|
const IsEmailExistsQuery = gql `
|
|
@@ -12989,14 +13024,14 @@ const AuthChallengeQuery = gql `
|
|
|
12989
13024
|
}
|
|
12990
13025
|
}
|
|
12991
13026
|
`;
|
|
12992
|
-
const
|
|
12993
|
-
|
|
13027
|
+
const AccountSubscriptions = {
|
|
13028
|
+
listenChanges: gql `subscription updateAccount($interval: Int){
|
|
12994
13029
|
data: updateAccount(interval: $interval) {
|
|
12995
13030
|
id
|
|
12996
13031
|
updateDate
|
|
12997
13032
|
}
|
|
12998
|
-
}
|
|
12999
|
-
|
|
13033
|
+
}`
|
|
13034
|
+
};
|
|
13000
13035
|
class AccountService extends BaseGraphqlService {
|
|
13001
13036
|
constructor(cryptoService, network, graphql, settings, storage, file, environment) {
|
|
13002
13037
|
super(graphql, environment);
|
|
@@ -13534,9 +13569,9 @@ class AccountService extends BaseGraphqlService {
|
|
|
13534
13569
|
if (!this._cache.pubkey)
|
|
13535
13570
|
return Subscription.EMPTY;
|
|
13536
13571
|
const self = this;
|
|
13537
|
-
console.debug('[account] [WS] Listening
|
|
13572
|
+
console.debug('[account] [WS] Listening changes');
|
|
13538
13573
|
const subscription = this.graphql.subscribe({
|
|
13539
|
-
query:
|
|
13574
|
+
query: AccountSubscriptions.listenChanges,
|
|
13540
13575
|
variables: {
|
|
13541
13576
|
interval: 10
|
|
13542
13577
|
},
|
|
@@ -13573,7 +13608,7 @@ class AccountService extends BaseGraphqlService {
|
|
|
13573
13608
|
}
|
|
13574
13609
|
});
|
|
13575
13610
|
// Add log when closing WS
|
|
13576
|
-
subscription.add(() => console.debug('[account] [WS] Stop listening
|
|
13611
|
+
subscription.add(() => console.debug('[account] [WS] Stop listening changes'));
|
|
13577
13612
|
return subscription;
|
|
13578
13613
|
}
|
|
13579
13614
|
get additionalFields() {
|
|
@@ -15364,20 +15399,30 @@ ComponentDirtyGuard.ctorParameters = () => [
|
|
|
15364
15399
|
];
|
|
15365
15400
|
|
|
15366
15401
|
class CustomReuseStrategy extends IonicRouteStrategy {
|
|
15402
|
+
/**
|
|
15403
|
+
* Force to reuse the route when:
|
|
15404
|
+
* - path change from [/new] -> [/:id]
|
|
15405
|
+
* - or path change from [/new] -> [/new?id=:id]
|
|
15406
|
+
* @param future
|
|
15407
|
+
* @param curr
|
|
15408
|
+
*/
|
|
15367
15409
|
shouldReuseRoute(future, curr) {
|
|
15368
15410
|
const result = super.shouldReuseRoute(future, curr);
|
|
15369
|
-
//
|
|
15370
|
-
// - path change from [/new] -> [/:id]
|
|
15371
|
-
// - or path change from [/new] -> [/new?id=:id]
|
|
15411
|
+
// Is sam route config
|
|
15372
15412
|
if (!result && future.routeConfig && future.routeConfig === curr.routeConfig) {
|
|
15413
|
+
// Read the parameter name, where id is stored
|
|
15373
15414
|
const pathIdParam = future.routeConfig.data && future.routeConfig.data.pathIdParam || 'id';
|
|
15374
|
-
|
|
15375
|
-
|
|
15376
|
-
|
|
15377
|
-
|
|
15378
|
-
|
|
15379
|
-
|
|
15380
|
-
|
|
15415
|
+
// Read the current route id
|
|
15416
|
+
const currId = curr.params[pathIdParam] === 'new'
|
|
15417
|
+
? (curr.queryParams[pathIdParam] || curr.queryParams['id'] || 'new') // e.g. path like '/new/?id=<ID>'
|
|
15418
|
+
: curr.params[pathIdParam]; // e.g. path like '/<ID>'
|
|
15419
|
+
// Read the future route id
|
|
15420
|
+
const futureId = future.params[pathIdParam] === 'new'
|
|
15421
|
+
? (future.queryParams[pathIdParam] || future.queryParams['id'] || 'new') // e.g. path like '/new/?id=<ID>'
|
|
15422
|
+
: future.params[pathIdParam]; // e.g. path like '/<ID>'
|
|
15423
|
+
// Reuse if same ID, but never when 'new' expected
|
|
15424
|
+
return futureId !== 'new' && currId !== 'new'
|
|
15425
|
+
&& futureId === currId;
|
|
15381
15426
|
}
|
|
15382
15427
|
return result;
|
|
15383
15428
|
}
|