@sumaris-net/ngx-components 1.0.7 → 1.1.0
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 +105 -52
- 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/form/form.utils.js +2 -2
- package/esm2015/src/app/core/graphql/graphql.service.js +6 -3
- package/esm2015/src/app/core/services/account.service.js +2 -2
- package/esm2015/src/app/core/services/base-graphql-service.class.js +3 -3
- package/esm2015/src/app/core/services/local-settings.service.js +5 -3
- package/esm2015/src/app/core/services/model/config.model.js +2 -2
- package/esm2015/src/app/core/services/model/entity.model.js +2 -2
- package/esm2015/src/app/core/services/pipes/department-to-string.pipe.js +2 -2
- package/esm2015/src/app/core/services/storage/entity-store.class.js +3 -3
- package/esm2015/src/app/shared/dates.js +9 -1
- package/esm2015/src/app/shared/form/field.component.js +2 -2
- package/esm2015/src/app/shared/functions.js +1 -1
- 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 +104 -52
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/shared/dates.d.ts +3 -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
|
@@ -2120,6 +2120,14 @@ class DateUtils {
|
|
|
2120
2120
|
static max(date1, date2) {
|
|
2121
2121
|
return !date1 ? date2 : (!date2 || date1.isSameOrAfter(date2) ? date1 : date2);
|
|
2122
2122
|
}
|
|
2123
|
+
static equals(date1, date2) {
|
|
2124
|
+
return DateUtils.isSame(date1, date2);
|
|
2125
|
+
}
|
|
2126
|
+
static isSame(date1, date2, granularity) {
|
|
2127
|
+
const d1 = fromDateISOString(date1);
|
|
2128
|
+
const d2 = fromDateISOString(date2);
|
|
2129
|
+
return (!d1 && !d2) || d1.isSame(d2, granularity);
|
|
2130
|
+
}
|
|
2123
2131
|
}
|
|
2124
2132
|
function toDateISOString(value) {
|
|
2125
2133
|
if (!value)
|
|
@@ -2509,35 +2517,15 @@ TranslateContextService.ctorParameters = () => [
|
|
|
2509
2517
|
];
|
|
2510
2518
|
|
|
2511
2519
|
class TranslateContextPipe {
|
|
2512
|
-
constructor(translate
|
|
2520
|
+
constructor(translate) {
|
|
2513
2521
|
this.translate = translate;
|
|
2514
|
-
this._ref = _ref;
|
|
2515
|
-
this.value = '';
|
|
2516
|
-
this.lastKey = null;
|
|
2517
|
-
this.lastSuffix = null;
|
|
2518
|
-
this.lastParams = [];
|
|
2519
2522
|
}
|
|
2520
2523
|
transform(query, ...params) {
|
|
2521
|
-
if (!query || !query.length)
|
|
2524
|
+
if (!query || !query.length)
|
|
2522
2525
|
return query;
|
|
2523
|
-
}
|
|
2524
2526
|
const suffix = params && params.length ? params[0] : '';
|
|
2525
2527
|
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;
|
|
2528
|
+
return this.translate.instant(query, suffix, params);
|
|
2541
2529
|
}
|
|
2542
2530
|
}
|
|
2543
2531
|
TranslateContextPipe.decorators = [
|
|
@@ -2547,8 +2535,7 @@ TranslateContextPipe.decorators = [
|
|
|
2547
2535
|
},] }
|
|
2548
2536
|
];
|
|
2549
2537
|
TranslateContextPipe.ctorParameters = () => [
|
|
2550
|
-
{ type: TranslateContextService }
|
|
2551
|
-
{ type: ChangeDetectorRef }
|
|
2538
|
+
{ type: TranslateContextService }
|
|
2552
2539
|
];
|
|
2553
2540
|
class TranslatablePipe {
|
|
2554
2541
|
transform(value) {
|
|
@@ -3206,7 +3193,7 @@ function adaptValueToControl(source, control, path) {
|
|
|
3206
3193
|
source = source.split('|');
|
|
3207
3194
|
}
|
|
3208
3195
|
// Skip if value is not an array
|
|
3209
|
-
if (!(source
|
|
3196
|
+
if (!Array.isArray(source) || control.length === 0) {
|
|
3210
3197
|
if (isNotEmptyArray(source))
|
|
3211
3198
|
console.warn(`WARN: please resize the FormArray '${path}' to the same length of the input array`);
|
|
3212
3199
|
return [];
|
|
@@ -3675,20 +3662,70 @@ FormErrorTranslator.ctorParameters = () => [
|
|
|
3675
3662
|
];
|
|
3676
3663
|
|
|
3677
3664
|
class FormErrorTranslatePipe {
|
|
3678
|
-
constructor(adapter) {
|
|
3665
|
+
constructor(adapter, _ref) {
|
|
3679
3666
|
this.adapter = adapter;
|
|
3667
|
+
this._ref = _ref;
|
|
3668
|
+
this.value = '';
|
|
3669
|
+
this._lastForm = null;
|
|
3670
|
+
this._lastOptions = null;
|
|
3680
3671
|
}
|
|
3681
3672
|
transform(form, opts) {
|
|
3682
|
-
|
|
3673
|
+
if (!form) {
|
|
3674
|
+
this._dispose();
|
|
3675
|
+
return '';
|
|
3676
|
+
}
|
|
3677
|
+
// if we ask another time for the same form and opts, return the last value
|
|
3678
|
+
if (form === this._lastForm && equals(opts, this._lastOptions)) {
|
|
3679
|
+
return this.value;
|
|
3680
|
+
}
|
|
3681
|
+
// store the query, in case it changes
|
|
3682
|
+
this._lastForm = form;
|
|
3683
|
+
// store the params, in case they change
|
|
3684
|
+
this._lastOptions = opts;
|
|
3685
|
+
// set the value
|
|
3686
|
+
this._updateValue(form, opts);
|
|
3687
|
+
// if there is a subscription to onLangChange, clean it
|
|
3688
|
+
this._dispose();
|
|
3689
|
+
// subscribe to onTranslationChange event, in case the translations change
|
|
3690
|
+
if (!this._onFormStatusChange) {
|
|
3691
|
+
this._onFormStatusChange = form.statusChanges.subscribe((status) => {
|
|
3692
|
+
this._updateValue(form, opts, status);
|
|
3693
|
+
});
|
|
3694
|
+
}
|
|
3695
|
+
return this.value;
|
|
3696
|
+
}
|
|
3697
|
+
ngOnDestroy() {
|
|
3698
|
+
this._dispose();
|
|
3699
|
+
}
|
|
3700
|
+
_updateValue(form, opts, status) {
|
|
3701
|
+
if (status === 'INVALID' || form.invalid) {
|
|
3702
|
+
this.value = this.adapter.translateErrors(form, opts);
|
|
3703
|
+
this._ref.markForCheck();
|
|
3704
|
+
}
|
|
3705
|
+
else if (this.value !== undefined) {
|
|
3706
|
+
this.value = undefined;
|
|
3707
|
+
this._ref.markForCheck();
|
|
3708
|
+
}
|
|
3709
|
+
}
|
|
3710
|
+
/**
|
|
3711
|
+
* Clean any existing subscription to change events
|
|
3712
|
+
*/
|
|
3713
|
+
_dispose() {
|
|
3714
|
+
if (typeof this._onFormStatusChange !== 'undefined') {
|
|
3715
|
+
this._onFormStatusChange.unsubscribe();
|
|
3716
|
+
this._onFormStatusChange = undefined;
|
|
3717
|
+
}
|
|
3683
3718
|
}
|
|
3684
3719
|
}
|
|
3685
3720
|
FormErrorTranslatePipe.decorators = [
|
|
3686
3721
|
{ type: Pipe, args: [{
|
|
3687
3722
|
name: 'translateFormError',
|
|
3723
|
+
pure: false
|
|
3688
3724
|
},] }
|
|
3689
3725
|
];
|
|
3690
3726
|
FormErrorTranslatePipe.ctorParameters = () => [
|
|
3691
|
-
{ type: FormErrorTranslator }
|
|
3727
|
+
{ type: FormErrorTranslator },
|
|
3728
|
+
{ type: ChangeDetectorRef }
|
|
3692
3729
|
];
|
|
3693
3730
|
|
|
3694
3731
|
class SharedPipesModule {
|
|
@@ -7686,7 +7723,7 @@ class AppFormField {
|
|
|
7686
7723
|
}
|
|
7687
7724
|
computeValuesFromToken(token) {
|
|
7688
7725
|
const values = this.injector.get(token);
|
|
7689
|
-
return values
|
|
7726
|
+
return Array.isArray(values) ? values : [];
|
|
7690
7727
|
}
|
|
7691
7728
|
checkAndResolveFormControl() {
|
|
7692
7729
|
if (this.formControl)
|
|
@@ -8726,7 +8763,7 @@ class EntityUtils {
|
|
|
8726
8763
|
}, {});
|
|
8727
8764
|
}
|
|
8728
8765
|
static getMapAsArray(source) {
|
|
8729
|
-
if (source
|
|
8766
|
+
if (Array.isArray(source))
|
|
8730
8767
|
return source;
|
|
8731
8768
|
return Object.getOwnPropertyNames(source || {})
|
|
8732
8769
|
.map(key => ({
|
|
@@ -9579,7 +9616,7 @@ class LocalSettingsService extends StartableService {
|
|
|
9579
9616
|
yield this.ready();
|
|
9580
9617
|
const data = Object.assign(Object.assign({}, this._data), settings);
|
|
9581
9618
|
if (equals(data, this._data))
|
|
9582
|
-
return; //
|
|
9619
|
+
return; // Skip if no changes
|
|
9583
9620
|
this._data = data;
|
|
9584
9621
|
// Save locally
|
|
9585
9622
|
if (opts && opts.persistImmediate) {
|
|
@@ -9642,9 +9679,11 @@ class LocalSettingsService extends StartableService {
|
|
|
9642
9679
|
if (!feature)
|
|
9643
9680
|
return; // Not found
|
|
9644
9681
|
if (typeof feature === 'string') {
|
|
9682
|
+
const lastSyncDate = feature.substring(featurePrefix.length);
|
|
9683
|
+
console.debug(`[${featureName}] Last synchronization date: ${lastSyncDate}`);
|
|
9645
9684
|
return {
|
|
9646
9685
|
name: featureName,
|
|
9647
|
-
lastSyncDate
|
|
9686
|
+
lastSyncDate
|
|
9648
9687
|
};
|
|
9649
9688
|
}
|
|
9650
9689
|
return feature;
|
|
@@ -10835,8 +10874,8 @@ class EntityStore {
|
|
|
10835
10874
|
this.storage.get(this._storageKey),
|
|
10836
10875
|
this.storage.get(this.storageKeyById)
|
|
10837
10876
|
]);
|
|
10838
|
-
const values = res[0] && res[0]
|
|
10839
|
-
const ids = res[1] && res[1]
|
|
10877
|
+
const values = res[0] && Array.isArray(res[0]) ? res[0] : null;
|
|
10878
|
+
const ids = res[1] && Array.isArray(res[1]) ? res[1] : null;
|
|
10840
10879
|
let migration = false;
|
|
10841
10880
|
let oldKeysToClean;
|
|
10842
10881
|
// "Split by id" mode
|
|
@@ -12117,7 +12156,7 @@ class GraphqlService extends StartableService {
|
|
|
12117
12156
|
update: opts.update
|
|
12118
12157
|
})
|
|
12119
12158
|
.pipe(catchError(error => this.onApolloError(error, opts.error)), first()).toPromise();
|
|
12120
|
-
if (res.errors
|
|
12159
|
+
if (Array.isArray(res.errors)) {
|
|
12121
12160
|
throw res.errors[0];
|
|
12122
12161
|
}
|
|
12123
12162
|
return res.data;
|
|
@@ -12642,7 +12681,10 @@ class GraphqlService extends StartableService {
|
|
|
12642
12681
|
const message = err && err.message || err;
|
|
12643
12682
|
if (typeof message === 'string' && message.trim().indexOf('{"code":') === 0) {
|
|
12644
12683
|
try {
|
|
12645
|
-
error = JSON.parse(
|
|
12684
|
+
error = JSON.parse(message
|
|
12685
|
+
// Remove special characters before parsing (e.g. SQL errors from an Oracle database)
|
|
12686
|
+
.replace('\n', ' ')
|
|
12687
|
+
.replace('\r', ''));
|
|
12646
12688
|
}
|
|
12647
12689
|
catch (parseError) {
|
|
12648
12690
|
console.error('Unable to parse error as JSON: ', parseError);
|
|
@@ -12742,7 +12784,7 @@ class BaseGraphqlService extends StartableService {
|
|
|
12742
12784
|
if (!queries.length)
|
|
12743
12785
|
return;
|
|
12744
12786
|
queries.forEach(query => {
|
|
12745
|
-
if (opts.data
|
|
12787
|
+
if (Array.isArray(opts.data)) {
|
|
12746
12788
|
// Filter values, if a filter function exists
|
|
12747
12789
|
const data = query.insertFilterFn ? opts.data.filter(i => query.insertFilterFn(i)) : opts.data;
|
|
12748
12790
|
if (isNotEmptyArray(data)) {
|
|
@@ -12779,7 +12821,7 @@ class BaseGraphqlService extends StartableService {
|
|
|
12779
12821
|
return;
|
|
12780
12822
|
console.debug(`[base-data-service] Removing data from watching queries: `, queries);
|
|
12781
12823
|
return queries.map(query => {
|
|
12782
|
-
if (opts.ids
|
|
12824
|
+
if (Array.isArray(opts.ids)) {
|
|
12783
12825
|
return this.graphql.removeFromCachedQueryByIds(cache, {
|
|
12784
12826
|
query: query.query,
|
|
12785
12827
|
variables: query.variables,
|
|
@@ -13574,7 +13616,7 @@ class AccountService extends BaseGraphqlService {
|
|
|
13574
13616
|
}
|
|
13575
13617
|
});
|
|
13576
13618
|
// Add log when closing WS
|
|
13577
|
-
subscription.add(() => console.debug('[account] [WS] Stop listening
|
|
13619
|
+
subscription.add(() => console.debug('[account] [WS] Stop listening changes'));
|
|
13578
13620
|
return subscription;
|
|
13579
13621
|
}
|
|
13580
13622
|
get additionalFields() {
|
|
@@ -13971,7 +14013,7 @@ let Software = Software_1 = class Software extends Entity {
|
|
|
13971
14013
|
this.comments = source.comments;
|
|
13972
14014
|
this.creationDate = fromDateISOString(source.creationDate);
|
|
13973
14015
|
this.statusId = source.statusId;
|
|
13974
|
-
if (source.properties && source.properties
|
|
14016
|
+
if (source.properties && Array.isArray(source.properties)) {
|
|
13975
14017
|
this.properties = EntityUtils.getPropertyArrayAsObject(source.properties);
|
|
13976
14018
|
}
|
|
13977
14019
|
else {
|
|
@@ -15365,20 +15407,30 @@ ComponentDirtyGuard.ctorParameters = () => [
|
|
|
15365
15407
|
];
|
|
15366
15408
|
|
|
15367
15409
|
class CustomReuseStrategy extends IonicRouteStrategy {
|
|
15410
|
+
/**
|
|
15411
|
+
* Force to reuse the route when:
|
|
15412
|
+
* - path change from [/new] -> [/:id]
|
|
15413
|
+
* - or path change from [/new] -> [/new?id=:id]
|
|
15414
|
+
* @param future
|
|
15415
|
+
* @param curr
|
|
15416
|
+
*/
|
|
15368
15417
|
shouldReuseRoute(future, curr) {
|
|
15369
15418
|
const result = super.shouldReuseRoute(future, curr);
|
|
15370
|
-
//
|
|
15371
|
-
// - path change from [/new] -> [/:id]
|
|
15372
|
-
// - or path change from [/new] -> [/new?id=:id]
|
|
15419
|
+
// Is sam route config
|
|
15373
15420
|
if (!result && future.routeConfig && future.routeConfig === curr.routeConfig) {
|
|
15421
|
+
// Read the parameter name, where id is stored
|
|
15374
15422
|
const pathIdParam = future.routeConfig.data && future.routeConfig.data.pathIdParam || 'id';
|
|
15375
|
-
|
|
15376
|
-
|
|
15377
|
-
|
|
15378
|
-
|
|
15379
|
-
|
|
15380
|
-
|
|
15381
|
-
|
|
15423
|
+
// Read the current route id
|
|
15424
|
+
const currId = curr.params[pathIdParam] === 'new'
|
|
15425
|
+
? (curr.queryParams[pathIdParam] || curr.queryParams['id'] || 'new') // e.g. path like '/new/?id=<ID>'
|
|
15426
|
+
: curr.params[pathIdParam]; // e.g. path like '/<ID>'
|
|
15427
|
+
// Read the future route id
|
|
15428
|
+
const futureId = future.params[pathIdParam] === 'new'
|
|
15429
|
+
? (future.queryParams[pathIdParam] || future.queryParams['id'] || 'new') // e.g. path like '/new/?id=<ID>'
|
|
15430
|
+
: future.params[pathIdParam]; // e.g. path like '/<ID>'
|
|
15431
|
+
// Reuse if same ID, but never when 'new' expected
|
|
15432
|
+
return futureId !== 'new' && currId !== 'new'
|
|
15433
|
+
&& futureId === currId;
|
|
15382
15434
|
}
|
|
15383
15435
|
return result;
|
|
15384
15436
|
}
|
|
@@ -19205,7 +19257,7 @@ AccountToStringPipe.decorators = [
|
|
|
19205
19257
|
|
|
19206
19258
|
class DepartmentToStringPipe {
|
|
19207
19259
|
transform(value, separator) {
|
|
19208
|
-
if (value
|
|
19260
|
+
if (Array.isArray(value))
|
|
19209
19261
|
return departmentsToString(value, separator);
|
|
19210
19262
|
return departmentToString(value);
|
|
19211
19263
|
}
|