@planeasyinc/le-angular 0.0.16 → 0.0.18
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.
|
@@ -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,61 @@ 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) {
|
|
1732
|
+
return;
|
|
1733
|
+
}
|
|
1734
|
+
const value = engine.values.get(ctrl.id);
|
|
1735
|
+
if (value === undefined) {
|
|
1736
|
+
return;
|
|
1737
|
+
}
|
|
1738
|
+
result[ctrl.id] = value;
|
|
1739
|
+
});
|
|
1740
|
+
return result;
|
|
1741
|
+
};
|
|
1742
|
+
const mapFormValuesToJSON = (values) => {
|
|
1743
|
+
return JSON.stringify(values, null, 2);
|
|
1744
|
+
};
|
|
1745
|
+
const mapJSONToFormValues = (json) => {
|
|
1746
|
+
return JSON.parse(json);
|
|
1747
|
+
};
|
|
1748
|
+
const getTabJSONControl = (control, engine) => {
|
|
1749
|
+
let result;
|
|
1750
|
+
traverse(control, ['meta', 'controls'], (ctrl) => {
|
|
1751
|
+
if (ctrl.type === 'textarea') {
|
|
1752
|
+
result = {
|
|
1753
|
+
...ctrl,
|
|
1754
|
+
value: engine.values.get(ctrl.id)
|
|
1755
|
+
};
|
|
1756
|
+
}
|
|
1757
|
+
});
|
|
1758
|
+
return result;
|
|
1759
|
+
};
|
|
1705
1760
|
|
|
1706
1761
|
class ToastListComponent {
|
|
1707
1762
|
toastService = inject(LeToastService);
|
|
@@ -1963,6 +2018,7 @@ class FormViewComponent {
|
|
|
1963
2018
|
attachmentService = inject(FormViewAttachmentService);
|
|
1964
2019
|
viewportScroller = inject(ViewportScroller);
|
|
1965
2020
|
toastService = inject(LeToastService);
|
|
2021
|
+
cdr = inject(ChangeDetectorRef);
|
|
1966
2022
|
_isLoading = signal(false);
|
|
1967
2023
|
_form = signal(null);
|
|
1968
2024
|
_sections = signal([]);
|
|
@@ -2055,6 +2111,26 @@ class FormViewComponent {
|
|
|
2055
2111
|
this.dataService.navigateByNodeId(action.section_id);
|
|
2056
2112
|
return of(null);
|
|
2057
2113
|
},
|
|
2114
|
+
align_values: (action) => {
|
|
2115
|
+
const engine = this._engine();
|
|
2116
|
+
try {
|
|
2117
|
+
if (isTabJSON(action.source)) {
|
|
2118
|
+
const values = mapJSONToFormValues(getTabJSONControl(action.source, engine).value);
|
|
2119
|
+
Object.entries(values).forEach(({ 0: key, 1: value }) => {
|
|
2120
|
+
engine.values.set(key, value);
|
|
2121
|
+
});
|
|
2122
|
+
}
|
|
2123
|
+
else {
|
|
2124
|
+
const value = mapFormValuesToJSON(getTabFormValues(action.source, engine));
|
|
2125
|
+
const target = getTabJSONControl(action.target, engine);
|
|
2126
|
+
engine.values.set(target.id, value);
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
catch (e) {
|
|
2130
|
+
console.error(e);
|
|
2131
|
+
}
|
|
2132
|
+
return of(null);
|
|
2133
|
+
},
|
|
2058
2134
|
};
|
|
2059
2135
|
node = input.required();
|
|
2060
2136
|
config = input();
|