@sumaris-net/ngx-components 1.0.8 → 1.1.1
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 +104 -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/esm2015/src/app/core/form/editor.class.js +4 -2
- 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 +2 -2
- 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 +103 -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
|
@@ -2489,6 +2489,14 @@
|
|
|
2489
2489
|
DateUtils.max = function (date1, date2) {
|
|
2490
2490
|
return !date1 ? date2 : (!date2 || date1.isSameOrAfter(date2) ? date1 : date2);
|
|
2491
2491
|
};
|
|
2492
|
+
DateUtils.equals = function (date1, date2) {
|
|
2493
|
+
return DateUtils.isSame(date1, date2);
|
|
2494
|
+
};
|
|
2495
|
+
DateUtils.isSame = function (date1, date2, granularity) {
|
|
2496
|
+
var d1 = fromDateISOString(date1);
|
|
2497
|
+
var d2 = fromDateISOString(date2);
|
|
2498
|
+
return (!d1 && !d2) || d1.isSame(d2, granularity);
|
|
2499
|
+
};
|
|
2492
2500
|
return DateUtils;
|
|
2493
2501
|
}());
|
|
2494
2502
|
function toDateISOString(value) {
|
|
@@ -2945,39 +2953,19 @@
|
|
|
2945
2953
|
]; };
|
|
2946
2954
|
|
|
2947
2955
|
var TranslateContextPipe = /** @class */ (function () {
|
|
2948
|
-
function TranslateContextPipe(translate
|
|
2956
|
+
function TranslateContextPipe(translate) {
|
|
2949
2957
|
this.translate = translate;
|
|
2950
|
-
this._ref = _ref;
|
|
2951
|
-
this.value = '';
|
|
2952
|
-
this.lastKey = null;
|
|
2953
|
-
this.lastSuffix = null;
|
|
2954
|
-
this.lastParams = [];
|
|
2955
2958
|
}
|
|
2956
2959
|
TranslateContextPipe.prototype.transform = function (query) {
|
|
2957
2960
|
var params = [];
|
|
2958
2961
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2959
2962
|
params[_i - 1] = arguments[_i];
|
|
2960
2963
|
}
|
|
2961
|
-
if (!query || !query.length)
|
|
2964
|
+
if (!query || !query.length)
|
|
2962
2965
|
return query;
|
|
2963
|
-
}
|
|
2964
2966
|
var suffix = params && params.length ? params[0] : '';
|
|
2965
2967
|
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;
|
|
2968
|
+
return this.translate.instant(query, suffix, params);
|
|
2981
2969
|
};
|
|
2982
2970
|
return TranslateContextPipe;
|
|
2983
2971
|
}());
|
|
@@ -2988,8 +2976,7 @@
|
|
|
2988
2976
|
},] }
|
|
2989
2977
|
];
|
|
2990
2978
|
TranslateContextPipe.ctorParameters = function () { return [
|
|
2991
|
-
{ type: TranslateContextService }
|
|
2992
|
-
{ type: i0.ChangeDetectorRef }
|
|
2979
|
+
{ type: TranslateContextService }
|
|
2993
2980
|
]; };
|
|
2994
2981
|
var TranslatablePipe = /** @class */ (function () {
|
|
2995
2982
|
function TranslatablePipe() {
|
|
@@ -3735,7 +3722,7 @@
|
|
|
3735
3722
|
source = source.split('|');
|
|
3736
3723
|
}
|
|
3737
3724
|
// Skip if value is not an array
|
|
3738
|
-
if (!(source
|
|
3725
|
+
if (!Array.isArray(source) || control.length === 0) {
|
|
3739
3726
|
if (isNotEmptyArray(source))
|
|
3740
3727
|
console.warn("WARN: please resize the FormArray '" + path + "' to the same length of the input array");
|
|
3741
3728
|
return [];
|
|
@@ -4216,21 +4203,72 @@
|
|
|
4216
4203
|
]; };
|
|
4217
4204
|
|
|
4218
4205
|
var FormErrorTranslatePipe = /** @class */ (function () {
|
|
4219
|
-
function FormErrorTranslatePipe(adapter) {
|
|
4206
|
+
function FormErrorTranslatePipe(adapter, _ref) {
|
|
4220
4207
|
this.adapter = adapter;
|
|
4208
|
+
this._ref = _ref;
|
|
4209
|
+
this.value = '';
|
|
4210
|
+
this._lastForm = null;
|
|
4211
|
+
this._lastOptions = null;
|
|
4221
4212
|
}
|
|
4222
4213
|
FormErrorTranslatePipe.prototype.transform = function (form, opts) {
|
|
4223
|
-
|
|
4214
|
+
var _this = this;
|
|
4215
|
+
if (!form) {
|
|
4216
|
+
this._dispose();
|
|
4217
|
+
return '';
|
|
4218
|
+
}
|
|
4219
|
+
// if we ask another time for the same form and opts, return the last value
|
|
4220
|
+
if (form === this._lastForm && equals(opts, this._lastOptions)) {
|
|
4221
|
+
return this.value;
|
|
4222
|
+
}
|
|
4223
|
+
// store the query, in case it changes
|
|
4224
|
+
this._lastForm = form;
|
|
4225
|
+
// store the params, in case they change
|
|
4226
|
+
this._lastOptions = opts;
|
|
4227
|
+
// set the value
|
|
4228
|
+
this._updateValue(form, opts);
|
|
4229
|
+
// if there is a subscription to onLangChange, clean it
|
|
4230
|
+
this._dispose();
|
|
4231
|
+
// subscribe to onTranslationChange event, in case the translations change
|
|
4232
|
+
if (!this._onFormStatusChange) {
|
|
4233
|
+
this._onFormStatusChange = form.statusChanges.subscribe(function (status) {
|
|
4234
|
+
_this._updateValue(form, opts, status);
|
|
4235
|
+
});
|
|
4236
|
+
}
|
|
4237
|
+
return this.value;
|
|
4238
|
+
};
|
|
4239
|
+
FormErrorTranslatePipe.prototype.ngOnDestroy = function () {
|
|
4240
|
+
this._dispose();
|
|
4241
|
+
};
|
|
4242
|
+
FormErrorTranslatePipe.prototype._updateValue = function (form, opts, status) {
|
|
4243
|
+
if (status === 'INVALID' || form.invalid) {
|
|
4244
|
+
this.value = this.adapter.translateErrors(form, opts);
|
|
4245
|
+
this._ref.markForCheck();
|
|
4246
|
+
}
|
|
4247
|
+
else if (this.value !== undefined) {
|
|
4248
|
+
this.value = undefined;
|
|
4249
|
+
this._ref.markForCheck();
|
|
4250
|
+
}
|
|
4251
|
+
};
|
|
4252
|
+
/**
|
|
4253
|
+
* Clean any existing subscription to change events
|
|
4254
|
+
*/
|
|
4255
|
+
FormErrorTranslatePipe.prototype._dispose = function () {
|
|
4256
|
+
if (typeof this._onFormStatusChange !== 'undefined') {
|
|
4257
|
+
this._onFormStatusChange.unsubscribe();
|
|
4258
|
+
this._onFormStatusChange = undefined;
|
|
4259
|
+
}
|
|
4224
4260
|
};
|
|
4225
4261
|
return FormErrorTranslatePipe;
|
|
4226
4262
|
}());
|
|
4227
4263
|
FormErrorTranslatePipe.decorators = [
|
|
4228
4264
|
{ type: i0.Pipe, args: [{
|
|
4229
4265
|
name: 'translateFormError',
|
|
4266
|
+
pure: false
|
|
4230
4267
|
},] }
|
|
4231
4268
|
];
|
|
4232
4269
|
FormErrorTranslatePipe.ctorParameters = function () { return [
|
|
4233
|
-
{ type: FormErrorTranslator }
|
|
4270
|
+
{ type: FormErrorTranslator },
|
|
4271
|
+
{ type: i0.ChangeDetectorRef }
|
|
4234
4272
|
]; };
|
|
4235
4273
|
|
|
4236
4274
|
var SharedPipesModule = /** @class */ (function () {
|
|
@@ -8626,7 +8664,7 @@
|
|
|
8626
8664
|
};
|
|
8627
8665
|
AppFormField.prototype.computeValuesFromToken = function (token) {
|
|
8628
8666
|
var values = this.injector.get(token);
|
|
8629
|
-
return values
|
|
8667
|
+
return Array.isArray(values) ? values : [];
|
|
8630
8668
|
};
|
|
8631
8669
|
AppFormField.prototype.checkAndResolveFormControl = function () {
|
|
8632
8670
|
var _this = this;
|
|
@@ -9844,7 +9882,7 @@
|
|
|
9844
9882
|
}, {});
|
|
9845
9883
|
};
|
|
9846
9884
|
EntityUtils.getMapAsArray = function (source) {
|
|
9847
|
-
if (source
|
|
9885
|
+
if (Array.isArray(source))
|
|
9848
9886
|
return source;
|
|
9849
9887
|
return Object.getOwnPropertyNames(source || {})
|
|
9850
9888
|
.map(function (key) { return ({
|
|
@@ -10843,7 +10881,7 @@
|
|
|
10843
10881
|
case 2:
|
|
10844
10882
|
data = Object.assign(Object.assign({}, this._data), settings);
|
|
10845
10883
|
if (equals(data, this._data))
|
|
10846
|
-
return [2 /*return*/]; //
|
|
10884
|
+
return [2 /*return*/]; // Skip if no changes
|
|
10847
10885
|
this._data = data;
|
|
10848
10886
|
if (!(opts && opts.persistImmediate)) return [3 /*break*/, 4];
|
|
10849
10887
|
return [4 /*yield*/, this.persistLocally(true)];
|
|
@@ -10924,9 +10962,11 @@
|
|
|
10924
10962
|
if (!feature)
|
|
10925
10963
|
return; // Not found
|
|
10926
10964
|
if (typeof feature === 'string') {
|
|
10965
|
+
var lastSyncDate = feature.substring(featurePrefix.length);
|
|
10966
|
+
console.debug("[" + featureName + "] Last synchronization date: " + lastSyncDate);
|
|
10927
10967
|
return {
|
|
10928
10968
|
name: featureName,
|
|
10929
|
-
lastSyncDate:
|
|
10969
|
+
lastSyncDate: lastSyncDate
|
|
10930
10970
|
};
|
|
10931
10971
|
}
|
|
10932
10972
|
return feature;
|
|
@@ -12348,8 +12388,8 @@
|
|
|
12348
12388
|
])];
|
|
12349
12389
|
case 1:
|
|
12350
12390
|
res = _a.sent();
|
|
12351
|
-
values = res[0] && res[0]
|
|
12352
|
-
ids = res[1] && res[1]
|
|
12391
|
+
values = res[0] && Array.isArray(res[0]) ? res[0] : null;
|
|
12392
|
+
ids = res[1] && Array.isArray(res[1]) ? res[1] : null;
|
|
12353
12393
|
migration = false;
|
|
12354
12394
|
if (!this.isByIdMode) return [3 /*break*/, 5];
|
|
12355
12395
|
if (!isNotNil(ids)) return [3 /*break*/, 3];
|
|
@@ -13947,7 +13987,7 @@
|
|
|
13947
13987
|
.pipe(operators.catchError(function (error) { return _this.onApolloError(error, opts.error); }), operators.first()).toPromise()];
|
|
13948
13988
|
case 5:
|
|
13949
13989
|
res = _b.sent();
|
|
13950
|
-
if (res.errors
|
|
13990
|
+
if (Array.isArray(res.errors)) {
|
|
13951
13991
|
throw res.errors[0];
|
|
13952
13992
|
}
|
|
13953
13993
|
return [2 /*return*/, res.data];
|
|
@@ -14621,7 +14661,7 @@
|
|
|
14621
14661
|
if (!queries.length)
|
|
14622
14662
|
return;
|
|
14623
14663
|
queries.forEach(function (query) {
|
|
14624
|
-
if (opts.data
|
|
14664
|
+
if (Array.isArray(opts.data)) {
|
|
14625
14665
|
// Filter values, if a filter function exists
|
|
14626
14666
|
var data = query.insertFilterFn ? opts.data.filter(function (i) { return query.insertFilterFn(i); }) : opts.data;
|
|
14627
14667
|
if (isNotEmptyArray(data)) {
|
|
@@ -14659,7 +14699,7 @@
|
|
|
14659
14699
|
return;
|
|
14660
14700
|
console.debug("[base-data-service] Removing data from watching queries: ", queries);
|
|
14661
14701
|
return queries.map(function (query) {
|
|
14662
|
-
if (opts.ids
|
|
14702
|
+
if (Array.isArray(opts.ids)) {
|
|
14663
14703
|
return _this.graphql.removeFromCachedQueryByIds(cache, {
|
|
14664
14704
|
query: query.query,
|
|
14665
14705
|
variables: query.variables,
|
|
@@ -15576,7 +15616,7 @@
|
|
|
15576
15616
|
}
|
|
15577
15617
|
});
|
|
15578
15618
|
// Add log when closing WS
|
|
15579
|
-
subscription.add(function () { return console.debug('[account] [WS] Stop listening
|
|
15619
|
+
subscription.add(function () { return console.debug('[account] [WS] Stop listening changes'); });
|
|
15580
15620
|
return subscription;
|
|
15581
15621
|
};
|
|
15582
15622
|
Object.defineProperty(AccountService.prototype, "additionalFields", {
|
|
@@ -16057,7 +16097,7 @@
|
|
|
16057
16097
|
this.comments = source.comments;
|
|
16058
16098
|
this.creationDate = fromDateISOString(source.creationDate);
|
|
16059
16099
|
this.statusId = source.statusId;
|
|
16060
|
-
if (source.properties && source.properties
|
|
16100
|
+
if (source.properties && Array.isArray(source.properties)) {
|
|
16061
16101
|
this.properties = EntityUtils.getPropertyArrayAsObject(source.properties);
|
|
16062
16102
|
}
|
|
16063
16103
|
else {
|
|
@@ -17671,20 +17711,30 @@
|
|
|
17671
17711
|
function CustomReuseStrategy() {
|
|
17672
17712
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
17673
17713
|
}
|
|
17714
|
+
/**
|
|
17715
|
+
* Force to reuse the route when:
|
|
17716
|
+
* - path change from [/new] -> [/:id]
|
|
17717
|
+
* - or path change from [/new] -> [/new?id=:id]
|
|
17718
|
+
* @param future
|
|
17719
|
+
* @param curr
|
|
17720
|
+
*/
|
|
17674
17721
|
CustomReuseStrategy.prototype.shouldReuseRoute = function (future, curr) {
|
|
17675
17722
|
var result = _super.prototype.shouldReuseRoute.call(this, future, curr);
|
|
17676
|
-
//
|
|
17677
|
-
// - path change from [/new] -> [/:id]
|
|
17678
|
-
// - or path change from [/new] -> [/new?id=:id]
|
|
17723
|
+
// Is sam route config
|
|
17679
17724
|
if (!result && future.routeConfig && future.routeConfig === curr.routeConfig) {
|
|
17725
|
+
// Read the parameter name, where id is stored
|
|
17680
17726
|
var pathIdParam = future.routeConfig.data && future.routeConfig.data.pathIdParam || 'id';
|
|
17681
|
-
|
|
17682
|
-
|
|
17683
|
-
|
|
17684
|
-
|
|
17685
|
-
|
|
17686
|
-
|
|
17687
|
-
|
|
17727
|
+
// Read the current route id
|
|
17728
|
+
var currId = curr.params[pathIdParam] === 'new'
|
|
17729
|
+
? (curr.queryParams[pathIdParam] || curr.queryParams['id'] || 'new') // e.g. path like '/new/?id=<ID>'
|
|
17730
|
+
: curr.params[pathIdParam]; // e.g. path like '/<ID>'
|
|
17731
|
+
// Read the future route id
|
|
17732
|
+
var futureId = future.params[pathIdParam] === 'new'
|
|
17733
|
+
? (future.queryParams[pathIdParam] || future.queryParams['id'] || 'new') // e.g. path like '/new/?id=<ID>'
|
|
17734
|
+
: future.params[pathIdParam]; // e.g. path like '/<ID>'
|
|
17735
|
+
// Reuse if same ID, but never when 'new' expected
|
|
17736
|
+
return futureId !== 'new' && currId !== 'new'
|
|
17737
|
+
&& futureId === currId;
|
|
17688
17738
|
}
|
|
17689
17739
|
return result;
|
|
17690
17740
|
};
|
|
@@ -22192,7 +22242,7 @@
|
|
|
22192
22242
|
function DepartmentToStringPipe() {
|
|
22193
22243
|
}
|
|
22194
22244
|
DepartmentToStringPipe.prototype.transform = function (value, separator) {
|
|
22195
|
-
if (value
|
|
22245
|
+
if (Array.isArray(value))
|
|
22196
22246
|
return departmentsToString(value, separator);
|
|
22197
22247
|
return departmentToString(value);
|
|
22198
22248
|
};
|
|
@@ -25784,10 +25834,12 @@
|
|
|
25784
25834
|
var _a;
|
|
25785
25835
|
if (this._loading) {
|
|
25786
25836
|
this._loading = false;
|
|
25787
|
-
if (!opts || opts.
|
|
25837
|
+
if (!opts || opts.onlySelf !== true) {
|
|
25788
25838
|
// Emit to children forms
|
|
25789
25839
|
// Tables should be changed by parent
|
|
25790
25840
|
(_a = this.forms) === null || _a === void 0 ? void 0 : _a.forEach(function (c) { return c.markAsLoaded(opts); });
|
|
25841
|
+
}
|
|
25842
|
+
if (!opts || opts.emitEvent !== false) {
|
|
25791
25843
|
this.markForCheck();
|
|
25792
25844
|
}
|
|
25793
25845
|
}
|