@planeasyinc/le-angular 0.0.13 → 0.0.15
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/dist/fesm2022/planeasyinc-le-angular.mjs +45 -7
- package/dist/fesm2022/planeasyinc-le-angular.mjs.map +1 -1
- package/dist/lib/services/le-api.service.d.ts +1 -1
- package/dist/lib/services/le-data.service.d.ts +1 -1
- package/dist/lib/views/form-view/form-view.utils.d.ts +3 -1
- package/package.json +1 -1
|
@@ -1362,13 +1362,14 @@ class TableViewComponent {
|
|
|
1362
1362
|
}
|
|
1363
1363
|
processRowClickAction(action, row) {
|
|
1364
1364
|
const { type, node } = action;
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1365
|
+
const clone = JSON.parse(JSON.stringify(node));
|
|
1366
|
+
if (type === 'open_sidebar' && 'controlSource' in clone) {
|
|
1367
|
+
if (clone.controlSource?.params) {
|
|
1368
|
+
clone.controlSource.params = this.interpolateRowValues(clone.controlSource.params, row);
|
|
1368
1369
|
}
|
|
1369
1370
|
this.sidePanelService
|
|
1370
1371
|
.show({
|
|
1371
|
-
node,
|
|
1372
|
+
node: clone,
|
|
1372
1373
|
tabs: [],
|
|
1373
1374
|
config: { hasCloseButton: true, skipLocationChange: true },
|
|
1374
1375
|
}, {
|
|
@@ -1644,7 +1645,36 @@ const getValueByPath = (obj = {}, path) => {
|
|
|
1644
1645
|
}
|
|
1645
1646
|
return obj[path];
|
|
1646
1647
|
};
|
|
1647
|
-
const
|
|
1648
|
+
const parseLooseJSON = (str) => {
|
|
1649
|
+
const clean = str.trim().replace(/,\s*([}\]])/g, '$1');
|
|
1650
|
+
try {
|
|
1651
|
+
return JSON.parse(clean);
|
|
1652
|
+
}
|
|
1653
|
+
catch {
|
|
1654
|
+
return str;
|
|
1655
|
+
}
|
|
1656
|
+
};
|
|
1657
|
+
const mapBodyStringModelToRequestBody = (bodyModel, values = {}) => {
|
|
1658
|
+
if (isPlaceholder(bodyModel)) {
|
|
1659
|
+
const path = getPlaceholderValue(bodyModel);
|
|
1660
|
+
const value = getValueByPath(values, path);
|
|
1661
|
+
if (value !== null && value !== undefined && value !== '') {
|
|
1662
|
+
try {
|
|
1663
|
+
return parseLooseJSON(value);
|
|
1664
|
+
}
|
|
1665
|
+
catch {
|
|
1666
|
+
return value;
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
else {
|
|
1670
|
+
return null;
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
else {
|
|
1674
|
+
return bodyModel;
|
|
1675
|
+
}
|
|
1676
|
+
};
|
|
1677
|
+
const mapBodyObjectModelToRequestBody = (bodyModel = {}, values = {}) => {
|
|
1648
1678
|
const result = {};
|
|
1649
1679
|
for (const { 0: key, 1: placeholder } of Object.entries(bodyModel)) {
|
|
1650
1680
|
if (isPlaceholder(placeholder)) {
|
|
@@ -1658,7 +1688,7 @@ const mapBodyModelToRequestBody = (bodyModel = {}, values = {}) => {
|
|
|
1658
1688
|
}
|
|
1659
1689
|
}
|
|
1660
1690
|
else if (isObject(placeholder)) {
|
|
1661
|
-
result[key] =
|
|
1691
|
+
result[key] = mapBodyObjectModelToRequestBody(placeholder, values);
|
|
1662
1692
|
}
|
|
1663
1693
|
else {
|
|
1664
1694
|
result[key] = placeholder;
|
|
@@ -1666,6 +1696,12 @@ const mapBodyModelToRequestBody = (bodyModel = {}, values = {}) => {
|
|
|
1666
1696
|
}
|
|
1667
1697
|
return result;
|
|
1668
1698
|
};
|
|
1699
|
+
const mapBodyModelToRequestBody = (bodyModel, values) => {
|
|
1700
|
+
if (typeof bodyModel === 'string') {
|
|
1701
|
+
return mapBodyStringModelToRequestBody(bodyModel, values);
|
|
1702
|
+
}
|
|
1703
|
+
return mapBodyObjectModelToRequestBody(bodyModel, values);
|
|
1704
|
+
};
|
|
1669
1705
|
|
|
1670
1706
|
class ToastListComponent {
|
|
1671
1707
|
toastService = inject(LeToastService);
|
|
@@ -1966,6 +2002,8 @@ class FormViewComponent {
|
|
|
1966
2002
|
else {
|
|
1967
2003
|
this._isLoading.set(false);
|
|
1968
2004
|
}
|
|
2005
|
+
this.event.emit({ type: 'refresh' });
|
|
2006
|
+
this.event.emit({ type: 'close' });
|
|
1969
2007
|
}), map(() => null), catchError(() => {
|
|
1970
2008
|
if (action.onError) {
|
|
1971
2009
|
this.processActionList(action.onError);
|
|
@@ -1988,7 +2026,7 @@ class FormViewComponent {
|
|
|
1988
2026
|
return of(null);
|
|
1989
2027
|
},
|
|
1990
2028
|
update_value: (action, response) => {
|
|
1991
|
-
return of(action).pipe(filter((action) => isPlaceholder(action.value)), map((action) =>
|
|
2029
|
+
return of(action).pipe(filter((action) => isPlaceholder(action.value)), map((action) => mapBodyObjectModelToRequestBody({ [action.field_id]: action.value }, { response })), tap((result) => {
|
|
1992
2030
|
if (result[action.field_id]) {
|
|
1993
2031
|
this._engine()?.values.set(action.field_id, result[action.field_id]);
|
|
1994
2032
|
}
|