@sumaris-net/ngx-components 2.4.50 → 2.4.52
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/esm2020/src/app/shared/form/field.component.mjs +4 -2
- package/esm2020/src/app/shared/functions.mjs +6 -4
- package/fesm2015/sumaris-net.ngx-components.mjs +8 -4
- package/fesm2015/sumaris-net.ngx-components.mjs.map +1 -1
- package/fesm2020/sumaris-net.ngx-components.mjs +8 -4
- package/fesm2020/sumaris-net.ngx-components.mjs.map +1 -1
- package/package.json +1 -1
- package/src/app/shared/functions.d.ts +2 -1
|
@@ -210,7 +210,8 @@ function arrayGroupBy(obj, key) {
|
|
|
210
210
|
}, {});
|
|
211
211
|
}
|
|
212
212
|
/**
|
|
213
|
-
* Remove duplicated value, in array. Will compute a unique key (from given properties, or given function)
|
|
213
|
+
* Remove duplicated value, in array. Will compute a unique key (from given properties, or given function).
|
|
214
|
+
* If propertiesOrKeyFn is nil or undefined, will use all object properties
|
|
214
215
|
* @param values
|
|
215
216
|
* @param propertiesOrKeyFn
|
|
216
217
|
*/
|
|
@@ -220,6 +221,7 @@ function arrayDistinct(values, propertiesOrKeyFn) {
|
|
|
220
221
|
const properties = (!propertiesOrKeyFn && Object.keys(values[0])) || (Array.isArray(propertiesOrKeyFn) && propertiesOrKeyFn);
|
|
221
222
|
const getKey = (typeof propertiesOrKeyFn === 'function' && propertiesOrKeyFn)
|
|
222
223
|
|| (typeof propertiesOrKeyFn === 'string' && ((obj) => getPropertyByPathAsString(obj, propertiesOrKeyFn)))
|
|
224
|
+
|| (isEmptyArray(properties) && ((obj) => obj?.toString()))
|
|
223
225
|
|| ((obj) => joinPropertiesPath(obj, properties, '|'));
|
|
224
226
|
const existingIds = new Set();
|
|
225
227
|
return values.reduce((res, item) => {
|
|
@@ -318,8 +320,8 @@ function suggestFromStringArray(values, value, options) {
|
|
|
318
320
|
function joinPropertiesPath(obj, properties, separator) {
|
|
319
321
|
if (!obj)
|
|
320
322
|
throw new Error('Could not display an undefined entity.');
|
|
321
|
-
if (
|
|
322
|
-
throw new Error('Missing \'properties\' argument');
|
|
323
|
+
if (isEmptyArray(properties))
|
|
324
|
+
throw new Error('Missing or empty \'properties\' argument');
|
|
323
325
|
return properties
|
|
324
326
|
.map(path => getPropertyByPath(obj, path))
|
|
325
327
|
.filter(isNotNilOrBlank)
|
|
@@ -10239,7 +10241,9 @@ class AppFormField {
|
|
|
10239
10241
|
computeValues(values) {
|
|
10240
10242
|
if (!values)
|
|
10241
10243
|
return [];
|
|
10242
|
-
return values.map(v => (typeof v === 'string'
|
|
10244
|
+
return values.map(v => (typeof v === 'string')
|
|
10245
|
+
? { key: v, value: v }
|
|
10246
|
+
: { key: v.key, value: this.translate.instant(v.value) });
|
|
10243
10247
|
}
|
|
10244
10248
|
checkAndResolveFormControl() {
|
|
10245
10249
|
if (this.formControl)
|