@planeasyinc/le-angular 0.0.15 → 0.0.17
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 +72 -1
- package/dist/fesm2022/planeasyinc-le-angular.mjs.map +1 -1
- package/dist/lib/views/form-view/form-view.component.d.ts +1 -0
- package/dist/lib/views/form-view/form-view.utils.d.ts +6 -0
- package/dist/styles/styles.scss +1 -1
- package/package.json +2 -2
|
@@ -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, viewChild } from '@angular/core';
|
|
2
|
+
import { InjectionToken, inject, signal, Injectable, computed, effect, untracked, Directive, input, ChangeDetectionStrategy, Component, output, forwardRef, ViewContainerRef, Injector, Renderer2, ElementRef, DestroyRef, ChangeDetectorRef, 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';
|
|
@@ -1702,6 +1702,56 @@ const mapBodyModelToRequestBody = (bodyModel, values) => {
|
|
|
1702
1702
|
}
|
|
1703
1703
|
return mapBodyObjectModelToRequestBody(bodyModel, values);
|
|
1704
1704
|
};
|
|
1705
|
+
/**
|
|
1706
|
+
* FORM JSON TABS
|
|
1707
|
+
*/
|
|
1708
|
+
const getByPath = (entity, path) => {
|
|
1709
|
+
if (path.length) {
|
|
1710
|
+
return path.reduce((acc, chunk) => {
|
|
1711
|
+
return acc && acc[chunk];
|
|
1712
|
+
}, entity);
|
|
1713
|
+
}
|
|
1714
|
+
return entity;
|
|
1715
|
+
};
|
|
1716
|
+
const traverse = (entity, path, cb) => {
|
|
1717
|
+
const items = getByPath(entity, path);
|
|
1718
|
+
if (Array.isArray(items)) {
|
|
1719
|
+
items.forEach((item) => {
|
|
1720
|
+
cb(item);
|
|
1721
|
+
traverse(item, path, cb);
|
|
1722
|
+
});
|
|
1723
|
+
}
|
|
1724
|
+
};
|
|
1725
|
+
const isTabJSON = (control) => {
|
|
1726
|
+
return control.name.toLowerCase().includes('json');
|
|
1727
|
+
};
|
|
1728
|
+
const getTabFormValues = (control, engine) => {
|
|
1729
|
+
const result = {};
|
|
1730
|
+
traverse(control, ['meta', 'controls'], (ctrl) => {
|
|
1731
|
+
if (ctrl.id && ctrl.value) {
|
|
1732
|
+
result[ctrl.id] = engine.values.get(ctrl.id);
|
|
1733
|
+
}
|
|
1734
|
+
});
|
|
1735
|
+
return result;
|
|
1736
|
+
};
|
|
1737
|
+
const mapFormValuesToJSON = (values) => {
|
|
1738
|
+
return JSON.stringify(values, null, 2);
|
|
1739
|
+
};
|
|
1740
|
+
const mapJSONToFormValues = (json) => {
|
|
1741
|
+
return JSON.parse(json);
|
|
1742
|
+
};
|
|
1743
|
+
const getTabJSONControl = (control, engine) => {
|
|
1744
|
+
let result;
|
|
1745
|
+
traverse(control, ['meta', 'controls'], (ctrl) => {
|
|
1746
|
+
if (ctrl.type === 'textarea') {
|
|
1747
|
+
result = {
|
|
1748
|
+
...ctrl,
|
|
1749
|
+
value: engine.values.get(ctrl.id)
|
|
1750
|
+
};
|
|
1751
|
+
}
|
|
1752
|
+
});
|
|
1753
|
+
return result;
|
|
1754
|
+
};
|
|
1705
1755
|
|
|
1706
1756
|
class ToastListComponent {
|
|
1707
1757
|
toastService = inject(LeToastService);
|
|
@@ -1963,6 +2013,7 @@ class FormViewComponent {
|
|
|
1963
2013
|
attachmentService = inject(FormViewAttachmentService);
|
|
1964
2014
|
viewportScroller = inject(ViewportScroller);
|
|
1965
2015
|
toastService = inject(LeToastService);
|
|
2016
|
+
cdr = inject(ChangeDetectorRef);
|
|
1966
2017
|
_isLoading = signal(false);
|
|
1967
2018
|
_form = signal(null);
|
|
1968
2019
|
_sections = signal([]);
|
|
@@ -2055,6 +2106,26 @@ class FormViewComponent {
|
|
|
2055
2106
|
this.dataService.navigateByNodeId(action.section_id);
|
|
2056
2107
|
return of(null);
|
|
2057
2108
|
},
|
|
2109
|
+
align_values: (action) => {
|
|
2110
|
+
const engine = this._engine();
|
|
2111
|
+
try {
|
|
2112
|
+
if (isTabJSON(action.source)) {
|
|
2113
|
+
const values = mapJSONToFormValues(getTabJSONControl(action.source, engine).value);
|
|
2114
|
+
Object.entries(values).forEach(({ 0: key, 1: value }) => {
|
|
2115
|
+
engine.values.set(key, value);
|
|
2116
|
+
});
|
|
2117
|
+
}
|
|
2118
|
+
else {
|
|
2119
|
+
const value = mapFormValuesToJSON(getTabFormValues(action.source, engine));
|
|
2120
|
+
const target = getTabJSONControl(action.target, engine);
|
|
2121
|
+
engine.values.set(target.id, value);
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
catch (e) {
|
|
2125
|
+
console.error(e);
|
|
2126
|
+
}
|
|
2127
|
+
return of(null);
|
|
2128
|
+
},
|
|
2058
2129
|
};
|
|
2059
2130
|
node = input.required();
|
|
2060
2131
|
config = input();
|