@planeasyinc/le-angular 0.0.18 → 0.0.20
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 +23 -7
- package/dist/fesm2022/planeasyinc-le-angular.mjs.map +1 -1
- package/dist/lib/icons/le-icon.component.d.ts +1 -1
- package/dist/lib/views/form-view/form-view.component.d.ts +0 -1
- package/dist/lib/views/form-view/form-view.utils.d.ts +13 -3
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, inject, signal, Injectable, computed, effect, untracked, Directive, input, ChangeDetectionStrategy, Component, output, forwardRef, ViewContainerRef, Injector, Renderer2, ElementRef, DestroyRef,
|
|
2
|
+
import { InjectionToken, inject, signal, Injectable, computed, effect, untracked, Directive, input, ChangeDetectionStrategy, Component, output, forwardRef, ViewContainerRef, Injector, Renderer2, ElementRef, DestroyRef, viewChild } from '@angular/core';
|
|
3
3
|
import { HttpContextToken, HttpClient, HttpContext, HttpRequest, HttpEventType } from '@angular/common/http';
|
|
4
4
|
import { map, filter, distinctUntilChanged, BehaviorSubject, Subject, takeUntil, firstValueFrom, of, tap, catchError, from, concatMap, finalize, fromEvent, startWith } from 'rxjs';
|
|
5
5
|
import { decodeJwt, UrlFragmentBuilder, normalizeConfig } from '@planeasyinc/le-core';
|
|
@@ -1725,13 +1725,27 @@ const traverse = (entity, path, cb) => {
|
|
|
1725
1725
|
const isTabJSON = (control) => {
|
|
1726
1726
|
return control.name.toLowerCase().includes('json');
|
|
1727
1727
|
};
|
|
1728
|
-
|
|
1728
|
+
/**
|
|
1729
|
+
*
|
|
1730
|
+
* @param source Control Config with nested controls
|
|
1731
|
+
* @param target Control Config with json value
|
|
1732
|
+
* @param engine Form Engine
|
|
1733
|
+
*
|
|
1734
|
+
* @description
|
|
1735
|
+
* Traverse source Control Config tree, get latest value from state.
|
|
1736
|
+
* If no value found in state, set target Control Config initial value
|
|
1737
|
+
*/
|
|
1738
|
+
const getTabFormValues = (source, target, engine) => {
|
|
1729
1739
|
const result = {};
|
|
1730
|
-
|
|
1740
|
+
const targetValueObject = mapJSONToFormValues(target.value);
|
|
1741
|
+
traverse(source, ['meta', 'controls'], (ctrl) => {
|
|
1731
1742
|
if (!ctrl.id) {
|
|
1732
1743
|
return;
|
|
1733
1744
|
}
|
|
1734
|
-
|
|
1745
|
+
let value = engine.values.get(ctrl.id);
|
|
1746
|
+
if (value === undefined) {
|
|
1747
|
+
value = targetValueObject[ctrl.id];
|
|
1748
|
+
}
|
|
1735
1749
|
if (value === undefined) {
|
|
1736
1750
|
return;
|
|
1737
1751
|
}
|
|
@@ -1743,7 +1757,10 @@ const mapFormValuesToJSON = (values) => {
|
|
|
1743
1757
|
return JSON.stringify(values, null, 2);
|
|
1744
1758
|
};
|
|
1745
1759
|
const mapJSONToFormValues = (json) => {
|
|
1746
|
-
|
|
1760
|
+
if (typeof json === 'string') {
|
|
1761
|
+
return JSON.parse(json);
|
|
1762
|
+
}
|
|
1763
|
+
throw new Error('The `json` parameter is not a valid JSON');
|
|
1747
1764
|
};
|
|
1748
1765
|
const getTabJSONControl = (control, engine) => {
|
|
1749
1766
|
let result;
|
|
@@ -2018,7 +2035,6 @@ class FormViewComponent {
|
|
|
2018
2035
|
attachmentService = inject(FormViewAttachmentService);
|
|
2019
2036
|
viewportScroller = inject(ViewportScroller);
|
|
2020
2037
|
toastService = inject(LeToastService);
|
|
2021
|
-
cdr = inject(ChangeDetectorRef);
|
|
2022
2038
|
_isLoading = signal(false);
|
|
2023
2039
|
_form = signal(null);
|
|
2024
2040
|
_sections = signal([]);
|
|
@@ -2121,8 +2137,8 @@ class FormViewComponent {
|
|
|
2121
2137
|
});
|
|
2122
2138
|
}
|
|
2123
2139
|
else {
|
|
2124
|
-
const value = mapFormValuesToJSON(getTabFormValues(action.source, engine));
|
|
2125
2140
|
const target = getTabJSONControl(action.target, engine);
|
|
2141
|
+
const value = mapFormValuesToJSON(getTabFormValues(action.source, target, engine));
|
|
2126
2142
|
engine.values.set(target.id, value);
|
|
2127
2143
|
}
|
|
2128
2144
|
}
|