@praxisui/crud 8.0.0-beta.32 → 8.0.0-beta.34

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,12 +1,12 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, InjectionToken, inject, input, signal, computed, effect, ChangeDetectionStrategy, Component, EventEmitter, DestroyRef, ChangeDetectorRef, ViewChild, Output, Input, Inject, ENVIRONMENT_INITIALIZER } from '@angular/core';
2
+ import { Injectable, InjectionToken, inject, input, signal, computed, effect, ChangeDetectionStrategy, Component, EventEmitter, DestroyRef, ChangeDetectorRef, Injector, ViewChild, Output, Input, Inject, ENVIRONMENT_INITIALIZER } from '@angular/core';
3
3
  import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
4
4
  import { HttpClient } from '@angular/common/http';
5
5
  import { Router, ActivatedRoute, RouterLink } from '@angular/router';
6
6
  import { MatSnackBar } from '@angular/material/snack-bar';
7
7
  import { firstValueFrom, BehaviorSubject, Subscription } from 'rxjs';
8
8
  import * as i2$1 from '@praxisui/core';
9
- import { ASYNC_CONFIG_STORAGE, GlobalConfigService, CrudOperationResolutionService, fillUndefined, SETTINGS_PANEL_DATA, PraxisI18nService, providePraxisI18nConfig, createDefaultTableConfig, ResourceDiscoveryService, ResourceActionOpenAdapterService, ResourceSurfaceOpenAdapterService, GLOBAL_SURFACE_SERVICE, ComponentKeyService, translateUnavailableWorkflowMessage, EmptyStateCardComponent, RESOURCE_DISCOVERY_I18N_CONFIG, PraxisIconDirective, GenericCrudService, ComponentMetadataRegistry } from '@praxisui/core';
9
+ import { ASYNC_CONFIG_STORAGE, GlobalConfigService, CrudOperationResolutionService, fillUndefined, SETTINGS_PANEL_DATA, PraxisI18nService, providePraxisI18nConfig, createDefaultTableConfig, GLOBAL_SURFACE_SERVICE, ComponentKeyService, ResourceDiscoveryService, ResourceActionOpenAdapterService, ResourceSurfaceOpenAdapterService, translateUnavailableWorkflowMessage, EmptyStateCardComponent, RESOURCE_DISCOVERY_I18N_CONFIG, PraxisIconDirective, GenericCrudService, ComponentMetadataRegistry } from '@praxisui/core';
10
10
  import { SettingsPanelService } from '@praxisui/settings-panel';
11
11
  import { PraxisTableInlineAuthoringEditorComponent, PraxisTable } from '@praxisui/table';
12
12
  import { ConfirmDialogComponent } from '@praxisui/dynamic-fields';
@@ -249,6 +249,9 @@ class CrudLauncherService {
249
249
  if (action.form?.initialValue != null) {
250
250
  inputs['initialValue'] = action.form.initialValue;
251
251
  }
252
+ else if (action.action !== 'create' && row && typeof row === 'object') {
253
+ inputs['initialValue'] = { ...row };
254
+ }
252
255
  return inputs;
253
256
  }
254
257
  resolveActionForLaunch(action, metadata) {
@@ -3326,9 +3329,10 @@ class PraxisCrudComponent {
3326
3329
  snack = inject(MatSnackBar);
3327
3330
  dialog = inject(DialogService);
3328
3331
  i18n = inject(PraxisI18nService);
3329
- resourceDiscovery = inject(ResourceDiscoveryService);
3330
- actionOpenAdapter = inject(ResourceActionOpenAdapterService);
3331
- surfaceOpenAdapter = inject(ResourceSurfaceOpenAdapterService);
3332
+ injector = inject(Injector);
3333
+ resourceDiscoveryInstance;
3334
+ actionOpenAdapterInstance;
3335
+ surfaceOpenAdapterInstance;
3332
3336
  global = (() => {
3333
3337
  try {
3334
3338
  return inject(GlobalConfigService);
@@ -3358,6 +3362,18 @@ class PraxisCrudComponent {
3358
3362
  collectionCapabilitiesResolvedHref = null;
3359
3363
  collectionCapabilitiesRequestSeq = 0;
3360
3364
  currentAuthoringDocument;
3365
+ getResourceDiscovery() {
3366
+ const assigned = this.resourceDiscovery;
3367
+ return assigned ?? (this.resourceDiscoveryInstance ??= this.injector.get(ResourceDiscoveryService));
3368
+ }
3369
+ getActionOpenAdapter() {
3370
+ const assigned = this.actionOpenAdapter;
3371
+ return assigned ?? (this.actionOpenAdapterInstance ??= this.injector.get(ResourceActionOpenAdapterService));
3372
+ }
3373
+ getSurfaceOpenAdapter() {
3374
+ const assigned = this.surfaceOpenAdapter;
3375
+ return assigned ?? (this.surfaceOpenAdapterInstance ??= this.injector.get(ResourceSurfaceOpenAdapterService));
3376
+ }
3361
3377
  onResetPreferences() {
3362
3378
  try {
3363
3379
  const keyId = this.componentKeyId();
@@ -3414,14 +3430,6 @@ class PraxisCrudComponent {
3414
3430
  async onAction(action, row, runtimeEvent) {
3415
3431
  try {
3416
3432
  document.activeElement?.blur();
3417
- const openedByDiscovery = await this.tryOpenDiscoveredCrudSurface(action, row, runtimeEvent);
3418
- if (openedByDiscovery) {
3419
- return;
3420
- }
3421
- const handledByWorkflowAction = await this.tryOpenDiscoveredWorkflowAction(action, row, runtimeEvent);
3422
- if (handledByWorkflowAction) {
3423
- return;
3424
- }
3425
3433
  let actionMeta = this.resolvedMetadata.actions?.find((candidate) => candidate.action === action);
3426
3434
  if (!actionMeta) {
3427
3435
  const ctxAction = this.tableCrudContext?.actions?.find((candidate) => candidate.action === action);
@@ -3438,6 +3446,16 @@ class PraxisCrudComponent {
3438
3446
  }
3439
3447
  }
3440
3448
  const effectiveAction = (actionMeta || { action });
3449
+ if (!this.hasExplicitOpenBinding(effectiveAction)) {
3450
+ const openedByDiscovery = await this.tryOpenDiscoveredCrudSurface(action, row, runtimeEvent);
3451
+ if (openedByDiscovery) {
3452
+ return;
3453
+ }
3454
+ const handledByWorkflowAction = await this.tryOpenDiscoveredWorkflowAction(action, row, runtimeEvent);
3455
+ if (handledByWorkflowAction) {
3456
+ return;
3457
+ }
3458
+ }
3441
3459
  const handledByDelete = await this.tryHandleCanonicalDeleteAction(effectiveAction, row);
3442
3460
  if (handledByDelete) {
3443
3461
  return;
@@ -3500,6 +3518,19 @@ class PraxisCrudComponent {
3500
3518
  this.error.emit(err);
3501
3519
  }
3502
3520
  }
3521
+ hasExplicitOpenBinding(action) {
3522
+ const mode = action.openMode;
3523
+ if (mode === 'route') {
3524
+ return !!String(action.route || '').trim();
3525
+ }
3526
+ if (mode === 'modal' || mode === 'drawer') {
3527
+ return !!String(action.formId || '').trim();
3528
+ }
3529
+ return !!(String(action.route || '').trim() ||
3530
+ String(action.formId || '').trim() ||
3531
+ String(action.form?.schemaUrl || '').trim() ||
3532
+ String(action.form?.submitUrl || '').trim());
3533
+ }
3503
3534
  getCurrentTableConfigSnapshot() {
3504
3535
  const current = this.table?.config || this.tableConfigForBinding || this.effectiveTableConfig;
3505
3536
  if (!current)
@@ -3542,7 +3573,7 @@ class PraxisCrudComponent {
3542
3573
  }
3543
3574
  const requestSeq = ++this.collectionCapabilitiesRequestSeq;
3544
3575
  this.collectionCapabilitiesRequestHref = capabilitiesHref;
3545
- void firstValueFrom(this.resourceDiscovery.getCapabilities(links || {}, this.buildDiscoveryOptions()))
3576
+ void firstValueFrom(this.getResourceDiscovery().getCapabilities(links || {}, this.buildDiscoveryOptions()))
3546
3577
  .then((snapshot) => {
3547
3578
  if (requestSeq !== this.collectionCapabilitiesRequestSeq) {
3548
3579
  return;
@@ -3733,7 +3764,7 @@ class PraxisCrudComponent {
3733
3764
  }
3734
3765
  let payload;
3735
3766
  try {
3736
- payload = this.surfaceOpenAdapter.toPayload(surface, {
3767
+ payload = this.getSurfaceOpenAdapter().toPayload(surface, {
3737
3768
  resourcePath,
3738
3769
  resourceId: this.resolveRowResourceId(row),
3739
3770
  endpointKey: this.resolvedMetadata?.resource?.endpointKey,
@@ -3783,13 +3814,13 @@ class PraxisCrudComponent {
3783
3814
  if (!this.tableCollectionLinks) {
3784
3815
  return null;
3785
3816
  }
3786
- return await firstValueFrom(this.resourceDiscovery.getSurfaces(this.tableCollectionLinks, this.buildDiscoveryOptions()));
3817
+ return await firstValueFrom(this.getResourceDiscovery().getSurfaces(this.tableCollectionLinks, this.buildDiscoveryOptions()));
3787
3818
  }
3788
3819
  const rowLinks = row?._links;
3789
3820
  if (!rowLinks) {
3790
3821
  return null;
3791
3822
  }
3792
- return await firstValueFrom(this.resourceDiscovery.getSurfaces(rowLinks, this.buildDiscoveryOptions()));
3823
+ return await firstValueFrom(this.getResourceDiscovery().getSurfaces(rowLinks, this.buildDiscoveryOptions()));
3793
3824
  }
3794
3825
  catch {
3795
3826
  return null;
@@ -3813,7 +3844,7 @@ class PraxisCrudComponent {
3813
3844
  }
3814
3845
  let payload;
3815
3846
  try {
3816
- payload = this.actionOpenAdapter.toPayload(discoveredAction, {
3847
+ payload = this.getActionOpenAdapter().toPayload(discoveredAction, {
3817
3848
  resourcePath,
3818
3849
  resourceId: this.resolveRowResourceId(row),
3819
3850
  endpointKey: this.resolvedMetadata?.resource?.endpointKey,
@@ -3864,12 +3895,12 @@ class PraxisCrudComponent {
3864
3895
  if (!rowLinks) {
3865
3896
  return null;
3866
3897
  }
3867
- return await firstValueFrom(this.resourceDiscovery.getActions(rowLinks, this.buildDiscoveryOptions()));
3898
+ return await firstValueFrom(this.getResourceDiscovery().getActions(rowLinks, this.buildDiscoveryOptions()));
3868
3899
  }
3869
3900
  if (!this.tableCollectionLinks) {
3870
3901
  return null;
3871
3902
  }
3872
- return await firstValueFrom(this.resourceDiscovery.getActions(this.tableCollectionLinks, this.buildDiscoveryOptions()));
3903
+ return await firstValueFrom(this.getResourceDiscovery().getActions(this.tableCollectionLinks, this.buildDiscoveryOptions()));
3873
3904
  }
3874
3905
  catch {
3875
3906
  return null;
@@ -4333,7 +4364,7 @@ class PraxisCrudComponent {
4333
4364
  }
4334
4365
  resolveCollectionCapabilitiesHref(links) {
4335
4366
  try {
4336
- return this.resourceDiscovery.resolveLinkHref(links || undefined, 'capabilities', this.buildDiscoveryOptions());
4367
+ return this.getResourceDiscovery().resolveLinkHref(links || undefined, 'capabilities', this.buildDiscoveryOptions());
4337
4368
  }
4338
4369
  catch {
4339
4370
  return null;
@@ -4353,7 +4384,7 @@ class PraxisCrudComponent {
4353
4384
  }
4354
4385
  resolveDiscoveryApiEntry() {
4355
4386
  try {
4356
- return this.resourceDiscovery.resolveApiEntry(this.buildDiscoveryOptions());
4387
+ return this.getResourceDiscovery().resolveApiEntry(this.buildDiscoveryOptions());
4357
4388
  }
4358
4389
  catch {
4359
4390
  return null;
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "@praxisui/crud",
3
- "version": "8.0.0-beta.32",
3
+ "version": "8.0.0-beta.34",
4
4
  "description": "CRUD building blocks for Praxis UI: integrates dynamic forms and tables with unified configuration and services.",
5
5
  "peerDependencies": {
6
6
  "@angular/common": "^21.0.0",
7
7
  "@angular/core": "^21.0.0",
8
- "@praxisui/dynamic-form": "^8.0.0-beta.32",
9
- "@praxisui/table": "^8.0.0-beta.32",
10
- "@praxisui/core": "^8.0.0-beta.32",
11
- "@praxisui/dynamic-fields": "^8.0.0-beta.32",
12
- "@praxisui/settings-panel": "^8.0.0-beta.32",
8
+ "@praxisui/dynamic-form": "^8.0.0-beta.34",
9
+ "@praxisui/table": "^8.0.0-beta.34",
10
+ "@praxisui/core": "^8.0.0-beta.34",
11
+ "@praxisui/dynamic-fields": "^8.0.0-beta.34",
12
+ "@praxisui/settings-panel": "^8.0.0-beta.34",
13
13
  "@angular/cdk": "^21.0.0",
14
14
  "@angular/forms": "^21.0.0",
15
15
  "@angular/material": "^21.0.0",
16
16
  "@angular/router": "^21.0.0",
17
- "@praxisui/ai": "^8.0.0-beta.32",
17
+ "@praxisui/ai": "^8.0.0-beta.34",
18
18
  "rxjs": "~7.8.0"
19
19
  },
20
20
  "dependencies": {
@@ -184,9 +184,10 @@ declare class PraxisCrudComponent implements OnChanges {
184
184
  private readonly snack;
185
185
  private readonly dialog;
186
186
  private readonly i18n;
187
- private readonly resourceDiscovery;
188
- private readonly actionOpenAdapter;
189
- private readonly surfaceOpenAdapter;
187
+ private readonly injector;
188
+ private resourceDiscoveryInstance?;
189
+ private actionOpenAdapterInstance?;
190
+ private surfaceOpenAdapterInstance?;
190
191
  private readonly global;
191
192
  private readonly surfaceService;
192
193
  private readonly componentKeys;
@@ -202,11 +203,15 @@ declare class PraxisCrudComponent implements OnChanges {
202
203
  private collectionCapabilitiesResolvedHref;
203
204
  private collectionCapabilitiesRequestSeq;
204
205
  private currentAuthoringDocument?;
206
+ private getResourceDiscovery;
207
+ private getActionOpenAdapter;
208
+ private getSurfaceOpenAdapter;
205
209
  onResetPreferences(): void;
206
210
  onTableRowClick(event: unknown): void;
207
211
  onTableSelectionChange(event: unknown): void;
208
212
  ngOnChanges(changes: SimpleChanges): void;
209
213
  onAction(action: string, row?: Record<string, unknown>, runtimeEvent?: CrudActionRuntimeEvent): Promise<void>;
214
+ private hasExplicitOpenBinding;
210
215
  getCurrentTableConfigSnapshot(): TableConfig | null;
211
216
  onTableMetadataChange(): void;
212
217
  onTableLoadingStateChange(state: LoadingState): void;