verben-workflow-ui 0.5.83 → 0.5.85
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/README.md +33 -2
- package/esm2022/src/lib/base/core/base-data-page.facade.mjs +412 -0
- package/esm2022/src/lib/base/core/base-data-page.service.mjs +140 -0
- package/esm2022/src/lib/base/core/base-data-page.state.mjs +216 -0
- package/esm2022/src/lib/base/handlers/filter-handler.service.mjs +138 -0
- package/esm2022/src/lib/base/handlers/search-handler.service.mjs +31 -0
- package/esm2022/src/lib/base/handlers/sort-handler.service.mjs +73 -0
- package/esm2022/src/lib/base/index.mjs +2 -0
- package/esm2022/src/lib/base/models/api-payload.mjs +7 -0
- package/esm2022/src/lib/base/models/page-config.interface.mjs +2 -0
- package/esm2022/src/lib/base/models/page-filter-tab-option.interface.mjs +2 -0
- package/esm2022/src/lib/base/public-api.mjs +14 -0
- package/esm2022/src/lib/base/utils/column-helpers.mjs +55 -0
- package/esm2022/src/lib/base/verben-workflow-ui-src-lib-base.mjs +5 -0
- package/esm2022/src/lib/components/actors/actors.component.mjs +156 -110
- package/esm2022/src/lib/components/actors/actors.config.mjs +49 -0
- package/esm2022/src/lib/components/actors/actors.facade.mjs +46 -242
- package/esm2022/src/lib/components/actors/actors.form.component.mjs +20 -24
- package/esm2022/src/lib/components/actors/actors.service.mjs +49 -62
- package/esm2022/src/lib/components/actors/actors.state.mjs +11 -80
- package/esm2022/src/lib/components/designer/components/node-selector.component.mjs +1 -3
- package/esm2022/src/lib/components/designer/components/wf-designer.component.mjs +1 -4
- package/esm2022/src/lib/components/designer/services/node-precondition.service.mjs +1 -2
- package/esm2022/src/lib/components/designer/services/wf-mapper.service.mjs +1 -2
- package/esm2022/src/lib/components/designer/services/wf-persistence.service.mjs +27 -25
- package/esm2022/src/lib/components/flowable-status/flowable-status.component.mjs +169 -102
- package/esm2022/src/lib/components/flowable-status/flowable-status.config.mjs +47 -0
- package/esm2022/src/lib/components/flowable-status/flowable-status.facade.mjs +56 -203
- package/esm2022/src/lib/components/flowable-status/flowable-status.service.mjs +25 -44
- package/esm2022/src/lib/components/flowable-status/flowable-status.state.mjs +10 -80
- package/esm2022/src/lib/components/form-control/form-control.component.mjs +1 -3
- package/esm2022/src/lib/components/form-group/form-fields/form-fields.component.mjs +2 -8
- package/esm2022/src/lib/components/form-group/form-group.component.mjs +2 -10
- package/esm2022/src/lib/components/form-response/form-response.component.mjs +1 -5
- package/esm2022/src/lib/components/form-timer/form-timer.component.mjs +1 -4
- package/esm2022/src/lib/components/forms/forms.component.mjs +1 -1
- package/esm2022/src/lib/components/my-queue/my-queue.component.mjs +3 -3
- package/esm2022/src/lib/components/my-queue/my-queue.facade.mjs +6 -25
- package/esm2022/src/lib/components/my-queue/my-queue.state.mjs +4 -4
- package/esm2022/src/lib/components/my-queue/tasks.form.component.mjs +1 -4
- package/esm2022/src/lib/components/operation-popup/operation-popup.component.mjs +1 -13
- package/esm2022/src/lib/components/operation-popup/operation-popup.facade.mjs +1 -15
- package/esm2022/src/lib/components/stage-details/stage-details.component.mjs +1 -3
- package/esm2022/src/lib/components/task-history/task-history.component.mjs +1 -5
- package/esm2022/src/lib/components/task-notification/task-notification.component.mjs +1 -1
- package/esm2022/src/lib/components/tasks/tasks.component.mjs +10 -5
- package/esm2022/src/lib/components/tasks/tasks.facade.mjs +23 -26
- package/esm2022/src/lib/components/tasks/tasks.form.component.mjs +1 -4
- package/esm2022/src/lib/components/tasks/tasks.state.mjs +11 -3
- package/esm2022/src/lib/components/wf/wf.component.mjs +1 -2
- package/esm2022/src/lib/components/workflow/workflow.component.mjs +2 -8
- package/esm2022/src/lib/components/workflow-designer/action-dialog/action-dialog.component.mjs +16 -10
- package/esm2022/src/lib/components/workflow-designer/actor-tags-dialog/actor-tags-dialog.component.mjs +10 -2
- package/esm2022/src/lib/components/workflow-designer/conditions-popup/conditions-popup.component.mjs +12 -1
- package/esm2022/src/lib/components/workflow-designer/decision-popup/decision-popup.component.mjs +20 -1
- package/esm2022/src/lib/components/workflow-designer/designer-canvas/designer-canvas.component.mjs +105 -66
- package/esm2022/src/lib/components/workflow-designer/designer-toolbar/designer-toolbar.component.mjs +14 -1
- package/esm2022/src/lib/components/workflow-designer/escalation-dialog/escalation-dialog.component.mjs +16 -12
- package/esm2022/src/lib/components/workflow-designer/services/connection.service.mjs +17 -2
- package/esm2022/src/lib/components/workflow-designer/services/node-management.service.mjs +23 -2
- package/esm2022/src/lib/components/workflow-designer/services/popup.service.mjs +10 -5
- package/esm2022/src/lib/components/workflow-designer/services/swimlane.service.mjs +16 -3
- package/esm2022/src/lib/components/workflow-designer/services/transformer.service.mjs +16 -1
- package/esm2022/src/lib/components/workflow-designer/stage-dialog/stage-dialog.component.mjs +16 -14
- package/esm2022/src/lib/components/workflow-designer/stage-node/stage-node.component.mjs +15 -6
- package/esm2022/src/lib/components/workflow-designer/swimlane-dialog/swimlane-dialog.component.mjs +15 -8
- package/esm2022/src/lib/components/workflow-designer/workflow-data.service.mjs +25 -1
- package/esm2022/src/lib/components/workflow-designer/workflow-designer.component.mjs +75 -23
- package/esm2022/src/lib/components/workflow-designer/workflow-designer.module.mjs +20 -1
- package/esm2022/src/lib/components/workflow-designer/workflow-designer.state.mjs +181 -18
- package/esm2022/src/lib/components/workflow-designer/workflow-designer.types.mjs +1 -1
- package/esm2022/src/lib/components/workflows/public-api.mjs +4 -1
- package/esm2022/src/lib/components/workflows/workflow-form/workflow-form.component.mjs +1 -5
- package/esm2022/src/lib/components/workflows/workflows.api.mjs +63 -0
- package/esm2022/src/lib/components/workflows/workflows.component.mjs +194 -148
- package/esm2022/src/lib/components/workflows/workflows.config.mjs +50 -0
- package/esm2022/src/lib/components/workflows/workflows.facade.mjs +106 -298
- package/esm2022/src/lib/components/workflows/workflows.service.mjs +58 -117
- package/esm2022/src/lib/components/workflows/workflows.state.mjs +12 -81
- package/esm2022/src/lib/services/environment.service.mjs +1 -2
- package/esm2022/src/lib/services/http-web-request.service.mjs +12 -10
- package/esm2022/src/lib/services/util.service.mjs +18 -16
- package/esm2022/src/lib/shared/components/base-data-view.component.mjs +1 -5
- package/fesm2022/verben-workflow-ui-src-lib-base.mjs +1055 -0
- package/fesm2022/verben-workflow-ui-src-lib-base.mjs.map +1 -0
- package/fesm2022/verben-workflow-ui-src-lib-components-actors.mjs +314 -508
- package/fesm2022/verben-workflow-ui-src-lib-components-actors.mjs.map +1 -1
- package/fesm2022/verben-workflow-ui-src-lib-components-designer.mjs +26 -31
- package/fesm2022/verben-workflow-ui-src-lib-components-designer.mjs.map +1 -1
- package/fesm2022/verben-workflow-ui-src-lib-components-flowable-status.mjs +289 -417
- package/fesm2022/verben-workflow-ui-src-lib-components-flowable-status.mjs.map +1 -1
- package/fesm2022/verben-workflow-ui-src-lib-components-form-control.mjs +0 -2
- package/fesm2022/verben-workflow-ui-src-lib-components-form-control.mjs.map +1 -1
- package/fesm2022/verben-workflow-ui-src-lib-components-form-group.mjs +2 -16
- package/fesm2022/verben-workflow-ui-src-lib-components-form-group.mjs.map +1 -1
- package/fesm2022/verben-workflow-ui-src-lib-components-form-response.mjs +0 -4
- package/fesm2022/verben-workflow-ui-src-lib-components-form-response.mjs.map +1 -1
- package/fesm2022/verben-workflow-ui-src-lib-components-form-timer.mjs +0 -3
- package/fesm2022/verben-workflow-ui-src-lib-components-form-timer.mjs.map +1 -1
- package/fesm2022/verben-workflow-ui-src-lib-components-forms.mjs +1 -1
- package/fesm2022/verben-workflow-ui-src-lib-components-forms.mjs.map +1 -1
- package/fesm2022/verben-workflow-ui-src-lib-components-my-queue.mjs +8 -30
- package/fesm2022/verben-workflow-ui-src-lib-components-my-queue.mjs.map +1 -1
- package/fesm2022/verben-workflow-ui-src-lib-components-operation-popup.mjs +0 -26
- package/fesm2022/verben-workflow-ui-src-lib-components-operation-popup.mjs.map +1 -1
- package/fesm2022/verben-workflow-ui-src-lib-components-stage-details.mjs +0 -2
- package/fesm2022/verben-workflow-ui-src-lib-components-stage-details.mjs.map +1 -1
- package/fesm2022/verben-workflow-ui-src-lib-components-task-history.mjs +0 -4
- package/fesm2022/verben-workflow-ui-src-lib-components-task-history.mjs.map +1 -1
- package/fesm2022/verben-workflow-ui-src-lib-components-task-notification.mjs +1 -1
- package/fesm2022/verben-workflow-ui-src-lib-components-task-notification.mjs.map +1 -1
- package/fesm2022/verben-workflow-ui-src-lib-components-tasks.mjs +37 -30
- package/fesm2022/verben-workflow-ui-src-lib-components-tasks.mjs.map +1 -1
- package/fesm2022/verben-workflow-ui-src-lib-components-wf.mjs +0 -1
- package/fesm2022/verben-workflow-ui-src-lib-components-wf.mjs.map +1 -1
- package/fesm2022/verben-workflow-ui-src-lib-components-workflow-designer.mjs +603 -158
- package/fesm2022/verben-workflow-ui-src-lib-components-workflow-designer.mjs.map +1 -1
- package/fesm2022/verben-workflow-ui-src-lib-components-workflow.mjs +1 -7
- package/fesm2022/verben-workflow-ui-src-lib-components-workflow.mjs.map +1 -1
- package/fesm2022/verben-workflow-ui-src-lib-components-workflows.mjs +427 -623
- package/fesm2022/verben-workflow-ui-src-lib-components-workflows.mjs.map +1 -1
- package/fesm2022/verben-workflow-ui-src-lib-services.mjs +28 -25
- package/fesm2022/verben-workflow-ui-src-lib-services.mjs.map +1 -1
- package/fesm2022/verben-workflow-ui-src-lib-shared.mjs +0 -4
- package/fesm2022/verben-workflow-ui-src-lib-shared.mjs.map +1 -1
- package/package.json +47 -41
- package/src/lib/base/README.md +146 -0
- package/src/lib/base/core/base-data-page.facade.d.ts +138 -0
- package/src/lib/base/core/base-data-page.service.d.ts +61 -0
- package/src/lib/base/core/base-data-page.state.d.ts +73 -0
- package/src/lib/base/handlers/filter-handler.service.d.ts +34 -0
- package/src/lib/base/handlers/search-handler.service.d.ts +20 -0
- package/src/lib/base/handlers/sort-handler.service.d.ts +30 -0
- package/src/lib/base/index.d.ts +1 -0
- package/src/lib/base/models/api-payload.d.ts +2 -0
- package/src/lib/base/models/page-config.interface.d.ts +24 -0
- package/src/lib/base/models/page-filter-tab-option.interface.d.ts +19 -0
- package/src/lib/base/public-api.d.ts +9 -0
- package/src/lib/base/utils/column-helpers.d.ts +24 -0
- package/src/lib/components/actors/actors.component.d.ts +66 -18
- package/src/lib/components/actors/actors.config.d.ts +10 -0
- package/src/lib/components/actors/actors.facade.d.ts +19 -27
- package/src/lib/components/actors/actors.form.component.d.ts +8 -8
- package/src/lib/components/actors/actors.service.d.ts +23 -43
- package/src/lib/components/actors/actors.state.d.ts +10 -27
- package/src/lib/components/flowable-status/flowable-status.component.d.ts +64 -18
- package/src/lib/components/flowable-status/flowable-status.config.d.ts +11 -0
- package/src/lib/components/flowable-status/flowable-status.facade.d.ts +19 -25
- package/src/lib/components/flowable-status/flowable-status.service.d.ts +17 -29
- package/src/lib/components/flowable-status/flowable-status.state.d.ts +7 -26
- package/src/lib/components/tasks/tasks.component.d.ts +2 -1
- package/src/lib/components/tasks/tasks.facade.d.ts +5 -2
- package/src/lib/components/tasks/tasks.state.d.ts +10 -3
- package/src/lib/components/workflow-designer/action-dialog/action-dialog.component.d.ts +4 -0
- package/src/lib/components/workflow-designer/actor-tags-dialog/actor-tags-dialog.component.d.ts +1 -0
- package/src/lib/components/workflow-designer/conditions-popup/conditions-popup.component.d.ts +4 -0
- package/src/lib/components/workflow-designer/decision-popup/decision-popup.component.d.ts +3 -0
- package/src/lib/components/workflow-designer/designer-canvas/designer-canvas.component.d.ts +104 -0
- package/src/lib/components/workflow-designer/designer-toolbar/designer-toolbar.component.d.ts +6 -0
- package/src/lib/components/workflow-designer/escalation-dialog/escalation-dialog.component.d.ts +4 -0
- package/src/lib/components/workflow-designer/services/connection.service.d.ts +16 -0
- package/src/lib/components/workflow-designer/services/node-management.service.d.ts +22 -1
- package/src/lib/components/workflow-designer/services/popup.service.d.ts +9 -1
- package/src/lib/components/workflow-designer/services/swimlane.service.d.ts +15 -0
- package/src/lib/components/workflow-designer/services/transformer.service.d.ts +15 -0
- package/src/lib/components/workflow-designer/stage-dialog/stage-dialog.component.d.ts +3 -0
- package/src/lib/components/workflow-designer/stage-node/stage-node.component.d.ts +4 -0
- package/src/lib/components/workflow-designer/swimlane-dialog/swimlane-dialog.component.d.ts +4 -0
- package/src/lib/components/workflow-designer/workflow-data.service.d.ts +24 -0
- package/src/lib/components/workflow-designer/workflow-designer.component.d.ts +74 -0
- package/src/lib/components/workflow-designer/workflow-designer.module.d.ts +19 -0
- package/src/lib/components/workflow-designer/workflow-designer.state.d.ts +179 -0
- package/src/lib/components/workflow-designer/workflow-designer.types.d.ts +80 -0
- package/src/lib/components/workflows/public-api.d.ts +1 -0
- package/src/lib/components/workflows/workflows.api.d.ts +38 -0
- package/src/lib/components/workflows/workflows.component.d.ts +78 -29
- package/src/lib/components/workflows/workflows.config.d.ts +10 -0
- package/src/lib/components/workflows/workflows.facade.d.ts +31 -28
- package/src/lib/components/workflows/workflows.service.d.ts +28 -74
- package/src/lib/components/workflows/workflows.state.d.ts +8 -26
- package/src/lib/services/http-web-request.service.d.ts +1 -1
- package/src/lib/services/util.service.d.ts +8 -0
- package/esm2022/src/lib/components/workflows/workflows.helper.mjs +0 -21
- package/src/lib/components/workflows/workflows.helper.d.ts +0 -3
|
@@ -0,0 +1,1055 @@
|
|
|
1
|
+
import { SearchPropertyValueType, SortDirection, SearchOperator, SearchPropertySign, ErrorResponse, ObjectState } from 'verben-workflow-ui/src/lib/models';
|
|
2
|
+
export { SearchOperator, SearchPropertySign, SearchPropertyValueType, SortDirection } from 'verben-workflow-ui/src/lib/models';
|
|
3
|
+
import * as i0 from '@angular/core';
|
|
4
|
+
import { signal, Injectable } from '@angular/core';
|
|
5
|
+
import { BehaviorSubject, lastValueFrom, Subject, debounce, timer, distinctUntilChanged, takeUntil } from 'rxjs';
|
|
6
|
+
import * as i1 from 'verben-workflow-ui/src/lib/services';
|
|
7
|
+
import { DataFilterType, SortDirection as SortDirection$1 } from 'verben-ng-ui';
|
|
8
|
+
|
|
9
|
+
// Re-export the shared API payload models so base-page consumers can import
|
|
10
|
+
// them from a single place without reaching into the models entry point.
|
|
11
|
+
//
|
|
12
|
+
// Values and types are exported separately: `isolatedModules` is on, so
|
|
13
|
+
// re-exporting a type alongside values in one statement fails with TS1205.
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Extract property name from column definition.
|
|
17
|
+
* Only columns with accessorKey can be used for filter/sort — a column defined
|
|
18
|
+
* with accessorFn alone (e.g. the actors "tags" column) has no server-side
|
|
19
|
+
* property to filter or sort on.
|
|
20
|
+
*/
|
|
21
|
+
function getPropertyName(column) {
|
|
22
|
+
if (!column.accessorKey) {
|
|
23
|
+
throw new Error(`Column '${column.id}' must have accessorKey for filter/sort operations`);
|
|
24
|
+
}
|
|
25
|
+
return String(column.accessorKey);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Infer API property type from column definition.
|
|
29
|
+
* Uses basic heuristics based on the accessor key name.
|
|
30
|
+
*/
|
|
31
|
+
function inferPropertyType(column) {
|
|
32
|
+
if (!column.accessorKey) {
|
|
33
|
+
return SearchPropertyValueType.String;
|
|
34
|
+
}
|
|
35
|
+
const propertyName = String(column.accessorKey).toLowerCase();
|
|
36
|
+
// Date detection. Includes the common audit fields (CreatedAt, UpdatedAt,
|
|
37
|
+
// ModifiedAt, DeletedAt) whose names contain neither "date" nor "time".
|
|
38
|
+
if (propertyName.includes('date') ||
|
|
39
|
+
propertyName.includes('time') ||
|
|
40
|
+
/^(created|updated|modified|deleted)/.test(propertyName)) {
|
|
41
|
+
return SearchPropertyValueType.Date;
|
|
42
|
+
}
|
|
43
|
+
if (propertyName.startsWith('is') || propertyName.startsWith('has')) {
|
|
44
|
+
return SearchPropertyValueType.Bool;
|
|
45
|
+
}
|
|
46
|
+
if (propertyName.includes('count') ||
|
|
47
|
+
propertyName.includes('amount') ||
|
|
48
|
+
propertyName.includes('price') ||
|
|
49
|
+
propertyName.includes('total')) {
|
|
50
|
+
return SearchPropertyValueType.Decimal;
|
|
51
|
+
}
|
|
52
|
+
return SearchPropertyValueType.String;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Find a column by its id.
|
|
56
|
+
*/
|
|
57
|
+
function findColumn(columns, columnId) {
|
|
58
|
+
return columns.find((col) => col.id === columnId);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Columns that can take part in filter/sort — i.e. those backed by a real
|
|
62
|
+
* property on the entity. Use this to feed the filter and sort builders so a
|
|
63
|
+
* display-only column never produces a payload the API cannot honour.
|
|
64
|
+
*/
|
|
65
|
+
function filterableColumns(columns) {
|
|
66
|
+
return columns.filter((col) => !!col.accessorKey);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Abstract state management for base data pages.
|
|
71
|
+
* Tracks items, loading state, query params, filters, sorts, search, and
|
|
72
|
+
* visible columns. Card data is held in signals for cheap change detection.
|
|
73
|
+
*/
|
|
74
|
+
class BaseDataPageState {
|
|
75
|
+
updating$ = new BehaviorSubject(false);
|
|
76
|
+
items$ = new BehaviorSubject([]);
|
|
77
|
+
totalCount$ = new BehaviorSubject(0);
|
|
78
|
+
queryParams$ = new BehaviorSubject({
|
|
79
|
+
skip: 0,
|
|
80
|
+
limit: 20,
|
|
81
|
+
sortOrder: SortDirection.Desc,
|
|
82
|
+
});
|
|
83
|
+
searchTerm$ = new BehaviorSubject('');
|
|
84
|
+
filters$ = new BehaviorSubject([]);
|
|
85
|
+
sorts$ = new BehaviorSubject([]);
|
|
86
|
+
visibleColumns$ = new BehaviorSubject([]);
|
|
87
|
+
// Last table/card view (true = table, false = card). Persisted per page.
|
|
88
|
+
isTableView$ = new BehaviorSubject(false);
|
|
89
|
+
cardData = signal([]);
|
|
90
|
+
currentCardData = signal(null);
|
|
91
|
+
cardDataMapper;
|
|
92
|
+
/**
|
|
93
|
+
* Stable identity for a record. `Code` comes first: it is what every page in
|
|
94
|
+
* this library matches on, and what the backend assigns on persist. `Id` is
|
|
95
|
+
* frequently the empty string on records that came back from a save, and the
|
|
96
|
+
* lowercase `id` is a client-generated UUID that exists only on unsaved rows.
|
|
97
|
+
*/
|
|
98
|
+
getItemKey(item) {
|
|
99
|
+
return item.Code || item.Id || item.id;
|
|
100
|
+
}
|
|
101
|
+
updateCardDataFromItems(items) {
|
|
102
|
+
if (this.cardDataMapper) {
|
|
103
|
+
this.cardData.set(items.map((item) => this.cardDataMapper(item)));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// ===== Loading State =====
|
|
107
|
+
isUpdating$() {
|
|
108
|
+
return this.updating$.asObservable();
|
|
109
|
+
}
|
|
110
|
+
setUpdating(isUpdating) {
|
|
111
|
+
this.updating$.next(isUpdating);
|
|
112
|
+
}
|
|
113
|
+
// ===== Items =====
|
|
114
|
+
getItems$() {
|
|
115
|
+
return this.items$.asObservable();
|
|
116
|
+
}
|
|
117
|
+
getItemsValue() {
|
|
118
|
+
return this.items$.getValue();
|
|
119
|
+
}
|
|
120
|
+
setItems(items) {
|
|
121
|
+
this.items$.next(items);
|
|
122
|
+
this.updateCardDataFromItems(items);
|
|
123
|
+
}
|
|
124
|
+
appendItems(newItems) {
|
|
125
|
+
const allItems = [...this.items$.getValue(), ...newItems];
|
|
126
|
+
this.items$.next(allItems);
|
|
127
|
+
this.updateCardDataFromItems(allItems);
|
|
128
|
+
}
|
|
129
|
+
addItem(item) {
|
|
130
|
+
const allItems = [item, ...this.items$.getValue()];
|
|
131
|
+
this.items$.next(allItems);
|
|
132
|
+
this.updateCardDataFromItems(allItems);
|
|
133
|
+
}
|
|
134
|
+
updateItem(updatedItem) {
|
|
135
|
+
const items = this.items$.getValue();
|
|
136
|
+
const key = this.getItemKey(updatedItem);
|
|
137
|
+
const index = items.findIndex((item) => this.getItemKey(item) === key);
|
|
138
|
+
if (index !== -1) {
|
|
139
|
+
items[index] = updatedItem;
|
|
140
|
+
const allItems = [...items];
|
|
141
|
+
this.items$.next(allItems);
|
|
142
|
+
this.updateCardDataFromItems(allItems);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/** Update the item when its key already exists, otherwise prepend it. */
|
|
146
|
+
upsertItem(item) {
|
|
147
|
+
const key = this.getItemKey(item);
|
|
148
|
+
const exists = this.items$
|
|
149
|
+
.getValue()
|
|
150
|
+
.some((existing) => this.getItemKey(existing) === key);
|
|
151
|
+
if (exists) {
|
|
152
|
+
this.updateItem(item);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
this.addItem(item);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
removeItem(itemKey) {
|
|
159
|
+
const filteredItems = this.items$
|
|
160
|
+
.getValue()
|
|
161
|
+
.filter((item) => this.getItemKey(item) !== itemKey);
|
|
162
|
+
this.items$.next(filteredItems);
|
|
163
|
+
this.updateCardDataFromItems(filteredItems);
|
|
164
|
+
}
|
|
165
|
+
clearItems() {
|
|
166
|
+
this.items$.next([]);
|
|
167
|
+
this.updateCardDataFromItems([]);
|
|
168
|
+
}
|
|
169
|
+
// ===== Total Count =====
|
|
170
|
+
getTotalCount$() {
|
|
171
|
+
return this.totalCount$.asObservable();
|
|
172
|
+
}
|
|
173
|
+
setTotalCount(count) {
|
|
174
|
+
this.totalCount$.next(count);
|
|
175
|
+
}
|
|
176
|
+
// ===== Query Parameters =====
|
|
177
|
+
getQueryParams$() {
|
|
178
|
+
return this.queryParams$.asObservable();
|
|
179
|
+
}
|
|
180
|
+
getQueryParamsValue() {
|
|
181
|
+
return this.queryParams$.getValue();
|
|
182
|
+
}
|
|
183
|
+
updateQueryParams(params) {
|
|
184
|
+
this.queryParams$.next({ ...this.queryParams$.getValue(), ...params });
|
|
185
|
+
}
|
|
186
|
+
resetPagination() {
|
|
187
|
+
this.queryParams$.next({ ...this.queryParams$.getValue(), skip: 0 });
|
|
188
|
+
}
|
|
189
|
+
incrementPagination() {
|
|
190
|
+
const currentParams = this.queryParams$.getValue();
|
|
191
|
+
this.queryParams$.next({
|
|
192
|
+
...currentParams,
|
|
193
|
+
skip: currentParams.skip + currentParams.limit,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
// ===== Search =====
|
|
197
|
+
getSearchTerm$() {
|
|
198
|
+
return this.searchTerm$.asObservable();
|
|
199
|
+
}
|
|
200
|
+
getSearchTermValue() {
|
|
201
|
+
return this.searchTerm$.getValue();
|
|
202
|
+
}
|
|
203
|
+
setSearchTerm(term) {
|
|
204
|
+
this.searchTerm$.next(term);
|
|
205
|
+
}
|
|
206
|
+
// ===== Filters =====
|
|
207
|
+
getFilters$() {
|
|
208
|
+
return this.filters$.asObservable();
|
|
209
|
+
}
|
|
210
|
+
getFiltersValue() {
|
|
211
|
+
return this.filters$.getValue();
|
|
212
|
+
}
|
|
213
|
+
setFilters(filters) {
|
|
214
|
+
this.filters$.next(filters);
|
|
215
|
+
}
|
|
216
|
+
clearFilters() {
|
|
217
|
+
this.filters$.next([]);
|
|
218
|
+
}
|
|
219
|
+
// ===== Sorts =====
|
|
220
|
+
getSorts$() {
|
|
221
|
+
return this.sorts$.asObservable();
|
|
222
|
+
}
|
|
223
|
+
getSortsValue() {
|
|
224
|
+
return this.sorts$.getValue();
|
|
225
|
+
}
|
|
226
|
+
setSorts(sorts) {
|
|
227
|
+
this.sorts$.next(sorts);
|
|
228
|
+
}
|
|
229
|
+
clearSorts() {
|
|
230
|
+
this.sorts$.next([]);
|
|
231
|
+
}
|
|
232
|
+
// ===== Visible Columns =====
|
|
233
|
+
getVisibleColumns$() {
|
|
234
|
+
return this.visibleColumns$.asObservable();
|
|
235
|
+
}
|
|
236
|
+
getVisibleColumnsValue() {
|
|
237
|
+
return this.visibleColumns$.getValue();
|
|
238
|
+
}
|
|
239
|
+
setVisibleColumns(columns) {
|
|
240
|
+
this.visibleColumns$.next(columns);
|
|
241
|
+
}
|
|
242
|
+
// ===== Table/Card View =====
|
|
243
|
+
getIsTableView$() {
|
|
244
|
+
return this.isTableView$.asObservable();
|
|
245
|
+
}
|
|
246
|
+
getIsTableViewValue() {
|
|
247
|
+
return this.isTableView$.getValue();
|
|
248
|
+
}
|
|
249
|
+
setIsTableView(isTableView) {
|
|
250
|
+
this.isTableView$.next(isTableView);
|
|
251
|
+
}
|
|
252
|
+
// ===== Card Data =====
|
|
253
|
+
setCardDataMapper(mapper) {
|
|
254
|
+
this.cardDataMapper = mapper;
|
|
255
|
+
}
|
|
256
|
+
getCardData() {
|
|
257
|
+
return this.cardData;
|
|
258
|
+
}
|
|
259
|
+
setCardData(data) {
|
|
260
|
+
this.cardData.set(data);
|
|
261
|
+
}
|
|
262
|
+
getCurrentCardData() {
|
|
263
|
+
return this.currentCardData;
|
|
264
|
+
}
|
|
265
|
+
setCurrentCardData(data) {
|
|
266
|
+
this.currentCardData.set(data);
|
|
267
|
+
}
|
|
268
|
+
// ===== Reset All =====
|
|
269
|
+
reset() {
|
|
270
|
+
this.clearItems();
|
|
271
|
+
this.setSearchTerm('');
|
|
272
|
+
this.clearFilters();
|
|
273
|
+
this.clearSorts();
|
|
274
|
+
this.setVisibleColumns([]);
|
|
275
|
+
this.cardData.set([]);
|
|
276
|
+
this.currentCardData.set(null);
|
|
277
|
+
this.resetPagination();
|
|
278
|
+
this.setTotalCount(0);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Converts filter conditions emitted by the verben-ng-ui filter components into
|
|
284
|
+
* the SearchPropertyValue[] payload the search API expects.
|
|
285
|
+
*
|
|
286
|
+
* Two input shapes are supported. `lib-data-filter` emits `FilterCondition[]`,
|
|
287
|
+
* which carries a columnId and an operator and is the shape the base prefers.
|
|
288
|
+
* `verben-table-filter` emits `IDataFilter[]`, which names the property directly
|
|
289
|
+
* and has no operator; it is kept working so pages can migrate one at a time.
|
|
290
|
+
*/
|
|
291
|
+
class FilterHandlerService {
|
|
292
|
+
buildFilterPayload(filters, columns) {
|
|
293
|
+
return filters
|
|
294
|
+
.map((filter) => this.isDataFilter(filter)
|
|
295
|
+
? this.fromDataFilter(filter)
|
|
296
|
+
: this.fromFilterCondition(filter, columns))
|
|
297
|
+
.filter(Boolean);
|
|
298
|
+
}
|
|
299
|
+
isDataFilter(filter) {
|
|
300
|
+
return filter.name !== undefined;
|
|
301
|
+
}
|
|
302
|
+
fromFilterCondition(filter, columns) {
|
|
303
|
+
const column = findColumn(columns, filter.columnId);
|
|
304
|
+
if (!column) {
|
|
305
|
+
return null;
|
|
306
|
+
}
|
|
307
|
+
// A display-only column (accessorFn with no accessorKey) has no server-side
|
|
308
|
+
// property to filter on; skip it rather than throwing out of getPropertyName.
|
|
309
|
+
if (!column.accessorKey) {
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
return {
|
|
313
|
+
PropertyName: getPropertyName(column),
|
|
314
|
+
EntityValue: String(filter.value),
|
|
315
|
+
Type: inferPropertyType(column),
|
|
316
|
+
Operator: SearchOperator.And,
|
|
317
|
+
Sign: this.mapOperatorToSign(filter.operator),
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
/** Legacy `verben-table-filter` shape: property name and type, no operator. */
|
|
321
|
+
fromDataFilter(filter) {
|
|
322
|
+
if (filter.value === undefined || filter.value === null) {
|
|
323
|
+
return null;
|
|
324
|
+
}
|
|
325
|
+
return {
|
|
326
|
+
PropertyName: filter.name,
|
|
327
|
+
EntityValue: String(filter.value),
|
|
328
|
+
Type: this.mapDataFilterType(filter.type),
|
|
329
|
+
Operator: SearchOperator.And,
|
|
330
|
+
Sign: filter.condition
|
|
331
|
+
? this.mapOperatorToSign(filter.condition)
|
|
332
|
+
: SearchPropertySign.EQ,
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Inverse of {@link buildFilterPayload}: rebuild FilterCondition[] from a
|
|
337
|
+
* persisted SearchPropertyValue[] (restoring saved filters). Sign-preserving,
|
|
338
|
+
* so re-running buildFilterPayload reproduces the same query.
|
|
339
|
+
*/
|
|
340
|
+
buildFilterConditions(payload, columns) {
|
|
341
|
+
return payload
|
|
342
|
+
.map((pv) => {
|
|
343
|
+
const column = columns.find((col) => col.accessorKey && String(col.accessorKey) === pv.PropertyName);
|
|
344
|
+
if (!column) {
|
|
345
|
+
console.warn(`Column not found for saved filter property: ${pv.PropertyName}`);
|
|
346
|
+
return null;
|
|
347
|
+
}
|
|
348
|
+
return {
|
|
349
|
+
columnId: column.id,
|
|
350
|
+
operator: this.mapSignToOperator(pv.Sign),
|
|
351
|
+
value: pv.EntityValue,
|
|
352
|
+
};
|
|
353
|
+
})
|
|
354
|
+
.filter(Boolean);
|
|
355
|
+
}
|
|
356
|
+
mapSignToOperator(sign) {
|
|
357
|
+
switch (sign) {
|
|
358
|
+
case SearchPropertySign.LIKE:
|
|
359
|
+
return 'contains';
|
|
360
|
+
case SearchPropertySign.GT:
|
|
361
|
+
return 'greaterThan';
|
|
362
|
+
case SearchPropertySign.LT:
|
|
363
|
+
return 'lessThan';
|
|
364
|
+
case SearchPropertySign.EQ:
|
|
365
|
+
default:
|
|
366
|
+
return 'equals';
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
mapOperatorToSign(operator) {
|
|
370
|
+
const operatorMap = {
|
|
371
|
+
startsWith: SearchPropertySign.LIKE,
|
|
372
|
+
endsWith: SearchPropertySign.LIKE,
|
|
373
|
+
contains: SearchPropertySign.LIKE,
|
|
374
|
+
equals: SearchPropertySign.EQ,
|
|
375
|
+
equal: SearchPropertySign.EQ,
|
|
376
|
+
greaterThan: SearchPropertySign.GT,
|
|
377
|
+
lessThan: SearchPropertySign.LT,
|
|
378
|
+
on: SearchPropertySign.EQ,
|
|
379
|
+
before: SearchPropertySign.LT,
|
|
380
|
+
after: SearchPropertySign.GT,
|
|
381
|
+
};
|
|
382
|
+
return operatorMap[operator] || SearchPropertySign.EQ;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Carried over from the original workflows.helper.ts so the legacy
|
|
386
|
+
* `verben-table-filter` path keeps producing the same payload types.
|
|
387
|
+
*/
|
|
388
|
+
mapDataFilterType(type) {
|
|
389
|
+
switch (type) {
|
|
390
|
+
case DataFilterType.String:
|
|
391
|
+
return SearchPropertyValueType.String;
|
|
392
|
+
case DataFilterType.Integer:
|
|
393
|
+
case DataFilterType.Number:
|
|
394
|
+
return SearchPropertyValueType.Int;
|
|
395
|
+
case DataFilterType.Decimal:
|
|
396
|
+
return SearchPropertyValueType.Decimal;
|
|
397
|
+
case DataFilterType.Credit:
|
|
398
|
+
return SearchPropertyValueType.Float;
|
|
399
|
+
case DataFilterType.Date:
|
|
400
|
+
return SearchPropertyValueType.Date;
|
|
401
|
+
case DataFilterType.Bool:
|
|
402
|
+
return SearchPropertyValueType.Bool;
|
|
403
|
+
default:
|
|
404
|
+
return SearchPropertyValueType.String;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: FilterHandlerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
408
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: FilterHandlerService, providedIn: 'root' });
|
|
409
|
+
}
|
|
410
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: FilterHandlerService, decorators: [{
|
|
411
|
+
type: Injectable,
|
|
412
|
+
args: [{ providedIn: 'root' }]
|
|
413
|
+
}] });
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Converts SortCondition[] emitted by lib-data-sort into what the workflow API
|
|
417
|
+
* needs.
|
|
418
|
+
*
|
|
419
|
+
* This API carries sort in the URL — every endpoint ends
|
|
420
|
+
* `/{skip}/{limit}/{sortParam}/{sortOrder}`, including the POST search — so
|
|
421
|
+
* `buildPrimarySort()` is the load-bearing one and only the first condition can
|
|
422
|
+
* be honoured. `buildSortPayload()` still emits the full set on the POST body so
|
|
423
|
+
* multi-column sort starts working the moment the backend reads it.
|
|
424
|
+
*/
|
|
425
|
+
class SortHandlerService {
|
|
426
|
+
/**
|
|
427
|
+
* Collapse the sort conditions to the single sort the URL can carry.
|
|
428
|
+
* Returns null when nothing sortable was selected, so callers fall back to
|
|
429
|
+
* the page's configured default.
|
|
430
|
+
*/
|
|
431
|
+
buildPrimarySort(sorts, columns) {
|
|
432
|
+
for (const sort of sorts) {
|
|
433
|
+
const column = findColumn(columns, sort.columnId);
|
|
434
|
+
if (!column?.accessorKey) {
|
|
435
|
+
continue;
|
|
436
|
+
}
|
|
437
|
+
return {
|
|
438
|
+
sortParam: getPropertyName(column),
|
|
439
|
+
sortOrder: this.mapSortDirection(sort.direction),
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
return null;
|
|
443
|
+
}
|
|
444
|
+
buildSortPayload(sorts, columns) {
|
|
445
|
+
return sorts
|
|
446
|
+
.map((sort) => {
|
|
447
|
+
const column = findColumn(columns, sort.columnId);
|
|
448
|
+
if (!column) {
|
|
449
|
+
return null;
|
|
450
|
+
}
|
|
451
|
+
if (!column.accessorKey) {
|
|
452
|
+
return null;
|
|
453
|
+
}
|
|
454
|
+
return {
|
|
455
|
+
PropertyName: getPropertyName(column),
|
|
456
|
+
EntityValue: '',
|
|
457
|
+
Type: inferPropertyType(column),
|
|
458
|
+
Operator: SearchOperator.And,
|
|
459
|
+
Sign: SearchPropertySign.EQ,
|
|
460
|
+
Sort: this.mapSortDirection(sort.direction),
|
|
461
|
+
};
|
|
462
|
+
})
|
|
463
|
+
.filter(Boolean);
|
|
464
|
+
}
|
|
465
|
+
mapSortDirection(direction) {
|
|
466
|
+
switch (direction) {
|
|
467
|
+
case SortDirection$1.Asc:
|
|
468
|
+
return SortDirection.Asc;
|
|
469
|
+
case SortDirection$1.Desc:
|
|
470
|
+
return SortDirection.Desc;
|
|
471
|
+
default:
|
|
472
|
+
return SortDirection.None;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: SortHandlerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
476
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: SortHandlerService, providedIn: 'root' });
|
|
477
|
+
}
|
|
478
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: SortHandlerService, decorators: [{
|
|
479
|
+
type: Injectable,
|
|
480
|
+
args: [{ providedIn: 'root' }]
|
|
481
|
+
}] });
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Abstract base service for data pages.
|
|
485
|
+
* Handles list/search/save/delete with filter and sort support.
|
|
486
|
+
*
|
|
487
|
+
* The concrete URLs are built by the protected `*Url` seams below. Unlike the
|
|
488
|
+
* sibling libraries, every endpoint in the workflow API carries the sort as URL
|
|
489
|
+
* segments — `Get{Endpoint}/{skip}/{limit}/{sortParam}/{sortOrder}`, and the
|
|
490
|
+
* POST search does too — so the seams take sort parameters. Services whose
|
|
491
|
+
* endpoint names or shapes deviate (plural vs singular, query-string deletes)
|
|
492
|
+
* override just the URL rather than reimplementing `getData()`.
|
|
493
|
+
*
|
|
494
|
+
* When `baseUrl` is omitted, HttpWebRequestService falls back to the WorkFlowAPI
|
|
495
|
+
* base.
|
|
496
|
+
*/
|
|
497
|
+
class BaseDataPageService {
|
|
498
|
+
server;
|
|
499
|
+
filterHandler;
|
|
500
|
+
sortHandler;
|
|
501
|
+
baseUrl;
|
|
502
|
+
constructor(server, filterHandler, sortHandler, baseUrl) {
|
|
503
|
+
this.server = server;
|
|
504
|
+
this.filterHandler = filterHandler;
|
|
505
|
+
this.sortHandler = sortHandler;
|
|
506
|
+
this.baseUrl = baseUrl;
|
|
507
|
+
}
|
|
508
|
+
/** Sort property used when the user has not chosen one. */
|
|
509
|
+
defaultSortParam() {
|
|
510
|
+
return 'CreatedAt';
|
|
511
|
+
}
|
|
512
|
+
defaultSortOrder() {
|
|
513
|
+
return SortDirection.Desc;
|
|
514
|
+
}
|
|
515
|
+
// ===== URL seams (override in child services when the API deviates) =====
|
|
516
|
+
listUrl(skip, limit, sortParam, sortOrder) {
|
|
517
|
+
return `Get${this.getEndpoint()}/${skip}/${limit}/${sortParam}/${sortOrder}`;
|
|
518
|
+
}
|
|
519
|
+
searchTermUrl(term, skip, limit, sortParam, sortOrder) {
|
|
520
|
+
return `Get${this.getEndpoint()}WithParam/${term}/${skip}/${limit}/${sortParam}/${sortOrder}`;
|
|
521
|
+
}
|
|
522
|
+
filterSearchUrl(skip, limit, sortParam, sortOrder) {
|
|
523
|
+
return `Search${this.getEndpoint()}/${skip}/${limit}/${sortParam}/${sortOrder}`;
|
|
524
|
+
}
|
|
525
|
+
saveUrl() {
|
|
526
|
+
return `Save${this.getEndpoint()}`;
|
|
527
|
+
}
|
|
528
|
+
deleteUrl(itemIds) {
|
|
529
|
+
return `${this.getEndpoint()}/${itemIds.join(',')}`;
|
|
530
|
+
}
|
|
531
|
+
// ===== Payload =====
|
|
532
|
+
buildPayload(filters, sorts, columns) {
|
|
533
|
+
const filterPayload = this.filterHandler.buildFilterPayload(filters, columns);
|
|
534
|
+
const sortPayload = this.sortHandler.buildSortPayload(sorts, columns);
|
|
535
|
+
return [...filterPayload, ...sortPayload];
|
|
536
|
+
}
|
|
537
|
+
/** Filter-only payload (no sorts) for persisting saved filters. */
|
|
538
|
+
buildFilterPayloadOnly(filters, columns) {
|
|
539
|
+
return this.filterHandler.buildFilterPayload(filters, columns);
|
|
540
|
+
}
|
|
541
|
+
/** Inverse of {@link buildFilterPayloadOnly}: rebuild FilterCondition[] on restore. */
|
|
542
|
+
parseFilterPayload(payload, columns) {
|
|
543
|
+
return this.filterHandler.buildFilterConditions(payload, columns);
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* The sort the URL will carry: the user's first sortable selection, else the
|
|
547
|
+
* page default.
|
|
548
|
+
*/
|
|
549
|
+
resolveSort(sorts, columns) {
|
|
550
|
+
const chosen = sorts && columns ? this.sortHandler.buildPrimarySort(sorts, columns) : null;
|
|
551
|
+
return (chosen ?? {
|
|
552
|
+
sortParam: this.defaultSortParam(),
|
|
553
|
+
sortOrder: this.defaultSortOrder(),
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
// ===== Reads =====
|
|
557
|
+
/**
|
|
558
|
+
* Fetch data, automatically choosing the endpoint based on parameters:
|
|
559
|
+
* search-only -> GET WithParam, filters -> POST Search, otherwise plain GET.
|
|
560
|
+
*
|
|
561
|
+
* Sorts alone do not force the POST path: the plain GET already carries sort
|
|
562
|
+
* in its URL, so a sort-only request stays a GET.
|
|
563
|
+
*/
|
|
564
|
+
async getData(skip, limit, filters, sorts, searchTerm, columns) {
|
|
565
|
+
const hasFilters = !!filters && filters.length > 0;
|
|
566
|
+
const { sortParam, sortOrder } = this.resolveSort(sorts, columns);
|
|
567
|
+
if (hasFilters) {
|
|
568
|
+
if (!columns) {
|
|
569
|
+
throw new Error('Columns required for filter operations');
|
|
570
|
+
}
|
|
571
|
+
const payload = this.buildPayload(filters, sorts || [], columns);
|
|
572
|
+
// NOTE: post() here is (url, body, overrideToken?, baseUrl?) — baseUrl is
|
|
573
|
+
// the FOURTH argument, unlike get()/delete() where it is the second.
|
|
574
|
+
// Passing it third would send the URL as an auth token, and because
|
|
575
|
+
// HttpWebRequestService resolves errors into ErrorResponse rather than
|
|
576
|
+
// throwing, the failure would be silent.
|
|
577
|
+
return this.server.post(this.filterSearchUrl(skip, limit, sortParam, sortOrder), payload, undefined, this.baseUrl);
|
|
578
|
+
}
|
|
579
|
+
if (searchTerm) {
|
|
580
|
+
return this.server.get(this.searchTermUrl(searchTerm, skip, limit, sortParam, sortOrder), this.baseUrl);
|
|
581
|
+
}
|
|
582
|
+
return this.server.get(this.listUrl(skip, limit, sortParam, sortOrder), this.baseUrl);
|
|
583
|
+
}
|
|
584
|
+
// ===== Writes =====
|
|
585
|
+
async saveItems(items) {
|
|
586
|
+
return this.server.post(this.saveUrl(), items, undefined, this.baseUrl);
|
|
587
|
+
}
|
|
588
|
+
async deleteItems(itemIds) {
|
|
589
|
+
// HttpWebRequestService.delete returns a raw observable that rejects on HTTP
|
|
590
|
+
// error (unlike get/post, which resolve an ErrorResponse), so normalize here
|
|
591
|
+
// to keep the facade's error-handling contract uniform.
|
|
592
|
+
try {
|
|
593
|
+
const result = await lastValueFrom(this.server.delete(this.deleteUrl(itemIds), this.baseUrl));
|
|
594
|
+
return result ?? false;
|
|
595
|
+
}
|
|
596
|
+
catch (err) {
|
|
597
|
+
const msg = err?.error?.ErrorMsg || err?.ErrorMsg || err?.message || 'Delete failed';
|
|
598
|
+
return new ErrorResponse(msg);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
// ===== Export =====
|
|
602
|
+
async exportData(filters, sorts, searchTerm, columns) {
|
|
603
|
+
const result = await this.getData(0, 999999, filters, sorts, searchTerm, columns);
|
|
604
|
+
if (result instanceof ErrorResponse) {
|
|
605
|
+
return result;
|
|
606
|
+
}
|
|
607
|
+
return result.Result || [];
|
|
608
|
+
}
|
|
609
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: BaseDataPageService, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
|
|
610
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: BaseDataPageService });
|
|
611
|
+
}
|
|
612
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: BaseDataPageService, decorators: [{
|
|
613
|
+
type: Injectable
|
|
614
|
+
}], ctorParameters: () => [{ type: i1.HttpWebRequestService }, { type: FilterHandlerService }, { type: SortHandlerService }, { type: undefined }] });
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* Debounces search terms. Emits the term after the user stops typing.
|
|
618
|
+
* Provided per page so each page owns its own debounce stream.
|
|
619
|
+
*
|
|
620
|
+
* `search$` is a stable observable whose debounce interval is read live from
|
|
621
|
+
* `debounceMs`, so `setDebounceTime()` can be called after subscribers have
|
|
622
|
+
* attached (e.g. from a runtime `@Input`) and still take effect.
|
|
623
|
+
*/
|
|
624
|
+
class SearchHandlerService {
|
|
625
|
+
searchSubject = new Subject();
|
|
626
|
+
debounceMs = 500;
|
|
627
|
+
search$ = this.searchSubject.asObservable().pipe(debounce(() => timer(this.debounceMs)), distinctUntilChanged());
|
|
628
|
+
search(term) {
|
|
629
|
+
this.searchSubject.next(term);
|
|
630
|
+
}
|
|
631
|
+
setDebounceTime(ms) {
|
|
632
|
+
this.debounceMs = ms;
|
|
633
|
+
}
|
|
634
|
+
ngOnDestroy() {
|
|
635
|
+
this.searchSubject.complete();
|
|
636
|
+
}
|
|
637
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: SearchHandlerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
638
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: SearchHandlerService });
|
|
639
|
+
}
|
|
640
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: SearchHandlerService, decorators: [{
|
|
641
|
+
type: Injectable
|
|
642
|
+
}] });
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Abstract facade for base data pages.
|
|
646
|
+
* Orchestrates state, service, and search handler, and surfaces the host app's
|
|
647
|
+
* busy indicator / toasts through UtilService.
|
|
648
|
+
*/
|
|
649
|
+
class BaseDataPageFacade {
|
|
650
|
+
state;
|
|
651
|
+
service;
|
|
652
|
+
searchHandler;
|
|
653
|
+
utilService;
|
|
654
|
+
config;
|
|
655
|
+
destroy$ = new Subject();
|
|
656
|
+
cardSelectionCleared = new Subject();
|
|
657
|
+
/**
|
|
658
|
+
* The saved config record for this page (once loaded/created), retained so
|
|
659
|
+
* successive saves in a session update the same record instead of duplicating.
|
|
660
|
+
*/
|
|
661
|
+
savedOption;
|
|
662
|
+
constructor(state, service, searchHandler, utilService, config) {
|
|
663
|
+
this.state = state;
|
|
664
|
+
this.service = service;
|
|
665
|
+
this.searchHandler = searchHandler;
|
|
666
|
+
this.utilService = utilService;
|
|
667
|
+
this.config = config;
|
|
668
|
+
this.initializeSearchHandler();
|
|
669
|
+
this.state.setVisibleColumns(this.config.columns);
|
|
670
|
+
this.state.updateQueryParams({ limit: this.config.pageSize });
|
|
671
|
+
if (this.config.cardDataMapper) {
|
|
672
|
+
this.state.setCardDataMapper(this.config.cardDataMapper);
|
|
673
|
+
}
|
|
674
|
+
// Drive the host busy indicator from the shared loading flag.
|
|
675
|
+
this.state
|
|
676
|
+
.isUpdating$()
|
|
677
|
+
.pipe(takeUntil(this.destroy$))
|
|
678
|
+
.subscribe((loading) => this.utilService.sendBI(loading));
|
|
679
|
+
}
|
|
680
|
+
// ===== Configuration =====
|
|
681
|
+
getConfig() {
|
|
682
|
+
return this.config;
|
|
683
|
+
}
|
|
684
|
+
getColumns() {
|
|
685
|
+
return this.config.columns;
|
|
686
|
+
}
|
|
687
|
+
// ===== Observables =====
|
|
688
|
+
get items$() {
|
|
689
|
+
return this.state.getItems$();
|
|
690
|
+
}
|
|
691
|
+
get isLoading$() {
|
|
692
|
+
return this.state.isUpdating$();
|
|
693
|
+
}
|
|
694
|
+
get totalCount$() {
|
|
695
|
+
return this.state.getTotalCount$();
|
|
696
|
+
}
|
|
697
|
+
get filters$() {
|
|
698
|
+
return this.state.getFilters$();
|
|
699
|
+
}
|
|
700
|
+
get sorts$() {
|
|
701
|
+
return this.state.getSorts$();
|
|
702
|
+
}
|
|
703
|
+
get searchTerm$() {
|
|
704
|
+
return this.state.getSearchTerm$();
|
|
705
|
+
}
|
|
706
|
+
get visibleColumns$() {
|
|
707
|
+
return this.state.getVisibleColumns$();
|
|
708
|
+
}
|
|
709
|
+
/** Last table/card view (true = table). Restored on load, persisted on change. */
|
|
710
|
+
get isTableView$() {
|
|
711
|
+
return this.state.getIsTableView$();
|
|
712
|
+
}
|
|
713
|
+
getIsTableViewValue() {
|
|
714
|
+
return this.state.getIsTableViewValue();
|
|
715
|
+
}
|
|
716
|
+
get cardData() {
|
|
717
|
+
return this.state.getCardData();
|
|
718
|
+
}
|
|
719
|
+
get currentCardData() {
|
|
720
|
+
return this.state.getCurrentCardData();
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* Emits when a refetch invalidates the current card selection.
|
|
724
|
+
* Card views listen to this to clear their own selection state.
|
|
725
|
+
*/
|
|
726
|
+
get cardSelectionCleared$() {
|
|
727
|
+
return this.cardSelectionCleared.asObservable();
|
|
728
|
+
}
|
|
729
|
+
// ===== Data Loading =====
|
|
730
|
+
async loadData() {
|
|
731
|
+
// Drop the open record before the list underneath it is replaced. Without
|
|
732
|
+
// this the detail form keeps rendering the previous record after a search
|
|
733
|
+
// or filter refetch — the "form doesn't close after search" bug.
|
|
734
|
+
this.clearCardSelection();
|
|
735
|
+
this.state.setUpdating(true);
|
|
736
|
+
this.state.clearItems();
|
|
737
|
+
this.state.resetPagination();
|
|
738
|
+
const params = this.state.getQueryParamsValue();
|
|
739
|
+
const filters = this.state.getFiltersValue();
|
|
740
|
+
const sorts = this.state.getSortsValue();
|
|
741
|
+
const searchTerm = this.state.getSearchTermValue();
|
|
742
|
+
const result = await this.service.getData(params.skip, params.limit, filters, sorts, searchTerm, this.config.columns);
|
|
743
|
+
this.state.setUpdating(false);
|
|
744
|
+
if (result instanceof ErrorResponse) {
|
|
745
|
+
this.utilService.showError(result.ErrorMsg);
|
|
746
|
+
return;
|
|
747
|
+
}
|
|
748
|
+
this.state.setItems(result.Result || []);
|
|
749
|
+
this.state.setTotalCount(result.Total || 0);
|
|
750
|
+
}
|
|
751
|
+
addItem(item) {
|
|
752
|
+
this.state.addItem(item);
|
|
753
|
+
}
|
|
754
|
+
async loadMore() {
|
|
755
|
+
this.state.setUpdating(true);
|
|
756
|
+
// Advance first, then fetch: the first page was loaded at skip=0 without
|
|
757
|
+
// moving the pointer, so the next page starts at skip + limit.
|
|
758
|
+
this.state.incrementPagination();
|
|
759
|
+
const params = this.state.getQueryParamsValue();
|
|
760
|
+
const filters = this.state.getFiltersValue();
|
|
761
|
+
const sorts = this.state.getSortsValue();
|
|
762
|
+
// Paging must stay inside the active search/filter, or page 2 returns
|
|
763
|
+
// unfiltered rows.
|
|
764
|
+
const searchTerm = this.state.getSearchTermValue();
|
|
765
|
+
const result = await this.service.getData(params.skip, params.limit, filters, sorts, searchTerm, this.config.columns);
|
|
766
|
+
this.state.setUpdating(false);
|
|
767
|
+
if (result instanceof ErrorResponse) {
|
|
768
|
+
this.utilService.showError(result.ErrorMsg);
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
771
|
+
this.state.appendItems(result.Result || []);
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* Fetch an arbitrary window without touching page state, honouring the active
|
|
775
|
+
* search, filters and sorts. Backs the export component's dataQueryFunction.
|
|
776
|
+
*/
|
|
777
|
+
async loadRange(skip, limit) {
|
|
778
|
+
const result = await this.service.getData(skip, limit, this.state.getFiltersValue(), this.state.getSortsValue(), this.state.getSearchTermValue(), this.config.columns);
|
|
779
|
+
if (result instanceof ErrorResponse) {
|
|
780
|
+
this.utilService.showError(result.ErrorMsg);
|
|
781
|
+
return [];
|
|
782
|
+
}
|
|
783
|
+
return result.Result || [];
|
|
784
|
+
}
|
|
785
|
+
async refresh() {
|
|
786
|
+
await this.loadData();
|
|
787
|
+
}
|
|
788
|
+
// ===== Search =====
|
|
789
|
+
onSearch(term) {
|
|
790
|
+
this.searchHandler.search(term);
|
|
791
|
+
}
|
|
792
|
+
initializeSearchHandler() {
|
|
793
|
+
if (this.config.searchDebounceTime) {
|
|
794
|
+
this.searchHandler.setDebounceTime(this.config.searchDebounceTime);
|
|
795
|
+
}
|
|
796
|
+
this.searchHandler.search$.pipe(takeUntil(this.destroy$)).subscribe((term) => {
|
|
797
|
+
this.state.setSearchTerm(term);
|
|
798
|
+
this.loadData();
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
// ===== Filters / Sorts =====
|
|
802
|
+
async applyFilters(filters) {
|
|
803
|
+
this.state.setFilters(filters);
|
|
804
|
+
this.persistConfig();
|
|
805
|
+
await this.loadData();
|
|
806
|
+
}
|
|
807
|
+
async clearFilters() {
|
|
808
|
+
this.state.clearFilters();
|
|
809
|
+
this.persistConfig();
|
|
810
|
+
await this.loadData();
|
|
811
|
+
}
|
|
812
|
+
async applySorts(sorts) {
|
|
813
|
+
this.state.setSorts(sorts);
|
|
814
|
+
await this.loadData();
|
|
815
|
+
}
|
|
816
|
+
async clearSorts() {
|
|
817
|
+
this.state.clearSorts();
|
|
818
|
+
await this.loadData();
|
|
819
|
+
}
|
|
820
|
+
// ===== Visible Columns =====
|
|
821
|
+
updateVisibleColumns(columns) {
|
|
822
|
+
this.state.setVisibleColumns(columns);
|
|
823
|
+
this.persistConfig();
|
|
824
|
+
}
|
|
825
|
+
// ===== Table/Card View =====
|
|
826
|
+
/**
|
|
827
|
+
* Update the table/card view flag WITHOUT persisting. Use for transient or
|
|
828
|
+
* internal switches (e.g. dropping to card view to open a create form).
|
|
829
|
+
*/
|
|
830
|
+
setViewState(isTableView) {
|
|
831
|
+
this.state.setIsTableView(isTableView);
|
|
832
|
+
}
|
|
833
|
+
/** Record the user's table/card choice and persist it (non-blocking). */
|
|
834
|
+
setView(isTableView) {
|
|
835
|
+
this.setViewState(isTableView);
|
|
836
|
+
this.persistConfig();
|
|
837
|
+
}
|
|
838
|
+
// ===== Persistence (saved filters, column arrangement, last view) =====
|
|
839
|
+
/**
|
|
840
|
+
* Restore this page's saved config (via the host UTIL_SERVICE), then load data.
|
|
841
|
+
* Safe to call in place of loadData() from the page's ngOnInit. When the page
|
|
842
|
+
* has no `ui` (opt-out) or nothing is saved / the host doesn't support it, it
|
|
843
|
+
* just loads data.
|
|
844
|
+
*/
|
|
845
|
+
async restoreSavedConfig() {
|
|
846
|
+
const ui = this.config.ui;
|
|
847
|
+
if (ui) {
|
|
848
|
+
const option = await this.utilService.getUserPageConfig(ui);
|
|
849
|
+
if (option) {
|
|
850
|
+
this.savedOption = option;
|
|
851
|
+
if (option.VisibleColumns?.length) {
|
|
852
|
+
const restored = this.rebuildColumns(option.VisibleColumns);
|
|
853
|
+
if (restored.length) {
|
|
854
|
+
this.state.setVisibleColumns(restored);
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
if (option.SavedFilters?.length) {
|
|
858
|
+
const conditions = this.service.parseFilterPayload(option.SavedFilters, this.config.columns);
|
|
859
|
+
this.state.setFilters(conditions);
|
|
860
|
+
}
|
|
861
|
+
this.state.setIsTableView(!option.IsCardView);
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
await this.loadData();
|
|
865
|
+
}
|
|
866
|
+
/**
|
|
867
|
+
* Assemble the current page config and persist it through the host. Fire-and-
|
|
868
|
+
* forget: never awaited, so the triggering UI action is not blocked. No-op when
|
|
869
|
+
* the page opts out of persistence (`ui` unset).
|
|
870
|
+
*/
|
|
871
|
+
persistConfig() {
|
|
872
|
+
const ui = this.config.ui;
|
|
873
|
+
if (!ui)
|
|
874
|
+
return;
|
|
875
|
+
const option = {
|
|
876
|
+
...this.newOption(ui),
|
|
877
|
+
...(this.savedOption ?? {}),
|
|
878
|
+
UIRoute: ui,
|
|
879
|
+
IsCardView: !this.state.getIsTableViewValue(),
|
|
880
|
+
VisibleColumns: this.state.getVisibleColumnsValue().map((col) => col.id),
|
|
881
|
+
SavedFilters: this.service.buildFilterPayloadOnly(this.state.getFiltersValue(), this.config.columns),
|
|
882
|
+
DataState: this.savedOption ? ObjectState.Changed : ObjectState.New,
|
|
883
|
+
};
|
|
884
|
+
this.utilService.saveUserPageConfig(option).then((saved) => {
|
|
885
|
+
if (saved)
|
|
886
|
+
this.savedOption = saved;
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
/** Map ordered saved column ids back onto the config's ColumnDefinitions. */
|
|
890
|
+
rebuildColumns(ids) {
|
|
891
|
+
const byId = new Map(this.config.columns.map((col) => [col.id, col]));
|
|
892
|
+
return ids
|
|
893
|
+
.map((id) => byId.get(id))
|
|
894
|
+
.filter((col) => !!col);
|
|
895
|
+
}
|
|
896
|
+
/** A fresh, unsaved PageFilterTabOption for this page. */
|
|
897
|
+
newOption(ui) {
|
|
898
|
+
return {
|
|
899
|
+
id: '',
|
|
900
|
+
Id: '',
|
|
901
|
+
Code: '',
|
|
902
|
+
TenantId: '',
|
|
903
|
+
ServiceName: '',
|
|
904
|
+
CreatedAt: new Date(),
|
|
905
|
+
UpdatedAt: new Date(),
|
|
906
|
+
DataState: ObjectState.New,
|
|
907
|
+
UIRoute: ui,
|
|
908
|
+
IsCardView: false,
|
|
909
|
+
VisibleColumns: [],
|
|
910
|
+
SavedFilters: [],
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
// ===== Card Data =====
|
|
914
|
+
selectCard(cardData) {
|
|
915
|
+
this.state.setCurrentCardData(cardData);
|
|
916
|
+
}
|
|
917
|
+
/**
|
|
918
|
+
* Close the detail form.
|
|
919
|
+
*
|
|
920
|
+
* Goes through clearCardSelection rather than `selectCard(null)`: nulling the
|
|
921
|
+
* signal alone only empties the form's fields, because CardDataViewComponent
|
|
922
|
+
* holds its own `currentItem` that keeps the right-hand panel on screen. The
|
|
923
|
+
* cardSelectionCleared$ notification is what lets the component tear that down.
|
|
924
|
+
*/
|
|
925
|
+
closeForm() {
|
|
926
|
+
this.clearCardSelection();
|
|
927
|
+
}
|
|
928
|
+
/**
|
|
929
|
+
* Open the detail form for a record. Routed through selectCard so table-row
|
|
930
|
+
* edit and card click share one source of truth for the open record — the
|
|
931
|
+
* form template binds the current card, not a separate "selected item".
|
|
932
|
+
* Reuses the matching existing card when there is one.
|
|
933
|
+
*/
|
|
934
|
+
openForm(item) {
|
|
935
|
+
if (!item) {
|
|
936
|
+
this.selectCard(null);
|
|
937
|
+
return;
|
|
938
|
+
}
|
|
939
|
+
const key = this.itemKey(item);
|
|
940
|
+
const existing = this.state
|
|
941
|
+
.getCardData()()
|
|
942
|
+
.find((card) => card.data && this.itemKey(card.data) === key);
|
|
943
|
+
this.selectCard(existing ?? this.config.cardDataMapper(item));
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* Prepend a blank record and open it. Replaces the old approach of inferring
|
|
947
|
+
* "this must be the new one" from a falsy Name, which re-opened the form
|
|
948
|
+
* whenever a refetch happened to contain a blank-named record.
|
|
949
|
+
*/
|
|
950
|
+
createItem(blank) {
|
|
951
|
+
this.state.addItem(blank);
|
|
952
|
+
this.openForm(blank);
|
|
953
|
+
return blank;
|
|
954
|
+
}
|
|
955
|
+
/**
|
|
956
|
+
* Stable identity, matching BaseDataPageState.getItemKey. Kept here so the
|
|
957
|
+
* facade can match cards without widening the state's protected seam.
|
|
958
|
+
*/
|
|
959
|
+
itemKey(item) {
|
|
960
|
+
return item.Code || item.Id || item.id;
|
|
961
|
+
}
|
|
962
|
+
/**
|
|
963
|
+
* Drop the current card selection because the data it referred to is being
|
|
964
|
+
* replaced. Called by loadData(); deliberately not by loadMore(), which only
|
|
965
|
+
* appends and leaves an existing selection valid.
|
|
966
|
+
*/
|
|
967
|
+
clearCardSelection() {
|
|
968
|
+
this.state.setCurrentCardData(null);
|
|
969
|
+
this.cardSelectionCleared.next();
|
|
970
|
+
}
|
|
971
|
+
// ===== CRUD =====
|
|
972
|
+
/**
|
|
973
|
+
* Stamp the write state a record should be saved with.
|
|
974
|
+
*
|
|
975
|
+
* A record is new only when it has no Code yet (the backend always assigns
|
|
976
|
+
* Code on persisted records). Don't trust the loaded DataState here: records
|
|
977
|
+
* returned from the backend come through unchanged and report DataState
|
|
978
|
+
* 'New', which would force an insert (and thus duplicate) on every edit.
|
|
979
|
+
*/
|
|
980
|
+
withDataState(item) {
|
|
981
|
+
return {
|
|
982
|
+
...item,
|
|
983
|
+
DataState: item.Code ? ObjectState.Changed : ObjectState.New,
|
|
984
|
+
};
|
|
985
|
+
}
|
|
986
|
+
async saveItems(items) {
|
|
987
|
+
this.state.setUpdating(true);
|
|
988
|
+
const result = await this.service.saveItems(items.map((item) => this.withDataState(item)));
|
|
989
|
+
this.state.setUpdating(false);
|
|
990
|
+
if (result instanceof ErrorResponse) {
|
|
991
|
+
this.utilService.showError(result.ErrorMsg);
|
|
992
|
+
return false;
|
|
993
|
+
}
|
|
994
|
+
this.utilService.showSuccess('Record(s) saved successfully');
|
|
995
|
+
// A save that inserted assigns a Code the client never had, so the saved
|
|
996
|
+
// record cannot be matched against the blank one it replaces. Refetch in
|
|
997
|
+
// that case; otherwise reconcile in place.
|
|
998
|
+
//
|
|
999
|
+
// The save endpoints are typed `Promise<any>` across this library and not
|
|
1000
|
+
// all of them echo the saved rows back, so only reconcile when the response
|
|
1001
|
+
// actually is an array — and refetch when it is not, rather than leaving the
|
|
1002
|
+
// list showing pre-save values.
|
|
1003
|
+
const inserted = items.some((item) => !item.Code);
|
|
1004
|
+
if (inserted || !Array.isArray(result)) {
|
|
1005
|
+
await this.refresh();
|
|
1006
|
+
}
|
|
1007
|
+
else {
|
|
1008
|
+
result.forEach((savedItem) => this.state.upsertItem(savedItem));
|
|
1009
|
+
}
|
|
1010
|
+
return true;
|
|
1011
|
+
}
|
|
1012
|
+
async deleteItems(itemIds) {
|
|
1013
|
+
this.state.setUpdating(true);
|
|
1014
|
+
const result = await this.service.deleteItems(itemIds);
|
|
1015
|
+
this.state.setUpdating(false);
|
|
1016
|
+
if (result instanceof ErrorResponse) {
|
|
1017
|
+
this.utilService.showError(result.ErrorMsg);
|
|
1018
|
+
return false;
|
|
1019
|
+
}
|
|
1020
|
+
itemIds.forEach((id) => this.state.removeItem(id));
|
|
1021
|
+
this.utilService.showSuccess('Record(s) deleted successfully');
|
|
1022
|
+
return true;
|
|
1023
|
+
}
|
|
1024
|
+
// ===== Export =====
|
|
1025
|
+
async exportData() {
|
|
1026
|
+
const filters = this.state.getFiltersValue();
|
|
1027
|
+
const sorts = this.state.getSortsValue();
|
|
1028
|
+
const searchTerm = this.state.getSearchTermValue();
|
|
1029
|
+
const result = await this.service.exportData(filters, sorts, searchTerm, this.config.columns);
|
|
1030
|
+
if (result instanceof ErrorResponse) {
|
|
1031
|
+
return [];
|
|
1032
|
+
}
|
|
1033
|
+
return result;
|
|
1034
|
+
}
|
|
1035
|
+
// ===== Cleanup =====
|
|
1036
|
+
ngOnDestroy() {
|
|
1037
|
+
this.destroy$.next();
|
|
1038
|
+
this.destroy$.complete();
|
|
1039
|
+
this.cardSelectionCleared.complete();
|
|
1040
|
+
}
|
|
1041
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: BaseDataPageFacade, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
|
|
1042
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: BaseDataPageFacade });
|
|
1043
|
+
}
|
|
1044
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: BaseDataPageFacade, decorators: [{
|
|
1045
|
+
type: Injectable
|
|
1046
|
+
}], ctorParameters: () => [{ type: BaseDataPageState }, { type: BaseDataPageService }, { type: SearchHandlerService }, { type: i1.UtilService }, { type: undefined }] });
|
|
1047
|
+
|
|
1048
|
+
// Models and interfaces
|
|
1049
|
+
|
|
1050
|
+
/**
|
|
1051
|
+
* Generated bundle index. Do not edit.
|
|
1052
|
+
*/
|
|
1053
|
+
|
|
1054
|
+
export { BaseDataPageFacade, BaseDataPageService, BaseDataPageState, FilterHandlerService, SearchHandlerService, SortHandlerService, filterableColumns, findColumn, getPropertyName, inferPropertyType };
|
|
1055
|
+
//# sourceMappingURL=verben-workflow-ui-src-lib-base.mjs.map
|