@acorex/platform 20.6.0-next.9 → 20.6.0

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.
Files changed (62) hide show
  1. package/common/index.d.ts +9 -2
  2. package/core/index.d.ts +209 -55
  3. package/fesm2022/acorex-platform-common.mjs.map +1 -1
  4. package/fesm2022/acorex-platform-core.mjs +225 -24
  5. package/fesm2022/acorex-platform-core.mjs.map +1 -1
  6. package/fesm2022/acorex-platform-domain.mjs +49 -4
  7. package/fesm2022/acorex-platform-domain.mjs.map +1 -1
  8. package/fesm2022/acorex-platform-layout-builder.mjs +39 -118
  9. package/fesm2022/acorex-platform-layout-builder.mjs.map +1 -1
  10. package/fesm2022/acorex-platform-layout-components.mjs +1011 -257
  11. package/fesm2022/acorex-platform-layout-components.mjs.map +1 -1
  12. package/fesm2022/acorex-platform-layout-designer.mjs +2 -2
  13. package/fesm2022/acorex-platform-layout-designer.mjs.map +1 -1
  14. package/fesm2022/acorex-platform-layout-entity.mjs +9318 -4439
  15. package/fesm2022/acorex-platform-layout-entity.mjs.map +1 -1
  16. package/fesm2022/acorex-platform-layout-views.mjs +30 -24
  17. package/fesm2022/acorex-platform-layout-views.mjs.map +1 -1
  18. package/fesm2022/acorex-platform-layout-widget-core.mjs +4 -8
  19. package/fesm2022/acorex-platform-layout-widget-core.mjs.map +1 -1
  20. package/fesm2022/acorex-platform-layout-widgets-image-preview.popup-V31OpYah.mjs +30 -0
  21. package/fesm2022/acorex-platform-layout-widgets-image-preview.popup-V31OpYah.mjs.map +1 -0
  22. package/fesm2022/{acorex-platform-layout-widgets-tabular-data-edit-popup.component-C1l2KSDa.mjs → acorex-platform-layout-widgets-tabular-data-edit-popup.component-m8rHZP8L.mjs} +2 -2
  23. package/fesm2022/acorex-platform-layout-widgets-tabular-data-edit-popup.component-m8rHZP8L.mjs.map +1 -0
  24. package/fesm2022/{acorex-platform-layout-widgets-tabular-data-view-popup.component-D-31ej0C.mjs → acorex-platform-layout-widgets-tabular-data-view-popup.component-y8vjUiVs.mjs} +2 -2
  25. package/fesm2022/acorex-platform-layout-widgets-tabular-data-view-popup.component-y8vjUiVs.mjs.map +1 -0
  26. package/fesm2022/acorex-platform-layout-widgets.mjs +2081 -1238
  27. package/fesm2022/acorex-platform-layout-widgets.mjs.map +1 -1
  28. package/fesm2022/acorex-platform-runtime.mjs +79 -3
  29. package/fesm2022/acorex-platform-runtime.mjs.map +1 -1
  30. package/fesm2022/acorex-platform-themes-default-entity-master-create-view.component-mARj77Mr.mjs +136 -0
  31. package/fesm2022/acorex-platform-themes-default-entity-master-create-view.component-mARj77Mr.mjs.map +1 -0
  32. package/fesm2022/acorex-platform-themes-default-entity-master-list-view.component-Cym8pq0v.mjs +1543 -0
  33. package/fesm2022/acorex-platform-themes-default-entity-master-list-view.component-Cym8pq0v.mjs.map +1 -0
  34. package/fesm2022/acorex-platform-themes-default.mjs +124 -21
  35. package/fesm2022/acorex-platform-themes-default.mjs.map +1 -1
  36. package/fesm2022/acorex-platform-themes-shared-icon-chooser-column.component-C0EpfU2k.mjs +55 -0
  37. package/fesm2022/acorex-platform-themes-shared-icon-chooser-column.component-C0EpfU2k.mjs.map +1 -0
  38. package/fesm2022/acorex-platform-themes-shared.mjs +15 -110
  39. package/fesm2022/acorex-platform-themes-shared.mjs.map +1 -1
  40. package/fesm2022/acorex-platform-workflow.mjs +658 -45
  41. package/fesm2022/acorex-platform-workflow.mjs.map +1 -1
  42. package/layout/builder/index.d.ts +6 -33
  43. package/layout/components/index.d.ts +301 -60
  44. package/layout/designer/index.d.ts +1 -1
  45. package/layout/entity/index.d.ts +650 -86
  46. package/layout/views/index.d.ts +5 -58
  47. package/layout/widget-core/index.d.ts +24 -26
  48. package/layout/widgets/README.md +0 -1
  49. package/layout/widgets/index.d.ts +134 -84
  50. package/package.json +9 -9
  51. package/runtime/index.d.ts +36 -8
  52. package/themes/default/index.d.ts +29 -73
  53. package/themes/shared/index.d.ts +1 -39
  54. package/workflow/index.d.ts +401 -90
  55. package/fesm2022/acorex-platform-layout-entity-create-entity.command-DGeylNSY.mjs +0 -52
  56. package/fesm2022/acorex-platform-layout-entity-create-entity.command-DGeylNSY.mjs.map +0 -1
  57. package/fesm2022/acorex-platform-layout-widgets-tabular-data-edit-popup.component-C1l2KSDa.mjs.map +0 -1
  58. package/fesm2022/acorex-platform-layout-widgets-tabular-data-view-popup.component-D-31ej0C.mjs.map +0 -1
  59. package/fesm2022/acorex-platform-themes-default-entity-master-create-view.component-WbPPqDON.mjs +0 -115
  60. package/fesm2022/acorex-platform-themes-default-entity-master-create-view.component-WbPPqDON.mjs.map +0 -1
  61. package/fesm2022/acorex-platform-themes-default-entity-master-list-view.component-CD7rJIMh.mjs +0 -803
  62. package/fesm2022/acorex-platform-themes-default-entity-master-list-view.component-CD7rJIMh.mjs.map +0 -1
@@ -0,0 +1,1543 @@
1
+ import { AXActionSheetModule } from '@acorex/components/action-sheet';
2
+ import * as i7 from '@acorex/components/data-table';
3
+ import { AXDataTableModule } from '@acorex/components/data-table';
4
+ import { AXDrawerModule } from '@acorex/components/drawer';
5
+ import * as i1$1 from '@acorex/core/platform';
6
+ import * as i0 from '@angular/core';
7
+ import { inject, input, viewChild, signal, computed, afterNextRender, ViewEncapsulation, Component, effect, Input, ChangeDetectionStrategy } from '@angular/core';
8
+ import { Router, ActivatedRoute, RouterModule } from '@angular/router';
9
+ import { AXBadgeModule } from '@acorex/components/badge';
10
+ import { AXBreadcrumbsModule } from '@acorex/components/breadcrumbs';
11
+ import * as i3 from '@acorex/components/button';
12
+ import { AXButtonModule } from '@acorex/components/button';
13
+ import * as i2 from '@acorex/components/decorators';
14
+ import { AXDecoratorModule } from '@acorex/components/decorators';
15
+ import { AXDialogModule } from '@acorex/components/dialog';
16
+ import * as i5 from '@acorex/components/dropdown';
17
+ import { AXDropdownModule } from '@acorex/components/dropdown';
18
+ import { AXFormModule } from '@acorex/components/form';
19
+ import { AXLoadingModule } from '@acorex/components/loading';
20
+ import * as i3$1 from '@acorex/components/popover';
21
+ import { AXPopoverModule } from '@acorex/components/popover';
22
+ import * as i6 from '@acorex/components/search-box';
23
+ import { AXSearchBoxModule } from '@acorex/components/search-box';
24
+ import { AXTabsModule } from '@acorex/components/tabs';
25
+ import { AXTooltipModule } from '@acorex/components/tooltip';
26
+ import * as i10 from '@acorex/core/translation';
27
+ import { AXTranslationService, AXTranslationModule, translateSync } from '@acorex/core/translation';
28
+ import { AXPAuthModule } from '@acorex/platform/auth';
29
+ import { AXPThemeLayoutBlockComponent, AXPThemeLayoutHeaderComponent, AXPThemeLayoutToolbarComponent, AXPStateMessageComponent, AXPQueryFiltersComponent, AXPQuerySortsComponent, AXPQueryViewsComponent, AXPQueryColumnsComponent, AXPThemeLayoutStartSideComponent } from '@acorex/platform/layout/components';
30
+ import * as i7$1 from '@acorex/platform/layout/widget-core';
31
+ import { AXPWidgetCoreModule } from '@acorex/platform/layout/widget-core';
32
+ import { AXPWidgetsModule } from '@acorex/platform/layout/widgets';
33
+ import { DragDropModule } from '@angular/cdk/drag-drop';
34
+ import * as i1 from '@angular/common';
35
+ import { CommonModule } from '@angular/common';
36
+ import { FormsModule } from '@angular/forms';
37
+ import { AXDropdownButtonModule } from '@acorex/components/dropdown-button';
38
+ import { AXPPageLayoutBaseComponent, AXPPageLayoutComponent, AXPPageLayoutBase } from '@acorex/platform/layout/views';
39
+ import { AXPLayoutThemeService } from '@acorex/platform/themes/shared';
40
+ import * as i2$1 from '@acorex/components/skeleton';
41
+ import { AXSkeletonModule } from '@acorex/components/skeleton';
42
+ import { AXTreeViewModule, AXTreeViewComponent } from '@acorex/components/tree-view';
43
+ import { AXPRefreshEvent, AXPSettingService, AXPCommonSettings } from '@acorex/platform/common';
44
+ import { AXHighlightService, AXPDeviceService } from '@acorex/platform/core';
45
+ import { AXPEntityResolver, AXPCategoryTreeService, AXPEntityListViewColumnViewModel } from '@acorex/platform/layout/entity';
46
+ import { AXPWorkflowService, ofType } from '@acorex/platform/workflow';
47
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
48
+ import { isEqual } from 'lodash-es';
49
+
50
+ //#region ---- Constants ----
51
+ const ROOT_NODE_ID = 'all';
52
+ const LOADING_DELAY_MS = 300;
53
+ const DEFAULT_TEXT_FIELD = 'title';
54
+ const DEFAULT_VALUE_FIELD = 'id';
55
+ //#endregion
56
+ class AXPEntityCategoryComponent {
57
+ //#endregion
58
+ //#region ---- Constructor & Lifecycle ----
59
+ constructor() {
60
+ //#region ---- Services & Dependencies ----
61
+ this.entityResolver = inject(AXPEntityResolver);
62
+ this.translate = inject(AXTranslationService);
63
+ this.workflow = inject(AXPWorkflowService);
64
+ this.categoryTreeService = inject(AXPCategoryTreeService);
65
+ this.highlightService = inject(AXHighlightService);
66
+ //#endregion
67
+ //#region ---- Component Inputs & View Queries ----
68
+ this.vm = input.required(...(ngDevMode ? [{ debugName: "vm" }] : []));
69
+ this.tree = viewChild('tree', ...(ngDevMode ? [{ debugName: "tree" }] : []));
70
+ this.searchValue = input('', ...(ngDevMode ? [{ debugName: "searchValue" }] : []));
71
+ // Tree view inputs with defaults
72
+ this.selectMode = input('single', ...(ngDevMode ? [{ debugName: "selectMode" }] : []));
73
+ this.selectionBehavior = input('intermediate', ...(ngDevMode ? [{ debugName: "selectionBehavior" }] : []));
74
+ this.dragArea = input('handler', ...(ngDevMode ? [{ debugName: "dragArea" }] : []));
75
+ this.dragBehavior = input('none', ...(ngDevMode ? [{ debugName: "dragBehavior" }] : []));
76
+ this.showIcons = input(true, ...(ngDevMode ? [{ debugName: "showIcons" }] : []));
77
+ this.showChildrenBadge = input(false, ...(ngDevMode ? [{ debugName: "showChildrenBadge" }] : []));
78
+ this.expandedIcon = input('fa-solid fa-chevron-down', ...(ngDevMode ? [{ debugName: "expandedIcon" }] : []));
79
+ this.collapsedIcon = input('fa-solid fa-chevron-right', ...(ngDevMode ? [{ debugName: "collapsedIcon" }] : []));
80
+ this.indentSize = input(16, ...(ngDevMode ? [{ debugName: "indentSize" }] : []));
81
+ this.look = input('default', ...(ngDevMode ? [{ debugName: "look" }] : []));
82
+ this.searchWithChildren = input(true, ...(ngDevMode ? [{ debugName: "searchWithChildren" }] : [])); // Include children of search results
83
+ //#endregion
84
+ //#region ---- Component State ----
85
+ this.isLoading = signal(true, ...(ngDevMode ? [{ debugName: "isLoading" }] : []));
86
+ this.isSearching = signal(false, ...(ngDevMode ? [{ debugName: "isSearching" }] : []));
87
+ this.searchResultCount = signal(0, ...(ngDevMode ? [{ debugName: "searchResultCount" }] : []));
88
+ this.currentSearchValue = signal('', ...(ngDevMode ? [{ debugName: "currentSearchValue" }] : []));
89
+ this.resultsFoundText = signal('', ...(ngDevMode ? [{ debugName: "resultsFoundText" }] : []));
90
+ //#endregion
91
+ //#region ---- Private Properties ----
92
+ this.loadingTimeoutId = null;
93
+ this.treeData = null;
94
+ this.treeConfig = null;
95
+ this.matchingNodeIds = new Set();
96
+ this.relevantNodeIds = new Set(); // For search filtering
97
+ this.nodeDataCache = new Map(); // Cache parent data from search results
98
+ this.expandedNodesBeforeSearch = [];
99
+ this.nodesExpandedDuringSearch = [];
100
+ this.currentSearchTerm = null;
101
+ //#endregion
102
+ //#region ---- Computed Properties ----
103
+ this.textField = computed(() => this.vm().entityDef.category?.textField || DEFAULT_TEXT_FIELD, ...(ngDevMode ? [{ debugName: "textField" }] : []));
104
+ this.valueField = computed(() => this.vm().entityDef.category?.valueField || DEFAULT_VALUE_FIELD, ...(ngDevMode ? [{ debugName: "valueField" }] : []));
105
+ /**
106
+ * Computed property to check if we should show the "no search results" empty state.
107
+ * Returns true when search is active, not searching, and no results found.
108
+ */
109
+ this.showNoSearchResults = computed(() => {
110
+ const searchValue = this.currentSearchValue().trim();
111
+ const isSearching = this.isSearching();
112
+ const resultCount = this.searchResultCount();
113
+ return searchValue.length > 0 && !isSearching && resultCount === 0;
114
+ }, ...(ngDevMode ? [{ debugName: "showNoSearchResults" }] : []));
115
+ this.categoryEntityKey = computed(() => {
116
+ const key = this.vm().entityDef.category?.entity;
117
+ if (!key) {
118
+ throw new Error('Category entity is not configured');
119
+ }
120
+ return key;
121
+ }, ...(ngDevMode ? [{ debugName: "categoryEntityKey" }] : []));
122
+ // protected toggleExpand(e: AXTreeViewNodeDoubleClickEvent) {
123
+ // (e.component as AXTreeViewComponent).toggleNodeExpansion(String(e.node[this.valueField()] ?? ''));
124
+ // }
125
+ //#endregion
126
+ //#region ---- Tree Data Source ----
127
+ /**
128
+ * Datasource callback for tree-view component.
129
+ * Provides lazy loading support for tree nodes.
130
+ */
131
+ this.datasource = async (parentId) => {
132
+ console.log('datasource', parentId);
133
+ if (!this.isTreeInitialized()) {
134
+ return [];
135
+ }
136
+ // Load root nodes if no parent ID provided
137
+ if (!parentId) {
138
+ return await this.loadRootNodes();
139
+ }
140
+ // Load children for the specified parent
141
+ return await this.loadChildNodes(parentId);
142
+ };
143
+ afterNextRender(() => {
144
+ this.initializeTree();
145
+ });
146
+ this.workflow.events$
147
+ .pipe(ofType(AXPRefreshEvent))
148
+ .pipe(takeUntilDestroyed())
149
+ .subscribe((event) => {
150
+ this.tree()?.reloadData();
151
+ // this.tree()?.refresh();
152
+ });
153
+ }
154
+ //#endregion
155
+ //#region ---- Public Methods ----
156
+ /**
157
+ * Handles category search input changes - Uses server-side search for efficiency and reliability
158
+ */
159
+ async handleCategorySearchChange(event) {
160
+ if (!this.isTreeInitialized()) {
161
+ return;
162
+ }
163
+ const searchTerm = (event.value ?? '').trim().toLowerCase();
164
+ const previousSearchTerm = this.currentSearchValue();
165
+ // If search is cleared, reset tree
166
+ if (!searchTerm) {
167
+ if (previousSearchTerm || this.matchingNodeIds.size > 0) {
168
+ this.currentSearchValue.set('');
169
+ this.currentSearchTerm = null;
170
+ await this.resetSearch();
171
+ }
172
+ return;
173
+ }
174
+ // For non-empty search, only process user interactions
175
+ if (!event.isUserInteraction) {
176
+ return;
177
+ }
178
+ // Prevent concurrent searches
179
+ if (this.isSearching() && this.currentSearchTerm !== null) {
180
+ if (this.currentSearchTerm === searchTerm) {
181
+ return;
182
+ }
183
+ }
184
+ this.currentSearchValue.set(event.value ?? '');
185
+ this.currentSearchTerm = searchTerm;
186
+ const treeComponent = this.tree();
187
+ if (!treeComponent) {
188
+ return;
189
+ }
190
+ // Store expanded nodes before starting a new search (only on first search)
191
+ if (!previousSearchTerm && this.expandedNodesBeforeSearch.length === 0) {
192
+ const expandedNodes = treeComponent.getExpandedNodes();
193
+ this.expandedNodesBeforeSearch = expandedNodes
194
+ .map((node) => String(node['id'] ?? ''))
195
+ .filter((id) => id && id !== ROOT_NODE_ID);
196
+ }
197
+ // Collapse nodes from previous search before starting new search
198
+ if (previousSearchTerm && this.nodesExpandedDuringSearch.length > 0) {
199
+ const nodesToCollapse = [...this.nodesExpandedDuringSearch].reverse();
200
+ this.nodesExpandedDuringSearch = [];
201
+ for (const nodeId of nodesToCollapse) {
202
+ // Only collapse if it wasn't originally expanded before search
203
+ if (!this.expandedNodesBeforeSearch.includes(nodeId)) {
204
+ try {
205
+ treeComponent.collapseNode(nodeId);
206
+ }
207
+ catch {
208
+ // Node might not exist anymore, ignore
209
+ }
210
+ }
211
+ }
212
+ }
213
+ this.isSearching.set(true);
214
+ try {
215
+ // Step 1: Use server-side search to get matching items
216
+ const searchResults = await this.categoryTreeService.searchCategories(searchTerm, this.treeData, this.treeConfig);
217
+ // Check if search term changed during the API call
218
+ if (this.currentSearchTerm !== searchTerm) {
219
+ return;
220
+ }
221
+ if (!searchResults || searchResults.length === 0) {
222
+ this.matchingNodeIds.clear();
223
+ this.relevantNodeIds.clear();
224
+ this.searchResultCount.set(0);
225
+ await this.updateTranslatedMessages(0);
226
+ // Clear highlighting and reload tree to show all nodes
227
+ this.highlightService.clear();
228
+ await treeComponent.reloadData();
229
+ return;
230
+ }
231
+ // Store matching node IDs from search results
232
+ this.matchingNodeIds.clear();
233
+ const valueField = this.valueField();
234
+ searchResults.forEach((item) => {
235
+ const nodeId = String(item[valueField] ?? '');
236
+ if (nodeId) {
237
+ this.matchingNodeIds.add(nodeId);
238
+ }
239
+ });
240
+ const resultCount = searchResults.length;
241
+ this.searchResultCount.set(resultCount);
242
+ // Update translated messages
243
+ await this.updateTranslatedMessages(resultCount);
244
+ // Step 2: Collect parent IDs (builds relevantNodeIds for filtering)
245
+ const parentsToExpand = await this.collectParentIds(searchResults);
246
+ // Step 2.5: Collect children IDs if searchWithChildren is enabled
247
+ if (this.searchWithChildren()) {
248
+ await this.collectChildrenIds(searchResults);
249
+ }
250
+ // Step 3: Reload tree to apply filtering
251
+ await treeComponent.reloadData();
252
+ // Step 4: Expand root node
253
+ if (!treeComponent.isNodeExpanded(ROOT_NODE_ID)) {
254
+ try {
255
+ await treeComponent.expandNode(ROOT_NODE_ID);
256
+ this.nodesExpandedDuringSearch.push(ROOT_NODE_ID);
257
+ }
258
+ catch {
259
+ // Root might not exist
260
+ }
261
+ }
262
+ // Step 4: Expand all parent nodes in order (from root to leaves)
263
+ // Sort parents by their depth to expand in correct order
264
+ const sortedParents = await this.sortParentsByDepth(Array.from(parentsToExpand));
265
+ for (const parentId of sortedParents) {
266
+ // Only expand if not already expanded
267
+ if (!treeComponent.isNodeExpanded(parentId)) {
268
+ try {
269
+ await treeComponent.expandNode(parentId);
270
+ this.nodesExpandedDuringSearch.push(parentId);
271
+ // Small delay to prevent overwhelming the tree component
272
+ await new Promise((resolve) => setTimeout(resolve, 10));
273
+ }
274
+ catch {
275
+ // Node might not exist, ignore
276
+ }
277
+ }
278
+ }
279
+ // Step 5: Apply highlighting after tree is rendered
280
+ // Use setTimeout to ensure DOM is updated after tree reload
281
+ setTimeout(() => {
282
+ if (this.currentSearchValue().trim()) {
283
+ this.highlightService.highlight('ax-tree-view .ax-truncate', this.currentSearchValue().trim());
284
+ }
285
+ }, 100);
286
+ }
287
+ catch (error) {
288
+ console.error('Error searching categories:', error);
289
+ this.matchingNodeIds.clear();
290
+ this.relevantNodeIds.clear();
291
+ this.searchResultCount.set(0);
292
+ this.highlightService.clear();
293
+ // Reload tree to clear any filters
294
+ const treeComponent = this.tree();
295
+ if (treeComponent) {
296
+ await treeComponent.reloadData();
297
+ }
298
+ }
299
+ finally {
300
+ if (this.currentSearchTerm === searchTerm) {
301
+ this.currentSearchTerm = null;
302
+ }
303
+ this.isSearching.set(false);
304
+ }
305
+ }
306
+ /**
307
+ * Collects all parent IDs for the given search results
308
+ * Handles both nested 'parent' object and 'parentId' field in search results
309
+ * Recursively fetches parent nodes to build the full parent chain
310
+ */
311
+ async collectParentIds(items) {
312
+ const parentsToExpand = new Set();
313
+ const valueField = this.valueField();
314
+ const parentKey = this.treeData?.categoryEntityDef?.parentKey || 'parentId';
315
+ // Build relevantNodeIds = matching nodes + all parents
316
+ this.relevantNodeIds.clear();
317
+ this.matchingNodeIds.forEach((id) => this.relevantNodeIds.add(id));
318
+ // Recursively extract all parent IDs
319
+ const extractParentIds = async (item) => {
320
+ // First, try to get parent from nested 'parent' object (if available)
321
+ const parent = item['parent'];
322
+ if (parent) {
323
+ const parentId = String(parent[valueField] ?? parent['id'] ?? '');
324
+ if (parentId && parentId !== ROOT_NODE_ID) {
325
+ parentsToExpand.add(parentId);
326
+ this.relevantNodeIds.add(parentId); // Add to filter set
327
+ this.nodeDataCache.set(parentId, parent);
328
+ await extractParentIds(parent);
329
+ }
330
+ }
331
+ else {
332
+ // Fallback: use parentId field and fetch parent from server
333
+ // Try both parentKey from entity definition and common 'parentId' field
334
+ const parentIdValue = item[parentKey] ?? item['parentId'];
335
+ if (parentIdValue) {
336
+ const parentId = String(parentIdValue);
337
+ if (parentId && parentId !== ROOT_NODE_ID) {
338
+ // Add to sets first
339
+ parentsToExpand.add(parentId);
340
+ this.relevantNodeIds.add(parentId);
341
+ // Fetch parent from server if not already cached
342
+ if (!this.nodeDataCache.has(parentId)) {
343
+ const parentItem = await this.fetchItemById(parentId);
344
+ if (parentItem) {
345
+ this.nodeDataCache.set(parentId, parentItem);
346
+ // Recursively fetch parent's parent
347
+ await extractParentIds(parentItem);
348
+ }
349
+ }
350
+ else {
351
+ // Parent already in cache, recursively process it
352
+ const cachedParent = this.nodeDataCache.get(parentId);
353
+ if (cachedParent) {
354
+ await extractParentIds(cachedParent);
355
+ }
356
+ }
357
+ }
358
+ }
359
+ }
360
+ };
361
+ // Process all items
362
+ for (const item of items) {
363
+ await extractParentIds(item);
364
+ }
365
+ return parentsToExpand;
366
+ }
367
+ /**
368
+ * Collects children IDs for matching search results recursively
369
+ * Adds all descendants (children, grandchildren, etc.) to relevantNodeIds so they appear in the filtered tree
370
+ */
371
+ async collectChildrenIds(items) {
372
+ if (!this.treeData?.categoryEntityQueryFunc || !this.treeConfig) {
373
+ return;
374
+ }
375
+ const valueField = this.valueField();
376
+ const parentKey = this.treeData.categoryEntityDef?.parentKey;
377
+ if (!parentKey) {
378
+ return;
379
+ }
380
+ // For each matching node, recursively fetch all its descendants
381
+ for (const item of items) {
382
+ const nodeId = String(item[valueField] ?? '');
383
+ if (!nodeId || nodeId === ROOT_NODE_ID) {
384
+ continue;
385
+ }
386
+ await this.collectChildrenRecursively(nodeId, valueField, parentKey);
387
+ }
388
+ }
389
+ /**
390
+ * Recursively collects all descendant IDs for a given node
391
+ */
392
+ async collectChildrenRecursively(nodeId, valueField, parentKey) {
393
+ if (!this.treeData?.categoryEntityQueryFunc) {
394
+ return;
395
+ }
396
+ try {
397
+ // Fetch children for this node
398
+ const event = {
399
+ ...this.treeData.basicQueryEvent,
400
+ filter: {
401
+ field: parentKey,
402
+ value: nodeId,
403
+ operator: { type: 'equal' },
404
+ },
405
+ };
406
+ const res = await this.treeData.categoryEntityQueryFunc(event);
407
+ if (res?.items && res.items.length > 0) {
408
+ // Add children IDs to relevantNodeIds so they appear in filtered tree
409
+ for (const child of res.items) {
410
+ const childId = String(child[valueField] ?? '');
411
+ if (childId && childId !== ROOT_NODE_ID) {
412
+ this.relevantNodeIds.add(childId);
413
+ // Cache child data
414
+ this.nodeDataCache.set(childId, child);
415
+ // Recursively fetch children of this child
416
+ await this.collectChildrenRecursively(childId, valueField, parentKey);
417
+ }
418
+ }
419
+ }
420
+ }
421
+ catch (error) {
422
+ console.error(`Error fetching children for node ${nodeId}:`, error);
423
+ }
424
+ }
425
+ /**
426
+ * Fetches a single item by ID from the server
427
+ */
428
+ async fetchItemById(id) {
429
+ if (!this.treeData?.categoryEntityQueryFunc) {
430
+ return null;
431
+ }
432
+ try {
433
+ const valueField = this.valueField();
434
+ const event = {
435
+ ...this.treeData.basicQueryEvent,
436
+ filter: {
437
+ field: valueField,
438
+ value: id,
439
+ operator: { type: 'equal' },
440
+ },
441
+ };
442
+ const res = await this.treeData.categoryEntityQueryFunc(event);
443
+ return res?.items?.[0] ?? null;
444
+ }
445
+ catch (error) {
446
+ console.error('Error fetching item by ID:', error);
447
+ return null;
448
+ }
449
+ }
450
+ /**
451
+ * Sorts parent IDs by their depth (root first, leaves last)
452
+ * Uses cached data from collectParentIds
453
+ */
454
+ async sortParentsByDepth(parentIds) {
455
+ const parentKey = this.treeData?.categoryEntityDef?.parentKey;
456
+ if (!parentKey || parentIds.length === 0) {
457
+ return parentIds;
458
+ }
459
+ // Build depth map using cached data
460
+ const depthMap = new Map();
461
+ for (const parentId of parentIds) {
462
+ if (depthMap.has(parentId)) {
463
+ continue;
464
+ }
465
+ let depth = 0;
466
+ let currentId = parentId;
467
+ const visited = new Set();
468
+ while (currentId && currentId !== ROOT_NODE_ID && !visited.has(currentId)) {
469
+ visited.add(currentId);
470
+ depth++;
471
+ // Use nodeDataCache which was populated by collectParentIds
472
+ const item = this.nodeDataCache.get(currentId);
473
+ if (item) {
474
+ currentId = item[parentKey] ? String(item[parentKey]) : null;
475
+ }
476
+ else {
477
+ break;
478
+ }
479
+ }
480
+ depthMap.set(parentId, depth);
481
+ }
482
+ // Sort by depth (lower depth = closer to root = expand first)
483
+ return parentIds.sort((a, b) => {
484
+ const depthA = depthMap.get(a) ?? 0;
485
+ const depthB = depthMap.get(b) ?? 0;
486
+ return depthA - depthB;
487
+ });
488
+ }
489
+ /**
490
+ * Updates translated messages for search results
491
+ */
492
+ async updateTranslatedMessages(resultCount) {
493
+ if (resultCount > 0) {
494
+ const key = resultCount === 1
495
+ ? '@general:terms.interface.category.search.results-found.singular'
496
+ : '@general:terms.interface.category.search.results-found.plural';
497
+ const text = await this.translate.translateAsync(key, { params: { count: resultCount } });
498
+ this.resultsFoundText.set(text);
499
+ }
500
+ else {
501
+ this.resultsFoundText.set('');
502
+ }
503
+ }
504
+ /**
505
+ * Resets search state and restores tree to original expanded state
506
+ */
507
+ async resetSearch() {
508
+ this.searchResultCount.set(0);
509
+ this.resultsFoundText.set('');
510
+ this.currentSearchTerm = null;
511
+ this.isSearching.set(false);
512
+ this.matchingNodeIds.clear();
513
+ this.relevantNodeIds.clear();
514
+ this.nodeDataCache.clear();
515
+ // Clear highlighting
516
+ this.highlightService.clear();
517
+ const treeComponent = this.tree();
518
+ if (!treeComponent) {
519
+ this.expandedNodesBeforeSearch = [];
520
+ this.nodesExpandedDuringSearch = [];
521
+ return;
522
+ }
523
+ // Reload tree to show all nodes (no filtering)
524
+ await treeComponent.reloadData();
525
+ // Collapse nodes that were expanded during search (in reverse order - leaves first)
526
+ const nodesToCollapse = [...this.nodesExpandedDuringSearch].reverse();
527
+ this.nodesExpandedDuringSearch = [];
528
+ for (const nodeId of nodesToCollapse) {
529
+ // Only collapse if it wasn't originally expanded before search
530
+ if (!this.expandedNodesBeforeSearch.includes(nodeId)) {
531
+ try {
532
+ treeComponent.collapseNode(nodeId);
533
+ }
534
+ catch {
535
+ // Node might not exist anymore, ignore
536
+ }
537
+ }
538
+ }
539
+ // Clear the stored expanded nodes
540
+ this.expandedNodesBeforeSearch = [];
541
+ }
542
+ /**
543
+ * Checks if a node matches the current search term
544
+ */
545
+ isMatchingNode(nodeId) {
546
+ return this.matchingNodeIds.has(nodeId);
547
+ }
548
+ /**
549
+ * Handles node click events to apply category filters
550
+ */
551
+ handleNodeClick(node) {
552
+ const nodeData = this.extractNodeData(node);
553
+ const applyConditions = this.vm().entityDef.category?.applyConditions || [];
554
+ const categoryFilters = this.buildCategoryFilters(nodeData, applyConditions);
555
+ const viewFilters = this.buildViewFilters();
556
+ this.vm().dataSource.filter({
557
+ filters: [...viewFilters, ...categoryFilters],
558
+ logic: 'and',
559
+ });
560
+ this.vm().dataSource.refresh();
561
+ }
562
+ /**
563
+ * Handles node toggle events (expansion/collapse)
564
+ */
565
+ async onNodeToggle(_event) {
566
+ // Tree component handles lazy loading via datasource callback
567
+ }
568
+ //#endregion
569
+ //#region ---- CRUD Operations ----
570
+ /**
571
+ * Creates a new root category node
572
+ */
573
+ async handleCreateRootClick(event) {
574
+ this.preventDefaultAndStopPropagation(event);
575
+ try {
576
+ const context = await this.executeCreateWorkflow(undefined);
577
+ await this.handleCreateResult(context, undefined);
578
+ }
579
+ catch (error) {
580
+ console.error('Error creating root category:', error);
581
+ }
582
+ }
583
+ /**
584
+ * Creates a new child category under the given parent node
585
+ */
586
+ async handleCreateChildClick(node, event) {
587
+ this.preventDefaultAndStopPropagation(event);
588
+ try {
589
+ const parentId = this.extractNodeId(node);
590
+ const context = await this.executeCreateWorkflow(parentId);
591
+ await this.handleCreateResult(context, parentId);
592
+ }
593
+ catch (error) {
594
+ console.error('Error creating child category:', error);
595
+ }
596
+ }
597
+ /**
598
+ * Updates an existing category node
599
+ */
600
+ async handleEditNodeClick(node, event) {
601
+ this.preventDefaultAndStopPropagation(event);
602
+ try {
603
+ const nodeData = this.extractNodeData(node);
604
+ const context = await this.executeModifyWorkflow(nodeData);
605
+ await this.handleModifyResult(context, node);
606
+ }
607
+ catch (error) {
608
+ console.error('Error editing category:', error);
609
+ }
610
+ }
611
+ /**
612
+ * Deletes a category node
613
+ */
614
+ async handleDeleteNodeClick(node, event) {
615
+ this.preventDefaultAndStopPropagation(event);
616
+ try {
617
+ const nodeData = this.extractNodeData(node);
618
+ const context = await this.executeDeleteWorkflow(nodeData);
619
+ await this.handleDeleteResult(context, node);
620
+ }
621
+ catch (error) {
622
+ console.error('Error deleting category:', error);
623
+ }
624
+ }
625
+ //#endregion
626
+ //#region ---- Private Tree Management Methods ----
627
+ /**
628
+ * Initializes the category tree data structure
629
+ */
630
+ async initializeTree() {
631
+ this.setLoadingWithDelay(true);
632
+ try {
633
+ const entityKey = this.categoryEntityKey();
634
+ this.treeConfig = {
635
+ entityKey,
636
+ textField: this.textField(),
637
+ valueField: this.valueField(),
638
+ };
639
+ this.treeData = await this.categoryTreeService.initializeCategoryTree(this.treeConfig);
640
+ if (!this.treeData) {
641
+ this.clearLoadingState();
642
+ return;
643
+ }
644
+ // Set parent key from entity definition
645
+ if (this.treeData.categoryEntityDef?.parentKey) {
646
+ this.treeConfig.parentKey = this.treeData.categoryEntityDef.parentKey;
647
+ }
648
+ }
649
+ catch (error) {
650
+ console.error('Error loading categories:', error);
651
+ }
652
+ finally {
653
+ this.clearLoadingState();
654
+ }
655
+ }
656
+ /**
657
+ * Loads root nodes for the tree
658
+ */
659
+ async loadRootNodes() {
660
+ if (!this.isTreeInitialized()) {
661
+ return [];
662
+ }
663
+ // Load root categories
664
+ const items = await this.categoryTreeService.loadRootCategories(this.treeData, this.treeConfig);
665
+ if (!items) {
666
+ return [];
667
+ }
668
+ const rootNode = await this.categoryTreeService.createRootNode(items, this.treeConfig);
669
+ // Filter root's children when search is active
670
+ if (this.relevantNodeIds.size > 0 && rootNode['children']) {
671
+ rootNode['children'] = rootNode['children'].filter((child) => {
672
+ const childId = String(child['id'] ?? '');
673
+ return this.relevantNodeIds.has(childId);
674
+ });
675
+ rootNode['childrenCount'] = rootNode['children'].length;
676
+ }
677
+ return [rootNode];
678
+ }
679
+ /**
680
+ * Loads child nodes for a given parent ID
681
+ */
682
+ async loadChildNodes(parentId) {
683
+ if (!this.isTreeInitialized()) {
684
+ return [];
685
+ }
686
+ // Create minimal node object - loadChildren only needs node.id
687
+ const targetNode = {
688
+ id: parentId,
689
+ };
690
+ let children = await this.categoryTreeService.loadChildren(targetNode, this.treeData, this.treeConfig);
691
+ // Filter children when search is active
692
+ if (this.relevantNodeIds.size > 0) {
693
+ children = children.filter((child) => {
694
+ const childId = String(child['id'] ?? '');
695
+ return this.relevantNodeIds.has(childId);
696
+ });
697
+ }
698
+ return children;
699
+ }
700
+ /**
701
+ * Refreshes the tree view component
702
+ */
703
+ refreshTree() {
704
+ const treeComponent = this.tree();
705
+ if (treeComponent) {
706
+ treeComponent.refresh();
707
+ }
708
+ }
709
+ /**
710
+ * Refreshes tree after CRUD operations
711
+ */
712
+ async refreshAfterChange(parentId) {
713
+ this.refreshTree();
714
+ }
715
+ /**
716
+ * Adds a new node to the tree after create operation
717
+ */
718
+ async addNodeToTree(entityData, parentId) {
719
+ if (!this.isTreeInitialized()) {
720
+ return;
721
+ }
722
+ const treeComponent = this.tree();
723
+ if (!treeComponent) {
724
+ return;
725
+ }
726
+ const newNode = this.categoryTreeService.convertToTreeNode(entityData, this.treeConfig);
727
+ if (parentId) {
728
+ await this.addChildNode(treeComponent, parentId, newNode);
729
+ }
730
+ else {
731
+ await this.addRootNode(treeComponent, newNode);
732
+ }
733
+ }
734
+ /**
735
+ * Adds a child node to a parent node
736
+ */
737
+ async addChildNode(treeComponent, parentId, newNode) {
738
+ const parentNode = treeComponent.findNode(parentId);
739
+ if (!parentNode) {
740
+ await this.refreshAfterChange(parentId);
741
+ return;
742
+ }
743
+ if (!treeComponent.isNodeExpanded(parentId)) {
744
+ await treeComponent.expandNode(parentId);
745
+ }
746
+ treeComponent.addChild(parentId, newNode);
747
+ }
748
+ /**
749
+ * Adds a root node to the tree
750
+ */
751
+ async addRootNode(treeComponent, newNode) {
752
+ const rootNode = treeComponent.findNode(ROOT_NODE_ID);
753
+ if (!rootNode) {
754
+ await this.refreshAfterChange();
755
+ return;
756
+ }
757
+ if (!treeComponent.isNodeExpanded(ROOT_NODE_ID)) {
758
+ await treeComponent.expandNode(ROOT_NODE_ID);
759
+ }
760
+ treeComponent.addChild(ROOT_NODE_ID, newNode);
761
+ }
762
+ /**
763
+ * Updates an existing node in the tree after edit operation
764
+ */
765
+ async updateNodeInTree(nodeId, entityData) {
766
+ if (!this.isTreeInitialized()) {
767
+ return;
768
+ }
769
+ const treeComponent = this.tree();
770
+ if (!treeComponent) {
771
+ return;
772
+ }
773
+ const existingNode = treeComponent.findNode(nodeId);
774
+ if (!existingNode) {
775
+ await this.refreshNodeParent(entityData);
776
+ return;
777
+ }
778
+ // Check if parent changed
779
+ const parentKey = this.treeData?.categoryEntityDef?.parentKey;
780
+ let newParentId = undefined;
781
+ if (parentKey && entityData[parentKey]) {
782
+ const parentValue = String(entityData[parentKey]);
783
+ // 'all' means root, so treat it as undefined
784
+ newParentId = parentValue !== 'all' && parentValue !== '' ? parentValue : undefined;
785
+ }
786
+ const currentParent = treeComponent.getParent(nodeId);
787
+ const currentParentId = currentParent ? String(currentParent['id'] ?? '') : undefined;
788
+ // Normalize current parent: 'all' means root (undefined)
789
+ const normalizedCurrentParentId = currentParentId === 'all' || currentParentId === '' ? undefined : currentParentId;
790
+ // Handle parent change: move node to new parent if parent changed
791
+ if (newParentId !== normalizedCurrentParentId) {
792
+ // If parent changed, move the node first
793
+ const moved = treeComponent.moveNode(nodeId, newParentId);
794
+ if (!moved) {
795
+ // If move failed, refresh the tree to ensure consistency
796
+ await this.refreshNodeParent(entityData);
797
+ return;
798
+ }
799
+ // After moving, we need to ensure the new parent is expanded
800
+ if (newParentId) {
801
+ if (!treeComponent.isNodeExpanded(newParentId)) {
802
+ await treeComponent.expandNode(newParentId);
803
+ }
804
+ }
805
+ else {
806
+ // Moving to root - ensure root is expanded
807
+ if (!treeComponent.isNodeExpanded(ROOT_NODE_ID)) {
808
+ await treeComponent.expandNode(ROOT_NODE_ID);
809
+ }
810
+ }
811
+ }
812
+ // Update node properties (title, data, etc.)
813
+ const updatedNode = this.categoryTreeService.convertToTreeNode(entityData, this.treeConfig);
814
+ const updates = {
815
+ ['title']: updatedNode['title'],
816
+ ['data']: updatedNode['data'],
817
+ ['childrenCount']: updatedNode['childrenCount'],
818
+ ['icon']: updatedNode['icon'],
819
+ };
820
+ treeComponent.editNode(nodeId, updates);
821
+ }
822
+ /**
823
+ * Removes a node from the tree after delete operation
824
+ */
825
+ async removeNodeFromTree(nodeId) {
826
+ const treeComponent = this.tree();
827
+ if (!treeComponent) {
828
+ return;
829
+ }
830
+ const nodeToDelete = treeComponent.findNode(nodeId);
831
+ if (!nodeToDelete) {
832
+ await this.refreshAfterChange();
833
+ return;
834
+ }
835
+ treeComponent.removeNode(nodeId);
836
+ }
837
+ //#endregion
838
+ //#region ---- Workflow Execution Methods ----
839
+ /**
840
+ * Executes the create entity workflow
841
+ */
842
+ async executeCreateWorkflow(parentId) {
843
+ const entityKey = this.categoryEntityKey();
844
+ const workflowData = {};
845
+ if (parentId && this.treeData?.categoryEntityDef?.parentKey) {
846
+ workflowData[this.treeData.categoryEntityDef.parentKey] = parentId;
847
+ }
848
+ return await this.workflow.execute('create-entity', {
849
+ entity: entityKey,
850
+ data: Object.keys(workflowData).length > 0 ? workflowData : undefined,
851
+ options: { process: { redirect: false, canCreateNewOne: !!parentId } },
852
+ });
853
+ }
854
+ /**
855
+ * Executes the modify entity workflow
856
+ */
857
+ async executeModifyWorkflow(nodeData) {
858
+ return await this.workflow.execute('quick-modify-entity', {
859
+ entity: this.categoryEntityKey(),
860
+ data: nodeData,
861
+ options: { layout: { size: 'md' } },
862
+ });
863
+ }
864
+ /**
865
+ * Executes the delete entity workflow
866
+ */
867
+ async executeDeleteWorkflow(nodeData) {
868
+ return await this.workflow.execute('delete-entity', {
869
+ entity: this.categoryEntityKey(),
870
+ data: nodeData,
871
+ options: { process: { showResult: true } },
872
+ });
873
+ }
874
+ /**
875
+ * Handles the result of a create operation
876
+ */
877
+ async handleCreateResult(context, parentId) {
878
+ const result = context.getOutput('result');
879
+ if (!result || !this.isTreeInitialized()) {
880
+ await this.refreshAfterChange(parentId);
881
+ return;
882
+ }
883
+ const newEntityData = context.getVariable('data');
884
+ if (newEntityData) {
885
+ await this.addNodeToTree(newEntityData, parentId);
886
+ }
887
+ else {
888
+ await this.refreshAfterChange(parentId);
889
+ }
890
+ }
891
+ /**
892
+ * Handles the result of a modify operation
893
+ */
894
+ async handleModifyResult(context, node) {
895
+ const result = context.getOutput('result');
896
+ if (!result || !this.isTreeInitialized()) {
897
+ await this.refreshNodeParent(this.extractNodeData(node));
898
+ return;
899
+ }
900
+ const updatedEntityData = context.getVariable('data');
901
+ if (updatedEntityData) {
902
+ await this.updateNodeInTree(this.extractNodeId(node), updatedEntityData);
903
+ }
904
+ else {
905
+ await this.refreshNodeParent(this.extractNodeData(node));
906
+ }
907
+ }
908
+ /**
909
+ * Handles the result of a delete operation
910
+ */
911
+ async handleDeleteResult(context, node) {
912
+ const result = context.getOutput('result');
913
+ if (result) {
914
+ await this.removeNodeFromTree(this.extractNodeId(node));
915
+ }
916
+ else {
917
+ await this.refreshNodeParent(this.extractNodeData(node));
918
+ }
919
+ }
920
+ //#endregion
921
+ //#region ---- Utility Methods ----
922
+ /**
923
+ * Checks if tree data and config are initialized
924
+ */
925
+ isTreeInitialized() {
926
+ return !!(this.treeData && this.treeConfig);
927
+ }
928
+ /**
929
+ * Extracts node data from a tree node
930
+ */
931
+ extractNodeData(node) {
932
+ return (node['data'] || node);
933
+ }
934
+ /**
935
+ * Extracts node ID from a tree node
936
+ */
937
+ extractNodeId(node) {
938
+ return String(node['id'] ?? '');
939
+ }
940
+ /**
941
+ * Builds category filters from node data and apply conditions
942
+ */
943
+ buildCategoryFilters(nodeData, applyConditions) {
944
+ return applyConditions
945
+ .map((condition) => {
946
+ const value = nodeData[condition.value];
947
+ if (value === 'all' || value == null) {
948
+ return null;
949
+ }
950
+ return {
951
+ field: condition.name,
952
+ value,
953
+ operator: condition.operator,
954
+ };
955
+ })
956
+ .filter((item) => item !== null);
957
+ }
958
+ /**
959
+ * Builds view filters from view conditions
960
+ */
961
+ buildViewFilters() {
962
+ return this.vm()
963
+ .view()
964
+ .conditions.map((condition) => ({ ...condition, field: condition.name }));
965
+ }
966
+ /**
967
+ * Refreshes the parent node of the given entity data
968
+ */
969
+ async refreshNodeParent(entityData) {
970
+ const parentKey = this.treeData?.categoryEntityDef?.parentKey;
971
+ const parentId = parentKey && entityData[parentKey] ? entityData[parentKey] : undefined;
972
+ await this.refreshAfterChange(parentId);
973
+ }
974
+ /**
975
+ * Prevents default behavior and stops event propagation
976
+ */
977
+ preventDefaultAndStopPropagation(event) {
978
+ event.nativeEvent.preventDefault();
979
+ event.nativeEvent.stopPropagation();
980
+ }
981
+ //#endregion
982
+ //#region ---- Loading State Management ----
983
+ /**
984
+ * Sets loading state with delay to avoid flickering for fast responses
985
+ */
986
+ setLoadingWithDelay(loading) {
987
+ if (!loading) {
988
+ return;
989
+ }
990
+ if (this.loadingTimeoutId) {
991
+ clearTimeout(this.loadingTimeoutId);
992
+ }
993
+ this.loadingTimeoutId = setTimeout(() => {
994
+ this.isLoading.set(true);
995
+ this.loadingTimeoutId = null;
996
+ }, LOADING_DELAY_MS);
997
+ }
998
+ /**
999
+ * Clears loading state and cancels any pending timeout
1000
+ */
1001
+ clearLoadingState() {
1002
+ if (this.loadingTimeoutId) {
1003
+ clearTimeout(this.loadingTimeoutId);
1004
+ this.loadingTimeoutId = null;
1005
+ }
1006
+ this.isLoading.set(false);
1007
+ }
1008
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: AXPEntityCategoryComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1009
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.12", type: AXPEntityCategoryComponent, isStandalone: true, selector: "axp-entity-category", inputs: { vm: { classPropertyName: "vm", publicName: "vm", isSignal: true, isRequired: true, transformFunction: null }, searchValue: { classPropertyName: "searchValue", publicName: "searchValue", isSignal: true, isRequired: false, transformFunction: null }, selectMode: { classPropertyName: "selectMode", publicName: "selectMode", isSignal: true, isRequired: false, transformFunction: null }, selectionBehavior: { classPropertyName: "selectionBehavior", publicName: "selectionBehavior", isSignal: true, isRequired: false, transformFunction: null }, dragArea: { classPropertyName: "dragArea", publicName: "dragArea", isSignal: true, isRequired: false, transformFunction: null }, dragBehavior: { classPropertyName: "dragBehavior", publicName: "dragBehavior", isSignal: true, isRequired: false, transformFunction: null }, showIcons: { classPropertyName: "showIcons", publicName: "showIcons", isSignal: true, isRequired: false, transformFunction: null }, showChildrenBadge: { classPropertyName: "showChildrenBadge", publicName: "showChildrenBadge", isSignal: true, isRequired: false, transformFunction: null }, expandedIcon: { classPropertyName: "expandedIcon", publicName: "expandedIcon", isSignal: true, isRequired: false, transformFunction: null }, collapsedIcon: { classPropertyName: "collapsedIcon", publicName: "collapsedIcon", isSignal: true, isRequired: false, transformFunction: null }, indentSize: { classPropertyName: "indentSize", publicName: "indentSize", isSignal: true, isRequired: false, transformFunction: null }, look: { classPropertyName: "look", publicName: "look", isSignal: true, isRequired: false, transformFunction: null }, searchWithChildren: { classPropertyName: "searchWithChildren", publicName: "searchWithChildren", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "tree", first: true, predicate: ["tree"], descendants: true, isSignal: true }], ngImport: i0, template: "<axp-layout-header>\n <axp-layout-title>{{\n vm().entityDef.category?.title || '@general:terms.classification.category' | translate | async\n }}</axp-layout-title>\n <axp-layout-toolbar>\n <div class=\"ax-flex ax-flex-col ax-gap-1 ax-w-full\">\n <ax-search-box\n (onValueChanged)=\"handleCategorySearchChange($event)\"\n [delayTime]=\"300\"\n [placeholder]=\"'@general:terms.interface.category.search.placeholder' | translate | async\"\n >\n </ax-search-box>\n @if (isSearching() && currentSearchValue().trim()) {\n <div class=\"ax-text-xs ax-text-muted ax-flex ax-items-center ax-gap-1\">\n <span>{{ '@general:terms.interface.category.search.searching' | translate | async }}</span>\n </div>\n } @else if (currentSearchValue().trim() && !isSearching()) {\n <div class=\"ax-text-xs ax-text-muted ax-flex ax-items-center ax-gap-1\">\n @if (searchResultCount() > 0) {\n <span>{{ resultsFoundText() }}</span>\n }\n </div>\n }\n </div>\n </axp-layout-toolbar>\n</axp-layout-header>\n<axp-layout-content>\n @if (isLoading()) {\n <div class=\"ax-p-4 ax-flex ax-flex-col ax-gap-3\">\n <ax-skeleton class=\"ax-w-full ax-h-6 ax-rounded-md\"></ax-skeleton>\n <ax-skeleton class=\"ax-w-full ax-h-6 ax-rounded-md\"></ax-skeleton>\n <ax-skeleton class=\"ax-w-full ax-h-6 ax-rounded-md\"></ax-skeleton>\n <ax-skeleton class=\"ax-w-full ax-h-6 ax-rounded-md\"></ax-skeleton>\n <ax-skeleton class=\"ax-w-full ax-h-6 ax-rounded-md\"></ax-skeleton>\n <ax-skeleton class=\"ax-w-full ax-h-6 ax-rounded-md\"></ax-skeleton>\n </div>\n } @else if (showNoSearchResults()) {\n <div class=\"__empty-state\">\n <axp-state-message\n icon=\"fa-light fa-search\"\n [title]=\"'@general:terms.interface.category.search.no-results-found.title'\"\n [description]=\"'@general:terms.interface.category.search.no-results-found.description'\"\n >\n </axp-state-message>\n </div>\n } @else if (treeData) {\n <div class=\"ax-px-4 ax-max-h-[calc(100vh-250px)] ax-overflow-auto\">\n <ax-tree-view\n [datasource]=\"datasource\"\n [selectMode]=\"selectMode()\"\n [selectionBehavior]=\"selectionBehavior()\"\n [dragArea]=\"dragArea()\"\n [dragBehavior]=\"dragBehavior()\"\n [showIcons]=\"showIcons()\"\n [showChildrenBadge]=\"showChildrenBadge()\"\n [expandedIcon]=\"expandedIcon()\"\n [collapsedIcon]=\"collapsedIcon()\"\n [indentSize]=\"indentSize()\"\n [look]=\"look()\"\n [titleField]=\"textField()\"\n [idField]=\"valueField()\"\n [expandOnDoubleClick]=\"true\"\n [nodeTemplate]=\"itemTemplate\"\n (onNodeToggle)=\"onNodeToggle($event)\"\n (onNodeClick)=\"handleNodeClick($event.node)\"\n #tree\n >\n </ax-tree-view>\n </div>\n } @else {\n <div class=\"__empty-state\">\n <axp-state-message\n icon=\"fa-light fa-folder-open\"\n [title]=\"'@general:terms.interface.category.search.no-records.title'\"\n [description]=\"'@general:terms.interface.category.search.no-records.description'\"\n >\n <ax-button\n slot=\"actions\"\n (onClick)=\"handleCreateRootClick($event)\"\n look=\"solid\"\n color=\"primary\"\n [text]=\"'@general:actions.add-new.title' | translate | async\"\n >\n <ax-icon class=\"fas fa-plus\"></ax-icon>\n </ax-button>\n </axp-state-message>\n </div>\n }\n\n <ng-template #itemTemplate let-node=\"node\" let-level=\"level\">\n @let item = node.data || node;\n @let textField = vm().entityDef.category?.textField || 'title';\n @let valueField = vm().entityDef.category?.valueField || 'id';\n @let itemId = item[valueField] || node.id;\n @let itemTitle = item[textField] || node.title;\n <div class=\"ax-flex ax-items-center ax-justify-between ax-w-full ax-gap-2 ax-overflow-hidden ax-py-1\">\n <div class=\"ax-flex ax-items-center ax-gap-2 ax-min-w-0\">\n <ax-icon\n class=\"fas fa-folder\"\n [style.color]=\"item.color ?? 'rgba(var(--ax-sys-color-warning-500), 1)'\"\n ></ax-icon>\n <span class=\"ax-truncate\">{{ itemTitle }}</span>\n </div>\n @if (itemId && itemId !== 'all') {\n <div class=\"ax-flex ax-items-center ax-gap-1\">\n <ax-button class=\"ax-xs\" color=\"default\" look=\"blank\" (onClick)=\"$event.nativeEvent.stopPropagation()\">\n <ax-icon class=\"fas fa-ellipsis-v\"></ax-icon>\n <ax-dropdown-panel>\n <ax-button-item-list>\n <ax-button-item\n (onClick)=\"handleCreateChildClick(node, $event)\"\n look=\"blank\"\n color=\"default\"\n text=\"Add New Child\"\n >\n <ax-icon class=\"fas fa-plus\"></ax-icon>\n </ax-button-item>\n <ax-button-item (onClick)=\"handleEditNodeClick(node, $event)\" look=\"blank\" text=\"Edit\">\n <ax-icon class=\"fas fa-pen\"></ax-icon>\n </ax-button-item>\n <ax-button-item\n (onClick)=\"handleDeleteNodeClick(node, $event)\"\n color=\"danger\"\n look=\"blank\"\n text=\"Delete\"\n >\n <ax-icon class=\"fas fa-trash\"></ax-icon>\n </ax-button-item>\n </ax-button-item-list>\n </ax-dropdown-panel>\n </ax-button>\n </div>\n } @else if (itemId === 'all') {\n <div class=\"ax-flex ax-items-center ax-gap-1\">\n <ax-button class=\"ax-xs\" (onClick)=\"handleCreateRootClick($event)\" look=\"blank\" color=\"default\">\n <ax-icon class=\"fas fa-plus\"></ax-icon>\n </ax-button>\n </div>\n }\n </div>\n </ng-template>\n</axp-layout-content>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: AXDecoratorModule }, { kind: "component", type: i2.AXDecoratorIconComponent, selector: "ax-icon", inputs: ["icon"] }, { kind: "ngmodule", type: AXTreeViewModule }, { kind: "component", type: AXTreeViewComponent, selector: "ax-tree-view", inputs: ["datasource", "selectMode", "selectionBehavior", "dragArea", "dragBehavior", "showIcons", "showChildrenBadge", "expandedIcon", "collapsedIcon", "indentSize", "look", "nodeTemplate", "idField", "titleField", "tooltipField", "iconField", "expandedField", "selectedField", "indeterminateField", "disabledField", "hiddenField", "childrenField", "childrenCountField", "dataField", "inheritDisabled", "expandOnDoubleClick"], outputs: ["datasourceChange", "onBeforeDrop", "onNodeToggle", "onNodeSelect", "onNodeDoubleClick", "onNodeClick", "onSelectionChange", "onOrderChange", "onMoveChange", "onItemsChange"] }, { kind: "ngmodule", type: AXSkeletonModule }, { kind: "component", type: i2$1.AXSkeletonComponent, selector: "ax-skeleton", inputs: ["animated"] }, { kind: "component", type: AXPThemeLayoutBlockComponent, selector: " axp-page-content, axp-page-footer-container, axp-page-footer, axp-page-header, axp-page-header-container, axp-page-toolbar, axp-layout-content, axp-layout-page-content, axp-layout-sections, axp-layout-body, axp-layout-page-body, axp-layout-prefix, axp-layout-suffix, axp-layout-title-bar, axp-layout-title, axp-layout-title-actions, axp-layout-nav-button, axp-layout-description, axp-layout-breadcrumbs, axp-layout-list-action, " }, { kind: "ngmodule", type: AXSearchBoxModule }, { kind: "component", type: i6.AXSearchBoxComponent, selector: "ax-search-box", inputs: ["disabled", "readonly", "tabIndex", "placeholder", "value", "state", "name", "id", "look", "class", "delayTime", "type", "autoSearch"], outputs: ["valueChange", "stateChange", "onValueChanged", "onBlur", "onFocus", "readonlyChange", "disabledChange", "onKeyDown", "onKeyUp", "onKeyPress"] }, { kind: "component", type: AXPThemeLayoutHeaderComponent, selector: "axp-layout-header" }, { kind: "component", type: AXPThemeLayoutToolbarComponent, selector: "axp-layout-toolbar" }, { kind: "ngmodule", type: AXTranslationModule }, { kind: "ngmodule", type: AXButtonModule }, { kind: "component", type: i3.AXButtonComponent, selector: "ax-button", inputs: ["disabled", "size", "tabIndex", "color", "look", "text", "toggleable", "selected", "iconOnly", "type", "loadingText"], outputs: ["onBlur", "onFocus", "onClick", "selectedChange", "toggleableChange", "lookChange", "colorChange", "disabledChange", "loadingTextChange"] }, { kind: "component", type: i3.AXButtonItemComponent, selector: "ax-button-item", inputs: ["color", "disabled", "text", "selected", "divided", "data", "name"], outputs: ["onClick", "onFocus", "onBlur", "disabledChange"] }, { kind: "component", type: i3.AXButtonItemListComponent, selector: "ax-button-item-list", inputs: ["items", "closeParentOnClick", "lockOnLoading"], outputs: ["onItemClick"] }, { kind: "ngmodule", type: AXDropdownModule }, { kind: "component", type: i5.AXDropdownPanelComponent, selector: "ax-dropdown-panel", inputs: ["isOpen", "fitParent", "dropdownWidth", "position", "placement", "_target", "adaptivityEnabled"], outputs: ["onOpened", "onClosed"] }, { kind: "component", type: AXPStateMessageComponent, selector: "axp-state-message", inputs: ["mode", "icon", "title", "description", "variant"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }, { kind: "pipe", type: i10.AXTranslatorPipe, name: "translate" }], encapsulation: i0.ViewEncapsulation.None }); }
1010
+ }
1011
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: AXPEntityCategoryComponent, decorators: [{
1012
+ type: Component,
1013
+ args: [{ selector: 'axp-entity-category', standalone: true, encapsulation: ViewEncapsulation.None, imports: [
1014
+ CommonModule,
1015
+ AXDecoratorModule,
1016
+ AXTreeViewModule,
1017
+ AXTreeViewComponent,
1018
+ AXSkeletonModule,
1019
+ AXPThemeLayoutBlockComponent,
1020
+ AXSearchBoxModule,
1021
+ AXPThemeLayoutHeaderComponent,
1022
+ AXPThemeLayoutToolbarComponent,
1023
+ AXTranslationModule,
1024
+ AXButtonModule,
1025
+ AXDropdownModule,
1026
+ AXPStateMessageComponent,
1027
+ ], template: "<axp-layout-header>\n <axp-layout-title>{{\n vm().entityDef.category?.title || '@general:terms.classification.category' | translate | async\n }}</axp-layout-title>\n <axp-layout-toolbar>\n <div class=\"ax-flex ax-flex-col ax-gap-1 ax-w-full\">\n <ax-search-box\n (onValueChanged)=\"handleCategorySearchChange($event)\"\n [delayTime]=\"300\"\n [placeholder]=\"'@general:terms.interface.category.search.placeholder' | translate | async\"\n >\n </ax-search-box>\n @if (isSearching() && currentSearchValue().trim()) {\n <div class=\"ax-text-xs ax-text-muted ax-flex ax-items-center ax-gap-1\">\n <span>{{ '@general:terms.interface.category.search.searching' | translate | async }}</span>\n </div>\n } @else if (currentSearchValue().trim() && !isSearching()) {\n <div class=\"ax-text-xs ax-text-muted ax-flex ax-items-center ax-gap-1\">\n @if (searchResultCount() > 0) {\n <span>{{ resultsFoundText() }}</span>\n }\n </div>\n }\n </div>\n </axp-layout-toolbar>\n</axp-layout-header>\n<axp-layout-content>\n @if (isLoading()) {\n <div class=\"ax-p-4 ax-flex ax-flex-col ax-gap-3\">\n <ax-skeleton class=\"ax-w-full ax-h-6 ax-rounded-md\"></ax-skeleton>\n <ax-skeleton class=\"ax-w-full ax-h-6 ax-rounded-md\"></ax-skeleton>\n <ax-skeleton class=\"ax-w-full ax-h-6 ax-rounded-md\"></ax-skeleton>\n <ax-skeleton class=\"ax-w-full ax-h-6 ax-rounded-md\"></ax-skeleton>\n <ax-skeleton class=\"ax-w-full ax-h-6 ax-rounded-md\"></ax-skeleton>\n <ax-skeleton class=\"ax-w-full ax-h-6 ax-rounded-md\"></ax-skeleton>\n </div>\n } @else if (showNoSearchResults()) {\n <div class=\"__empty-state\">\n <axp-state-message\n icon=\"fa-light fa-search\"\n [title]=\"'@general:terms.interface.category.search.no-results-found.title'\"\n [description]=\"'@general:terms.interface.category.search.no-results-found.description'\"\n >\n </axp-state-message>\n </div>\n } @else if (treeData) {\n <div class=\"ax-px-4 ax-max-h-[calc(100vh-250px)] ax-overflow-auto\">\n <ax-tree-view\n [datasource]=\"datasource\"\n [selectMode]=\"selectMode()\"\n [selectionBehavior]=\"selectionBehavior()\"\n [dragArea]=\"dragArea()\"\n [dragBehavior]=\"dragBehavior()\"\n [showIcons]=\"showIcons()\"\n [showChildrenBadge]=\"showChildrenBadge()\"\n [expandedIcon]=\"expandedIcon()\"\n [collapsedIcon]=\"collapsedIcon()\"\n [indentSize]=\"indentSize()\"\n [look]=\"look()\"\n [titleField]=\"textField()\"\n [idField]=\"valueField()\"\n [expandOnDoubleClick]=\"true\"\n [nodeTemplate]=\"itemTemplate\"\n (onNodeToggle)=\"onNodeToggle($event)\"\n (onNodeClick)=\"handleNodeClick($event.node)\"\n #tree\n >\n </ax-tree-view>\n </div>\n } @else {\n <div class=\"__empty-state\">\n <axp-state-message\n icon=\"fa-light fa-folder-open\"\n [title]=\"'@general:terms.interface.category.search.no-records.title'\"\n [description]=\"'@general:terms.interface.category.search.no-records.description'\"\n >\n <ax-button\n slot=\"actions\"\n (onClick)=\"handleCreateRootClick($event)\"\n look=\"solid\"\n color=\"primary\"\n [text]=\"'@general:actions.add-new.title' | translate | async\"\n >\n <ax-icon class=\"fas fa-plus\"></ax-icon>\n </ax-button>\n </axp-state-message>\n </div>\n }\n\n <ng-template #itemTemplate let-node=\"node\" let-level=\"level\">\n @let item = node.data || node;\n @let textField = vm().entityDef.category?.textField || 'title';\n @let valueField = vm().entityDef.category?.valueField || 'id';\n @let itemId = item[valueField] || node.id;\n @let itemTitle = item[textField] || node.title;\n <div class=\"ax-flex ax-items-center ax-justify-between ax-w-full ax-gap-2 ax-overflow-hidden ax-py-1\">\n <div class=\"ax-flex ax-items-center ax-gap-2 ax-min-w-0\">\n <ax-icon\n class=\"fas fa-folder\"\n [style.color]=\"item.color ?? 'rgba(var(--ax-sys-color-warning-500), 1)'\"\n ></ax-icon>\n <span class=\"ax-truncate\">{{ itemTitle }}</span>\n </div>\n @if (itemId && itemId !== 'all') {\n <div class=\"ax-flex ax-items-center ax-gap-1\">\n <ax-button class=\"ax-xs\" color=\"default\" look=\"blank\" (onClick)=\"$event.nativeEvent.stopPropagation()\">\n <ax-icon class=\"fas fa-ellipsis-v\"></ax-icon>\n <ax-dropdown-panel>\n <ax-button-item-list>\n <ax-button-item\n (onClick)=\"handleCreateChildClick(node, $event)\"\n look=\"blank\"\n color=\"default\"\n text=\"Add New Child\"\n >\n <ax-icon class=\"fas fa-plus\"></ax-icon>\n </ax-button-item>\n <ax-button-item (onClick)=\"handleEditNodeClick(node, $event)\" look=\"blank\" text=\"Edit\">\n <ax-icon class=\"fas fa-pen\"></ax-icon>\n </ax-button-item>\n <ax-button-item\n (onClick)=\"handleDeleteNodeClick(node, $event)\"\n color=\"danger\"\n look=\"blank\"\n text=\"Delete\"\n >\n <ax-icon class=\"fas fa-trash\"></ax-icon>\n </ax-button-item>\n </ax-button-item-list>\n </ax-dropdown-panel>\n </ax-button>\n </div>\n } @else if (itemId === 'all') {\n <div class=\"ax-flex ax-items-center ax-gap-1\">\n <ax-button class=\"ax-xs\" (onClick)=\"handleCreateRootClick($event)\" look=\"blank\" color=\"default\">\n <ax-icon class=\"fas fa-plus\"></ax-icon>\n </ax-button>\n </div>\n }\n </div>\n </ng-template>\n</axp-layout-content>\n" }]
1028
+ }], ctorParameters: () => [], propDecorators: { vm: [{ type: i0.Input, args: [{ isSignal: true, alias: "vm", required: true }] }], tree: [{ type: i0.ViewChild, args: ['tree', { isSignal: true }] }], searchValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "searchValue", required: false }] }], selectMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectMode", required: false }] }], selectionBehavior: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectionBehavior", required: false }] }], dragArea: [{ type: i0.Input, args: [{ isSignal: true, alias: "dragArea", required: false }] }], dragBehavior: [{ type: i0.Input, args: [{ isSignal: true, alias: "dragBehavior", required: false }] }], showIcons: [{ type: i0.Input, args: [{ isSignal: true, alias: "showIcons", required: false }] }], showChildrenBadge: [{ type: i0.Input, args: [{ isSignal: true, alias: "showChildrenBadge", required: false }] }], expandedIcon: [{ type: i0.Input, args: [{ isSignal: true, alias: "expandedIcon", required: false }] }], collapsedIcon: [{ type: i0.Input, args: [{ isSignal: true, alias: "collapsedIcon", required: false }] }], indentSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "indentSize", required: false }] }], look: [{ type: i0.Input, args: [{ isSignal: true, alias: "look", required: false }] }], searchWithChildren: [{ type: i0.Input, args: [{ isSignal: true, alias: "searchWithChildren", required: false }] }] } });
1029
+
1030
+ class AXPEntityMasterToolbarViewComponent {
1031
+ constructor() {
1032
+ this.layoutService = inject(AXPLayoutThemeService);
1033
+ this.deviceService = inject(AXPDeviceService);
1034
+ this.parent = inject(AXPEntityMasterListViewComponent);
1035
+ this.router = inject(Router);
1036
+ this.activeRoute = inject(ActivatedRoute);
1037
+ this.settingsService = inject(AXPSettingService);
1038
+ this.isInitializing = false;
1039
+ this.pendingInitialFilters = true;
1040
+ this.pendingInitialSorts = true;
1041
+ this.filterTriggerMode = 'manual';
1042
+ this.previousFilterQueries = signal([], ...(ngDevMode ? [{ debugName: "previousFilterQueries" }] : []));
1043
+ this.initialFilters = signal([], ...(ngDevMode ? [{ debugName: "initialFilters" }] : []));
1044
+ this.filtersDefinitions = signal([], ...(ngDevMode ? [{ debugName: "filtersDefinitions" }] : []));
1045
+ this.viewQueries = computed(() => this.vm.views().map((v) => ({
1046
+ name: v.name,
1047
+ fixed: false,
1048
+ title: v.title,
1049
+ columns: v.columns,
1050
+ conditions: v.conditions.map((c) => ({
1051
+ field: c.name,
1052
+ operator: c.operator,
1053
+ value: c.value,
1054
+ })),
1055
+ sorts: v.sorts,
1056
+ })), ...(ngDevMode ? [{ debugName: "viewQueries" }] : []));
1057
+ this.selectedViewQuery = computed(() => ({
1058
+ name: this.vm.view().name,
1059
+ fixed: false,
1060
+ title: this.vm.view().title,
1061
+ columns: this.vm.view().columns,
1062
+ conditions: this.vm.view().conditions.map((c) => ({
1063
+ field: c.name,
1064
+ operator: c.operator,
1065
+ value: c.value,
1066
+ })),
1067
+ sorts: this.vm.view().sorts,
1068
+ }), ...(ngDevMode ? [{ debugName: "selectedViewQuery" }] : []));
1069
+ this.isFiltersDirty = computed(() => !isEqual(this.vm.filterQueries(), this.previousFilterQueries()), ...(ngDevMode ? [{ debugName: "isFiltersDirty" }] : []));
1070
+ // Debounced apply to coalesce multiple UI changes (filters/sorts/columns)
1071
+ this.applyTimer = null;
1072
+ this.#effect = effect(() => {
1073
+ // Keep definitions up to date; initial filters are set explicitly from settings or view
1074
+ this.filtersDefinitions.set(this.vm.filtersDef);
1075
+ }, ...(ngDevMode ? [{ debugName: "#effect" }] : []));
1076
+ this.sortQueries = computed(() => this.vm
1077
+ .sortedFields()
1078
+ .filter((s) => !!s.dir)
1079
+ .map((s) => ({ name: s.name, dir: s.dir })), ...(ngDevMode ? [{ debugName: "sortQueries" }] : []));
1080
+ this.sortDefinitions = computed(() => this.vm.sortableFields().map((s) => ({
1081
+ name: s.name,
1082
+ title: s.title,
1083
+ dir: s.dir,
1084
+ })), ...(ngDevMode ? [{ debugName: "sortDefinitions" }] : []));
1085
+ }
1086
+ async ngOnInit() {
1087
+ // Prefer saved settings (view/columns/sorts/filters) if available, then apply
1088
+ await this.loadSettings();
1089
+ await this.vm.setView();
1090
+ this.filtersDefinitions.set(this.vm.filtersDef);
1091
+ this.isInitializing = true;
1092
+ // this.pendingInitialFilters = true;
1093
+ // this.pendingInitialSorts = true;
1094
+ this.setInitialFiltersFromSettingsOrView();
1095
+ // Ensure initial load even when filters/sorts are absent
1096
+ setTimeout(() => {
1097
+ this.isInitializing = false;
1098
+ this.scheduleApply();
1099
+ }, 0);
1100
+ }
1101
+ async loadSettings() {
1102
+ const filterTriggerMode = await this.settingsService.get(AXPCommonSettings.EntityFilterApplyMode);
1103
+ this.filterTriggerMode = (filterTriggerMode?.value ?? 'auto');
1104
+ }
1105
+ scheduleApply() {
1106
+ clearTimeout(this.applyTimer);
1107
+ this.applyTimer = setTimeout(() => {
1108
+ this.vm.applyFilterAndSort();
1109
+ }, 50);
1110
+ }
1111
+ async onViewChanged(view) {
1112
+ await this.vm.setView(view.name);
1113
+ // Sync query param immediately on tab change
1114
+ this.router.navigate([], {
1115
+ relativeTo: this.activeRoute,
1116
+ queryParams: { view: view.name },
1117
+ queryParamsHandling: 'merge',
1118
+ replaceUrl: true,
1119
+ });
1120
+ this.isInitializing = true;
1121
+ this.pendingInitialFilters = true;
1122
+ this.pendingInitialSorts = true;
1123
+ this.setInitialFiltersFromSettingsOrView();
1124
+ // Ensure initial load after view change
1125
+ setTimeout(() => {
1126
+ this.isInitializing = false;
1127
+ this.scheduleApply();
1128
+ }, 0);
1129
+ }
1130
+ #effect;
1131
+ setInitialFiltersFromSettingsOrView() {
1132
+ const saved = this.vm.filterQueries();
1133
+ this.previousFilterQueries.set(saved);
1134
+ const viewConditions = this.vm.view().conditions.map((c) => c.name);
1135
+ if (saved && saved.length) {
1136
+ this.initialFilters.set(saved.map((s) => ({ ...s, hidden: viewConditions.includes(s.field) })));
1137
+ return;
1138
+ }
1139
+ this.initialFilters.set(this.vm.view().conditions.map((c) => ({
1140
+ field: c.name,
1141
+ operator: c.operator,
1142
+ value: c.value,
1143
+ hidden: true,
1144
+ })));
1145
+ }
1146
+ onFiltersChanged(filters) {
1147
+ if (this.isInitializing || this.pendingInitialFilters) {
1148
+ this.pendingInitialFilters = false;
1149
+ return;
1150
+ }
1151
+ this.vm.filterQueries.set(filters);
1152
+ if (this.filterTriggerMode === 'auto') {
1153
+ this.applyFilters();
1154
+ }
1155
+ }
1156
+ applyFilters() {
1157
+ this.previousFilterQueries.set(this.vm.filterQueries());
1158
+ this.vm.saveSettings('filters', this.vm.filterQueries());
1159
+ this.scheduleApply();
1160
+ }
1161
+ onSortQueriesChange(e) {
1162
+ if (this.isInitializing || this.pendingInitialSorts) {
1163
+ this.pendingInitialSorts = false;
1164
+ return;
1165
+ }
1166
+ this.vm.sortedFields.set(e.map((s) => ({
1167
+ name: s.name,
1168
+ title: s.name,
1169
+ dir: s.dir,
1170
+ })));
1171
+ // Persist sorts per module/entity/view
1172
+ this.vm.saveSettings('sorts', e);
1173
+ this.scheduleApply();
1174
+ }
1175
+ onColumnsChange(columns) {
1176
+ const keyOf = (c) => c.column?.options?.dataPath ?? c.name;
1177
+ this.vm.columns.update((prev) => {
1178
+ const byKey = new Map(prev.map((c) => [keyOf(c), c]));
1179
+ return columns.map((newColumn) => {
1180
+ const existing = byKey.get(keyOf(newColumn));
1181
+ return new AXPEntityListViewColumnViewModel(existing.property, {
1182
+ ...existing.column,
1183
+ options: {
1184
+ ...existing.column.options,
1185
+ visible: newColumn.visible,
1186
+ },
1187
+ });
1188
+ });
1189
+ });
1190
+ // Persist column order/visibility
1191
+ this.vm.onColumnsChanged(this.vm.columns());
1192
+ // Use debounced apply to avoid triple refresh when combined with sorts/filters
1193
+ // this.scheduleApply();
1194
+ }
1195
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: AXPEntityMasterToolbarViewComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1196
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.12", type: AXPEntityMasterToolbarViewComponent, isStandalone: true, selector: "axp-entity-master-toolbar-view", inputs: { vm: ["viewModel", "vm"] }, host: { classAttribute: "ax-w-full" }, ngImport: i0, template: "<!-- <axp-entity-view-toolbar [viewModel]=\"vm\"></axp-entity-view-toolbar> -->\n<axp-query-views\n id=\"axp-toolbar-view-selector\"\n [views]=\"viewQueries()\"\n [selectedView]=\"selectedViewQuery()\"\n (selectedViewChange)=\"onViewChanged($event)\"\n></axp-query-views>\n<div class=\"ax-flex ax-items-center ax-gap-2 ax-border-b ax-border-light w-full\">\n <!-- <axp-entity-filter-toolbar [viewModel]=\"vm\"></axp-entity-filter-toolbar> -->\n <axp-query-filters\n id=\"axp-toolbar-filters\"\n [filtersDefinitions]=\"filtersDefinitions()\"\n [initialFilters]=\"initialFilters()\"\n (onFiltersChanged)=\"onFiltersChanged($event)\"\n ></axp-query-filters>\n\n <div class=\"ax-flex ax-items-center ax-gap-2 md:ax-gap-2\">\n @if (filterTriggerMode === 'manual' && isFiltersDirty()) {\n <ax-button\n id=\"axp-toolbar-btn-filter\"\n [title]=\"'@general:actions.apply.title'\"\n [iconOnly]=\"true\"\n #filterButton\n [color]=\"'primary'\"\n (onClick)=\"applyFilters()\"\n >\n <ax-prefix>\n <i class=\"fa-light fa-search\"></i>\n </ax-prefix>\n </ax-button>\n }\n <div>\n <ax-button id=\"axp-toolbar-btn-columns\" [iconOnly]=\"true\" #columnButton [color]=\"'default'\">\n <i class=\"fa-light fa-table-columns\"></i>\n </ax-button>\n <ax-popover\n id=\"axp-popover-columns\"\n [adaptivityEnabled]=\"true\"\n [offsetY]=\"30\"\n [target]=\"columnButton\"\n [openOn]=\"'toggle'\"\n [closeOn]=\"'clickOut'\"\n #popover\n >\n <div class=\"ax-lightest-surface ax-shadow-md ax-border md:ax-w-72 ax-w-full ax-rounded-md\">\n <ax-header class=\"ax-border-b ax-lighter-surface ax-rounded-t-md ax-p-4 ax-font-bold\">\n {{ '@general:terms.common.columns' | translate | async }}\n </ax-header>\n <div class=\"ax-py-2 ax-px-4\">\n <axp-query-columns [columns]=\"vm.columns()\" (columnsChange)=\"onColumnsChange($event)\"></axp-query-columns>\n <!-- <axp-list-view-option-columns [viewModel]=\"vm\"></axp-list-view-option-columns> -->\n </div>\n </div>\n </ax-popover>\n </div>\n\n @if (vm.canSort()) {\n <div>\n <ax-button id=\"axp-toolbar-btn-sort\" [iconOnly]=\"true\" [text]=\"'Sorts'\" #sortButton [color]=\"'default'\">\n <i class=\"fa-light fa-sort-amount-up\"></i>\n </ax-button>\n <ax-popover\n id=\"axp-popover-sort\"\n [adaptivityEnabled]=\"true\"\n [offsetY]=\"10\"\n [target]=\"sortButton\"\n [openOn]=\"'toggle'\"\n [closeOn]=\"'clickOut'\"\n #popover\n >\n <div class=\"ax-lightest-surface ax-shadow-md ax-border md:ax-w-72 ax-w-full ax-rounded-md\">\n <ax-header class=\"ax-border-b ax-lighter-surface ax-rounded-t-md ax-p-4 ax-font-bold\">\n {{ '@general:terms.common.sorts' | translate | async }}\n </ax-header>\n <div class=\"ax-py-2 ax-px-4\">\n <!-- <axp-list-view-option-sorting [viewModel]=\"vm\"></axp-list-view-option-sorting> -->\n <axp-query-sorts\n [sortDefinitions]=\"sortDefinitions()\"\n (sortQueriesChange)=\"onSortQueriesChange($event)\"\n [initialSortQueries]=\"sortQueries()\"\n ></axp-query-sorts>\n </div>\n </div>\n </ax-popover>\n </div>\n }\n @if (deviceService.isSmall()) {\n <ax-button\n id=\"axp-toolbar-btn-category\"\n (onClick)=\"parent.toggleCategoryDrawer()\"\n [iconOnly]=\"true\"\n [color]=\"'default'\"\n >\n <i class=\"fa-light fa-bars\"></i>\n </ax-button>\n }\n </div>\n</div>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: AXButtonModule }, { kind: "component", type: i3.AXButtonComponent, selector: "ax-button", inputs: ["disabled", "size", "tabIndex", "color", "look", "text", "toggleable", "selected", "iconOnly", "type", "loadingText"], outputs: ["onBlur", "onFocus", "onClick", "selectedChange", "toggleableChange", "lookChange", "colorChange", "disabledChange", "loadingTextChange"] }, { kind: "ngmodule", type: AXDecoratorModule }, { kind: "component", type: i2.AXDecoratorGenericComponent, selector: "ax-footer, ax-header, ax-content, ax-divider, ax-form-hint, ax-prefix, ax-suffix, ax-text, ax-title, ax-subtitle, ax-placeholder, ax-overlay" }, { kind: "ngmodule", type: AXTranslationModule }, { kind: "component", type: AXPQueryFiltersComponent, selector: "axp-query-filters", inputs: ["filtersDefinitions", "initialFilters"], outputs: ["onFiltersChanged"] }, { kind: "ngmodule", type: AXPopoverModule }, { kind: "component", type: i3$1.AXPopoverComponent, selector: "ax-popover", inputs: ["width", "disabled", "offsetX", "offsetY", "target", "placement", "content", "openOn", "closeOn", "hasBackdrop", "openAfter", "closeAfter", "backdropClass", "panelClass", "adaptivityEnabled"], outputs: ["onOpened", "onClosed"] }, { kind: "component", type: AXPQuerySortsComponent, selector: "axp-query-sorts", inputs: ["sortDefinitions", "initialSortQueries"], outputs: ["sortDefinitionsChange", "sortQueriesChange"] }, { kind: "component", type: AXPQueryViewsComponent, selector: "axp-query-views", inputs: ["views", "selectedView"], outputs: ["viewsChange", "selectedViewChange"] }, { kind: "component", type: AXPQueryColumnsComponent, selector: "axp-query-columns", inputs: ["columns"], outputs: ["columnsChange"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }, { kind: "pipe", type: i10.AXTranslatorPipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
1197
+ }
1198
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: AXPEntityMasterToolbarViewComponent, decorators: [{
1199
+ type: Component,
1200
+ args: [{ selector: 'axp-entity-master-toolbar-view', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [
1201
+ CommonModule,
1202
+ AXButtonModule,
1203
+ AXDecoratorModule,
1204
+ AXTranslationModule,
1205
+ AXPQueryFiltersComponent,
1206
+ AXPopoverModule,
1207
+ AXPQuerySortsComponent,
1208
+ AXPQueryViewsComponent,
1209
+ AXPQueryColumnsComponent,
1210
+ ], host: {
1211
+ class: 'ax-w-full',
1212
+ }, template: "<!-- <axp-entity-view-toolbar [viewModel]=\"vm\"></axp-entity-view-toolbar> -->\n<axp-query-views\n id=\"axp-toolbar-view-selector\"\n [views]=\"viewQueries()\"\n [selectedView]=\"selectedViewQuery()\"\n (selectedViewChange)=\"onViewChanged($event)\"\n></axp-query-views>\n<div class=\"ax-flex ax-items-center ax-gap-2 ax-border-b ax-border-light w-full\">\n <!-- <axp-entity-filter-toolbar [viewModel]=\"vm\"></axp-entity-filter-toolbar> -->\n <axp-query-filters\n id=\"axp-toolbar-filters\"\n [filtersDefinitions]=\"filtersDefinitions()\"\n [initialFilters]=\"initialFilters()\"\n (onFiltersChanged)=\"onFiltersChanged($event)\"\n ></axp-query-filters>\n\n <div class=\"ax-flex ax-items-center ax-gap-2 md:ax-gap-2\">\n @if (filterTriggerMode === 'manual' && isFiltersDirty()) {\n <ax-button\n id=\"axp-toolbar-btn-filter\"\n [title]=\"'@general:actions.apply.title'\"\n [iconOnly]=\"true\"\n #filterButton\n [color]=\"'primary'\"\n (onClick)=\"applyFilters()\"\n >\n <ax-prefix>\n <i class=\"fa-light fa-search\"></i>\n </ax-prefix>\n </ax-button>\n }\n <div>\n <ax-button id=\"axp-toolbar-btn-columns\" [iconOnly]=\"true\" #columnButton [color]=\"'default'\">\n <i class=\"fa-light fa-table-columns\"></i>\n </ax-button>\n <ax-popover\n id=\"axp-popover-columns\"\n [adaptivityEnabled]=\"true\"\n [offsetY]=\"30\"\n [target]=\"columnButton\"\n [openOn]=\"'toggle'\"\n [closeOn]=\"'clickOut'\"\n #popover\n >\n <div class=\"ax-lightest-surface ax-shadow-md ax-border md:ax-w-72 ax-w-full ax-rounded-md\">\n <ax-header class=\"ax-border-b ax-lighter-surface ax-rounded-t-md ax-p-4 ax-font-bold\">\n {{ '@general:terms.common.columns' | translate | async }}\n </ax-header>\n <div class=\"ax-py-2 ax-px-4\">\n <axp-query-columns [columns]=\"vm.columns()\" (columnsChange)=\"onColumnsChange($event)\"></axp-query-columns>\n <!-- <axp-list-view-option-columns [viewModel]=\"vm\"></axp-list-view-option-columns> -->\n </div>\n </div>\n </ax-popover>\n </div>\n\n @if (vm.canSort()) {\n <div>\n <ax-button id=\"axp-toolbar-btn-sort\" [iconOnly]=\"true\" [text]=\"'Sorts'\" #sortButton [color]=\"'default'\">\n <i class=\"fa-light fa-sort-amount-up\"></i>\n </ax-button>\n <ax-popover\n id=\"axp-popover-sort\"\n [adaptivityEnabled]=\"true\"\n [offsetY]=\"10\"\n [target]=\"sortButton\"\n [openOn]=\"'toggle'\"\n [closeOn]=\"'clickOut'\"\n #popover\n >\n <div class=\"ax-lightest-surface ax-shadow-md ax-border md:ax-w-72 ax-w-full ax-rounded-md\">\n <ax-header class=\"ax-border-b ax-lighter-surface ax-rounded-t-md ax-p-4 ax-font-bold\">\n {{ '@general:terms.common.sorts' | translate | async }}\n </ax-header>\n <div class=\"ax-py-2 ax-px-4\">\n <!-- <axp-list-view-option-sorting [viewModel]=\"vm\"></axp-list-view-option-sorting> -->\n <axp-query-sorts\n [sortDefinitions]=\"sortDefinitions()\"\n (sortQueriesChange)=\"onSortQueriesChange($event)\"\n [initialSortQueries]=\"sortQueries()\"\n ></axp-query-sorts>\n </div>\n </div>\n </ax-popover>\n </div>\n }\n @if (deviceService.isSmall()) {\n <ax-button\n id=\"axp-toolbar-btn-category\"\n (onClick)=\"parent.toggleCategoryDrawer()\"\n [iconOnly]=\"true\"\n [color]=\"'default'\"\n >\n <i class=\"fa-light fa-bars\"></i>\n </ax-button>\n }\n </div>\n</div>\n" }]
1213
+ }], propDecorators: { vm: [{
1214
+ type: Input,
1215
+ args: ['viewModel']
1216
+ }] } });
1217
+
1218
+ class AXPEntityMasterListViewComponent extends AXPPageLayoutBaseComponent {
1219
+ constructor(platform) {
1220
+ super();
1221
+ this.platform = platform;
1222
+ this.activeRoute = inject(ActivatedRoute);
1223
+ this.router = inject(Router);
1224
+ this.vm = this.activeRoute.snapshot.data['vm'];
1225
+ //
1226
+ this.store = inject(AXPLayoutThemeService);
1227
+ //
1228
+ this.searchBarShown = signal(true, ...(ngDevMode ? [{ debugName: "searchBarShown" }] : []));
1229
+ this.activeEndSideView = signal('column', ...(ngDevMode ? [{ debugName: "activeEndSideView" }] : []));
1230
+ this.categorySearchValue = signal('', ...(ngDevMode ? [{ debugName: "categorySearchValue" }] : []));
1231
+ // @ViewChild('grid', { static: true}) grid: AXDataTableComponent;
1232
+ this.grid = viewChild('grid', ...(ngDevMode ? [{ debugName: "grid" }] : []));
1233
+ this.initializedFromRoute = false;
1234
+ this.commandRowItems = computed(() => {
1235
+ return this.vm.primaryRowActions().map((c) => {
1236
+ return {
1237
+ icon: c.icon,
1238
+ name: c.name,
1239
+ text: translateSync(c.title),
1240
+ color: c.color,
1241
+ disabled: c.disabled,
1242
+ default: c.default,
1243
+ };
1244
+ });
1245
+ }, ...(ngDevMode ? [{ debugName: "commandRowItems" }] : []));
1246
+ this.getDropdownRowItems = (rowData) => {
1247
+ return Promise.resolve(this.dropdownRowItems(rowData));
1248
+ };
1249
+ this.getCommandRowItems = () => {
1250
+ return this.commandRowItems();
1251
+ };
1252
+ effect(() => {
1253
+ if (this.grid()) {
1254
+ this.grid().selectedRows = this.vm.selectedItems();
1255
+ }
1256
+ });
1257
+ //
1258
+ this.vm.events$.subscribe(async (e) => {
1259
+ const refreshTargetId = e.meta?.refreshTargetId;
1260
+ if (e.action == 'refresh') {
1261
+ if (refreshTargetId) {
1262
+ this.grid()?.refreshItemChildren(refreshTargetId);
1263
+ }
1264
+ else {
1265
+ this.grid()?.refresh({
1266
+ reset: false,
1267
+ });
1268
+ }
1269
+ }
1270
+ });
1271
+ // Keep URL query param `view` in sync with current vm view
1272
+ effect(() => {
1273
+ if (!this.initializedFromRoute) {
1274
+ return;
1275
+ }
1276
+ const currentViewName = this.vm.view().name;
1277
+ const urlView = this.activeRoute.snapshot.queryParamMap.get('view');
1278
+ if (currentViewName && currentViewName !== urlView) {
1279
+ this.router.navigate([], {
1280
+ relativeTo: this.activeRoute,
1281
+ queryParams: { view: currentViewName },
1282
+ queryParamsHandling: 'merge',
1283
+ replaceUrl: true,
1284
+ });
1285
+ }
1286
+ });
1287
+ }
1288
+ async ngOnInit() {
1289
+ // React to external URL changes (back/forward navigation or deep links)
1290
+ this.queryParamSub = this.activeRoute.queryParamMap.subscribe(async (qp) => {
1291
+ const viewFromUrl = qp.get('view');
1292
+ await this.vm.setView(viewFromUrl);
1293
+ });
1294
+ }
1295
+ async ngAfterViewInit() {
1296
+ const viewFromUrl = this.activeRoute.snapshot.queryParamMap.get('view');
1297
+ await this.vm.setView(viewFromUrl);
1298
+ const resolvedView = this.vm.view().name;
1299
+ const currentUrlView = this.activeRoute.snapshot.queryParamMap.get('view');
1300
+ if (currentUrlView !== resolvedView) {
1301
+ this.router.navigate([], {
1302
+ relativeTo: this.activeRoute,
1303
+ queryParams: { view: resolvedView },
1304
+ queryParamsHandling: 'merge',
1305
+ replaceUrl: true,
1306
+ });
1307
+ }
1308
+ this.initializedFromRoute = true;
1309
+ }
1310
+ onColumnSizeChanged(e) {
1311
+ if (e.isUserInteraction && e.type === 'end') {
1312
+ this.vm.saveSettings('columnSizes', e.data);
1313
+ }
1314
+ }
1315
+ onPageChanged(e) {
1316
+ if (e.isUserInteraction) {
1317
+ const pageSizeChanged = e.take != this.vm.dataSource.pageSize;
1318
+ if (pageSizeChanged) {
1319
+ this.vm.saveSettings('pageSize', e.take);
1320
+ }
1321
+ }
1322
+ }
1323
+ onColumnsOrderChanged(e) {
1324
+ if (e.isUserInteraction) {
1325
+ this.vm.onColumnsOrderChanged(e.data.event);
1326
+ }
1327
+ }
1328
+ async dropdownRowItems(rowData) {
1329
+ return (await this.vm.secondaryRowActions(rowData)).map((c) => ({
1330
+ icon: c.icon,
1331
+ name: c.name,
1332
+ text: c.title,
1333
+ color: c.color,
1334
+ disabled: c.disabled,
1335
+ default: c.default,
1336
+ divided: c.separated,
1337
+ }));
1338
+ }
1339
+ async handleRowDbClick(e) {
1340
+ if (this.grid()?.dataSource.isLoading) {
1341
+ return;
1342
+ }
1343
+ const allItems = [...this.commandRowItems(), ...(await this.dropdownRowItems(e.data))];
1344
+ // const defaultAction = allItems.find((c) => (c as any).default) || allItems[0];
1345
+ const defaultAction = allItems.find((c) => {
1346
+ const commandName = c.name.split('&')[0];
1347
+ return (c.default || commandName === 'open-entity') && !c.disabled;
1348
+ });
1349
+ if (!defaultAction) {
1350
+ return;
1351
+ }
1352
+ const d = {
1353
+ component: e.component,
1354
+ name: defaultAction.name,
1355
+ data: e.data,
1356
+ };
1357
+ this.handleRowCommandClick(d);
1358
+ }
1359
+ async handleRowCommandClick(e) {
1360
+ if (this.grid()?.dataSource.isLoading) {
1361
+ return;
1362
+ }
1363
+ if (e.setLoading) {
1364
+ e.setLoading(true);
1365
+ }
1366
+ await this.vm.executeCommand(e.name, e.data);
1367
+ if (e.setLoading) {
1368
+ e.setLoading(false);
1369
+ }
1370
+ }
1371
+ async handleSelectedRowsChange(rows) {
1372
+ this.vm.selectedItems.set(rows);
1373
+ }
1374
+ makeResponsive(value) {
1375
+ if (this.platform.is('Mobile') || this.platform.is('SM')) {
1376
+ return '';
1377
+ }
1378
+ else {
1379
+ return value;
1380
+ }
1381
+ }
1382
+ toggleSideBar(sideBar) {
1383
+ this.toggleEndSide();
1384
+ if (sideBar) {
1385
+ this.activeEndSideView.set(sideBar);
1386
+ }
1387
+ }
1388
+ toggleSearchBar() {
1389
+ this.searchBarShown.update((v) => !v);
1390
+ }
1391
+ handleResetClick(sideBar) {
1392
+ switch (sideBar) {
1393
+ case 'filter': {
1394
+ this.vm.resetFilters();
1395
+ break;
1396
+ }
1397
+ case 'sort': {
1398
+ this.vm.resetSorts();
1399
+ break;
1400
+ }
1401
+ case 'column': {
1402
+ this.vm.resetColumns();
1403
+ break;
1404
+ }
1405
+ }
1406
+ }
1407
+ // protected handleDiscardClick(sideBar: 'filter' | 'sort' | 'column') {
1408
+ // switch (sideBar) {
1409
+ // case 'filter': {
1410
+ // this.vm.discardFilters();
1411
+ // break;
1412
+ // }
1413
+ // case 'sort': {
1414
+ // this.vm.resetSorts();
1415
+ // break;
1416
+ // }
1417
+ // case 'column': {
1418
+ // this.vm.resetColumns();
1419
+ // break;
1420
+ // }
1421
+ // }
1422
+ // }
1423
+ handleApplyClick(sideBar) {
1424
+ this.vm.applyFilterAndSort();
1425
+ this.toggleEndSide();
1426
+ }
1427
+ ngOnDestroy() {
1428
+ this.queryParamSub?.unsubscribe();
1429
+ this.vm.destroy();
1430
+ }
1431
+ toggleCategoryDrawer() {
1432
+ this.toggleStartSide();
1433
+ }
1434
+ getPageTitle() {
1435
+ return this.vm.title();
1436
+ }
1437
+ async getPageDescription() {
1438
+ const description = this.vm.description();
1439
+ if (description) {
1440
+ return this.translateService.translateAsync(description);
1441
+ }
1442
+ return '';
1443
+ }
1444
+ getPageBreadcrumbs() {
1445
+ return this.vm.beardcrumbs();
1446
+ }
1447
+ async getPrimaryMenuItems() {
1448
+ return (await this.vm.getPrimaryActions()).map((tr) => ({
1449
+ name: tr.name,
1450
+ title: tr.title,
1451
+ icon: tr.icon,
1452
+ color: tr.color,
1453
+ disabled: tr.disabled,
1454
+ command: {
1455
+ name: tr.name,
1456
+ options: tr.options,
1457
+ metadata: tr.metadata,
1458
+ },
1459
+ }));
1460
+ }
1461
+ async getSecondaryMenuItems() {
1462
+ return (await this.vm.getSecondaryActions()).map((tr) => ({
1463
+ name: tr.name,
1464
+ title: tr.title,
1465
+ icon: tr.icon,
1466
+ color: tr.color,
1467
+ disabled: tr.disabled,
1468
+ separated: tr.separated,
1469
+ command: {
1470
+ name: tr.name,
1471
+ options: tr.options,
1472
+ metadata: tr.metadata,
1473
+ },
1474
+ }));
1475
+ }
1476
+ async execute(command) {
1477
+ if (command) {
1478
+ this.vm.execute(command);
1479
+ }
1480
+ }
1481
+ handleUnselectAll() {
1482
+ this.vm.selectedItems.set([]);
1483
+ }
1484
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: AXPEntityMasterListViewComponent, deps: [{ token: i1$1.AXPlatform }], target: i0.ɵɵFactoryTarget.Component }); }
1485
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.12", type: AXPEntityMasterListViewComponent, isStandalone: true, selector: "axp-entity-master-list", providers: [
1486
+ {
1487
+ provide: AXPPageLayoutBase,
1488
+ useExisting: AXPEntityMasterListViewComponent,
1489
+ },
1490
+ ], viewQueries: [{ propertyName: "grid", first: true, predicate: ["grid"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<axp-page-layout *translate=\"let t\">\n @if (vm.entityDef.category) {\n <axp-layout-start-side id=\"axp-entity-category-drawer\">\n <axp-entity-category\n id=\"axp-entity-category\"\n class=\"ax-w-80\"\n [vm]=\"vm\"\n [searchValue]=\"categorySearchValue()\"\n ></axp-entity-category>\n </axp-layout-start-side>\n }\n <axp-page-toolbar id=\"axp-entity-toolbar\">\n <axp-entity-master-toolbar-view [viewModel]=\"vm\"></axp-entity-master-toolbar-view>\n </axp-page-toolbar>\n <axp-page-content class=\"ax-overflow-auto ax-pt-0\">\n <div\n class=\"ax-flex ax-items-center ax-justify-between ax-gap-1 ax-pb-1\"\n [class.ax-invisible]=\"!grid.selectedRows.length\"\n >\n <span\n >{{ grid.selectedRows.length }}\n <span>{{ '@general:terms.interface.items-selected' | translate | async }}</span>\n </span>\n <ax-button text=\"@general:terms.interface.unselect-all\" class=\"ax-xs\" (onClick)=\"handleUnselectAll()\"></ax-button>\n </div>\n <ax-data-table\n id=\"axp-entity-table\"\n [allowReordering]=\"true\"\n (onColumnsOrderChanged)=\"onColumnsOrderChanged($event)\"\n #grid\n [showFooter]=\"false\"\n class=\"ax-flex-1\"\n [paging]=\"true\"\n [fetchDataMode]=\"'manual'\"\n [parentField]=\"vm.parentKey()\"\n [loading]=\"{ enabled: true, animation: true }\"\n [dataSource]=\"vm.dataSource\"\n (selectedRowsChange)=\"handleSelectedRowsChange($event)\"\n (onRowDbClick)=\"handleRowDbClick($event)\"\n (onColumnSizeChanged)=\"onColumnSizeChanged($event)\"\n (onPageChanged)=\"onPageChanged($event)\"\n >\n @if (vm.view().indexCol === true) {\n <ax-index-column id=\"axp-table-col-index\" fixed=\"start\" [width]=\"'80px'\" [padZero]=\"true\"></ax-index-column>\n }\n @if (vm.selectedScopeActionsCount()) {\n <ax-select-column id=\"axp-table-col-select\" fixed=\"start\" [width]=\"'60px'\"></ax-select-column>\n }\n @for (col of vm.columns(); track col.name) {\n @if (col.visible) {\n <axp-widget-column-renderer\n [attr.id]=\"'axp-table-col-' + col.name\"\n [expandHandler]=\"$index === 0 && vm.parentKey() ? true : false\"\n [caption]=\"(col.title | translate | async)!\"\n [node]=\"col.node()\"\n [customWidth]=\"col.width\"\n ></axp-widget-column-renderer>\n }\n }\n @if (getCommandRowItems().length) {\n <ax-command-column\n id=\"axp-table-col-commands\"\n fixed=\"end\"\n [width]=\"getCommandRowItems().length * 70 + 'px'\"\n [items]=\"getCommandRowItems()\"\n (onItemClick)=\"handleRowCommandClick($event)\"\n ></ax-command-column>\n }\n <ax-dropdown-command-column\n id=\"axp-table-col-dropdown-commands\"\n fixed=\"end\"\n [width]=\"'60px'\"\n [items]=\"getDropdownRowItems\"\n (onItemClick)=\"handleRowCommandClick($event)\"\n ></ax-dropdown-command-column>\n </ax-data-table>\n </axp-page-content>\n</axp-page-layout>\n", styles: ["axp-entity-master-list axp-layout-start-side{min-width:20rem!important;border-inline-end-width:1px;background-color:rgb(var(--ax-sys-color-lightest-surface));color:rgb(var(--ax-sys-color-on-lightest-surface));border-color:rgb(var(--ax-sys-color-border-lightest-surface))}axp-entity-master-list axp-layout-header{padding-bottom:.25rem!important}.cdk-drag-preview{border-radius:.375rem;border-width:1px;--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow);background:rgba(var(--ax-color-on-surface));padding:.5rem;height:max-content!important}.collapsed-search-box{margin-top:0;height:0px;opacity:0}.view-drawer{width:85vw}@media (min-width: 768px){.view-drawer{width:45vw}}@media (min-width: 1024px){.view-drawer{width:35vw}}@media (min-width: 1536px){.view-drawer{width:20vw}}.view-drawer{--tw-bg-opacity: 1;background-color:rgba(var(--ax-sys-color-lightest-surface),var(--tw-bg-opacity, 1));border-inline-start-width:1px;border-inline-start-color:rgba(var(--ax-sys-color-border-lightest-surface),var(--tw-border-opacity, 1));border-top-width:1px;--tw-border-opacity: 1;border-top-color:rgba(var(--ax-sys-color-primary-600),var(--tw-border-opacity, 1))}.view-drawer ax-header{display:flex;align-items:center;border-bottom-width:1px;--tw-border-opacity: 1;border-color:rgba(var(--ax-sys-color-border-lightest-surface),var(--tw-border-opacity, 1));--tw-bg-opacity: 1;background-color:rgba(var(--ax-sys-color-lighter-surface),var(--tw-bg-opacity, 1));padding:.5rem 1rem}.view-drawer ax-header h2{font-size:1.25rem;line-height:1.75rem;font-weight:700;--tw-text-opacity: 1;color:rgba(var(--ax-sys-color-on-lighter-surface),var(--tw-text-opacity, 1))}.view-drawer ax-footer{position:absolute!important;bottom:0!important;width:100%!important;justify-content:flex-start!important;border-top-width:1px!important;--tw-border-opacity: 1 !important;border-color:rgba(var(--ax-sys-color-border-lightest-surface),var(--tw-border-opacity, 1))!important;padding:.5rem 1rem!important}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: FormsModule }, { kind: "ngmodule", type: RouterModule }, { kind: "ngmodule", type: AXButtonModule }, { kind: "component", type: i3.AXButtonComponent, selector: "ax-button", inputs: ["disabled", "size", "tabIndex", "color", "look", "text", "toggleable", "selected", "iconOnly", "type", "loadingText"], outputs: ["onBlur", "onFocus", "onClick", "selectedChange", "toggleableChange", "lookChange", "colorChange", "disabledChange", "loadingTextChange"] }, { kind: "ngmodule", type: AXDecoratorModule }, { kind: "ngmodule", type: AXBadgeModule }, { kind: "ngmodule", type: AXDropdownModule }, { kind: "ngmodule", type: AXPopoverModule }, { kind: "ngmodule", type: AXFormModule }, { kind: "ngmodule", type: AXActionSheetModule }, { kind: "ngmodule", type: AXDrawerModule }, { kind: "ngmodule", type: AXDialogModule }, { kind: "ngmodule", type: AXLoadingModule }, { kind: "ngmodule", type: AXTabsModule }, { kind: "ngmodule", type: AXTooltipModule }, { kind: "ngmodule", type: AXBreadcrumbsModule }, { kind: "ngmodule", type: AXDropdownButtonModule }, { kind: "ngmodule", type: AXSearchBoxModule }, { kind: "ngmodule", type: AXDataTableModule }, { kind: "component", type: i7.AXDataTableComponent, selector: "ax-data-table", inputs: ["dataSource", "selectedRows", "parentField", "rowDetailsTemplate", "rowTemplate", "emptyTemplate", "noDataTemplate", "alternative", "showHeader", "fixedHeader", "showFooter", "fixedFooter", "itemHeight", "allowReordering", "paging", "fetchDataMode", "loading", "focusedRow"], outputs: ["selectedRowsChange", "focusedRowChange", "onRowClick", "onRowDbClick", "onColumnsOrderChanged", "onColumnSizeChanged", "onPageChanged"] }, { kind: "component", type: i7.AXRowIndexColumnComponent, selector: "ax-index-column", inputs: ["width", "caption", "fixed", "footerTemplate", "padZero"] }, { kind: "component", type: i7.AXRowSelectColumnComponent, selector: "ax-select-column", inputs: ["width", "caption", "fixed"] }, { kind: "component", type: i7.AXRowCommandColumnComponent, selector: "ax-command-column", inputs: ["width", "caption", "fixed", "footerTemplate", "items"], outputs: ["onItemClick"] }, { kind: "component", type: i7.AXRowDropdownCommandColumnComponent, selector: "ax-dropdown-command-column", inputs: ["width", "caption", "fixed", "footerTemplate", "emptyStateTemplate", "emptyStateText", "items"], outputs: ["onItemClick"] }, { kind: "ngmodule", type: AXTranslationModule }, { kind: "directive", type: i10.AXTranslatorDirective, selector: "[translate]" }, { kind: "ngmodule", type: DragDropModule }, { kind: "ngmodule", type:
1491
+ //
1492
+ AXPWidgetCoreModule }, { kind: "component", type: i7$1.AXPWidgetColumnRendererComponent, selector: "axp-widget-column-renderer", inputs: ["caption", "customExpandIcon", "customCollapseIcon", "customWidth", "node", "footerTemplate", "expandHandler", "cellTemplate", "headerTemplate"] }, { kind: "ngmodule", type: AXPWidgetsModule }, { kind: "ngmodule", type: AXPAuthModule }, { kind: "component", type:
1493
+ //
1494
+ AXPEntityMasterToolbarViewComponent, selector: "axp-entity-master-toolbar-view", inputs: ["viewModel"] }, { kind: "component", type:
1495
+ //
1496
+ AXPPageLayoutComponent, selector: "axp-page-layout" }, { kind: "component", type: AXPThemeLayoutBlockComponent, selector: " axp-page-content, axp-page-footer-container, axp-page-footer, axp-page-header, axp-page-header-container, axp-page-toolbar, axp-layout-content, axp-layout-page-content, axp-layout-sections, axp-layout-body, axp-layout-page-body, axp-layout-prefix, axp-layout-suffix, axp-layout-title-bar, axp-layout-title, axp-layout-title-actions, axp-layout-nav-button, axp-layout-description, axp-layout-breadcrumbs, axp-layout-list-action, " }, { kind: "component", type: AXPThemeLayoutStartSideComponent, selector: "axp-layout-page-start-side, axp-layout-start-side" }, { kind: "component", type: AXPEntityCategoryComponent, selector: "axp-entity-category", inputs: ["vm", "searchValue", "selectMode", "selectionBehavior", "dragArea", "dragBehavior", "showIcons", "showChildrenBadge", "expandedIcon", "collapsedIcon", "indentSize", "look", "searchWithChildren"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }, { kind: "pipe", type: i10.AXTranslatorPipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
1497
+ }
1498
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: AXPEntityMasterListViewComponent, decorators: [{
1499
+ type: Component,
1500
+ args: [{ selector: 'axp-entity-master-list', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, imports: [
1501
+ CommonModule,
1502
+ FormsModule,
1503
+ RouterModule,
1504
+ AXButtonModule,
1505
+ AXDecoratorModule,
1506
+ AXBadgeModule,
1507
+ AXDropdownModule,
1508
+ AXPopoverModule,
1509
+ AXFormModule,
1510
+ AXActionSheetModule,
1511
+ AXDrawerModule,
1512
+ AXDialogModule,
1513
+ AXLoadingModule,
1514
+ AXTabsModule,
1515
+ AXTooltipModule,
1516
+ AXBreadcrumbsModule,
1517
+ AXDropdownButtonModule,
1518
+ AXSearchBoxModule,
1519
+ AXDataTableModule,
1520
+ AXTranslationModule,
1521
+ DragDropModule,
1522
+ //
1523
+ AXPWidgetCoreModule,
1524
+ AXPWidgetsModule,
1525
+ AXPAuthModule,
1526
+ //
1527
+ AXPEntityMasterToolbarViewComponent,
1528
+ //
1529
+ AXPPageLayoutComponent,
1530
+ AXPThemeLayoutBlockComponent,
1531
+ AXDropdownButtonModule,
1532
+ AXPThemeLayoutStartSideComponent,
1533
+ AXPEntityCategoryComponent,
1534
+ ], providers: [
1535
+ {
1536
+ provide: AXPPageLayoutBase,
1537
+ useExisting: AXPEntityMasterListViewComponent,
1538
+ },
1539
+ ], template: "<axp-page-layout *translate=\"let t\">\n @if (vm.entityDef.category) {\n <axp-layout-start-side id=\"axp-entity-category-drawer\">\n <axp-entity-category\n id=\"axp-entity-category\"\n class=\"ax-w-80\"\n [vm]=\"vm\"\n [searchValue]=\"categorySearchValue()\"\n ></axp-entity-category>\n </axp-layout-start-side>\n }\n <axp-page-toolbar id=\"axp-entity-toolbar\">\n <axp-entity-master-toolbar-view [viewModel]=\"vm\"></axp-entity-master-toolbar-view>\n </axp-page-toolbar>\n <axp-page-content class=\"ax-overflow-auto ax-pt-0\">\n <div\n class=\"ax-flex ax-items-center ax-justify-between ax-gap-1 ax-pb-1\"\n [class.ax-invisible]=\"!grid.selectedRows.length\"\n >\n <span\n >{{ grid.selectedRows.length }}\n <span>{{ '@general:terms.interface.items-selected' | translate | async }}</span>\n </span>\n <ax-button text=\"@general:terms.interface.unselect-all\" class=\"ax-xs\" (onClick)=\"handleUnselectAll()\"></ax-button>\n </div>\n <ax-data-table\n id=\"axp-entity-table\"\n [allowReordering]=\"true\"\n (onColumnsOrderChanged)=\"onColumnsOrderChanged($event)\"\n #grid\n [showFooter]=\"false\"\n class=\"ax-flex-1\"\n [paging]=\"true\"\n [fetchDataMode]=\"'manual'\"\n [parentField]=\"vm.parentKey()\"\n [loading]=\"{ enabled: true, animation: true }\"\n [dataSource]=\"vm.dataSource\"\n (selectedRowsChange)=\"handleSelectedRowsChange($event)\"\n (onRowDbClick)=\"handleRowDbClick($event)\"\n (onColumnSizeChanged)=\"onColumnSizeChanged($event)\"\n (onPageChanged)=\"onPageChanged($event)\"\n >\n @if (vm.view().indexCol === true) {\n <ax-index-column id=\"axp-table-col-index\" fixed=\"start\" [width]=\"'80px'\" [padZero]=\"true\"></ax-index-column>\n }\n @if (vm.selectedScopeActionsCount()) {\n <ax-select-column id=\"axp-table-col-select\" fixed=\"start\" [width]=\"'60px'\"></ax-select-column>\n }\n @for (col of vm.columns(); track col.name) {\n @if (col.visible) {\n <axp-widget-column-renderer\n [attr.id]=\"'axp-table-col-' + col.name\"\n [expandHandler]=\"$index === 0 && vm.parentKey() ? true : false\"\n [caption]=\"(col.title | translate | async)!\"\n [node]=\"col.node()\"\n [customWidth]=\"col.width\"\n ></axp-widget-column-renderer>\n }\n }\n @if (getCommandRowItems().length) {\n <ax-command-column\n id=\"axp-table-col-commands\"\n fixed=\"end\"\n [width]=\"getCommandRowItems().length * 70 + 'px'\"\n [items]=\"getCommandRowItems()\"\n (onItemClick)=\"handleRowCommandClick($event)\"\n ></ax-command-column>\n }\n <ax-dropdown-command-column\n id=\"axp-table-col-dropdown-commands\"\n fixed=\"end\"\n [width]=\"'60px'\"\n [items]=\"getDropdownRowItems\"\n (onItemClick)=\"handleRowCommandClick($event)\"\n ></ax-dropdown-command-column>\n </ax-data-table>\n </axp-page-content>\n</axp-page-layout>\n", styles: ["axp-entity-master-list axp-layout-start-side{min-width:20rem!important;border-inline-end-width:1px;background-color:rgb(var(--ax-sys-color-lightest-surface));color:rgb(var(--ax-sys-color-on-lightest-surface));border-color:rgb(var(--ax-sys-color-border-lightest-surface))}axp-entity-master-list axp-layout-header{padding-bottom:.25rem!important}.cdk-drag-preview{border-radius:.375rem;border-width:1px;--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow);background:rgba(var(--ax-color-on-surface));padding:.5rem;height:max-content!important}.collapsed-search-box{margin-top:0;height:0px;opacity:0}.view-drawer{width:85vw}@media (min-width: 768px){.view-drawer{width:45vw}}@media (min-width: 1024px){.view-drawer{width:35vw}}@media (min-width: 1536px){.view-drawer{width:20vw}}.view-drawer{--tw-bg-opacity: 1;background-color:rgba(var(--ax-sys-color-lightest-surface),var(--tw-bg-opacity, 1));border-inline-start-width:1px;border-inline-start-color:rgba(var(--ax-sys-color-border-lightest-surface),var(--tw-border-opacity, 1));border-top-width:1px;--tw-border-opacity: 1;border-top-color:rgba(var(--ax-sys-color-primary-600),var(--tw-border-opacity, 1))}.view-drawer ax-header{display:flex;align-items:center;border-bottom-width:1px;--tw-border-opacity: 1;border-color:rgba(var(--ax-sys-color-border-lightest-surface),var(--tw-border-opacity, 1));--tw-bg-opacity: 1;background-color:rgba(var(--ax-sys-color-lighter-surface),var(--tw-bg-opacity, 1));padding:.5rem 1rem}.view-drawer ax-header h2{font-size:1.25rem;line-height:1.75rem;font-weight:700;--tw-text-opacity: 1;color:rgba(var(--ax-sys-color-on-lighter-surface),var(--tw-text-opacity, 1))}.view-drawer ax-footer{position:absolute!important;bottom:0!important;width:100%!important;justify-content:flex-start!important;border-top-width:1px!important;--tw-border-opacity: 1 !important;border-color:rgba(var(--ax-sys-color-border-lightest-surface),var(--tw-border-opacity, 1))!important;padding:.5rem 1rem!important}\n"] }]
1540
+ }], ctorParameters: () => [{ type: i1$1.AXPlatform }], propDecorators: { grid: [{ type: i0.ViewChild, args: ['grid', { isSignal: true }] }] } });
1541
+
1542
+ export { AXPEntityMasterListViewComponent };
1543
+ //# sourceMappingURL=acorex-platform-themes-default-entity-master-list-view.component-Cym8pq0v.mjs.map