@sumaris-net/ngx-components 0.25.11 → 0.25.12
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 +30 -38
- 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/form-error.adapter.js +15 -7
- package/esm2015/src/app/core/table/table.class.js +13 -32
- package/fesm2015/sumaris-net.ngx-components.js +26 -38
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/core/form/form-error.adapter.d.ts +16 -4
- package/src/app/core/table/table.class.d.ts +3 -0
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -22219,6 +22219,11 @@
|
|
|
22219
22219
|
forward: [{ type: i0.Output }]
|
|
22220
22220
|
};
|
|
22221
22221
|
|
|
22222
|
+
var IFormI18nService = /** @class */ (function () {
|
|
22223
|
+
function IFormI18nService() {
|
|
22224
|
+
}
|
|
22225
|
+
return IFormI18nService;
|
|
22226
|
+
}());
|
|
22222
22227
|
var FormErrorAdapter = /** @class */ (function () {
|
|
22223
22228
|
function FormErrorAdapter(translate) {
|
|
22224
22229
|
this.translate = translate;
|
|
@@ -22230,12 +22235,12 @@
|
|
|
22230
22235
|
var separator = opts && opts.separator || ', ';
|
|
22231
22236
|
var recursive = !opts || opts.recursive !== false;
|
|
22232
22237
|
var errors = AppFormUtils.getFormErrors(form, { recursive: recursive });
|
|
22233
|
-
var i18nErrors = errors && Object.keys(errors).reduce(function (res,
|
|
22234
|
-
var control = form.get(
|
|
22238
|
+
var i18nErrors = errors && Object.keys(errors).reduce(function (res, fieldName) {
|
|
22239
|
+
var control = form.get(fieldName);
|
|
22235
22240
|
// Should be a control map of errors
|
|
22236
22241
|
if (control) {
|
|
22237
22242
|
// Try to convert from a map, for one column control
|
|
22238
|
-
var i18nFieldNameKey = _this.
|
|
22243
|
+
var i18nFieldNameKey = _this.getI18nKey(fieldName, opts);
|
|
22239
22244
|
var i18nFieldName = _this.translate.instant(i18nFieldNameKey);
|
|
22240
22245
|
// OK, we have a field name: use it
|
|
22241
22246
|
var columnErrors = Object.keys(control.errors).map(function (errorKey) { return _this.getI18nError(errorKey, control.errors[errorKey]); });
|
|
@@ -22247,18 +22252,24 @@
|
|
|
22247
22252
|
return res + i18nFieldName + ": " + columnErrors.join(separator);
|
|
22248
22253
|
}
|
|
22249
22254
|
// Or try as global form error
|
|
22250
|
-
var formError = _this.getI18nError(
|
|
22255
|
+
var formError = _this.getI18nError(fieldName, errors[fieldName]);
|
|
22251
22256
|
if (isNil(formError))
|
|
22252
22257
|
return res;
|
|
22253
22258
|
return res + (res.length ? separator : '') + formError;
|
|
22254
22259
|
}, "");
|
|
22255
22260
|
return i18nErrors;
|
|
22256
22261
|
};
|
|
22257
|
-
FormErrorAdapter.prototype.
|
|
22262
|
+
FormErrorAdapter.prototype.getI18nKey = function (fieldName, opts) {
|
|
22263
|
+
if (opts === null || opts === void 0 ? void 0 : opts.i18nService) {
|
|
22264
|
+
return opts === null || opts === void 0 ? void 0 : opts.i18nService.getI18nFieldName(fieldName);
|
|
22265
|
+
}
|
|
22258
22266
|
return (opts && opts.i18nPrefix || '') + changeCaseToUnderscore(fieldName).toUpperCase();
|
|
22259
22267
|
};
|
|
22260
|
-
FormErrorAdapter.prototype.getI18nError = function (errorKey, errorContent) {
|
|
22268
|
+
FormErrorAdapter.prototype.getI18nError = function (errorKey, errorContent, opts) {
|
|
22261
22269
|
var _this = this;
|
|
22270
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.i18nService) && (opts === null || opts === void 0 ? void 0 : opts.i18nService.getI18nError)) {
|
|
22271
|
+
return opts === null || opts === void 0 ? void 0 : opts.i18nService.getI18nError(errorKey, errorContent);
|
|
22272
|
+
}
|
|
22262
22273
|
return SharedValidators.translateError(function (a, b) { return _this.translate.instant(a, b); }, errorKey, errorContent);
|
|
22263
22274
|
};
|
|
22264
22275
|
return FormErrorAdapter;
|
|
@@ -23362,6 +23373,7 @@
|
|
|
23362
23373
|
// eslint-disable-next-line @angular-eslint/directive-class-suffix
|
|
23363
23374
|
var AppTable = /** @class */ (function () {
|
|
23364
23375
|
function AppTable(route, router, platform, location, modalCtrl, settings, columns, _dataSource, _filter, injector) {
|
|
23376
|
+
var _this = this;
|
|
23365
23377
|
this.route = route;
|
|
23366
23378
|
this.router = router;
|
|
23367
23379
|
this.platform = platform;
|
|
@@ -23410,13 +23422,18 @@
|
|
|
23410
23422
|
this.onError = new i0.EventEmitter();
|
|
23411
23423
|
this._paginator = null;
|
|
23412
23424
|
this.mobile = this.platform.is('mobile');
|
|
23413
|
-
this.translate = injector
|
|
23414
|
-
this.
|
|
23415
|
-
this.
|
|
23425
|
+
this.translate = injector === null || injector === void 0 ? void 0 : injector.get(i1$2.TranslateService);
|
|
23426
|
+
this.formErrorAdapter = injector === null || injector === void 0 ? void 0 : injector.get(FormErrorAdapter);
|
|
23427
|
+
this.alertCtrl = injector === null || injector === void 0 ? void 0 : injector.get(i1$5.AlertController);
|
|
23428
|
+
this.toastController = injector === null || injector === void 0 ? void 0 : injector.get(i1$5.ToastController);
|
|
23416
23429
|
this._autocompleteConfigHolder = new MatAutocompleteConfigHolder({
|
|
23417
23430
|
getUserAttributes: function (a, b) { return settings.getFieldDisplayAttributes(a, b); }
|
|
23418
23431
|
});
|
|
23419
23432
|
this.autocompleteFields = this._autocompleteConfigHolder.fields;
|
|
23433
|
+
this.i18nService = (injector === null || injector === void 0 ? void 0 : injector.get(IFormI18nService)) || {
|
|
23434
|
+
getI18nFieldName: function (f) { return _this.getI18nFieldName(f); },
|
|
23435
|
+
getI18nError: function (e, c) { return _this.getI18nError(e, c); }
|
|
23436
|
+
};
|
|
23420
23437
|
}
|
|
23421
23438
|
Object.defineProperty(AppTable.prototype, "error", {
|
|
23422
23439
|
get: function () {
|
|
@@ -24881,40 +24898,14 @@
|
|
|
24881
24898
|
this.setError(undefined, opts);
|
|
24882
24899
|
};
|
|
24883
24900
|
AppTable.prototype.getRowError = function (row, opts) {
|
|
24884
|
-
var _this = this;
|
|
24885
24901
|
row = row || this.editedRow;
|
|
24886
|
-
if (!row || !this.
|
|
24902
|
+
if (!row || !this.formErrorAdapter)
|
|
24887
24903
|
return undefined;
|
|
24888
|
-
|
|
24889
|
-
var recursive = !opts || opts.recursive !== false;
|
|
24890
|
-
var errors = AppFormUtils.getFormErrors(row.validator, { recursive: recursive });
|
|
24891
|
-
var i18nErrors = errors && Object.keys(errors).reduce(function (res, key) {
|
|
24892
|
-
var control = row.validator.get(key);
|
|
24893
|
-
// Should be a control map of errors
|
|
24894
|
-
if (control) {
|
|
24895
|
-
// Try to convert from a map, for one column control
|
|
24896
|
-
var i18nFieldNameKey = _this.getI18nFieldName(key);
|
|
24897
|
-
var i18nFieldName = _this.translate.instant(i18nFieldNameKey);
|
|
24898
|
-
// OK, we have a field name: use it
|
|
24899
|
-
var columnErrors = Object.keys(control.errors).map(function (errorKey) { return _this.getI18nError(errorKey, control.errors[errorKey]); });
|
|
24900
|
-
if (isEmptyArray(columnErrors))
|
|
24901
|
-
return res;
|
|
24902
|
-
// Add separator
|
|
24903
|
-
if (res.length)
|
|
24904
|
-
res += separator;
|
|
24905
|
-
return res + i18nFieldName + ": " + columnErrors.join(separator);
|
|
24906
|
-
}
|
|
24907
|
-
// Or try as global form error
|
|
24908
|
-
var formError = _this.getI18nError(key, errors[key]);
|
|
24909
|
-
if (isNil(formError))
|
|
24910
|
-
return res;
|
|
24911
|
-
return res + (res.length ? separator : '') + formError;
|
|
24912
|
-
}, "");
|
|
24913
|
-
return i18nErrors;
|
|
24904
|
+
return this.formErrorAdapter.formatError(row.validator, Object.assign({ i18nService: this.i18nService }, opts));
|
|
24914
24905
|
};
|
|
24915
24906
|
AppTable.prototype.getI18nFieldName = function (fieldName) {
|
|
24916
|
-
// Use columns has default name
|
|
24917
24907
|
// Can be override by subclasses, to resolve all field name
|
|
24908
|
+
// Use columns has default name
|
|
24918
24909
|
return this.getI18nColumnName(fieldName);
|
|
24919
24910
|
};
|
|
24920
24911
|
AppTable.prototype.getI18nError = function (errorKey, errorContent) {
|
|
@@ -27790,6 +27781,7 @@
|
|
|
27790
27781
|
exports.HomePage = HomePage;
|
|
27791
27782
|
exports.Hotkeys = Hotkeys;
|
|
27792
27783
|
exports.HotkeysDialogComponent = HotkeysDialogComponent;
|
|
27784
|
+
exports.IFormI18nService = IFormI18nService;
|
|
27793
27785
|
exports.InMemoryEntitiesService = InMemoryEntitiesService;
|
|
27794
27786
|
exports.IsLoginAccountPipe = IsLoginAccountPipe;
|
|
27795
27787
|
exports.IsNilOrBlankPipe = IsNilOrBlankPipe;
|