@sumaris-net/ngx-components 1.20.12 → 1.20.15
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 +43 -31
- 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 +6 -0
- package/esm2015/src/app/core/menu/menu.component.js +11 -7
- package/esm2015/src/app/shared/validator/validators.js +26 -18
- package/fesm2015/sumaris-net.ngx-components.js +35 -23
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/shared/validator/validators.d.ts +1 -1
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -2916,15 +2916,15 @@ const moment$2 = momentImported;
|
|
|
2916
2916
|
class SharedValidators {
|
|
2917
2917
|
static getDoubleRegexp(maxDecimals) {
|
|
2918
2918
|
if (isNil(maxDecimals))
|
|
2919
|
-
return this.
|
|
2919
|
+
return this._DOUBLE_REGEXP_CACHE.NO_LIMIT;
|
|
2920
2920
|
if (maxDecimals < 0)
|
|
2921
2921
|
throw new Error(`Invalid maxDecimals value: ${maxDecimals}`);
|
|
2922
|
-
const regexp = this.
|
|
2922
|
+
const regexp = this._DOUBLE_REGEXP_CACHE[maxDecimals];
|
|
2923
2923
|
if (regexp)
|
|
2924
2924
|
return regexp;
|
|
2925
|
-
// New
|
|
2926
|
-
this.
|
|
2927
|
-
return this.
|
|
2925
|
+
// New: add to cache
|
|
2926
|
+
this._DOUBLE_REGEXP_CACHE[maxDecimals] = new RegExp(`^-?\\d+([.,]\\d{1,${maxDecimals}})?$`);
|
|
2927
|
+
return this._DOUBLE_REGEXP_CACHE[maxDecimals];
|
|
2928
2928
|
}
|
|
2929
2929
|
static latitude(control) {
|
|
2930
2930
|
const value = control.value;
|
|
@@ -3022,8 +3022,10 @@ class SharedValidators {
|
|
|
3022
3022
|
const errorCode = msg ? 'msg' : 'dateRange';
|
|
3023
3023
|
const error = msg ? { msg } : { dateRange: true };
|
|
3024
3024
|
return (control) => {
|
|
3025
|
-
|
|
3026
|
-
|
|
3025
|
+
// Form group not created yet: skip
|
|
3026
|
+
if (!control.parent)
|
|
3027
|
+
return null;
|
|
3028
|
+
const startControl = control.parent.get(startDateFieldName);
|
|
3027
3029
|
if (!startControl) {
|
|
3028
3030
|
console.warn(`Cannot find brother control '${startDateFieldName}' in the parent form`);
|
|
3029
3031
|
return null;
|
|
@@ -3043,8 +3045,10 @@ class SharedValidators {
|
|
|
3043
3045
|
const errorCode = msg ? 'msg' : 'dateRange';
|
|
3044
3046
|
const error = msg ? { msg } : { dateRange: true };
|
|
3045
3047
|
return (control) => {
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
+
// Form group not created yet: skip
|
|
3049
|
+
if (!control.parent)
|
|
3050
|
+
return null;
|
|
3051
|
+
const endDateControl = control.parent.get(endDateFieldName);
|
|
3048
3052
|
if (!endDateControl) {
|
|
3049
3053
|
console.warn(`Cannot find control '${endDateFieldName}' in the parent form`);
|
|
3050
3054
|
return null;
|
|
@@ -3065,7 +3069,13 @@ class SharedValidators {
|
|
|
3065
3069
|
// Skip if control already has some errors
|
|
3066
3070
|
if (control.errors)
|
|
3067
3071
|
return null;
|
|
3068
|
-
|
|
3072
|
+
// Skip if parent form group not created yet
|
|
3073
|
+
if (!control.parent)
|
|
3074
|
+
return null;
|
|
3075
|
+
// Form group not created yet
|
|
3076
|
+
if (!control.parent)
|
|
3077
|
+
return null;
|
|
3078
|
+
const errors = control.parent.errors;
|
|
3069
3079
|
// No errors, or copy all errors
|
|
3070
3080
|
if (!errors || isEmptyArray(errorNames))
|
|
3071
3081
|
return errors;
|
|
@@ -3095,13 +3105,11 @@ class SharedValidators {
|
|
|
3095
3105
|
}
|
|
3096
3106
|
}
|
|
3097
3107
|
}
|
|
3098
|
-
SharedValidators.
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
3: /^[-]?[0-9]+([.,][0-9]{1,2})?$/,
|
|
3104
|
-
}
|
|
3108
|
+
SharedValidators._DOUBLE_REGEXP_CACHE = {
|
|
3109
|
+
NO_LIMIT: /^-?\d+([.,]\d*)?$/,
|
|
3110
|
+
1: /^-?\d+([.,]\d)?$/,
|
|
3111
|
+
2: /^-?\d+([.,]\d{1,2})?$/,
|
|
3112
|
+
3: /^-?\d+([.,]\d{1,3})?$/ // 3 decimals max
|
|
3105
3113
|
};
|
|
3106
3114
|
SharedValidators.I18N_ERROR_KEYS = {
|
|
3107
3115
|
required: 'ERROR.FIELD_REQUIRED',
|
|
@@ -21095,11 +21103,11 @@ class MenuComponent {
|
|
|
21095
21103
|
.pipe(distinctUntilChanged())
|
|
21096
21104
|
.subscribe((value) => value ? this.open() : this.close());
|
|
21097
21105
|
// Update component when refresh is need (=login events or config changed)
|
|
21098
|
-
this._subscription.add(merge(this.accountService.onLogin, this.accountService.onLogout
|
|
21099
|
-
.pipe(tap(config => this._config = config)))
|
|
21106
|
+
this._subscription.add(merge(merge(this.accountService.onLogin, this.accountService.onLogout)
|
|
21100
21107
|
.pipe(
|
|
21101
21108
|
// Wait account service ready (can be restarted)
|
|
21102
|
-
mergeMap(() => this.accountService.ready()), map(() => this.accountService.isLogin()), distinctUntilChanged())
|
|
21109
|
+
mergeMap(() => this.accountService.ready()), map(() => this.accountService.isLogin()), distinctUntilChanged()), this.configService.config
|
|
21110
|
+
.pipe(tap(config => this._config = config), mergeMap(() => this.accountService.ready()), map(() => this.accountService.isLogin())))
|
|
21103
21111
|
.subscribe(login => {
|
|
21104
21112
|
if (login) {
|
|
21105
21113
|
this.onLogin(this.accountService.account);
|
|
@@ -21112,7 +21120,7 @@ class MenuComponent {
|
|
|
21112
21120
|
}
|
|
21113
21121
|
onLogin(account) {
|
|
21114
21122
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21115
|
-
console.info('[menu] Update
|
|
21123
|
+
console.info('[menu] Update (login)');
|
|
21116
21124
|
this.accountAvatar = account.avatar;
|
|
21117
21125
|
this.accountName = account.displayName;
|
|
21118
21126
|
this.accountEmail = account.email;
|
|
@@ -21126,8 +21134,12 @@ class MenuComponent {
|
|
|
21126
21134
|
}
|
|
21127
21135
|
onLogout(skipRedirect) {
|
|
21128
21136
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21129
|
-
if (!skipRedirect)
|
|
21130
|
-
console.debug('[menu]
|
|
21137
|
+
if (!skipRedirect) {
|
|
21138
|
+
console.debug('[menu] Logout');
|
|
21139
|
+
}
|
|
21140
|
+
else {
|
|
21141
|
+
console.debug('[menu] Update (logout)');
|
|
21142
|
+
}
|
|
21131
21143
|
this.isLogin = false;
|
|
21132
21144
|
this.accountAvatar = null;
|
|
21133
21145
|
this.accountEmail = null;
|