@lenne.tech/ng-base 14.13.1 → 14.13.2
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/base-components/components/model-form/model-form.component.d.ts +7 -0
- package/esm2020/base-components/components/model-form/model-form.component.mjs +36 -23
- package/esm2020/shared/services/forms.service.mjs +12 -4
- package/fesm2015/lenne.tech-ng-base-base-components.mjs +41 -27
- package/fesm2015/lenne.tech-ng-base-base-components.mjs.map +1 -1
- package/fesm2015/lenne.tech-ng-base-shared.mjs +12 -3
- package/fesm2015/lenne.tech-ng-base-shared.mjs.map +1 -1
- package/fesm2020/lenne.tech-ng-base-base-components.mjs +35 -22
- package/fesm2020/lenne.tech-ng-base-base-components.mjs.map +1 -1
- package/fesm2020/lenne.tech-ng-base-shared.mjs +11 -3
- package/fesm2020/lenne.tech-ng-base-shared.mjs.map +1 -1
- package/package.json +1 -1
- package/shared/services/forms.service.d.ts +1 -0
|
@@ -1477,28 +1477,9 @@ class ModelFormComponent {
|
|
|
1477
1477
|
if (this.logging) {
|
|
1478
1478
|
console.log('ModelFormComponent::submit->formValue', this.form.value);
|
|
1479
1479
|
}
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
this.config[key]?.exclude) {
|
|
1484
|
-
delete data[key];
|
|
1485
|
-
}
|
|
1486
|
-
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
1487
|
-
data[key] = Object.keys(data[key])
|
|
1488
|
-
.filter((k) => data[key][k] != null)
|
|
1489
|
-
.reduce((a, k) => ({ ...a, [k]: data[key][k] }), {});
|
|
1490
|
-
if (Object.keys(data[key])?.length === 0) {
|
|
1491
|
-
if (this.logging) {
|
|
1492
|
-
console.log('Object is empty from result');
|
|
1493
|
-
}
|
|
1494
|
-
data[key] = null;
|
|
1495
|
-
}
|
|
1496
|
-
}
|
|
1497
|
-
// Set type for graphql method
|
|
1498
|
-
if (this.fields[key]?.type === 'Float') {
|
|
1499
|
-
data[key] = Number(value);
|
|
1500
|
-
}
|
|
1501
|
-
}
|
|
1480
|
+
// Prepare data for server request
|
|
1481
|
+
let data = Object.assign({}, this.form.value);
|
|
1482
|
+
data = this.prepareDataForRequest(this.config, this.fields, data);
|
|
1502
1483
|
if (this.logging) {
|
|
1503
1484
|
console.log('ModelFormComponent::submit->valueToGraphql', data);
|
|
1504
1485
|
}
|
|
@@ -1567,6 +1548,35 @@ class ModelFormComponent {
|
|
|
1567
1548
|
});
|
|
1568
1549
|
});
|
|
1569
1550
|
}
|
|
1551
|
+
/**
|
|
1552
|
+
* Prepare data for server
|
|
1553
|
+
*/
|
|
1554
|
+
prepareDataForRequest(config, fieldsConfig, data) {
|
|
1555
|
+
for (const [key, value] of Object.entries(data)) {
|
|
1556
|
+
if ((config[key]?.roles ? !this.user.hasAllRoles(config[key]?.roles) : false) || config[key]?.exclude) {
|
|
1557
|
+
delete data[key];
|
|
1558
|
+
}
|
|
1559
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
1560
|
+
data[key] = Object.keys(data[key])
|
|
1561
|
+
.filter((k) => data[key][k] != null)
|
|
1562
|
+
.reduce((a, k) => ({ ...a, [k]: data[key][k] }), {});
|
|
1563
|
+
if (Object.keys(data[key])?.length === 0) {
|
|
1564
|
+
if (this.logging) {
|
|
1565
|
+
console.log('Object is empty from result');
|
|
1566
|
+
}
|
|
1567
|
+
data[key] = null;
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
// Set type for graphql method
|
|
1571
|
+
if (fieldsConfig[key]?.type === 'Float') {
|
|
1572
|
+
data[key] = Number(value);
|
|
1573
|
+
}
|
|
1574
|
+
if (fieldsConfig[key]?.fields && Object.keys(fieldsConfig[key]?.fields).length > 0) {
|
|
1575
|
+
data[key] = this.prepareDataForRequest(config[key]?.fields, fieldsConfig[key]?.fields, data[key]);
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
return data;
|
|
1579
|
+
}
|
|
1570
1580
|
/**
|
|
1571
1581
|
* Init fab buttons for mobile devices
|
|
1572
1582
|
*/
|
|
@@ -1585,6 +1595,9 @@ class ModelFormComponent {
|
|
|
1585
1595
|
event.subscribe(() => this.deleteObject());
|
|
1586
1596
|
}
|
|
1587
1597
|
}
|
|
1598
|
+
/**
|
|
1599
|
+
* Set file changes for process
|
|
1600
|
+
*/
|
|
1588
1601
|
processFileChanges(event) {
|
|
1589
1602
|
const index = this.fileChanges?.findIndex((e) => e.field === event.field);
|
|
1590
1603
|
if (index !== undefined && index !== -1) {
|