@sumaris-net/ngx-components 1.3.2 → 1.3.3
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 +31 -6
- package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
- package/esm2015/src/app/core/form/entity-editor.class.js +4 -4
- package/esm2015/src/app/core/form/form.class.js +2 -2
- package/esm2015/src/app/core/table/table.class.js +2 -2
- package/esm2015/src/app/shared/pipes/form.pipes.js +2 -2
- package/esm2015/src/app/shared/validator/form-error-adapter.class.js +26 -2
- package/fesm2015/sumaris-net.ngx-components.js +30 -6
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/core/form/entity-editor.class.d.ts +1 -1
- package/src/app/shared/validator/form-error-adapter.class.d.ts +3 -1
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -4138,7 +4138,7 @@
|
|
|
4138
4138
|
this.translate = translate;
|
|
4139
4139
|
this.errorI18nKeys = Object.assign(Object.assign({}, SharedValidators.I18N_ERROR_KEYS), errorI18nKeys);
|
|
4140
4140
|
}
|
|
4141
|
-
FormErrorTranslator.prototype.
|
|
4141
|
+
FormErrorTranslator.prototype.translateFormErrors = function (control, opts) {
|
|
4142
4142
|
var _this = this;
|
|
4143
4143
|
if (!control || !control.invalid)
|
|
4144
4144
|
return '';
|
|
@@ -4167,6 +4167,31 @@
|
|
|
4167
4167
|
return res + (res.length ? separator : '') + formError;
|
|
4168
4168
|
}, "");
|
|
4169
4169
|
};
|
|
4170
|
+
FormErrorTranslator.prototype.translateErrors = function (errors, opts) {
|
|
4171
|
+
var _this = this;
|
|
4172
|
+
var separator = opts && opts.separator || ', ';
|
|
4173
|
+
return errors && Object.keys(errors).reduce(function (res, path) {
|
|
4174
|
+
var pathErrors = errors[path];
|
|
4175
|
+
// Should be a control map of errors
|
|
4176
|
+
if (pathErrors) {
|
|
4177
|
+
// Try to convert the control path
|
|
4178
|
+
var i18nPath = _this.translateControlPath(path, opts);
|
|
4179
|
+
// OK, we have a field name: use it
|
|
4180
|
+
var columnErrors = Object.keys(pathErrors).map(function (errorKey) { return _this.translateError(errorKey, pathErrors[errorKey]); });
|
|
4181
|
+
if (isEmptyArray(columnErrors))
|
|
4182
|
+
return res;
|
|
4183
|
+
// Add separator
|
|
4184
|
+
if (res.length)
|
|
4185
|
+
res += separator;
|
|
4186
|
+
return res + i18nPath + ": " + columnErrors.join(separator);
|
|
4187
|
+
}
|
|
4188
|
+
// Or try as global form error
|
|
4189
|
+
var formError = _this.translateError(path, pathErrors);
|
|
4190
|
+
if (isNil(formError))
|
|
4191
|
+
return res;
|
|
4192
|
+
return res + (res.length ? separator : '') + formError;
|
|
4193
|
+
}, "");
|
|
4194
|
+
};
|
|
4170
4195
|
FormErrorTranslator.prototype.translateControlPath = function (path, opts) {
|
|
4171
4196
|
if (opts === null || opts === void 0 ? void 0 : opts.controlPathTranslator) {
|
|
4172
4197
|
return opts === null || opts === void 0 ? void 0 : opts.controlPathTranslator.translateControlPath(path);
|
|
@@ -4241,7 +4266,7 @@
|
|
|
4241
4266
|
};
|
|
4242
4267
|
FormErrorTranslatePipe.prototype._updateValue = function (form, opts, status) {
|
|
4243
4268
|
if (status === 'INVALID' || form.invalid) {
|
|
4244
|
-
this.value = this.adapter.
|
|
4269
|
+
this.value = this.adapter.translateFormErrors(form, opts);
|
|
4245
4270
|
this._ref.markForCheck();
|
|
4246
4271
|
}
|
|
4247
4272
|
else if (this.value !== undefined) {
|
|
@@ -19578,7 +19603,7 @@
|
|
|
19578
19603
|
AppForm.prototype.getFormError = function (form, opts) {
|
|
19579
19604
|
if (!form || !this.errorTranslator)
|
|
19580
19605
|
return undefined;
|
|
19581
|
-
return this.errorTranslator.
|
|
19606
|
+
return this.errorTranslator.translateFormErrors(this.form, Object.assign({ controlPathTranslator: this }, opts));
|
|
19582
19607
|
};
|
|
19583
19608
|
AppForm.prototype.getI18nFieldName = function (path) {
|
|
19584
19609
|
return (this.i18nFieldPrefix || '') + changeCaseToUnderscore(path).toUpperCase();
|
|
@@ -25479,7 +25504,7 @@
|
|
|
25479
25504
|
row = row || this.editedRow;
|
|
25480
25505
|
if (!row || !this.formErrorAdapter)
|
|
25481
25506
|
return undefined;
|
|
25482
|
-
return this.formErrorAdapter.
|
|
25507
|
+
return this.formErrorAdapter.translateFormErrors(row.validator, Object.assign(Object.assign({}, this.errorTranslatorOptions), opts));
|
|
25483
25508
|
};
|
|
25484
25509
|
AppTable.prototype.setError = function (value, opts) {
|
|
25485
25510
|
if (this.errorSubject.value !== value) {
|
|
@@ -26404,7 +26429,7 @@
|
|
|
26404
26429
|
enableListenChanges: (injector.get(ENVIRONMENT).listenRemoteChanges === true), pathIdAttribute: 'id', autoLoad: true, autoUpdateRoute: true, i18nPrefix: ''
|
|
26405
26430
|
}, options);
|
|
26406
26431
|
_this.settings = injector.get(LocalSettingsService);
|
|
26407
|
-
_this.
|
|
26432
|
+
_this.errorTranslator = injector.get(FormErrorTranslator);
|
|
26408
26433
|
_this.cd = injector.get(i0.ChangeDetectorRef);
|
|
26409
26434
|
_this.dateFormat = injector.get(DateFormatPipe);
|
|
26410
26435
|
_this.toastController = injector.get(i1$5.ToastController);
|
|
@@ -26966,7 +26991,7 @@
|
|
|
26966
26991
|
var userMessage = err && err.message && this.translate.instant(err.message) || err;
|
|
26967
26992
|
// Add details error (if any) under the main message
|
|
26968
26993
|
var detailMessage = err && err.details && (err.details.message || err.details) || undefined;
|
|
26969
|
-
if (detailMessage) {
|
|
26994
|
+
if (isNotNilString(detailMessage)) {
|
|
26970
26995
|
userMessage += "<br/><small class=\"hidden-xs hidden-sm\" title=\"" + detailMessage + "\">";
|
|
26971
26996
|
userMessage += detailMessage.length < 70 ? detailMessage : detailMessage.substring(0, 67) + '...';
|
|
26972
26997
|
userMessage += '</small>';
|