@stemy/ngx-dynamic-form 19.9.18 → 19.9.19
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.
|
@@ -769,11 +769,13 @@ class DynamicFormBuilderService {
|
|
|
769
769
|
}
|
|
770
770
|
createFormSelect(key, data, parent, options) {
|
|
771
771
|
data = data || {};
|
|
772
|
+
const multiple = data.multiple === true;
|
|
773
|
+
data.defaultValue = data.defaultValue ?? (multiple ? [] : null);
|
|
772
774
|
const type = `${data.type || "select"}`;
|
|
773
775
|
const fieldType = type === "radio" ? type : (data.strict === false ? "chips" : "select");
|
|
774
776
|
const field = this.createFormField(key, fieldType, data, {
|
|
775
777
|
type,
|
|
776
|
-
multiple
|
|
778
|
+
multiple,
|
|
777
779
|
strict: data.strict !== false,
|
|
778
780
|
allowEmpty: data.allowEmpty === true,
|
|
779
781
|
groupBy: data.groupBy,
|
|
@@ -933,8 +935,15 @@ class DynamicFormBuilderService {
|
|
|
933
935
|
}));
|
|
934
936
|
const control = field.formControl;
|
|
935
937
|
const multiple = field.props.multiple;
|
|
936
|
-
|
|
937
|
-
|
|
938
|
+
if (multiple) {
|
|
939
|
+
// Handle if current control value is not an array
|
|
940
|
+
const value = Array.isArray(control.value)
|
|
941
|
+
? control.value
|
|
942
|
+
: String(control.value || "").split(",");
|
|
943
|
+
control.setValue(value);
|
|
944
|
+
return options;
|
|
945
|
+
}
|
|
946
|
+
if (options.length === 0 || options.findIndex(o => o.value === control.value) >= 0)
|
|
938
947
|
return options;
|
|
939
948
|
control.setValue(field.defaultValue);
|
|
940
949
|
return options;
|
|
@@ -1378,8 +1387,9 @@ class DynamicFormSchemaService {
|
|
|
1378
1387
|
const endpoint = entries.reduce((res, [key, control]) => {
|
|
1379
1388
|
return this.replaceOptionsEndpoint(res, key, control.value);
|
|
1380
1389
|
}, `${property.endpoint}`);
|
|
1390
|
+
const cache = property.cache ?? new Date(Date.now() + 20_000);
|
|
1381
1391
|
const data = await this.api.list(endpoint, this.api.makeListParams(1, -1), {
|
|
1382
|
-
cache: this.api.cached(
|
|
1392
|
+
cache: this.api.cached(cache),
|
|
1383
1393
|
read: String(property.responseProperty || "")
|
|
1384
1394
|
});
|
|
1385
1395
|
const items = ObjectUtils.isArray(data)
|