@stemy/ngx-dynamic-form 19.8.19 → 19.8.21
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.
|
@@ -239,7 +239,7 @@ function setFieldDefault(field, value) {
|
|
|
239
239
|
field.defaultValue = value instanceof Date ? convertToDateFormat(value, field.props?.type || "date") : value;
|
|
240
240
|
}
|
|
241
241
|
function setFieldValue(field, value) {
|
|
242
|
-
field.formControl
|
|
242
|
+
field.formControl?.setValue(value instanceof Date ? convertToDateFormat(value, field.props?.type || "date") : value);
|
|
243
243
|
}
|
|
244
244
|
function setFieldProps(field, values) {
|
|
245
245
|
if (!ObjectUtils.isObject(values))
|
|
@@ -1537,21 +1537,26 @@ class DynamicFormService {
|
|
|
1537
1537
|
}
|
|
1538
1538
|
async serialize(fields, purposes = []) {
|
|
1539
1539
|
const result = {};
|
|
1540
|
-
purposes = purposes ?? [];
|
|
1541
1540
|
if (!fields)
|
|
1542
1541
|
return result;
|
|
1542
|
+
purposes = purposes || [];
|
|
1543
1543
|
for (const field of fields) {
|
|
1544
1544
|
const serializer = field.serializer;
|
|
1545
1545
|
const key = `${field.key}`;
|
|
1546
1546
|
const shouldSerialize = field.serialize?.(field, this.injector) ?? field.props?.hidden !== true;
|
|
1547
|
-
|
|
1548
|
-
if (!shouldSerialize
|
|
1547
|
+
// If field should not be serialized
|
|
1548
|
+
if (!shouldSerialize) {
|
|
1549
1549
|
continue;
|
|
1550
1550
|
}
|
|
1551
|
+
// If a custom serializer is defined
|
|
1551
1552
|
if (ObjectUtils.isFunction(serializer)) {
|
|
1552
1553
|
result[key] = await serializer(field, this.injector);
|
|
1553
1554
|
continue;
|
|
1554
1555
|
}
|
|
1556
|
+
// If field purposes dont match
|
|
1557
|
+
if (purposes.length > 0 && field.key && purposes.every(p => !field.purposes?.includes(p))) {
|
|
1558
|
+
continue;
|
|
1559
|
+
}
|
|
1555
1560
|
const control = field.formControl;
|
|
1556
1561
|
if (field.fieldGroup) {
|
|
1557
1562
|
const group = await this.serialize(field.fieldGroup, purposes);
|