@planeasyinc/le-angular 0.0.21 → 0.0.23
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 +191 -34
- package/dist/fesm2022/planeasyinc-le-angular.mjs.map +1 -1
- package/dist/lib/components/toast-list/toast-list-item.component.d.ts +14 -0
- package/dist/lib/components/toast-list/toast-list.component.d.ts +2 -2
- package/dist/lib/icons/le-icon.component.d.ts +1 -1
- package/dist/lib/services/le-actions.service.d.ts +15 -0
- package/dist/lib/services/le-toast.service.d.ts +7 -14
- package/dist/lib/types/le-action.d.ts +5 -0
- package/dist/lib/views/form-view/form-view.component.d.ts +4 -0
- package/dist/lib/views/form-view/form-view.utils.d.ts +2 -0
- package/dist/styles/styles.scss +4 -4
- package/package.json +6 -6
- /package/dist/lib/{views/form-view → utils}/form.adapter.d.ts +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
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
|
-
import { map, filter, distinctUntilChanged, Subject, takeUntil, BehaviorSubject, firstValueFrom, of, tap, catchError, from, concatMap, finalize, fromEvent, startWith } from 'rxjs';
|
|
4
|
+
import { map, filter, distinctUntilChanged, Subject, takeUntil, BehaviorSubject, firstValueFrom, of, tap, catchError, switchMap, from, concatMap, finalize, fromEvent, startWith } from 'rxjs';
|
|
5
5
|
import { decodeJwt, UrlFragmentBuilder, normalizeConfig } from '@planeasyinc/le-core';
|
|
6
6
|
import { Location, UpperCasePipe, JsonPipe, DatePipe, ViewportScroller } from '@angular/common';
|
|
7
7
|
import { CdkDrag } from '@angular/cdk/drag-drop';
|
|
@@ -16,9 +16,9 @@ import { NestedTreeControl, CdkTree, CdkNestedTreeNode, CdkTreeNodeDef, CdkTreeN
|
|
|
16
16
|
import { ArrayDataSource, SelectionModel } from '@angular/cdk/collections';
|
|
17
17
|
import { CdkMenuTrigger, CdkMenu, CdkMenuItem } from '@angular/cdk/menu';
|
|
18
18
|
import { A11yModule } from '@angular/cdk/a11y';
|
|
19
|
+
import { createEngine } from '@planeasyinc/fe-core';
|
|
19
20
|
import { adaptOld } from '@planeasyinc/fe-adapters-old';
|
|
20
21
|
import { adaptSections } from '@planeasyinc/fe-adapters-sections';
|
|
21
|
-
import { createEngine } from '@planeasyinc/fe-core';
|
|
22
22
|
import { FeFieldHost } from '@planeasyinc/fe-angular';
|
|
23
23
|
import * as i1 from '@angular/forms';
|
|
24
24
|
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
|
@@ -165,7 +165,8 @@ class LeNavigationService {
|
|
|
165
165
|
if (!this.config.withRouting)
|
|
166
166
|
return;
|
|
167
167
|
const path = this.mapNodeToLocationPath(node);
|
|
168
|
-
this.
|
|
168
|
+
const fullPath = [this.config.rootPath, path].filter(Boolean).join('/');
|
|
169
|
+
this.location.go(`/${fullPath}`, undefined, { node });
|
|
169
170
|
}
|
|
170
171
|
mapNodeToLocationPath(node) {
|
|
171
172
|
let pathChunks = [];
|
|
@@ -173,13 +174,20 @@ class LeNavigationService {
|
|
|
173
174
|
if (node.type === 'table') {
|
|
174
175
|
pathChunks.push(node?.title || node?.dataSource?.entity);
|
|
175
176
|
if (node?.dataSource?.params) {
|
|
176
|
-
query = Object.entries(node.dataSource.params)
|
|
177
|
+
query = Object.entries(node.dataSource.params)
|
|
178
|
+
.map((entry) => entry.join('='))
|
|
179
|
+
.join('&');
|
|
177
180
|
}
|
|
178
181
|
}
|
|
179
|
-
if (node.type === 'form') {
|
|
182
|
+
else if (node.type === 'form') {
|
|
180
183
|
pathChunks.push('details', node.controlSource?.kind, node.controlSource?.entity, node.controlSource?.params?.className, node.controlSource?.params?.address, node.controlSource?.params?.mode);
|
|
181
184
|
}
|
|
182
|
-
|
|
185
|
+
else {
|
|
186
|
+
const title = (node.title ?? '').replace(' ', '-');
|
|
187
|
+
if (title)
|
|
188
|
+
pathChunks.push(title);
|
|
189
|
+
}
|
|
190
|
+
const path = pathChunks.filter((v) => !!v).join('/');
|
|
183
191
|
return query ? `${path}?${query}` : path;
|
|
184
192
|
}
|
|
185
193
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: LeNavigationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -1242,8 +1250,9 @@ class TableViewComponent {
|
|
|
1242
1250
|
const result = [];
|
|
1243
1251
|
const firstRow = this.data().getValueByIndex(0);
|
|
1244
1252
|
const columnKeys = this.columns().map((column) => column.key);
|
|
1253
|
+
const hasMetadata = !!(firstRow && firstRow._metadata);
|
|
1245
1254
|
const hasVersion = !!(firstRow && firstRow._metadata && firstRow._metadata.object_version);
|
|
1246
|
-
if (
|
|
1255
|
+
if (hasMetadata && !this.config()?.hideInfo) {
|
|
1247
1256
|
result.push('info');
|
|
1248
1257
|
}
|
|
1249
1258
|
result.push(...columnKeys);
|
|
@@ -1342,11 +1351,11 @@ class TableViewComponent {
|
|
|
1342
1351
|
injector: this.injector,
|
|
1343
1352
|
})
|
|
1344
1353
|
.subscribe({
|
|
1345
|
-
next: event => {
|
|
1354
|
+
next: (event) => {
|
|
1346
1355
|
if (event.type === 'cell_clicked') {
|
|
1347
1356
|
this.onCellClicked(event.data);
|
|
1348
1357
|
}
|
|
1349
|
-
}
|
|
1358
|
+
},
|
|
1350
1359
|
});
|
|
1351
1360
|
}
|
|
1352
1361
|
onCellClicked(data) {
|
|
@@ -1382,6 +1391,20 @@ class TableViewComponent {
|
|
|
1382
1391
|
}
|
|
1383
1392
|
});
|
|
1384
1393
|
}
|
|
1394
|
+
else if (type === 'update_form') {
|
|
1395
|
+
if (clone.controlSource?.params) {
|
|
1396
|
+
clone.controlSource.params = this.interpolateRowValues(clone.controlSource.params, row);
|
|
1397
|
+
}
|
|
1398
|
+
this.setView({
|
|
1399
|
+
id: action.type,
|
|
1400
|
+
type: 'form',
|
|
1401
|
+
controlSource: {
|
|
1402
|
+
kind: clone.controlSource.kind,
|
|
1403
|
+
entity: clone.controlSource.entity,
|
|
1404
|
+
params: clone.controlSource.params,
|
|
1405
|
+
},
|
|
1406
|
+
});
|
|
1407
|
+
}
|
|
1385
1408
|
}
|
|
1386
1409
|
processTableAction(action) {
|
|
1387
1410
|
if (action.type === 'update_form') {
|
|
@@ -1425,7 +1448,7 @@ class TableViewComponent {
|
|
|
1425
1448
|
}
|
|
1426
1449
|
if (node.dataSource?.kind === 'transaction') {
|
|
1427
1450
|
const body = Object.assign({}, node.dataSource.params, buildRequestBody(ctx));
|
|
1428
|
-
this.apiService.executeTransaction(node.dataSource.entity, body);
|
|
1451
|
+
return this.apiService.executeTransaction(node.dataSource.entity, body);
|
|
1429
1452
|
}
|
|
1430
1453
|
if (node.dataSource?.kind === 'object') {
|
|
1431
1454
|
return this.apiService.getObjectByAddress(node.dataSource.entity, node.dataSource.params ?? {});
|
|
@@ -1784,31 +1807,82 @@ const getTabJSONControl = (control, engine) => {
|
|
|
1784
1807
|
});
|
|
1785
1808
|
return result;
|
|
1786
1809
|
};
|
|
1810
|
+
const mapValueToString = (value) => {
|
|
1811
|
+
if (typeof value === 'object' && value !== null) {
|
|
1812
|
+
if (Array.isArray(value)) {
|
|
1813
|
+
return value.map((chunk) => mapValueToString(chunk)).join('\n');
|
|
1814
|
+
}
|
|
1815
|
+
else {
|
|
1816
|
+
return mapValueToString(Object.entries(value));
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
return `${value}`;
|
|
1820
|
+
};
|
|
1821
|
+
|
|
1822
|
+
class ToastListItemComponent {
|
|
1823
|
+
_engine = signal(null);
|
|
1824
|
+
_sections = signal([]);
|
|
1825
|
+
controls = input.required();
|
|
1826
|
+
actions = output();
|
|
1827
|
+
engine = this._engine.asReadonly();
|
|
1828
|
+
sections = this._sections.asReadonly();
|
|
1829
|
+
constructor() {
|
|
1830
|
+
effect((onCleanup) => {
|
|
1831
|
+
const controls = this.controls();
|
|
1832
|
+
const form = adaptForm(controls);
|
|
1833
|
+
const engine = createEngine(form);
|
|
1834
|
+
let cleanup = () => { };
|
|
1835
|
+
untracked(() => {
|
|
1836
|
+
this._engine.set(engine);
|
|
1837
|
+
this._sections.set(form.sections ?? []);
|
|
1838
|
+
cleanup = engine.on('action', ({ action }) => {
|
|
1839
|
+
const actionObj = action;
|
|
1840
|
+
this.actions.emit(actionObj.actions);
|
|
1841
|
+
});
|
|
1842
|
+
});
|
|
1843
|
+
onCleanup(() => {
|
|
1844
|
+
cleanup();
|
|
1845
|
+
});
|
|
1846
|
+
});
|
|
1847
|
+
}
|
|
1848
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: ToastListItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1849
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.21", type: ToastListItemComponent, isStandalone: true, selector: "le-toast-list-item", inputs: { controls: { classPropertyName: "controls", publicName: "controls", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { actions: "actions" }, ngImport: i0, template: "@if (engine(); as engine) {\n @for (section of sections(); track section) {\n @for (control of section.controls; track control) {\n <fe-field [engine]=\"engine\" [control]=\"control\"></fe-field>\n }\n }\n}\n", dependencies: [{ kind: "component", type: FeFieldHost, selector: "fe-field", inputs: ["engine", "control"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1850
|
+
}
|
|
1851
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: ToastListItemComponent, decorators: [{
|
|
1852
|
+
type: Component,
|
|
1853
|
+
args: [{ selector: 'le-toast-list-item', imports: [FeFieldHost], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (engine(); as engine) {\n @for (section of sections(); track section) {\n @for (control of section.controls; track control) {\n <fe-field [engine]=\"engine\" [control]=\"control\"></fe-field>\n }\n }\n}\n" }]
|
|
1854
|
+
}], ctorParameters: () => [] });
|
|
1787
1855
|
|
|
1788
1856
|
class ToastListComponent {
|
|
1789
1857
|
toastService = inject(LeToastService);
|
|
1790
1858
|
toasts = this.toastService.toasts;
|
|
1791
|
-
|
|
1792
|
-
actions.forEach((action) =>
|
|
1859
|
+
onActions(actions) {
|
|
1860
|
+
actions.forEach((action) => {
|
|
1861
|
+
this.toastService.action$.next(action);
|
|
1862
|
+
if (action.type === 'close_popup') {
|
|
1863
|
+
this.toastService.remove(action.target_id);
|
|
1864
|
+
}
|
|
1865
|
+
});
|
|
1793
1866
|
}
|
|
1794
1867
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: ToastListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1795
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.21", type: ToastListComponent, isStandalone: true, selector: "ng-component", ngImport: i0, template: "@if (toasts().length) {\n <div class=\"le-toast-list\">\n @for (toast of toasts(); track toast.id) {\n <div\n class=\"le-toast\"\n [class.le-toast--success]=\"toast.type === 'success'\"\n [class.le-toast--info]=\"toast.type === 'info'\"\n [class.le-toast--warning]=\"toast.type === 'warning'\"\n [class.le-toast--error]=\"toast.type === 'error'\"\n >\n <
|
|
1868
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.21", type: ToastListComponent, isStandalone: true, selector: "ng-component", ngImport: i0, template: "@if (toasts().length) {\n <div class=\"le-toast-list\">\n @for (toast of toasts(); track toast.id) {\n <div\n class=\"le-toast\"\n [class.le-toast--success]=\"toast.type === 'success'\"\n [class.le-toast--info]=\"toast.type === 'info'\"\n [class.le-toast--warning]=\"toast.type === 'warning'\"\n [class.le-toast--error]=\"toast.type === 'error'\"\n >\n <le-toast-list-item\n [controls]=\"toast.controls\"\n (actions)=\"onActions($event)\"\n ></le-toast-list-item>\n </div>\n }\n </div>\n}\n", dependencies: [{ kind: "component", type: ToastListItemComponent, selector: "le-toast-list-item", inputs: ["controls"], outputs: ["actions"] }] });
|
|
1796
1869
|
}
|
|
1797
1870
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: ToastListComponent, decorators: [{
|
|
1798
1871
|
type: Component,
|
|
1799
|
-
args: [{ template: "@if (toasts().length) {\n <div class=\"le-toast-list\">\n @for (toast of toasts(); track toast.id) {\n <div\n class=\"le-toast\"\n [class.le-toast--success]=\"toast.type === 'success'\"\n [class.le-toast--info]=\"toast.type === 'info'\"\n [class.le-toast--warning]=\"toast.type === 'warning'\"\n [class.le-toast--error]=\"toast.type === 'error'\"\n >\n <
|
|
1872
|
+
args: [{ imports: [ToastListItemComponent], template: "@if (toasts().length) {\n <div class=\"le-toast-list\">\n @for (toast of toasts(); track toast.id) {\n <div\n class=\"le-toast\"\n [class.le-toast--success]=\"toast.type === 'success'\"\n [class.le-toast--info]=\"toast.type === 'info'\"\n [class.le-toast--warning]=\"toast.type === 'warning'\"\n [class.le-toast--error]=\"toast.type === 'error'\"\n >\n <le-toast-list-item\n [controls]=\"toast.controls\"\n (actions)=\"onActions($event)\"\n ></le-toast-list-item>\n </div>\n }\n </div>\n}\n" }]
|
|
1800
1873
|
}] });
|
|
1801
1874
|
|
|
1802
|
-
let ID = 100_000_000;
|
|
1875
|
+
let ID$1 = 100_000_000;
|
|
1803
1876
|
class LeToastService {
|
|
1804
1877
|
overlayRef;
|
|
1805
1878
|
overlay = inject(Overlay);
|
|
1806
1879
|
_toasts = signal([]);
|
|
1807
1880
|
toasts = this._toasts.asReadonly();
|
|
1881
|
+
hasToasts = computed(() => this._toasts().length > 0);
|
|
1882
|
+
action$ = new Subject();
|
|
1808
1883
|
constructor() {
|
|
1809
1884
|
effect(() => {
|
|
1810
|
-
|
|
1811
|
-
if (toasts.length > 0) {
|
|
1885
|
+
if (this.hasToasts()) {
|
|
1812
1886
|
this.show();
|
|
1813
1887
|
}
|
|
1814
1888
|
else {
|
|
@@ -1834,11 +1908,6 @@ class LeToastService {
|
|
|
1834
1908
|
remove(id) {
|
|
1835
1909
|
this._toasts.update((toasts) => toasts.filter((toast) => toast.id !== id));
|
|
1836
1910
|
}
|
|
1837
|
-
processAction(action) {
|
|
1838
|
-
if (action.type === 'close_popup') {
|
|
1839
|
-
this.remove(action.target);
|
|
1840
|
-
}
|
|
1841
|
-
}
|
|
1842
1911
|
show() {
|
|
1843
1912
|
if (this.overlayRef)
|
|
1844
1913
|
return;
|
|
@@ -1853,20 +1922,27 @@ class LeToastService {
|
|
|
1853
1922
|
this.overlayRef = undefined;
|
|
1854
1923
|
}
|
|
1855
1924
|
buildToast(type, messages) {
|
|
1856
|
-
const id = `${type}_${ID++}`;
|
|
1857
|
-
|
|
1858
|
-
|
|
1925
|
+
const id = `${type}_${ID$1++}`;
|
|
1926
|
+
return {
|
|
1927
|
+
id,
|
|
1928
|
+
type,
|
|
1929
|
+
controls: [...this.buildTextControls(id, messages), this.buildButtonControl(id)],
|
|
1930
|
+
};
|
|
1931
|
+
}
|
|
1932
|
+
buildTextControls(id, messages) {
|
|
1933
|
+
return messages.map((message, index) => ({
|
|
1934
|
+
type: 'paragraph',
|
|
1859
1935
|
value: message,
|
|
1936
|
+
name: `${id}_${index}`
|
|
1860
1937
|
}));
|
|
1861
|
-
|
|
1938
|
+
}
|
|
1939
|
+
buildButtonControl(id) {
|
|
1940
|
+
return {
|
|
1862
1941
|
type: 'button',
|
|
1863
1942
|
label: 'Ok',
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
id,
|
|
1868
|
-
type,
|
|
1869
|
-
controls: [...textControls, buttonControl],
|
|
1943
|
+
hideLabel: true,
|
|
1944
|
+
name: `${id}_button`,
|
|
1945
|
+
actions: [{ type: 'close_popup', target_id: id }],
|
|
1870
1946
|
};
|
|
1871
1947
|
}
|
|
1872
1948
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: LeToastService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -2039,12 +2115,44 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.21", ngImpo
|
|
|
2039
2115
|
type: Injectable
|
|
2040
2116
|
}] });
|
|
2041
2117
|
|
|
2118
|
+
class LeActionsService {
|
|
2119
|
+
_queue = [];
|
|
2120
|
+
_data = null;
|
|
2121
|
+
get hasActions() {
|
|
2122
|
+
return this._queue.length > 0;
|
|
2123
|
+
}
|
|
2124
|
+
setActions(actions, data) {
|
|
2125
|
+
this._queue = actions;
|
|
2126
|
+
this._data = data;
|
|
2127
|
+
}
|
|
2128
|
+
getActions() {
|
|
2129
|
+
const actions = this._queue.slice();
|
|
2130
|
+
const data = Object.assign({}, this._data);
|
|
2131
|
+
this._queue = [];
|
|
2132
|
+
this._data = null;
|
|
2133
|
+
return {
|
|
2134
|
+
actions,
|
|
2135
|
+
data,
|
|
2136
|
+
};
|
|
2137
|
+
}
|
|
2138
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: LeActionsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2139
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: LeActionsService, providedIn: 'root' });
|
|
2140
|
+
}
|
|
2141
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: LeActionsService, decorators: [{
|
|
2142
|
+
type: Injectable,
|
|
2143
|
+
args: [{
|
|
2144
|
+
providedIn: 'root',
|
|
2145
|
+
}]
|
|
2146
|
+
}] });
|
|
2147
|
+
|
|
2148
|
+
let ID = 100_000_000;
|
|
2042
2149
|
class FormViewComponent {
|
|
2043
2150
|
apiService = inject(LEApiService);
|
|
2044
2151
|
dataService = inject(LEDataService);
|
|
2045
2152
|
attachmentService = inject(FormViewAttachmentService);
|
|
2046
2153
|
viewportScroller = inject(ViewportScroller);
|
|
2047
2154
|
toastService = inject(LeToastService);
|
|
2155
|
+
actionsService = inject(LeActionsService);
|
|
2048
2156
|
_isLoading = signal(false);
|
|
2049
2157
|
_form = signal(null);
|
|
2050
2158
|
_sections = signal([]);
|
|
@@ -2118,13 +2226,23 @@ class FormViewComponent {
|
|
|
2118
2226
|
this.viewportScroller.scrollToPosition([0, 0]);
|
|
2119
2227
|
return of(null);
|
|
2120
2228
|
},
|
|
2121
|
-
show_popup: (action) => {
|
|
2229
|
+
show_popup: (action, response) => {
|
|
2230
|
+
const rawControls = this.normalizeControls(action.controls);
|
|
2231
|
+
const controls = this.populatePopupControlsWithResponseData(rawControls, response);
|
|
2122
2232
|
this.toastService.notify({
|
|
2123
|
-
|
|
2233
|
+
controls,
|
|
2234
|
+
id: action.id,
|
|
2124
2235
|
type: 'success',
|
|
2125
2236
|
});
|
|
2126
2237
|
return of(null);
|
|
2127
2238
|
},
|
|
2239
|
+
close_popup: (action) => {
|
|
2240
|
+
// TODO: models alignment required (to target_id)
|
|
2241
|
+
// @ts-ignore
|
|
2242
|
+
const id = action.target_id || action.target;
|
|
2243
|
+
this.toastService.remove(id);
|
|
2244
|
+
return of(null);
|
|
2245
|
+
},
|
|
2128
2246
|
open_url: (action) => {
|
|
2129
2247
|
window.open(action.url, '_blank');
|
|
2130
2248
|
return of(null);
|
|
@@ -2199,6 +2317,9 @@ class FormViewComponent {
|
|
|
2199
2317
|
this.init(form);
|
|
2200
2318
|
});
|
|
2201
2319
|
});
|
|
2320
|
+
this.toastService.action$
|
|
2321
|
+
.pipe(switchMap((action) => this.processAction(action)), takeUntilDestroyed())
|
|
2322
|
+
.subscribe();
|
|
2202
2323
|
}
|
|
2203
2324
|
init(form) {
|
|
2204
2325
|
this._sections.set(this.sortSections(form.sections));
|
|
@@ -2208,6 +2329,7 @@ class FormViewComponent {
|
|
|
2208
2329
|
objectLatest: (className) => firstValueFrom(this.dataService.getObjectByClassName(className)),
|
|
2209
2330
|
};
|
|
2210
2331
|
this._engine.set(createEngine(form, {}, resolvers));
|
|
2332
|
+
this.checkDelayedActions();
|
|
2211
2333
|
// this._engine()?.on('valueChanges', (value) => {
|
|
2212
2334
|
// console.log('Value Changes', value);
|
|
2213
2335
|
// // this.cdr.markForCheck();
|
|
@@ -2288,12 +2410,47 @@ class FormViewComponent {
|
|
|
2288
2410
|
};
|
|
2289
2411
|
}
|
|
2290
2412
|
processActionList(items, response) {
|
|
2413
|
+
const updateViewActionIndex = items.findIndex((item) => item.type === 'update_form' || item.type === 'update_table');
|
|
2414
|
+
if (updateViewActionIndex !== -1) {
|
|
2415
|
+
const delayedActions = items.splice(updateViewActionIndex + 1);
|
|
2416
|
+
this.actionsService.setActions(delayedActions, response ?? null);
|
|
2417
|
+
}
|
|
2291
2418
|
from(items)
|
|
2292
2419
|
.pipe(concatMap((a) => this.processAction(a, response)), finalize(() => {
|
|
2293
2420
|
this._isLoading.set(false);
|
|
2294
2421
|
}))
|
|
2295
2422
|
.subscribe();
|
|
2296
2423
|
}
|
|
2424
|
+
checkDelayedActions() {
|
|
2425
|
+
if (this.actionsService.hasActions) {
|
|
2426
|
+
const { actions, data } = this.actionsService.getActions();
|
|
2427
|
+
this.processActionList(actions, data);
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2430
|
+
normalizeControls(controls) {
|
|
2431
|
+
return controls.map((control) => {
|
|
2432
|
+
if (!control.id) {
|
|
2433
|
+
return {
|
|
2434
|
+
...control,
|
|
2435
|
+
id: `${control.type}_${ID++}`,
|
|
2436
|
+
};
|
|
2437
|
+
}
|
|
2438
|
+
return control;
|
|
2439
|
+
});
|
|
2440
|
+
}
|
|
2441
|
+
populatePopupControlsWithResponseData(controls, response) {
|
|
2442
|
+
return controls.map((control) => {
|
|
2443
|
+
if (isPlaceholder(control.value)) {
|
|
2444
|
+
const path = getPlaceholderValue(control.value);
|
|
2445
|
+
const value = mapValueToString(getValueByPath({ response }, path));
|
|
2446
|
+
return {
|
|
2447
|
+
...control,
|
|
2448
|
+
value,
|
|
2449
|
+
};
|
|
2450
|
+
}
|
|
2451
|
+
return control;
|
|
2452
|
+
});
|
|
2453
|
+
}
|
|
2297
2454
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: FormViewComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2298
2455
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.21", type: FormViewComponent, isStandalone: true, selector: "form-view", inputs: { node: { classPropertyName: "node", publicName: "node", isSignal: true, isRequired: true, transformFunction: null }, config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { event: "event" }, providers: [FormViewAttachmentService], ngImport: i0, template: "<h2>{{ node()?.title }}</h2>\n\n@if (isLoading()) {\n <app-loading-view [rowCount]=\"5\"></app-loading-view>\n} @else {\n @if (data(); as data) {\n <le-form-renderer\n [config]=\"config()\"\n [engine]=\"data.engine\"\n [sections]=\"data.sections\"\n [customCss]=\"data.customCss\"\n [topLevelControls]=\"data.topLevelControls\"\n (event)=\"event.emit($event)\"\n ></le-form-renderer>\n }\n}\n", dependencies: [{ kind: "component", type: LoadingViewComponent, selector: "app-loading-view", inputs: ["headerHeight", "rowHeight", "rowCount"] }, { kind: "component", type: FormRendererComponent, selector: "le-form-renderer", inputs: ["engine", "sections", "topLevelControls", "customCss", "config"], outputs: ["event"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2299
2456
|
}
|