@acorex/platform 20.7.21 → 20.7.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,14 @@
1
1
  import { AXToastService } from '@acorex/components/toast';
2
2
  import * as i6 from '@acorex/core/translation';
3
3
  import { AXTranslationService, AXTranslationModule } from '@acorex/core/translation';
4
+ import * as i4$1 from '@acorex/platform/common';
5
+ import { AXPSettingsService, AXPCommonSettings, AXPFilterOperatorMiddlewareService, AXPEntityCommandScope, getEntityInfo, AXPRefreshEvent, AXPReloadEvent, AXPEntityQueryType, AXPCleanNestedFilters, AXPWorkflowNavigateAction, AXPToastAction, AXP_SEARCH_DEFINITION_PROVIDER } from '@acorex/platform/common';
4
6
  import * as i0 from '@angular/core';
5
7
  import { InjectionToken, inject, Injector, runInInjectionContext, Injectable, input, viewChild, signal, ElementRef, ChangeDetectionStrategy, Component, ApplicationRef, EnvironmentInjector, createComponent, computed, ChangeDetectorRef, effect, Input, afterNextRender, untracked, ViewEncapsulation, viewChildren, linkedSignal, HostBinding, output, NgModule } from '@angular/core';
6
8
  import { Subject, takeUntil } from 'rxjs';
7
9
  import { AXPLayoutBuilderService } from '@acorex/platform/layout/builder';
8
10
  import { AXPDeviceService, AXPBroadcastEventService, applyFilterArray, applySortArray, resolveActionLook, AXPExpressionEvaluatorService, AXPDistributedEventListenerService, AXPPlatformScope, AXPColumnWidthService, AXHighlightService, extractValue, setSmart, getChangedPaths, defaultColumnWidthProvider, AXP_COLUMN_WIDTH_PROVIDER, AXP_DATASOURCE_DEFINITION_PROVIDER, AXPSystemActionType } from '@acorex/platform/core';
9
11
  import { merge, castArray, get, cloneDeep, set, orderBy, isNil, isEmpty, isEqual } from 'lodash-es';
10
- import * as i4$1 from '@acorex/platform/common';
11
- import { AXPSettingsService, AXPFilterOperatorMiddlewareService, AXPEntityCommandScope, getEntityInfo, AXPRefreshEvent, AXPReloadEvent, AXPCommonSettings, AXPEntityQueryType, AXPCleanNestedFilters, AXPWorkflowNavigateAction, AXPToastAction, AXP_SEARCH_DEFINITION_PROVIDER } from '@acorex/platform/common';
12
12
  import { AXPSessionService, AXPAuthGuard } from '@acorex/platform/auth';
13
13
  import { Router, RouterModule, ROUTES } from '@angular/router';
14
14
  import * as i3 from '@acorex/components/button';
@@ -53,7 +53,7 @@ import { AXFormModule } from '@acorex/components/form';
53
53
  import * as i6$1 from '@acorex/components/tag-box';
54
54
  import { AXTagBoxModule } from '@acorex/components/tag-box';
55
55
  import { AXValidationModule } from '@acorex/core/validation';
56
- import { AXP_DISABLED_PROPERTY, AXP_ALLOW_CLEAR_PROPERTY, AXP_DATA_PATH_PROPERTY, AXP_DATA_PROPERTY_GROUP, AXP_ALLOW_MULTIPLE_PROPERTY, AXP_NAME_PROPERTY, AXPFileUploaderWidgetService } from '@acorex/platform/layout/widgets';
56
+ import { AXP_DISABLED_PROPERTY, AXP_ALLOW_CLEAR_PROPERTY, AXP_DATA_PATH_PROPERTY, AXP_DATA_PROPERTY_GROUP, AXP_ALLOW_MULTIPLE_PROPERTY, AXP_ROW_EXPR_PREFIX, AXP_NAME_PROPERTY, AXPFileUploaderWidgetService } from '@acorex/platform/layout/widgets';
57
57
  import * as i4$3 from '@acorex/components/dropdown';
58
58
  import { AXDropdownModule } from '@acorex/components/dropdown';
59
59
  import * as i4$4 from '@acorex/components/select-box';
@@ -1364,12 +1364,80 @@ function sortMergedSections(mainSections, extraSections, mainSectionIds) {
1364
1364
  return [...beforeSections, ...sortedMiddleBlock, ...afterSections];
1365
1365
  }
1366
1366
 
1367
+ //#endregion
1368
+ //#region ---- Entity Open Details Command ----
1369
+ /**
1370
+ * Generic command to open entity details view
1371
+ * Can be used by any entity to navigate to its detail page
1372
+ */
1373
+ class AXPOpenEntityDetailsCommand {
1374
+ constructor() {
1375
+ //#endregion
1376
+ //#region ---- Services & Dependencies ----
1377
+ this.router = inject(Router);
1378
+ this.sessionService = inject(AXPSessionService);
1379
+ }
1380
+ //#endregion
1381
+ //#region ---- Command Execution ----
1382
+ /**
1383
+ * Execute the command to navigate to entity details
1384
+ * @param input - Command input containing entity and data information
1385
+ */
1386
+ async execute(input) {
1387
+ const { entity, data } = input;
1388
+ if (!entity) {
1389
+ return {
1390
+ success: false,
1391
+ message: {
1392
+ text: 'Entity name is required for opening details view',
1393
+ },
1394
+ };
1395
+ }
1396
+ if (!data?.id) {
1397
+ return {
1398
+ success: false,
1399
+ message: {
1400
+ text: 'Entity ID is required for opening details view',
1401
+ },
1402
+ };
1403
+ }
1404
+ const [module, entityName] = entity.split('.');
1405
+ if (!module || !entityName) {
1406
+ return {
1407
+ success: false,
1408
+ message: {
1409
+ text: 'Entity must be in format "ModuleName.EntityName"',
1410
+ },
1411
+ };
1412
+ }
1413
+ const url = `/${this.sessionService.application?.name}/m/${module}/e/${entityName}/${data.id}/view`;
1414
+ // Navigate to the entity details page
1415
+ this.router.navigate([url]);
1416
+ return {
1417
+ success: true,
1418
+ };
1419
+ }
1420
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: AXPOpenEntityDetailsCommand, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1421
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: AXPOpenEntityDetailsCommand, providedIn: 'root' }); }
1422
+ }
1423
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: AXPOpenEntityDetailsCommand, decorators: [{
1424
+ type: Injectable,
1425
+ args: [{ providedIn: 'root' }]
1426
+ }] });
1427
+
1428
+ var openEntityDetails_command = /*#__PURE__*/Object.freeze({
1429
+ __proto__: null,
1430
+ AXPOpenEntityDetailsCommand: AXPOpenEntityDetailsCommand
1431
+ });
1432
+
1367
1433
  class AXPCreateEntityCommand {
1368
1434
  constructor() {
1369
1435
  this.entityForm = inject(AXPEntityFormBuilderService);
1370
1436
  this.entityService = inject(AXPEntityDefinitionRegistryService);
1371
1437
  this.toastService = inject(AXToastService);
1372
1438
  this.translationService = inject(AXTranslationService);
1439
+ this.settingsService = inject(AXPSettingsService);
1440
+ this.openEntityDetailsCommand = inject(AXPOpenEntityDetailsCommand);
1373
1441
  this.context = {};
1374
1442
  }
1375
1443
  async execute(input) {
@@ -1468,7 +1536,22 @@ class AXPCreateEntityCommand {
1468
1536
  }
1469
1537
  })
1470
1538
  .show();
1471
- return result;
1539
+ const commandResult = result;
1540
+ const redirectOption = options?.process?.redirect;
1541
+ const shouldRedirect = redirectOption !== undefined
1542
+ ? redirectOption
1543
+ : await this.settingsService.get(AXPCommonSettings.RedirectToDetailsAfterCreate);
1544
+ if (commandResult.success && shouldRedirect && commandResult.data) {
1545
+ const createdItem = commandResult.data?.item ?? commandResult.data;
1546
+ const createdId = createdItem?.id;
1547
+ if (createdId != null) {
1548
+ await this.openEntityDetailsCommand.execute({
1549
+ entity: `${moduleName}.${entityName}`,
1550
+ data: { id: String(createdId) },
1551
+ });
1552
+ }
1553
+ }
1554
+ return commandResult;
1472
1555
  }
1473
1556
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: AXPCreateEntityCommand, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1474
1557
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: AXPCreateEntityCommand, providedIn: 'root' }); }
@@ -1709,72 +1792,6 @@ var viewEntityDetails_command = /*#__PURE__*/Object.freeze({
1709
1792
  AXPViewEntityDetailsCommand: AXPViewEntityDetailsCommand
1710
1793
  });
1711
1794
 
1712
- //#endregion
1713
- //#region ---- Entity Open Details Command ----
1714
- /**
1715
- * Generic command to open entity details view
1716
- * Can be used by any entity to navigate to its detail page
1717
- */
1718
- class AXPOpenEntityDetailsCommand {
1719
- constructor() {
1720
- //#endregion
1721
- //#region ---- Services & Dependencies ----
1722
- this.router = inject(Router);
1723
- this.sessionService = inject(AXPSessionService);
1724
- }
1725
- //#endregion
1726
- //#region ---- Command Execution ----
1727
- /**
1728
- * Execute the command to navigate to entity details
1729
- * @param input - Command input containing entity and data information
1730
- */
1731
- async execute(input) {
1732
- const { entity, data } = input;
1733
- if (!entity) {
1734
- return {
1735
- success: false,
1736
- message: {
1737
- text: 'Entity name is required for opening details view',
1738
- },
1739
- };
1740
- }
1741
- if (!data?.id) {
1742
- return {
1743
- success: false,
1744
- message: {
1745
- text: 'Entity ID is required for opening details view',
1746
- },
1747
- };
1748
- }
1749
- const [module, entityName] = entity.split('.');
1750
- if (!module || !entityName) {
1751
- return {
1752
- success: false,
1753
- message: {
1754
- text: 'Entity must be in format "ModuleName.EntityName"',
1755
- },
1756
- };
1757
- }
1758
- const url = `/${this.sessionService.application?.name}/m/${module}/e/${entityName}/${data.id}/view`;
1759
- // Navigate to the entity details page
1760
- this.router.navigate([url]);
1761
- return {
1762
- success: true,
1763
- };
1764
- }
1765
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: AXPOpenEntityDetailsCommand, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1766
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: AXPOpenEntityDetailsCommand, providedIn: 'root' }); }
1767
- }
1768
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: AXPOpenEntityDetailsCommand, decorators: [{
1769
- type: Injectable,
1770
- args: [{ providedIn: 'root' }]
1771
- }] });
1772
-
1773
- var openEntityDetails_command = /*#__PURE__*/Object.freeze({
1774
- __proto__: null,
1775
- AXPOpenEntityDetailsCommand: AXPOpenEntityDetailsCommand
1776
- });
1777
-
1778
1795
  class AXPEntityDetailPopoverComponent {
1779
1796
  constructor() {
1780
1797
  //#region ---- Dependencies ----
@@ -5145,7 +5162,8 @@ class AXPPageListConverter extends AXPBaseRelatedEntityConverter {
5145
5162
  return {
5146
5163
  ...a,
5147
5164
  zone: 'header',
5148
- visible: !a.hidden,
5165
+ // visible: !a.hidden,
5166
+ hidden: a.hidden,
5149
5167
  priority: 'primary',
5150
5168
  name: a.name,
5151
5169
  title: a.title,
@@ -5293,7 +5311,7 @@ class AXPPageListConverter extends AXPBaseRelatedEntityConverter {
5293
5311
  return !usedOverrideActions.has(actionKey);
5294
5312
  })
5295
5313
  .map((action) => new AXPEntityCommandTriggerViewModel(entityDef, action));
5296
- return [...additionalActions, ...mergedActions].filter((a) => !a.hidden);
5314
+ return [...additionalActions, ...mergedActions];
5297
5315
  }
5298
5316
  }
5299
5317
 
@@ -10801,6 +10819,7 @@ class AXPEntityListTableService {
10801
10819
  // 🎪 Events
10802
10820
  ...this.createDefaultEvents(entity, allActions),
10803
10821
  };
10822
+ console.log('listOptions', listOptions);
10804
10823
  return listOptions;
10805
10824
  }
10806
10825
  //#endregion
@@ -10849,18 +10868,28 @@ class AXPEntityListTableService {
10849
10868
  createRowCommands(actions, priority) {
10850
10869
  return actions
10851
10870
  .filter((action) => action.scope === AXPEntityCommandScope.Individual && // Only individual actions
10852
- action.priority === priority && // Matching priority
10853
- !action.hidden)
10871
+ action.priority === priority)
10854
10872
  .map((action) => ({
10855
10873
  name: action.name,
10856
10874
  text: action.title,
10857
10875
  icon: action.icon,
10858
10876
  color: action.color,
10859
10877
  look: 'outline',
10860
- visible: !action.hidden,
10861
- disabled: action.disabled,
10878
+ hidden: priority === 'secondary' ? this.wrapRowExpr(action.hidden) : action.hidden,
10879
+ disabled: priority === 'secondary' ? this.wrapRowExpr(action.disabled) : action.disabled,
10862
10880
  }));
10863
10881
  }
10882
+ /**
10883
+ * Wraps string values with AXP_ROW_EXPR_PREFIX so widget-renderer does not
10884
+ * evaluate them (it only treats {{ ... }} as expressions). Data-list will
10885
+ * unwrap and evaluate per row with row data. Only used for secondary commands.
10886
+ */
10887
+ wrapRowExpr(value) {
10888
+ if (value === undefined || value === null || typeof value !== 'string') {
10889
+ return value;
10890
+ }
10891
+ return `${AXP_ROW_EXPR_PREFIX}${value}`;
10892
+ }
10864
10893
  /**
10865
10894
  * Check if entity has Selected Scope Actions
10866
10895
  */
@@ -11107,7 +11136,7 @@ class AXPEntityListWidgetViewComponent extends AXPValueWidgetComponent {
11107
11136
  return !usedOverrideActions.has(actionKey);
11108
11137
  })
11109
11138
  .map((action) => new AXPEntityCommandTriggerViewModel(this.entity(), action));
11110
- return [...additionalActions, ...mergedActions].filter((a) => !a.hidden);
11139
+ return [...additionalActions, ...mergedActions];
11111
11140
  }, ...(ngDevMode ? [{ debugName: "allActions" }] : []));
11112
11141
  this.primaryActions = computed(() => {
11113
11142
  const actions = this.allActions()