@processpuzzle/base-entity 0.6.2 → 0.7.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.
@@ -1,49 +1,50 @@
1
1
  import * as i0 from '@angular/core';
2
- import { inject, input, Component, computed, effect, Inject, Directive, InjectionToken, Injector, Injectable, EventEmitter, Output, signal, ViewChild, DestroyRef, untracked, isDevMode } from '@angular/core';
2
+ import { inject, input, Component, computed, effect, InjectionToken, Inject, Directive, Injector, signal, HostBinding, Injectable, EventEmitter, Output, ViewChild, DestroyRef, untracked, isDevMode, runInInjectionContext } from '@angular/core';
3
3
  import { MatSnackBar } from '@angular/material/snack-bar';
4
4
  import * as i1 from '@angular/common';
5
5
  import { CommonModule, NgClass, NgStyle, NgIf, NgForOf, SlicePipe } from '@angular/common';
6
6
  import { NavigationEnd, Router, ActivatedRoute, RouterOutlet, ROUTER_OUTLET_DATA } from '@angular/router';
7
7
  import { MatTabNav, MatTabLink, MatTabNavPanel } from '@angular/material/tabs';
8
- import { MatToolbar } from '@angular/material/toolbar';
8
+ import * as i2 from '@angular/material/toolbar';
9
+ import { MatToolbarModule, MatToolbar } from '@angular/material/toolbar';
9
10
  import { MatIcon } from '@angular/material/icon';
10
11
  import { MatButton, MatIconButton } from '@angular/material/button';
11
12
  import * as i3 from '@angular/material/form-field';
12
- import { MatFormField, MatFormFieldModule, MatLabel, MatSuffix, MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
13
+ import { MatFormField, MatSuffix, MatFormFieldModule, MatLabel, MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
13
14
  import * as i4 from '@angular/material/input';
14
15
  import { MatInput, MatInputModule } from '@angular/material/input';
15
16
  import { MatMenu, MatMenuItem, MatMenuTrigger } from '@angular/material/menu';
16
17
  import { signalStore, withState, withMethods, patchState, withHooks, signalStoreFeature, withProps, watchState, withComputed } from '@ngrx/signals';
17
18
  import { Stack, LayoutService, RUNTIME_CONFIGURATION } from '@processpuzzle/util';
18
19
  import { __decorate, __param } from 'tslib';
19
- import { map, filter, switchMap, pipe, tap, from, of } from 'rxjs';
20
+ import { map, filter, switchMap, from, of, firstValueFrom, pipe, tap } from 'rxjs';
20
21
  import { HttpClient, HttpHeaders } from '@angular/common/http';
21
22
  import { buildUrl } from 'build-url-ts';
22
23
  import * as i1$1 from '@angular/forms';
23
24
  import { ReactiveFormsModule, FormsModule, FormControl, Validators, FormBuilder } from '@angular/forms';
24
25
  import { MatCard, MatCardContent, MatCardActions } from '@angular/material/card';
26
+ import { NGXLogger } from 'ngx-logging-kit';
27
+ import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
25
28
  import { MAT_DIALOG_DATA, MatDialogTitle, MatDialogContent, MatDialogActions, MatDialogClose, MatDialog } from '@angular/material/dialog';
26
29
  import { TranslocoService, provideTranslocoScope } from '@jsverse/transloco';
27
30
  import * as i5 from '@angular/material/datepicker';
28
31
  import { MatDatepickerModule } from '@angular/material/datepicker';
29
- import * as i2 from '@angular/material/select';
32
+ import * as i2$1 from '@angular/material/select';
30
33
  import { MatSelectModule } from '@angular/material/select';
31
34
  import { MatCheckbox } from '@angular/material/checkbox';
32
35
  import { ENTER, COMMA } from '@angular/cdk/keycodes';
33
36
  import { MatChipGrid, MatChipRow, MatChipInput, MatChipRemove } from '@angular/material/chips';
34
- import { NGXLogger } from 'ngx-logging-kit';
35
- import * as i2$1 from '@angular/material/autocomplete';
37
+ import * as i2$2 from '@angular/material/autocomplete';
36
38
  import { MatAutocompleteModule } from '@angular/material/autocomplete';
37
- import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
38
39
  import { MatTableDataSource, MatTable, MatHeaderCell, MatHeaderRow, MatRow, MatCell, MatColumnDef, MatHeaderCellDef, MatCellDef, MatHeaderRowDef, MatRowDef } from '@angular/material/table';
39
40
  import { MatSort, MatSortHeader } from '@angular/material/sort';
40
41
  import { MatPaginator } from '@angular/material/paginator';
41
42
  import { MatProgressBar } from '@angular/material/progress-bar';
42
43
  import { SelectionModel } from '@angular/cdk/collections';
44
+ import { Firestore, collection, doc, deleteDoc, getDoc, setDoc, orderBy, where, query, limit, getDocs, updateDoc } from '@angular/fire/firestore';
43
45
  import { withDevtools } from '@angular-architects/ngrx-toolkit';
44
46
  import { tapResponse } from '@ngrx/operators';
45
47
  import { rxMethod } from '@ngrx/signals/rxjs-interop';
46
- import { Firestore, collection, doc, deleteDoc, getDoc, setDoc, orderBy, where, query, limit, getDocs, updateDoc } from '@angular/fire/firestore';
47
48
  import 'reflect-metadata';
48
49
 
49
50
  var FormControlType;
@@ -335,12 +336,21 @@ class BaseEntityToolbarComponent {
335
336
  this.formNavigator.navigateToDetails(this.entityDescriptor().entityName, BaseUrlSegments.NewEntity);
336
337
  }
337
338
  onDeleteEntities() {
338
- this.store.selectedEntities().forEach((entity) => this.store.delete(entity.id));
339
+ this.store.selectedEntities().forEach((entity) => void this.store.delete(entity.id));
340
+ }
341
+ onEditEntity() {
342
+ const entityId = this.store.currentEntity().id;
343
+ this.formNavigator.navigateToDetails(this.entityDescriptor().entityName, entityId);
339
344
  }
340
345
  onDoFilter($event) {
341
346
  const filterValue = $event.target.value;
342
347
  this.store.doFilter(filterValue);
343
348
  }
349
+ onClearFilter(input) {
350
+ input.value = '';
351
+ this.store.doFilter('');
352
+ this.store.load({});
353
+ }
344
354
  // endregion
345
355
  // public queries and mutators
346
356
  isSmallDevice() {
@@ -350,11 +360,11 @@ class BaseEntityToolbarComponent {
350
360
  // protected, private helper methods
351
361
  RouteSegments = RouteSegments;
352
362
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: BaseEntityToolbarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
353
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.12", type: BaseEntityToolbarComponent, isStandalone: true, selector: "base-entity-toolbar", inputs: { entityDescriptor: { classPropertyName: "entityDescriptor", publicName: "entityDescriptor", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "<mat-toolbar *ngIf=\"formNavigator.activeRouteSegment() === RouteSegments.LIST_ROUTE\">\n <div class=\"dense-3\" [ngStyle]=\"{'padding-top': '12px' }\">\n <mat-form-field>\n <input test-id=\"filter-input\" matInput type=\"text\" (keyup)=\"onDoFilter( $event )\" placeholder=\"Filter\">\n </mat-form-field>\n </div>\n <span class=\"toolbar-spacer\"></span>\n @if(isSmallDevice()) {\n <div [ngClass]=\"layoutService.layoutClass()\">\n <button test-id=\"menu-button\" mat-button [matMenuTriggerFor]=\"beforeMenu\"><mat-icon>menu</mat-icon> Choose action</button>\n <mat-menu test-id=\"menu\" #beforeMenu=\"matMenu\" xPosition=\"before\">\n <button test-id=\"add\" mat-menu-item (click)=\"onAddEntity()\"><mat-icon>add</mat-icon> New</button>\n <button test-id=\"delete\" mat-menu-item [disabled]=\"store.selectedEntities().length === 0\" (click)=\"onDeleteEntities()\"><mat-icon>delete</mat-icon> Delete</button>\n </mat-menu>\n </div>\n } @else {\n <div [ngClass]=\"layoutService.layoutClass()\">\n <button test-id=\"add\" mat-button (click)=\"onAddEntity()\"><mat-icon>add</mat-icon> New</button>\n <button test-id=\"delete\" mat-button [disabled]=\"store.selectedEntities().length === 0\" (click)=\"onDeleteEntities()\"><mat-icon>delete</mat-icon> Delete</button>\n </div>\n }\n</mat-toolbar>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: MatToolbar, selector: "mat-toolbar", inputs: ["color"], exportAs: ["matToolbar"] }, { kind: "component", type: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "component", type: MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: MatMenu, selector: "mat-menu", inputs: ["backdropClass", "aria-label", "aria-labelledby", "aria-describedby", "xPosition", "yPosition", "overlapTrigger", "hasBackdrop", "class", "classList"], outputs: ["closed", "close"], exportAs: ["matMenu"] }, { kind: "component", type: MatMenuItem, selector: "[mat-menu-item]", inputs: ["role", "disabled", "disableRipple"], exportAs: ["matMenuItem"] }, { kind: "directive", type: MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", inputs: ["mat-menu-trigger-for", "matMenuTriggerFor", "matMenuTriggerData", "matMenuTriggerRestoreFocus"], outputs: ["menuOpened", "onMenuOpen", "menuClosed", "onMenuClose"], exportAs: ["matMenuTrigger"] }] });
363
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.12", type: BaseEntityToolbarComponent, isStandalone: true, selector: "base-entity-toolbar", inputs: { entityDescriptor: { classPropertyName: "entityDescriptor", publicName: "entityDescriptor", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "<mat-toolbar *ngIf=\"formNavigator.activeRouteSegment() === RouteSegments.LIST_ROUTE\">\n <div class=\"dense-3\" [ngStyle]=\"{'padding-top': '12px' }\">\n <mat-form-field>\n <input #filterInput [attr.data-testid]=\"entityDescriptor().createTestId('filter')\" matInput type=\"text\" (keyup)=\"onDoFilter( $event )\" placeholder=\"Filter\">\n @if (filterInput.value) {\n <button [attr.data-testid]=\"entityDescriptor().createTestId('filter-clear')\" type=\"button\" mat-icon-button matSuffix aria-label=\"Clear filter\" (click)=\"onClearFilter(filterInput)\">\n <mat-icon>cancel</mat-icon>\n </button>\n }\n </mat-form-field>\n </div>\n <span class=\"toolbar-spacer\"></span>\n @if(isSmallDevice()) {\n <div [ngClass]=\"layoutService.layoutClass()\">\n <button test-id=\"menu-button\" mat-button [matMenuTriggerFor]=\"beforeMenu\"><mat-icon>menu</mat-icon> Choose action</button>\n <mat-menu #beforeMenu=\"matMenu\" xPosition=\"before\">\n <button [attr.data-testid]=\"entityDescriptor().createTestId('edit')\" mat-menu-item [disabled]=\"store.selectedEntities().length != 1\" (click)=\"onEditEntity()\"><mat-icon>edit</mat-icon> Edit</button>\n <button [attr.data-testid]=\"entityDescriptor().createTestId('new')\" mat-menu-item (click)=\"onAddEntity()\"><mat-icon>add</mat-icon> New</button>\n <button [attr.data-testid]=\"entityDescriptor().createTestId('delete')\" mat-menu-item [disabled]=\"store.selectedEntities().length === 0\" (click)=\"onDeleteEntities()\"><mat-icon>delete</mat-icon> Delete</button>\n </mat-menu>\n </div>\n } @else {\n <div [ngClass]=\"layoutService.layoutClass()\">\n <button [attr.data-testid]=\"entityDescriptor().createTestId('edit')\" mat-button [disabled]=\"store.selectedEntities().length != 1\" (click)=\"onEditEntity()\"><mat-icon>edit</mat-icon> Edit</button>\n <button [attr.data-testid]=\"entityDescriptor().createTestId('new')\" mat-button (click)=\"onAddEntity()\"><mat-icon>add</mat-icon> New</button>\n <button [attr.data-testid]=\"entityDescriptor().createTestId('delete')\" mat-button [disabled]=\"store.selectedEntities().length === 0\" (click)=\"onDeleteEntities()\"><mat-icon>delete</mat-icon> Delete</button>\n </div>\n }\n</mat-toolbar>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "ngmodule", type: MatToolbarModule }, { kind: "component", type: i2.MatToolbar, selector: "mat-toolbar", inputs: ["color"], exportAs: ["matToolbar"] }, { kind: "component", type: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "component", type: MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "directive", type: MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "component", type: MatMenu, selector: "mat-menu", inputs: ["backdropClass", "aria-label", "aria-labelledby", "aria-describedby", "xPosition", "yPosition", "overlapTrigger", "hasBackdrop", "class", "classList"], outputs: ["closed", "close"], exportAs: ["matMenu"] }, { kind: "component", type: MatMenuItem, selector: "[mat-menu-item]", inputs: ["role", "disabled", "disableRipple"], exportAs: ["matMenuItem"] }, { kind: "directive", type: MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", inputs: ["mat-menu-trigger-for", "matMenuTriggerFor", "matMenuTriggerData", "matMenuTriggerRestoreFocus"], outputs: ["menuOpened", "onMenuOpen", "menuClosed", "onMenuClose"], exportAs: ["matMenuTrigger"] }] });
354
364
  }
355
365
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: BaseEntityToolbarComponent, decorators: [{
356
366
  type: Component,
357
- args: [{ selector: 'base-entity-toolbar', standalone: true, imports: [CommonModule, MatToolbar, MatIcon, MatFormField, MatInput, MatButton, MatMenu, MatMenuItem, MatMenuTrigger], template: "<mat-toolbar *ngIf=\"formNavigator.activeRouteSegment() === RouteSegments.LIST_ROUTE\">\n <div class=\"dense-3\" [ngStyle]=\"{'padding-top': '12px' }\">\n <mat-form-field>\n <input test-id=\"filter-input\" matInput type=\"text\" (keyup)=\"onDoFilter( $event )\" placeholder=\"Filter\">\n </mat-form-field>\n </div>\n <span class=\"toolbar-spacer\"></span>\n @if(isSmallDevice()) {\n <div [ngClass]=\"layoutService.layoutClass()\">\n <button test-id=\"menu-button\" mat-button [matMenuTriggerFor]=\"beforeMenu\"><mat-icon>menu</mat-icon> Choose action</button>\n <mat-menu test-id=\"menu\" #beforeMenu=\"matMenu\" xPosition=\"before\">\n <button test-id=\"add\" mat-menu-item (click)=\"onAddEntity()\"><mat-icon>add</mat-icon> New</button>\n <button test-id=\"delete\" mat-menu-item [disabled]=\"store.selectedEntities().length === 0\" (click)=\"onDeleteEntities()\"><mat-icon>delete</mat-icon> Delete</button>\n </mat-menu>\n </div>\n } @else {\n <div [ngClass]=\"layoutService.layoutClass()\">\n <button test-id=\"add\" mat-button (click)=\"onAddEntity()\"><mat-icon>add</mat-icon> New</button>\n <button test-id=\"delete\" mat-button [disabled]=\"store.selectedEntities().length === 0\" (click)=\"onDeleteEntities()\"><mat-icon>delete</mat-icon> Delete</button>\n </div>\n }\n</mat-toolbar>\n" }]
367
+ args: [{ selector: 'base-entity-toolbar', standalone: true, imports: [CommonModule, MatToolbarModule, MatIcon, MatFormField, MatInput, MatButton, MatIconButton, MatSuffix, MatMenu, MatMenuItem, MatMenuTrigger], template: "<mat-toolbar *ngIf=\"formNavigator.activeRouteSegment() === RouteSegments.LIST_ROUTE\">\n <div class=\"dense-3\" [ngStyle]=\"{'padding-top': '12px' }\">\n <mat-form-field>\n <input #filterInput [attr.data-testid]=\"entityDescriptor().createTestId('filter')\" matInput type=\"text\" (keyup)=\"onDoFilter( $event )\" placeholder=\"Filter\">\n @if (filterInput.value) {\n <button [attr.data-testid]=\"entityDescriptor().createTestId('filter-clear')\" type=\"button\" mat-icon-button matSuffix aria-label=\"Clear filter\" (click)=\"onClearFilter(filterInput)\">\n <mat-icon>cancel</mat-icon>\n </button>\n }\n </mat-form-field>\n </div>\n <span class=\"toolbar-spacer\"></span>\n @if(isSmallDevice()) {\n <div [ngClass]=\"layoutService.layoutClass()\">\n <button test-id=\"menu-button\" mat-button [matMenuTriggerFor]=\"beforeMenu\"><mat-icon>menu</mat-icon> Choose action</button>\n <mat-menu #beforeMenu=\"matMenu\" xPosition=\"before\">\n <button [attr.data-testid]=\"entityDescriptor().createTestId('edit')\" mat-menu-item [disabled]=\"store.selectedEntities().length != 1\" (click)=\"onEditEntity()\"><mat-icon>edit</mat-icon> Edit</button>\n <button [attr.data-testid]=\"entityDescriptor().createTestId('new')\" mat-menu-item (click)=\"onAddEntity()\"><mat-icon>add</mat-icon> New</button>\n <button [attr.data-testid]=\"entityDescriptor().createTestId('delete')\" mat-menu-item [disabled]=\"store.selectedEntities().length === 0\" (click)=\"onDeleteEntities()\"><mat-icon>delete</mat-icon> Delete</button>\n </mat-menu>\n </div>\n } @else {\n <div [ngClass]=\"layoutService.layoutClass()\">\n <button [attr.data-testid]=\"entityDescriptor().createTestId('edit')\" mat-button [disabled]=\"store.selectedEntities().length != 1\" (click)=\"onEditEntity()\"><mat-icon>edit</mat-icon> Edit</button>\n <button [attr.data-testid]=\"entityDescriptor().createTestId('new')\" mat-button (click)=\"onAddEntity()\"><mat-icon>add</mat-icon> New</button>\n <button [attr.data-testid]=\"entityDescriptor().createTestId('delete')\" mat-button [disabled]=\"store.selectedEntities().length === 0\" (click)=\"onDeleteEntities()\"><mat-icon>delete</mat-icon> Delete</button>\n </div>\n }\n</mat-toolbar>\n" }]
358
368
  }], propDecorators: { entityDescriptor: [{ type: i0.Input, args: [{ isSignal: true, alias: "entityDescriptor", required: true }] }] } });
359
369
 
360
370
  class BaseEntityStatusbarComponent {
@@ -375,11 +385,28 @@ class BaseEntityStatusbarComponent {
375
385
  return fn(this);
376
386
  }
377
387
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: BaseEntityStatusbarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
378
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.12", type: BaseEntityStatusbarComponent, isStandalone: true, selector: "base-entity-statusbar", inputs: { entityDescriptor: { classPropertyName: "entityDescriptor", publicName: "entityDescriptor", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "<mat-toolbar *ngIf=\"isVisible()\">\n <div>\n <span>{{entityTitle()}}</span>\n </div>\n</mat-toolbar>", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: MatToolbar, selector: "mat-toolbar", inputs: ["color"], exportAs: ["matToolbar"] }] });
388
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.12", type: BaseEntityStatusbarComponent, isStandalone: true, selector: "base-entity-statusbar", inputs: { entityDescriptor: { classPropertyName: "entityDescriptor", publicName: "entityDescriptor", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: `
389
+ <mat-toolbar *ngIf="isVisible()">
390
+ <div>
391
+ <span>{{ entityTitle() }}</span>
392
+ </div>
393
+ </mat-toolbar>
394
+ `, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: MatToolbar, selector: "mat-toolbar", inputs: ["color"], exportAs: ["matToolbar"] }] });
379
395
  }
380
396
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: BaseEntityStatusbarComponent, decorators: [{
381
397
  type: Component,
382
- args: [{ selector: 'base-entity-statusbar', standalone: true, imports: [CommonModule, MatToolbar], template: "<mat-toolbar *ngIf=\"isVisible()\">\n <div>\n <span>{{entityTitle()}}</span>\n </div>\n</mat-toolbar>" }]
398
+ args: [{
399
+ selector: 'base-entity-statusbar',
400
+ standalone: true,
401
+ imports: [CommonModule, MatToolbar],
402
+ template: `
403
+ <mat-toolbar *ngIf="isVisible()">
404
+ <div>
405
+ <span>{{ entityTitle() }}</span>
406
+ </div>
407
+ </mat-toolbar>
408
+ `,
409
+ }]
383
410
  }], propDecorators: { entityDescriptor: [{ type: i0.Input, args: [{ isSignal: true, alias: "entityDescriptor", required: true }] }] } });
384
411
 
385
412
  class BaseEntityTabsComponent {
@@ -431,8 +458,15 @@ class BaseEntityTabsComponent {
431
458
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: BaseEntityTabsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
432
459
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.12", type: BaseEntityTabsComponent, isStandalone: true, selector: "base-entity-tabs", inputs: { entityDescriptor: { classPropertyName: "entityDescriptor", publicName: "entityDescriptor", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: `
433
460
  <nav mat-tab-nav-bar [tabPanel]="tabPanel">
434
- <a mat-tab-link (click)="onShowList()" [active]="store.currentTab() === listTabName()">{{ listTabName() }}</a>
435
- <a mat-tab-link [disabled]="store.currentEntity() === undefined" (click)="onShowDetails()" [active]="store.currentTab() === detailsTabName()">{{ detailsTabName() }}</a>
461
+ <a mat-tab-link [attr.data-testid]="entityDescriptor().createTestId('show-list')" (click)="onShowList()" [active]="store.currentTab() === listTabName()">{{ listTabName() }}</a>
462
+ <a
463
+ mat-tab-link
464
+ [attr.data-testid]="entityDescriptor().createTestId('show-details')"
465
+ [disabled]="store.currentEntity() === undefined"
466
+ (click)="onShowDetails()"
467
+ [active]="store.currentTab() === detailsTabName()"
468
+ >{{ detailsTabName() }}</a
469
+ >
436
470
  </nav>
437
471
 
438
472
  <mat-tab-nav-panel #tabPanel>
@@ -450,8 +484,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImpo
450
484
  imports: [CommonModule, MatTabNav, MatTabLink, MatTabNavPanel, RouterOutlet, BaseEntityToolbarComponent, BaseEntityStatusbarComponent],
451
485
  template: `
452
486
  <nav mat-tab-nav-bar [tabPanel]="tabPanel">
453
- <a mat-tab-link (click)="onShowList()" [active]="store.currentTab() === listTabName()">{{ listTabName() }}</a>
454
- <a mat-tab-link [disabled]="store.currentEntity() === undefined" (click)="onShowDetails()" [active]="store.currentTab() === detailsTabName()">{{ detailsTabName() }}</a>
487
+ <a mat-tab-link [attr.data-testid]="entityDescriptor().createTestId('show-list')" (click)="onShowList()" [active]="store.currentTab() === listTabName()">{{ listTabName() }}</a>
488
+ <a
489
+ mat-tab-link
490
+ [attr.data-testid]="entityDescriptor().createTestId('show-details')"
491
+ [disabled]="store.currentEntity() === undefined"
492
+ (click)="onShowDetails()"
493
+ [active]="store.currentTab() === detailsTabName()"
494
+ >{{ detailsTabName() }}</a
495
+ >
455
496
  </nav>
456
497
 
457
498
  <mat-tab-nav-panel #tabPanel>
@@ -463,34 +504,50 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImpo
463
504
  }]
464
505
  }], ctorParameters: () => [], propDecorators: { entityDescriptor: [{ type: i0.Input, args: [{ isSignal: true, alias: "entityDescriptor", required: true }] }] } });
465
506
 
507
+ const ACTIVE_ENTITY_FACADE = new InjectionToken('ACTIVE_ENTITY_FACADE');
508
+
466
509
  class BaseEntityContainerComponent {
467
- entityDescriptor = input.required(...(ngDevMode ? [{ debugName: "entityDescriptor" }] : /* istanbul ignore next */ []));
510
+ entityDescriptor = input(undefined, ...(ngDevMode ? [{ debugName: "entityDescriptor" }] : /* istanbul ignore next */ []));
511
+ facade = input(undefined, ...(ngDevMode ? [{ debugName: "facade" }] : /* istanbul ignore next */ []));
512
+ injectedFacade = inject(ACTIVE_ENTITY_FACADE, { optional: true });
468
513
  snackBar = inject(MatSnackBar);
469
514
  store;
515
+ activeFacade = computed(() => this.facade() ?? this.injectedFacade ?? undefined, ...(ngDevMode ? [{ debugName: "activeFacade" }] : /* istanbul ignore next */ []));
516
+ resolvedDescriptor = computed(() => {
517
+ const f = this.activeFacade();
518
+ if (f)
519
+ return f.descriptor;
520
+ const descriptor = this.entityDescriptor();
521
+ if (!descriptor) {
522
+ throw new Error('BaseEntityContainerComponent requires either [facade], ACTIVE_ENTITY_FACADE provider, or [entityDescriptor]');
523
+ }
524
+ return descriptor;
525
+ }, ...(ngDevMode ? [{ debugName: "resolvedDescriptor" }] : /* istanbul ignore next */ []));
470
526
  constructor() {
471
527
  this.registerEffects();
472
528
  }
473
529
  // region Angular lifecycle hooks
474
530
  ngOnDestroy() {
475
- this.store.reset();
531
+ this.store?.reset?.();
476
532
  }
477
533
  ngOnInit() {
478
- this.store = this.entityDescriptor().store;
534
+ this.store = this.activeFacade()?.store ?? this.resolvedDescriptor().store;
479
535
  }
480
536
  // endregion
481
537
  // region protected, private helper methods
482
538
  registerEffects() {
483
539
  effect(() => {
484
- if (this.store.error()) {
540
+ if (this.store?.error?.()) {
485
541
  const errorMessage = this.store.error() ? this.store.error() : 'Undefined Error';
486
542
  this.snackBar.open(errorMessage, 'Close', { duration: 5000 });
487
543
  }
488
544
  });
489
545
  }
490
546
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: BaseEntityContainerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
491
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.12", type: BaseEntityContainerComponent, isStandalone: true, selector: "base-entity-container", inputs: { entityDescriptor: { classPropertyName: "entityDescriptor", publicName: "entityDescriptor", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: `
547
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.12", type: BaseEntityContainerComponent, isStandalone: true, selector: "base-entity-container", inputs: { entityDescriptor: { classPropertyName: "entityDescriptor", publicName: "entityDescriptor", isSignal: true, isRequired: false, transformFunction: null }, facade: { classPropertyName: "facade", publicName: "facade", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
548
+ <ng-content></ng-content>
492
549
  <div>
493
- <base-entity-tabs [entityDescriptor]="entityDescriptor()"></base-entity-tabs>
550
+ <base-entity-tabs [entityDescriptor]="resolvedDescriptor()"></base-entity-tabs>
494
551
  </div>
495
552
  `, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: BaseEntityTabsComponent, selector: "base-entity-tabs", inputs: ["entityDescriptor"] }] });
496
553
  }
@@ -501,12 +558,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImpo
501
558
  standalone: true,
502
559
  imports: [CommonModule, BaseEntityTabsComponent],
503
560
  template: `
561
+ <ng-content></ng-content>
504
562
  <div>
505
- <base-entity-tabs [entityDescriptor]="entityDescriptor()"></base-entity-tabs>
563
+ <base-entity-tabs [entityDescriptor]="resolvedDescriptor()"></base-entity-tabs>
506
564
  </div>
507
565
  `,
508
566
  }]
509
- }], ctorParameters: () => [], propDecorators: { entityDescriptor: [{ type: i0.Input, args: [{ isSignal: true, alias: "entityDescriptor", required: true }] }] } });
567
+ }], ctorParameters: () => [], propDecorators: { entityDescriptor: [{ type: i0.Input, args: [{ isSignal: true, alias: "entityDescriptor", required: false }] }], facade: [{ type: i0.Input, args: [{ isSignal: true, alias: "facade", required: false }] }] } });
510
568
 
511
569
  const INITIAL_CONTAINER_STATE = {
512
570
  filterKey: undefined,
@@ -542,7 +600,13 @@ let BaseEntityRestService = class BaseEntityRestService {
542
600
  }
543
601
  // region public accessor and mutator methods
544
602
  delete(id) {
545
- return this.httpClient.delete(this.resourceUrl + `/${id}`, { headers: this.headers });
603
+ const pathParams = new Map([['id', String(id)]]);
604
+ const fullUrl = this.buildFullUrl(this.resourceUrl + '/%{id}', { pathParams });
605
+ if (fullUrl) {
606
+ return this.httpClient.delete(fullUrl, { headers: this.headers });
607
+ }
608
+ else
609
+ throw new Error('Could not determine the full url');
546
610
  }
547
611
  deleteAll() {
548
612
  return this.httpClient.delete(this.resourceUrl, { headers: this.headers });
@@ -705,9 +769,114 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImpo
705
769
  }]
706
770
  }], ctorParameters: () => [{ type: i0.ViewContainerRef }] });
707
771
 
708
- const BASE_ENTITY_STORE_REGISTRY = new InjectionToken('BASE_ENTITY_STORE_REGISTRY', {
772
+ var FlexDirection;
773
+ (function (FlexDirection) {
774
+ FlexDirection[FlexDirection["CONTAINER"] = 0] = "CONTAINER";
775
+ FlexDirection[FlexDirection["COLUMN"] = 1] = "COLUMN";
776
+ FlexDirection[FlexDirection["ROW"] = 2] = "ROW";
777
+ })(FlexDirection || (FlexDirection = {}));
778
+ class FlexboxDescriptor extends AbstractAttrDescriptor {
779
+ attrDescriptors;
780
+ direction;
781
+ constructor(attrDescriptors, direction) {
782
+ super('dummy', FormControlType.FLEX_BOX);
783
+ this.attrDescriptors = attrDescriptors;
784
+ this.direction = direction;
785
+ }
786
+ }
787
+
788
+ function filterAttributeDescriptors(descriptors) {
789
+ let attrDescriptors = [];
790
+ descriptors.forEach((descriptor) => {
791
+ if (descriptor instanceof BaseEntityAttrDescriptor)
792
+ attrDescriptors.push(descriptor);
793
+ else if (descriptor instanceof FlexboxDescriptor) {
794
+ attrDescriptors = attrDescriptors.concat(filterAttributeDescriptors(descriptor.attrDescriptors));
795
+ }
796
+ });
797
+ return attrDescriptors;
798
+ }
799
+
800
+ const BASE_ENTITY_FACADE_REGISTRY = new InjectionToken('BASE_ENTITY_FACADE_REGISTRY', {
709
801
  factory: () => ({}),
710
802
  });
803
+ class EntityRegistryComponent {
804
+ registry = inject(BASE_ENTITY_FACADE_REGISTRY);
805
+ injector = inject(Injector);
806
+ queryParams = toSignal(inject(ActivatedRoute).queryParamMap, { initialValue: null });
807
+ descriptors = signal(this.buildDescriptors(), ...(ngDevMode ? [{ debugName: "descriptors" }] : /* istanbul ignore next */ []));
808
+ registryJson = computed(() => {
809
+ const minified = this.queryParams()?.get('minified') === 'yes';
810
+ return minified ? JSON.stringify(this.descriptors(), null, 2) : JSON.stringify(this.descriptors(), null, 2);
811
+ }, ...(ngDevMode ? [{ debugName: "registryJson" }] : /* istanbul ignore next */ []));
812
+ buildDescriptors() {
813
+ return Object.entries(this.registry).map(([, facadeToken]) => {
814
+ const facade = this.injector.get(facadeToken);
815
+ const descriptor = facade.descriptor;
816
+ const attrDescriptors = filterAttributeDescriptors(facade.descriptor.attrDescriptors);
817
+ return {
818
+ entityName: descriptor.entityName,
819
+ entityTitle: descriptor.entityTitle,
820
+ attrDescriptors: attrDescriptors.map((attr) => this.serializeAttr(attr)),
821
+ };
822
+ });
823
+ }
824
+ serializeAttr(attr) {
825
+ const isBaseAttr = attr instanceof BaseEntityAttrDescriptor;
826
+ return {
827
+ attrName: attr.attrName,
828
+ formControlType: attr.formControlType,
829
+ disabled: attr.disabled,
830
+ style: attr.style,
831
+ ...(isBaseAttr && {
832
+ label: attr.label,
833
+ description: attr.description,
834
+ styleClass: attr.styleClass,
835
+ labelClass: attr.labelClass,
836
+ format: attr.format,
837
+ isLinkToDetails: attr.isLinkToDetails,
838
+ selectables: attr.selectables,
839
+ visible: attr.visible,
840
+ hideInTable: attr.hideInTable,
841
+ isHeading: attr.isHeading,
842
+ placeholder: attr.placeholder,
843
+ lines: attr.lines,
844
+ options: attr.options,
845
+ required: attr.required,
846
+ // linkedEntityType: attr.linkedEntityType,
847
+ }),
848
+ };
849
+ }
850
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: EntityRegistryComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
851
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.12", type: EntityRegistryComponent, isStandalone: true, selector: "pp-entity-registry", ngImport: i0, template: ` <pre>{{ registryJson() }}</pre> `, isInline: true });
852
+ }
853
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: EntityRegistryComponent, decorators: [{
854
+ type: Component,
855
+ args: [{
856
+ selector: 'pp-entity-registry',
857
+ template: ` <pre>{{ registryJson() }}</pre> `,
858
+ }]
859
+ }] });
860
+
861
+ function entityNameFromType(entityType) {
862
+ return entityType.name ?? 'base-entity';
863
+ }
864
+ function createTestId(entity, suffix) {
865
+ const entityName = typeof entity === 'string' ? entity : entityNameFromType(entity);
866
+ const camelCaseName = toTestId(entityName);
867
+ return `${camelCaseName}-${suffix}`;
868
+ }
869
+ function createTestLocator(entity, suffix) {
870
+ const entityName = typeof entity === 'string' ? entity : entityNameFromType(entity);
871
+ const camelCaseName = toTestId(entityName);
872
+ return `[data-testid="${camelCaseName}-${suffix}"]`;
873
+ }
874
+ function toTestId(entityName) {
875
+ return entityName
876
+ .split(' ')
877
+ .map((word, i) => (i === 0 ? word.charAt(0).toLowerCase() + word.slice(1) : word.charAt(0).toUpperCase() + word.slice(1)))
878
+ .join('');
879
+ }
711
880
 
712
881
  class BaseFormControlComponent {
713
882
  config = input.required(...(ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []));
@@ -715,17 +884,34 @@ class BaseFormControlComponent {
715
884
  formGroup;
716
885
  store;
717
886
  style = computed(() => this.config().style, ...(ngDevMode ? [{ debugName: "style" }] : /* istanbul ignore next */ []));
887
+ linkedEntityType = computed(() => {
888
+ const linkedEntityType = this.config().linkedEntityType;
889
+ if (linkedEntityType === undefined) {
890
+ this.logger.error(`linkedEntityType should be defined for '${this.config().attrName}'.`);
891
+ throw new Error(`linkedEntityType should be defined for '${this.config().attrName}'.`);
892
+ }
893
+ return linkedEntityType;
894
+ }, ...(ngDevMode ? [{ debugName: "linkedEntityType" }] : /* istanbul ignore next */ []));
718
895
  value = input.required(...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
896
+ get testId() {
897
+ const attrName = this.config()?.attrName;
898
+ const entity = this.entity();
899
+ if (!attrName || !entity)
900
+ return null;
901
+ return createTestId(entity.constructor, attrName);
902
+ }
903
+ logger = inject(NGXLogger);
719
904
  formNavigator = inject(BaseFormNavigatorSingletonStore);
720
905
  injector = inject(Injector);
721
- storeRegistry = inject(BASE_ENTITY_STORE_REGISTRY);
906
+ facadeRegistry = inject(BASE_ENTITY_FACADE_REGISTRY);
722
907
  // region Angular lifecycle hooks
723
908
  // endregion
724
909
  resolveRelatedEntityStore() {
725
910
  const entityName = this.config().linkedEntityType?.entityName;
726
- const registryStoreToken = entityName ? this.storeRegistry[entityName] : undefined;
727
- if (registryStoreToken) {
728
- return this.injector.get(registryStoreToken, undefined);
911
+ const facadeToken = entityName ? this.facadeRegistry[entityName] : undefined;
912
+ if (facadeToken) {
913
+ const facade = this.injector.get(facadeToken, undefined);
914
+ return facade?.store;
729
915
  }
730
916
  const store = this.config().linkedEntityType?.store;
731
917
  if (!store) {
@@ -742,12 +928,10 @@ class BaseFormControlComponent {
742
928
  }
743
929
  }
744
930
  isStoreInstance(store) {
745
- return (!!store &&
746
- (typeof store === 'object' || typeof store === 'function') &&
747
- ('load' in store || 'loadById' in store || 'entities' in store));
931
+ return !!store && (typeof store === 'object' || typeof store === 'function') && ('load' in store || 'loadById' in store || 'entities' in store);
748
932
  }
749
933
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: BaseFormControlComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
750
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.12", type: BaseFormControlComponent, isStandalone: true, selector: "ng-component", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: true, transformFunction: null }, entity: { classPropertyName: "entity", publicName: "entity", isSignal: true, isRequired: true, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: ``, isInline: true, dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }] });
934
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.12", type: BaseFormControlComponent, isStandalone: true, selector: "ng-component", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: true, transformFunction: null }, entity: { classPropertyName: "entity", publicName: "entity", isSignal: true, isRequired: true, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null } }, host: { properties: { "attr.data-testid": "this.testId" } }, ngImport: i0, template: ``, isInline: true, dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }] });
751
935
  }
752
936
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: BaseFormControlComponent, decorators: [{
753
937
  type: Component,
@@ -756,7 +940,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImpo
756
940
  template: ``,
757
941
  imports: [ReactiveFormsModule],
758
942
  }]
759
- }], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: true }] }], entity: [{ type: i0.Input, args: [{ isSignal: true, alias: "entity", required: true }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }] } });
943
+ }], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: true }] }], entity: [{ type: i0.Input, args: [{ isSignal: true, alias: "entity", required: true }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], testId: [{
944
+ type: HostBinding,
945
+ args: ['attr.data-testid']
946
+ }] } });
760
947
 
761
948
  class ObjectStoreService {
762
949
  runtimeConfiguration = inject(RUNTIME_CONFIGURATION);
@@ -1128,37 +1315,33 @@ class ForeignKeyComponent extends BaseFormControlComponent {
1128
1315
  this.hasFocus.set(!!currentTarget && !!relatedTarget && currentTarget.contains(relatedTarget));
1129
1316
  }
1130
1317
  navigateToRelated() {
1131
- const relatedEntityName = this.config().linkedEntityType?.entityName;
1132
- if (!relatedEntityName)
1133
- return;
1134
- this.formNavigator.navigateToRelated(relatedEntityName, this.foreignKeyId(), this.formNavigator.determineCurrentUrl());
1318
+ this.formNavigator.navigateToRelated(this.linkedEntityType().entityName, this.foreignKeyId(), this.formNavigator.determineCurrentUrl());
1135
1319
  }
1136
1320
  navigateToRelatedList() {
1137
- const relatedEntityName = this.config().linkedEntityType?.entityName;
1138
- if (this.config().disabled || !relatedEntityName) {
1321
+ if (this.config().disabled) {
1139
1322
  return;
1140
1323
  }
1141
- this.formNavigator.navigateToRelatedList(relatedEntityName, this.formNavigator.determineCurrentUrl(), {
1324
+ this.formNavigator.navigateToRelatedList(this.linkedEntityType().entityName, this.formNavigator.determineCurrentUrl(), {
1142
1325
  command: NavigatorCommand.SELECT_OR_CREATE,
1143
1326
  });
1144
1327
  }
1145
1328
  // endregion
1146
1329
  selectEntityTitle() {
1147
- return 'Select ' + (this.config().linkedEntityType?.entityName ?? 'Entity');
1330
+ return 'Select ' + this.linkedEntityType().entityName;
1148
1331
  }
1149
1332
  foreignKeyLabel() {
1150
- return this.config().linkedEntityType?.entityName ?? this.config().label;
1333
+ return this.linkedEntityType().entityName;
1151
1334
  }
1152
1335
  showSelectEntityButton() {
1153
- return !this.config().disabled && this.hasFocus() && this.config().linkedEntityType !== undefined;
1336
+ return !this.config().disabled && this.hasFocus();
1154
1337
  }
1155
1338
  foreignKeyDisplayName() {
1156
1339
  const relatedEntity = this.selectedEntity() ?? this.relatedEntityFromLinkedStore();
1157
1340
  if (!relatedEntity) {
1158
1341
  return this.foreignKeyId();
1159
1342
  }
1160
- const attrName = this.config().linkedEntityType?.componentIdentification();
1161
- const componentName = attrName ? relatedEntity[attrName] : undefined;
1343
+ const attrName = this.linkedEntityType().componentIdentification();
1344
+ const componentName = relatedEntity[attrName];
1162
1345
  return componentName === undefined || componentName === null ? relatedEntity.id : String(componentName);
1163
1346
  }
1164
1347
  addSelectedComponentFromNavigatorResponse() {
@@ -1284,7 +1467,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImpo
1284
1467
 
1285
1468
  class DropdownComponent extends BaseFormControlComponent {
1286
1469
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: DropdownComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
1287
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.12", type: DropdownComponent, isStandalone: true, selector: "base-dropdown", usesInheritance: true, ngImport: i0, template: "<ng-container *ngIf=\"config().visible\">\n <div class=\"row\" [formGroup]=\"formGroup\">\n <mat-form-field>\n <mat-label>{{config().label}}</mat-label>\n <mat-select formControlName=\"{{config().attrName}}\">\n @for (option of config().selectables; track option) {\n <mat-option [value]=\"option.value\">{{option.value}}</mat-option>\n }\n </mat-select>\n </mat-form-field>\n </div>\n</ng-container>", dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: MatLabel, selector: "mat-label" }, { kind: "component", type: MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "ngmodule", type: MatSelectModule }, { kind: "component", type: i2.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth", "canSelectNullableOptions"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "component", type: i2.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }] });
1470
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.12", type: DropdownComponent, isStandalone: true, selector: "base-dropdown", usesInheritance: true, ngImport: i0, template: "<ng-container *ngIf=\"config().visible\">\n <div class=\"row\" [formGroup]=\"formGroup\">\n <mat-form-field>\n <mat-label>{{config().label}}</mat-label>\n <mat-select formControlName=\"{{config().attrName}}\">\n @for (option of config().selectables; track option) {\n <mat-option [value]=\"option.value\">{{option.value}}</mat-option>\n }\n </mat-select>\n </mat-form-field>\n </div>\n</ng-container>", dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: MatLabel, selector: "mat-label" }, { kind: "component", type: MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "ngmodule", type: MatSelectModule }, { kind: "component", type: i2$1.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth", "canSelectNullableOptions"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "component", type: i2$1.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }] });
1288
1471
  }
1289
1472
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: DropdownComponent, decorators: [{
1290
1473
  type: Component,
@@ -1334,22 +1517,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImpo
1334
1517
  }]
1335
1518
  }], ctorParameters: () => [{ type: i0.ViewContainerRef }] });
1336
1519
 
1337
- var FlexDirection;
1338
- (function (FlexDirection) {
1339
- FlexDirection[FlexDirection["CONTAINER"] = 0] = "CONTAINER";
1340
- FlexDirection[FlexDirection["COLUMN"] = 1] = "COLUMN";
1341
- FlexDirection[FlexDirection["ROW"] = 2] = "ROW";
1342
- })(FlexDirection || (FlexDirection = {}));
1343
- class FlexboxDescriptor extends AbstractAttrDescriptor {
1344
- attrDescriptors;
1345
- direction;
1346
- constructor(attrDescriptors, direction) {
1347
- super('dummy', FormControlType.FLEX_BOX);
1348
- this.attrDescriptors = attrDescriptors;
1349
- this.direction = direction;
1350
- }
1351
- }
1352
-
1353
1520
  class FlexBoxComponent extends BaseFormControlComponent {
1354
1521
  flexBoxHost;
1355
1522
  flexBoxClass = computed(() => this.calculateFlexStyle(this.config().direction), ...(ngDevMode ? [{ debugName: "flexBoxClass" }] : /* istanbul ignore next */ []));
@@ -1522,15 +1689,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImpo
1522
1689
  }], propDecorators: { entity: [{ type: i0.Input, args: [{ isSignal: true, alias: "entity", required: true }] }], component: [{ type: i0.Input, args: [{ isSignal: true, alias: "component", required: true }] }], componentNameAttr: [{ type: i0.Input, args: [{ isSignal: true, alias: "componentNameAttr", required: true }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], formGroup: [{ type: i0.Input, args: [{ isSignal: true, alias: "formGroup", required: true }] }], linkedEntityType: [{ type: i0.Input, args: [{ isSignal: true, alias: "linkedEntityType", required: true }] }] } });
1523
1690
 
1524
1691
  class EntityComponentsListComponent extends BaseFormControlComponent {
1525
- logger = inject(NGXLogger);
1526
- linkedEntityType = computed(() => {
1527
- this.logger.debug('config(): ', this.config());
1528
- const linkedEntityType = this.config().linkedEntityType;
1529
- if (linkedEntityType === undefined) {
1530
- throw new Error('linkedEntityType should be defined for EntityComponentsListComponent.');
1531
- }
1532
- return linkedEntityType;
1533
- }, ...(ngDevMode ? [{ debugName: "linkedEntityType" }] : /* istanbul ignore next */ []));
1534
1692
  ngOnInit() {
1535
1693
  this.addSelectedComponentFromNavigatorResponse();
1536
1694
  }
@@ -1703,8 +1861,8 @@ class LookupComponent extends BaseFormControlComponent {
1703
1861
  }
1704
1862
  });
1705
1863
  }
1706
- selectLookupItem(event) {
1707
- this.setLookupKey(String(event.option.value ?? ''));
1864
+ selectLookupItem(selectedValue) {
1865
+ this.setLookupKey(String(selectedValue ?? ''));
1708
1866
  this.restoreSelectedValue();
1709
1867
  }
1710
1868
  restoreSelectedValue() {
@@ -1714,15 +1872,14 @@ class LookupComponent extends BaseFormControlComponent {
1714
1872
  this.filterText.set(displayValue);
1715
1873
  }
1716
1874
  navigateToRelated() {
1717
- const relatedEntityName = this.config().linkedEntityType?.entityName;
1718
1875
  const relatedEntityId = this.selectedLookupItem()?.id ?? this.lookupKey();
1719
- if (!relatedEntityName || !relatedEntityId) {
1876
+ if (!relatedEntityId) {
1720
1877
  return;
1721
1878
  }
1722
- this.formNavigator.navigateToRelated(relatedEntityName, relatedEntityId, this.formNavigator.determineCurrentUrl());
1879
+ this.formNavigator.navigateToRelated(this.linkedEntityType().entityName, relatedEntityId, this.formNavigator.determineCurrentUrl());
1723
1880
  }
1724
1881
  canNavigateToRelated() {
1725
- return !!this.config().linkedEntityType?.entityName && !!(this.selectedLookupItem()?.id ?? this.lookupKey());
1882
+ return !!(this.selectedLookupItem()?.id ?? this.lookupKey());
1726
1883
  }
1727
1884
  lookupDisplayValue(lookupItem) {
1728
1885
  return lookupItem.value === undefined || lookupItem.value === null ? lookupItem.key : String(lookupItem.value);
@@ -1775,7 +1932,7 @@ class LookupComponent extends BaseFormControlComponent {
1775
1932
  <button type="button" mat-icon-button matSuffix [disabled]="!canNavigateToRelated()" (click)="navigateToRelated()" aria-label="Related entity">
1776
1933
  <mat-icon>link</mat-icon>
1777
1934
  </button>
1778
- <mat-autocomplete #lookupOptions="matAutocomplete" (optionSelected)="selectLookupItem($event)">
1935
+ <mat-autocomplete #lookupOptions="matAutocomplete" (optionSelected)="selectLookupItem($any($event).option.value)">
1779
1936
  @for (lookupItem of filteredLookupItems(); track lookupItem.key) {
1780
1937
  <mat-option [value]="lookupItem.key">{{ lookupDisplayValue(lookupItem) }}</mat-option>
1781
1938
  }
@@ -1784,7 +1941,7 @@ class LookupComponent extends BaseFormControlComponent {
1784
1941
  <input type="hidden" [formControlName]="config().attrName" />
1785
1942
  </div>
1786
1943
  </ng-container>
1787
- `, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i1$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: MatLabel, selector: "mat-label" }, { kind: "component", type: MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "ngmodule", type: MatAutocompleteModule }, { kind: "component", type: i2$1.MatAutocomplete, selector: "mat-autocomplete", inputs: ["aria-label", "aria-labelledby", "displayWith", "autoActiveFirstOption", "autoSelectActiveOption", "requireSelection", "panelWidth", "disableRipple", "class", "hideSingleSelectionIndicator"], outputs: ["optionSelected", "opened", "closed", "optionActivated"], exportAs: ["matAutocomplete"] }, { kind: "component", type: i2.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "directive", type: i2$1.MatAutocompleteTrigger, selector: "input[matAutocomplete], textarea[matAutocomplete]", inputs: ["matAutocomplete", "matAutocompletePosition", "matAutocompleteConnectedTo", "autocomplete", "matAutocompleteDisabled"], exportAs: ["matAutocompleteTrigger"] }, { kind: "component", type: MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }] });
1944
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i1$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: MatLabel, selector: "mat-label" }, { kind: "component", type: MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "ngmodule", type: MatAutocompleteModule }, { kind: "component", type: i2$2.MatAutocomplete, selector: "mat-autocomplete", inputs: ["aria-label", "aria-labelledby", "displayWith", "autoActiveFirstOption", "autoSelectActiveOption", "requireSelection", "panelWidth", "disableRipple", "class", "hideSingleSelectionIndicator"], outputs: ["optionSelected", "opened", "closed", "optionActivated"], exportAs: ["matAutocomplete"] }, { kind: "component", type: i2$1.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "directive", type: i2$2.MatAutocompleteTrigger, selector: "input[matAutocomplete], textarea[matAutocomplete]", inputs: ["matAutocomplete", "matAutocompletePosition", "matAutocompleteConnectedTo", "autocomplete", "matAutocompleteDisabled"], exportAs: ["matAutocompleteTrigger"] }, { kind: "component", type: MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }] });
1788
1945
  }
1789
1946
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: LookupComponent, decorators: [{
1790
1947
  type: Component,
@@ -1800,7 +1957,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImpo
1800
1957
  <button type="button" mat-icon-button matSuffix [disabled]="!canNavigateToRelated()" (click)="navigateToRelated()" aria-label="Related entity">
1801
1958
  <mat-icon>link</mat-icon>
1802
1959
  </button>
1803
- <mat-autocomplete #lookupOptions="matAutocomplete" (optionSelected)="selectLookupItem($event)">
1960
+ <mat-autocomplete #lookupOptions="matAutocomplete" (optionSelected)="selectLookupItem($any($event).option.value)">
1804
1961
  @for (lookupItem of filteredLookupItems(); track lookupItem.key) {
1805
1962
  <mat-option [value]="lookupItem.key">{{ lookupDisplayValue(lookupItem) }}</mat-option>
1806
1963
  }
@@ -1844,7 +2001,7 @@ class BaseEntityFormBuilder {
1844
2001
  this.buildForm(componentRef.instance.flexBoxHost.viewContainerRef, baseEntityForm, store, column.attrDescriptors, entity);
1845
2002
  }
1846
2003
  else
1847
- throw Error('Undefined subclass of AbstractAttrDescriptor: ' + column);
2004
+ throw Error('Undefined subclass of AbstractAttrDescriptor');
1848
2005
  }
1849
2006
  });
1850
2007
  }
@@ -1891,7 +2048,7 @@ class BaseEntityFormBuilder {
1891
2048
  return TextboxComponent;
1892
2049
  }
1893
2050
  else
1894
- throw Error('Undefined form control type: ' + column.formControlType);
2051
+ throw Error('Undefined form control type');
1895
2052
  }
1896
2053
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: BaseEntityFormBuilder, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1897
2054
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: BaseEntityFormBuilder, providedIn: 'root' });
@@ -1906,12 +2063,12 @@ class BaseEntityFormComponent {
1906
2063
  entityDescriptor = inject(ROUTER_OUTLET_DATA);
1907
2064
  entity = computed(() => (this.isNewObject() ? this.store().createEntity() : this.store().loadById(this.entityId())), ...(ngDevMode ? [{ debugName: "entity" }] : /* istanbul ignore next */ []));
1908
2065
  entityId = input.required(...(ngDevMode ? [{ debugName: "entityId" }] : /* istanbul ignore next */ []));
1909
- componentHost;
2066
+ isNewObject = computed(() => this.entityId() === BaseUrlSegments.NewEntity, ...(ngDevMode ? [{ debugName: "isNewObject" }] : /* istanbul ignore next */ []));
1910
2067
  store = computed(() => this.entityDescriptor().store, ...(ngDevMode ? [{ debugName: "store" }] : /* istanbul ignore next */ []));
2068
+ componentHost;
1911
2069
  entityFormBuilder = inject((BaseEntityFormBuilder));
1912
2070
  formBuilder = inject(FormBuilder);
1913
2071
  formNavigator = inject(BaseFormNavigatorSingletonStore);
1914
- isNewObject = computed(() => this.entityId() === BaseUrlSegments.NewEntity, ...(ngDevMode ? [{ debugName: "isNewObject" }] : /* istanbul ignore next */ []));
1915
2072
  logger = inject(NGXLogger);
1916
2073
  constructor() {
1917
2074
  this.registerEffects();
@@ -1929,15 +2086,19 @@ class BaseEntityFormComponent {
1929
2086
  this.store().setCurrentEntity(undefined);
1930
2087
  await this.formNavigator.navigateBack();
1931
2088
  }
2089
+ async onDelete() {
2090
+ await this.store().delete(this.entityId());
2091
+ await this.formNavigator.navigateBack();
2092
+ }
1932
2093
  async onSubmit() {
1933
2094
  const objectToSave = { ...this.entity(), ...this.baseEntityForm.value };
2095
+ this.store().setCurrentEntity(undefined);
1934
2096
  if (this.isNewObject()) {
1935
- this.store().add(objectToSave);
2097
+ await this.store().add(objectToSave);
1936
2098
  }
1937
2099
  else {
1938
- this.store().update(objectToSave, objectToSave.id);
2100
+ await this.store().update(objectToSave);
1939
2101
  }
1940
- this.store().setCurrentEntity(undefined);
1941
2102
  await this.formNavigator.navigateBack();
1942
2103
  }
1943
2104
  // endregion
@@ -1955,28 +2116,16 @@ class BaseEntityFormComponent {
1955
2116
  });
1956
2117
  }
1957
2118
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: BaseEntityFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1958
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.12", type: BaseEntityFormComponent, isStandalone: true, selector: "base-form", inputs: { entityId: { classPropertyName: "entityId", publicName: "entityId", isSignal: true, isRequired: true, transformFunction: null } }, providers: [{ provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: { appearance: 'outline' } }], viewQueries: [{ propertyName: "componentHost", first: true, predicate: BaseFormHostDirective, descendants: true, read: BaseFormHostDirective, static: true }], ngImport: i0, template: "<mat-card appearance=\"outlined\" class=\"dense-3\">\n <mat-card-content>\n <form [formGroup]=\"baseEntityForm\" (ngSubmit)=\"onSubmit()\">\n <ng-template baseFormHost></ng-template>\n </form>\n </mat-card-content>\n <mat-card-actions>\n <button id=\"cancel\" mat-raised-button color=\"secondary\" (click)=\"onCancel()\">Cancel</button>\n <button id=\"submit\" mat-raised-button color=\"primary\" type=\"submit\" [disabled]=\"baseEntityForm.invalid || !baseEntityForm.dirty\" (click)=\"onSubmit()\">Save</button>\n </mat-card-actions>\n</mat-card>\n", dependencies: [{ kind: "directive", type: BaseFormHostDirective, selector: "[baseFormHost]" }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: MatCard, selector: "mat-card", inputs: ["appearance"], exportAs: ["matCard"] }, { kind: "directive", type: MatCardContent, selector: "mat-card-content" }, { kind: "directive", type: MatCardActions, selector: "mat-card-actions", inputs: ["align"], exportAs: ["matCardActions"] }, { kind: "component", type: MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }] });
2119
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.12", type: BaseEntityFormComponent, isStandalone: true, selector: "base-form", inputs: { entityId: { classPropertyName: "entityId", publicName: "entityId", isSignal: true, isRequired: true, transformFunction: null } }, providers: [{ provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: { appearance: 'outline' } }], viewQueries: [{ propertyName: "componentHost", first: true, predicate: BaseFormHostDirective, descendants: true, read: BaseFormHostDirective, static: true }], ngImport: i0, template: "<mat-card appearance=\"outlined\" class=\"dense-3\">\n <mat-card-content>\n <form [formGroup]=\"baseEntityForm\" (ngSubmit)=\"onSubmit()\">\n <ng-template baseFormHost></ng-template>\n </form>\n </mat-card-content>\n <mat-card-actions>\n <button id=\"cancel\" [attr.data-testid]=\"entityDescriptor().createTestId('cancel')\" mat-raised-button color=\"secondary\" (click)=\"onCancel()\">Cancel</button>\n <button id=\"delete\" [attr.data-testid]=\"entityDescriptor().createTestId('delete')\" mat-raised-button color=\"primary\" type=\"button\" [disabled]=\"isNewObject()\" (click)=\"onDelete()\">Delete</button>\n <button id=\"submit\" [attr.data-testid]=\"entityDescriptor().createTestId('save')\" mat-raised-button color=\"primary\" type=\"submit\" [disabled]=\"baseEntityForm.invalid || !baseEntityForm.dirty\" (click)=\"onSubmit()\">Save</button>\n </mat-card-actions>\n</mat-card>\n", dependencies: [{ kind: "directive", type: BaseFormHostDirective, selector: "[baseFormHost]" }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: MatCard, selector: "mat-card", inputs: ["appearance"], exportAs: ["matCard"] }, { kind: "directive", type: MatCardContent, selector: "mat-card-content" }, { kind: "directive", type: MatCardActions, selector: "mat-card-actions", inputs: ["align"], exportAs: ["matCardActions"] }, { kind: "component", type: MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }] });
1959
2120
  }
1960
2121
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: BaseEntityFormComponent, decorators: [{
1961
2122
  type: Component,
1962
- args: [{ selector: 'base-form', standalone: true, imports: [BaseFormHostDirective, ReactiveFormsModule, MatCard, MatCardContent, MatCardActions, MatButton], providers: [{ provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: { appearance: 'outline' } }], template: "<mat-card appearance=\"outlined\" class=\"dense-3\">\n <mat-card-content>\n <form [formGroup]=\"baseEntityForm\" (ngSubmit)=\"onSubmit()\">\n <ng-template baseFormHost></ng-template>\n </form>\n </mat-card-content>\n <mat-card-actions>\n <button id=\"cancel\" mat-raised-button color=\"secondary\" (click)=\"onCancel()\">Cancel</button>\n <button id=\"submit\" mat-raised-button color=\"primary\" type=\"submit\" [disabled]=\"baseEntityForm.invalid || !baseEntityForm.dirty\" (click)=\"onSubmit()\">Save</button>\n </mat-card-actions>\n</mat-card>\n" }]
2123
+ args: [{ selector: 'base-form', standalone: true, imports: [BaseFormHostDirective, ReactiveFormsModule, MatCard, MatCardContent, MatCardActions, MatButton], providers: [{ provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: { appearance: 'outline' } }], template: "<mat-card appearance=\"outlined\" class=\"dense-3\">\n <mat-card-content>\n <form [formGroup]=\"baseEntityForm\" (ngSubmit)=\"onSubmit()\">\n <ng-template baseFormHost></ng-template>\n </form>\n </mat-card-content>\n <mat-card-actions>\n <button id=\"cancel\" [attr.data-testid]=\"entityDescriptor().createTestId('cancel')\" mat-raised-button color=\"secondary\" (click)=\"onCancel()\">Cancel</button>\n <button id=\"delete\" [attr.data-testid]=\"entityDescriptor().createTestId('delete')\" mat-raised-button color=\"primary\" type=\"button\" [disabled]=\"isNewObject()\" (click)=\"onDelete()\">Delete</button>\n <button id=\"submit\" [attr.data-testid]=\"entityDescriptor().createTestId('save')\" mat-raised-button color=\"primary\" type=\"submit\" [disabled]=\"baseEntityForm.invalid || !baseEntityForm.dirty\" (click)=\"onSubmit()\">Save</button>\n </mat-card-actions>\n</mat-card>\n" }]
1963
2124
  }], ctorParameters: () => [], propDecorators: { entityId: [{ type: i0.Input, args: [{ isSignal: true, alias: "entityId", required: true }] }], componentHost: [{
1964
2125
  type: ViewChild,
1965
2126
  args: [BaseFormHostDirective, { static: true, read: BaseFormHostDirective }]
1966
2127
  }] } });
1967
2128
 
1968
- function filterAttributeDescriptors(descriptors) {
1969
- let attrDescriptors = [];
1970
- descriptors.forEach((descriptor) => {
1971
- if (descriptor instanceof BaseEntityAttrDescriptor)
1972
- attrDescriptors.push(descriptor);
1973
- else if (descriptor instanceof FlexboxDescriptor) {
1974
- attrDescriptors = attrDescriptors.concat(filterAttributeDescriptors(descriptor.attrDescriptors));
1975
- }
1976
- });
1977
- return attrDescriptors;
1978
- }
1979
-
1980
2129
  class BaseEntityDescriptor {
1981
2130
  store;
1982
2131
  attrDescriptors;
@@ -1988,6 +2137,9 @@ class BaseEntityDescriptor {
1988
2137
  this.entityName = entityName;
1989
2138
  this.entityTitle = entityTitle ?? '';
1990
2139
  }
2140
+ createTestId(suffix) {
2141
+ return createTestId(this.entityName, suffix);
2142
+ }
1991
2143
  componentIdentification() {
1992
2144
  const attrDescriptor = filterAttributeDescriptors(this.attrDescriptors).find((attrDescriptor) => attrDescriptor.isLinkToDetails === true);
1993
2145
  return attrDescriptor?.attrName ?? '';
@@ -2126,10 +2278,7 @@ class BaseEntityListComponent {
2126
2278
  }
2127
2279
  registerEffects() {
2128
2280
  effect(() => (this.dataSource.data = this.store.entities()));
2129
- effect(() => {
2130
- if (this.store.filterKey())
2131
- this.doFilter(this.store.filterKey());
2132
- });
2281
+ effect(() => this.doFilter(this.store.filterKey() ?? ''));
2133
2282
  }
2134
2283
  // endregion
2135
2284
  // region properties
@@ -2145,7 +2294,7 @@ class BaseEntityListComponent {
2145
2294
  return this.selection.selected.length === 1;
2146
2295
  }
2147
2296
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: BaseEntityListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2148
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.12", type: BaseEntityListComponent, isStandalone: true, selector: "base-list", viewQueries: [{ propertyName: "sort", first: true, predicate: MatSort, descendants: true }, { propertyName: "paginator", first: true, predicate: MatPaginator, descendants: true }], ngImport: i0, template: "@if (store.isLoading()) {\n <mat-progress-bar mode=\"query\"></mat-progress-bar>\n}\n<div class=\"base-entity-list mat-elevation-z8\">\n <mat-table [dataSource]=\"dataSource\" matSort aria-describedby=\"base-entity-list\">\n <!-- Checkbox Column -->\n <ng-container matColumnDef=\"select\">\n <mat-header-cell *matHeaderCellDef>\n <mat-checkbox (change)=\"$event ? onToggleAllRows() : null\" [checked]=\"selection.hasValue() && isAllSelected()\" [indeterminate]=\"selection.hasValue() && !isAllSelected()\"> </mat-checkbox>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let row\">\n <mat-checkbox (click)=\"$event.stopPropagation()\" (change)=\"$event ? selection.toggle(row) : null; onChangeSelection(row)\" [checked]=\"selection.isSelected(row)\"></mat-checkbox>\n </mat-cell>\n </ng-container>\n\n @for (colDescriptor of columnDescriptors(); track colDescriptor.attrName; let i = $index) {\n <ng-container [matColumnDef]=\"colDescriptor.attrName\">\n <mat-header-cell *matHeaderCellDef mat-sort-header>{{ colDescriptor.label }}</mat-header-cell>\n <mat-cell (click)=\"onRowClick(element)\" *matCellDef=\"let element\">\n @if (colDescriptor.isLinkToDetails) {\n <a (click)=\"onNavigateToDetails(element)\">{{ element[colDescriptor.attrName] }}</a>\n } @else if (colDescriptor.linkedEntityType !== undefined ) {\n <a (click)=\"onNavigateToRelated(colDescriptor, element)\">{{ element[colDescriptor.attrName] }}</a>\n } @else if (colDescriptor.formControlType === 'ARTIFACT' && element[colDescriptor.attrName] !== undefined ) {\n @let artifact = element[colDescriptor.attrName];\n <a (click)=\"onDownloadObject(artifact, $event)\">{{ ((artifact.name ?? artifact.objectId ?? '') | slice:0:20) + ((artifact.name ?? artifact.objectId ?? '').length > 20 ? '...' : '') }}</a>\n } @else if (colDescriptor.formControlType === 'TAGS' && element[colDescriptor.attrName] !== undefined ) {\n {{ (element[colDescriptor.attrName].join(', ') | slice:0:20) + (element[colDescriptor.attrName].join(', ').length > 20 ? '...' : '') }}\n } @else {\n {{ element[colDescriptor.attrName] }}\n }\n </mat-cell>\n </ng-container>\n }\n <mat-header-row *matHeaderRowDef=\"displayedColumns()\"></mat-header-row>\n <mat-row *matRowDef=\"let row; columns: displayedColumns()\"></mat-row>\n </mat-table>\n <mat-paginator [pageSizeOptions]=\"[3, 5, 8]\" showFirstLastButtons></mat-paginator>\n</div>\n@if (selectOrCreateMode) {\n <div class=\"base-entity-list-actions\">\n <button id=\"cancel\" type=\"button\" mat-raised-button color=\"secondary\" (click)=\"onCancelSelectOrCreate()\">Cancel</button>\n <button id=\"select\" type=\"button\" mat-raised-button color=\"primary\" [disabled]=\"!canSelectEntity()\" (click)=\"onSelectEntity()\">Select</button>\n </div>\n}\n", styles: [".base-entity-list{display:flex;flex-direction:column;max-height:500px;min-width:300px}.mat-table{overflow:auto;max-height:500px}.mat-column-select{overflow:visible}.mat-column-select{overflow:initial}.mat-mdc-row:hover{background-color:#6495ed;cursor:pointer}.base-entity-list-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:16px}\n"], dependencies: [{ kind: "component", type: MatTable, selector: "mat-table, table[mat-table]", exportAs: ["matTable"] }, { kind: "directive", type: MatSort, selector: "[matSort]", inputs: ["matSortActive", "matSortStart", "matSortDirection", "matSortDisableClear", "matSortDisabled"], outputs: ["matSortChange"], exportAs: ["matSort"] }, { kind: "directive", type: MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { kind: "component", type: MatPaginator, selector: "mat-paginator", inputs: ["color", "pageIndex", "length", "pageSize", "pageSizeOptions", "hidePageSize", "showFirstLastButtons", "selectConfig", "disabled"], outputs: ["page"], exportAs: ["matPaginator"] }, { kind: "component", type: MatHeaderRow, selector: "mat-header-row, tr[mat-header-row]", exportAs: ["matHeaderRow"] }, { kind: "component", type: MatRow, selector: "mat-row, tr[mat-row]", exportAs: ["matRow"] }, { kind: "directive", type: MatCell, selector: "mat-cell, td[mat-cell]" }, { kind: "directive", type: MatColumnDef, selector: "[matColumnDef]", inputs: ["matColumnDef"] }, { kind: "directive", type: MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { kind: "directive", type: MatCellDef, selector: "[matCellDef]" }, { kind: "directive", type: MatHeaderRowDef, selector: "[matHeaderRowDef]", inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"] }, { kind: "directive", type: MatRowDef, selector: "[matRowDef]", inputs: ["matRowDefColumns", "matRowDefWhen"] }, { kind: "component", type: MatSortHeader, selector: "[mat-sort-header]", inputs: ["mat-sort-header", "arrowPosition", "start", "disabled", "sortActionDescription", "disableClear"], exportAs: ["matSortHeader"] }, { kind: "component", type: MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "component", type: MatCheckbox, selector: "mat-checkbox", inputs: ["aria-label", "aria-labelledby", "aria-describedby", "aria-expanded", "aria-controls", "aria-owns", "id", "required", "labelPosition", "name", "value", "disableRipple", "tabIndex", "color", "disabledInteractive", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { kind: "component", type: MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }, { kind: "pipe", type: SlicePipe, name: "slice" }] });
2297
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.12", type: BaseEntityListComponent, isStandalone: true, selector: "base-list", viewQueries: [{ propertyName: "sort", first: true, predicate: MatSort, descendants: true }, { propertyName: "paginator", first: true, predicate: MatPaginator, descendants: true }], ngImport: i0, template: "@if (store.isLoading()) {\n <mat-progress-bar mode=\"query\"></mat-progress-bar>\n}\n<div class=\"base-entity-list mat-elevation-z8\">\n <mat-table [dataSource]=\"dataSource\" matSort aria-describedby=\"base-entity-list\">\n <!-- Checkbox Column -->\n <ng-container matColumnDef=\"select\">\n <mat-header-cell *matHeaderCellDef>\n <mat-checkbox (change)=\"$event ? onToggleAllRows() : null\" [checked]=\"selection.hasValue() && isAllSelected()\" [indeterminate]=\"selection.hasValue() && !isAllSelected()\"> </mat-checkbox>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let row\">\n <mat-checkbox (click)=\"$event.stopPropagation()\" (change)=\"$event ? selection.toggle(row) : null; onChangeSelection(row)\" [checked]=\"selection.isSelected(row)\"></mat-checkbox>\n </mat-cell>\n </ng-container>\n\n @for (colDescriptor of columnDescriptors(); track colDescriptor.attrName; let i = $index) {\n <ng-container [matColumnDef]=\"colDescriptor.attrName\">\n <mat-header-cell *matHeaderCellDef mat-sort-header>{{ colDescriptor.label }}</mat-header-cell>\n <mat-cell (click)=\"onRowClick(element)\" *matCellDef=\"let element\">\n @if (colDescriptor.isLinkToDetails) {\n <a (click)=\"onNavigateToDetails(element)\">{{ element[colDescriptor.attrName] }}</a>\n } @else if (colDescriptor.linkedEntityType !== undefined ) {\n <a (click)=\"onNavigateToRelated(colDescriptor, element)\">{{ element[colDescriptor.attrName] }}</a>\n } @else if (colDescriptor.formControlType === 'ARTIFACT' && element[colDescriptor.attrName] !== undefined ) {\n @let artifact = element[colDescriptor.attrName];\n <a (click)=\"onDownloadObject(artifact, $event)\">{{ ((artifact.name ?? artifact.objectId ?? '') | slice:0:20) + ((artifact.name ?? artifact.objectId ?? '').length > 20 ? '...' : '') }}</a>\n } @else if (colDescriptor.formControlType === 'TAGS' && element[colDescriptor.attrName] !== undefined ) {\n {{ (element[colDescriptor.attrName].join(', ') | slice:0:20) + (element[colDescriptor.attrName].join(', ').length > 20 ? '...' : '') }}\n } @else {\n {{ element[colDescriptor.attrName] }}\n }\n </mat-cell>\n </ng-container>\n }\n <mat-header-row *matHeaderRowDef=\"displayedColumns()\"></mat-header-row>\n <mat-row *matRowDef=\"let row; columns: displayedColumns()\"></mat-row>\n </mat-table>\n <mat-paginator [pageSizeOptions]=\"[10, 20, 50]\" showFirstLastButtons></mat-paginator>\n</div>\n@if (selectOrCreateMode) {\n <div class=\"base-entity-list-actions\">\n <button id=\"cancel\" [attr.data-testid]=\"entityDescriptor().createTestId('cancel')\" type=\"button\" mat-raised-button color=\"secondary\" (click)=\"onCancelSelectOrCreate()\">Cancel</button>\n <button id=\"select\" [attr.data-testid]=\"entityDescriptor().createTestId( 'select')\" type=\"button\" mat-raised-button color=\"primary\" [disabled]=\"!canSelectEntity()\" (click)=\"onSelectEntity()\">Select</button>\n </div>\n}\n", styles: [".base-entity-list{display:flex;flex-direction:column;max-height:500px;min-width:300px}.mat-table{overflow:auto;max-height:500px}.mat-column-select{overflow:visible}.mat-column-select{overflow:initial}.mat-mdc-row:hover{background-color:#6495ed;cursor:pointer}.base-entity-list-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:16px}\n"], dependencies: [{ kind: "component", type: MatTable, selector: "mat-table, table[mat-table]", exportAs: ["matTable"] }, { kind: "directive", type: MatSort, selector: "[matSort]", inputs: ["matSortActive", "matSortStart", "matSortDirection", "matSortDisableClear", "matSortDisabled"], outputs: ["matSortChange"], exportAs: ["matSort"] }, { kind: "directive", type: MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { kind: "component", type: MatPaginator, selector: "mat-paginator", inputs: ["color", "pageIndex", "length", "pageSize", "pageSizeOptions", "hidePageSize", "showFirstLastButtons", "selectConfig", "disabled"], outputs: ["page"], exportAs: ["matPaginator"] }, { kind: "component", type: MatHeaderRow, selector: "mat-header-row, tr[mat-header-row]", exportAs: ["matHeaderRow"] }, { kind: "component", type: MatRow, selector: "mat-row, tr[mat-row]", exportAs: ["matRow"] }, { kind: "directive", type: MatCell, selector: "mat-cell, td[mat-cell]" }, { kind: "directive", type: MatColumnDef, selector: "[matColumnDef]", inputs: ["matColumnDef"] }, { kind: "directive", type: MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { kind: "directive", type: MatCellDef, selector: "[matCellDef]" }, { kind: "directive", type: MatHeaderRowDef, selector: "[matHeaderRowDef]", inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"] }, { kind: "directive", type: MatRowDef, selector: "[matRowDef]", inputs: ["matRowDefColumns", "matRowDefWhen"] }, { kind: "component", type: MatSortHeader, selector: "[mat-sort-header]", inputs: ["mat-sort-header", "arrowPosition", "start", "disabled", "sortActionDescription", "disableClear"], exportAs: ["matSortHeader"] }, { kind: "component", type: MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "component", type: MatCheckbox, selector: "mat-checkbox", inputs: ["aria-label", "aria-labelledby", "aria-describedby", "aria-expanded", "aria-controls", "aria-owns", "id", "required", "labelPosition", "name", "value", "disableRipple", "tabIndex", "color", "disabledInteractive", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { kind: "component", type: MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }, { kind: "pipe", type: SlicePipe, name: "slice" }] });
2149
2298
  }
2150
2299
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: BaseEntityListComponent, decorators: [{
2151
2300
  type: Component,
@@ -2167,7 +2316,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImpo
2167
2316
  MatCheckbox,
2168
2317
  SlicePipe,
2169
2318
  MatButton,
2170
- ], template: "@if (store.isLoading()) {\n <mat-progress-bar mode=\"query\"></mat-progress-bar>\n}\n<div class=\"base-entity-list mat-elevation-z8\">\n <mat-table [dataSource]=\"dataSource\" matSort aria-describedby=\"base-entity-list\">\n <!-- Checkbox Column -->\n <ng-container matColumnDef=\"select\">\n <mat-header-cell *matHeaderCellDef>\n <mat-checkbox (change)=\"$event ? onToggleAllRows() : null\" [checked]=\"selection.hasValue() && isAllSelected()\" [indeterminate]=\"selection.hasValue() && !isAllSelected()\"> </mat-checkbox>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let row\">\n <mat-checkbox (click)=\"$event.stopPropagation()\" (change)=\"$event ? selection.toggle(row) : null; onChangeSelection(row)\" [checked]=\"selection.isSelected(row)\"></mat-checkbox>\n </mat-cell>\n </ng-container>\n\n @for (colDescriptor of columnDescriptors(); track colDescriptor.attrName; let i = $index) {\n <ng-container [matColumnDef]=\"colDescriptor.attrName\">\n <mat-header-cell *matHeaderCellDef mat-sort-header>{{ colDescriptor.label }}</mat-header-cell>\n <mat-cell (click)=\"onRowClick(element)\" *matCellDef=\"let element\">\n @if (colDescriptor.isLinkToDetails) {\n <a (click)=\"onNavigateToDetails(element)\">{{ element[colDescriptor.attrName] }}</a>\n } @else if (colDescriptor.linkedEntityType !== undefined ) {\n <a (click)=\"onNavigateToRelated(colDescriptor, element)\">{{ element[colDescriptor.attrName] }}</a>\n } @else if (colDescriptor.formControlType === 'ARTIFACT' && element[colDescriptor.attrName] !== undefined ) {\n @let artifact = element[colDescriptor.attrName];\n <a (click)=\"onDownloadObject(artifact, $event)\">{{ ((artifact.name ?? artifact.objectId ?? '') | slice:0:20) + ((artifact.name ?? artifact.objectId ?? '').length > 20 ? '...' : '') }}</a>\n } @else if (colDescriptor.formControlType === 'TAGS' && element[colDescriptor.attrName] !== undefined ) {\n {{ (element[colDescriptor.attrName].join(', ') | slice:0:20) + (element[colDescriptor.attrName].join(', ').length > 20 ? '...' : '') }}\n } @else {\n {{ element[colDescriptor.attrName] }}\n }\n </mat-cell>\n </ng-container>\n }\n <mat-header-row *matHeaderRowDef=\"displayedColumns()\"></mat-header-row>\n <mat-row *matRowDef=\"let row; columns: displayedColumns()\"></mat-row>\n </mat-table>\n <mat-paginator [pageSizeOptions]=\"[3, 5, 8]\" showFirstLastButtons></mat-paginator>\n</div>\n@if (selectOrCreateMode) {\n <div class=\"base-entity-list-actions\">\n <button id=\"cancel\" type=\"button\" mat-raised-button color=\"secondary\" (click)=\"onCancelSelectOrCreate()\">Cancel</button>\n <button id=\"select\" type=\"button\" mat-raised-button color=\"primary\" [disabled]=\"!canSelectEntity()\" (click)=\"onSelectEntity()\">Select</button>\n </div>\n}\n", styles: [".base-entity-list{display:flex;flex-direction:column;max-height:500px;min-width:300px}.mat-table{overflow:auto;max-height:500px}.mat-column-select{overflow:visible}.mat-column-select{overflow:initial}.mat-mdc-row:hover{background-color:#6495ed;cursor:pointer}.base-entity-list-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:16px}\n"] }]
2319
+ ], template: "@if (store.isLoading()) {\n <mat-progress-bar mode=\"query\"></mat-progress-bar>\n}\n<div class=\"base-entity-list mat-elevation-z8\">\n <mat-table [dataSource]=\"dataSource\" matSort aria-describedby=\"base-entity-list\">\n <!-- Checkbox Column -->\n <ng-container matColumnDef=\"select\">\n <mat-header-cell *matHeaderCellDef>\n <mat-checkbox (change)=\"$event ? onToggleAllRows() : null\" [checked]=\"selection.hasValue() && isAllSelected()\" [indeterminate]=\"selection.hasValue() && !isAllSelected()\"> </mat-checkbox>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let row\">\n <mat-checkbox (click)=\"$event.stopPropagation()\" (change)=\"$event ? selection.toggle(row) : null; onChangeSelection(row)\" [checked]=\"selection.isSelected(row)\"></mat-checkbox>\n </mat-cell>\n </ng-container>\n\n @for (colDescriptor of columnDescriptors(); track colDescriptor.attrName; let i = $index) {\n <ng-container [matColumnDef]=\"colDescriptor.attrName\">\n <mat-header-cell *matHeaderCellDef mat-sort-header>{{ colDescriptor.label }}</mat-header-cell>\n <mat-cell (click)=\"onRowClick(element)\" *matCellDef=\"let element\">\n @if (colDescriptor.isLinkToDetails) {\n <a (click)=\"onNavigateToDetails(element)\">{{ element[colDescriptor.attrName] }}</a>\n } @else if (colDescriptor.linkedEntityType !== undefined ) {\n <a (click)=\"onNavigateToRelated(colDescriptor, element)\">{{ element[colDescriptor.attrName] }}</a>\n } @else if (colDescriptor.formControlType === 'ARTIFACT' && element[colDescriptor.attrName] !== undefined ) {\n @let artifact = element[colDescriptor.attrName];\n <a (click)=\"onDownloadObject(artifact, $event)\">{{ ((artifact.name ?? artifact.objectId ?? '') | slice:0:20) + ((artifact.name ?? artifact.objectId ?? '').length > 20 ? '...' : '') }}</a>\n } @else if (colDescriptor.formControlType === 'TAGS' && element[colDescriptor.attrName] !== undefined ) {\n {{ (element[colDescriptor.attrName].join(', ') | slice:0:20) + (element[colDescriptor.attrName].join(', ').length > 20 ? '...' : '') }}\n } @else {\n {{ element[colDescriptor.attrName] }}\n }\n </mat-cell>\n </ng-container>\n }\n <mat-header-row *matHeaderRowDef=\"displayedColumns()\"></mat-header-row>\n <mat-row *matRowDef=\"let row; columns: displayedColumns()\"></mat-row>\n </mat-table>\n <mat-paginator [pageSizeOptions]=\"[10, 20, 50]\" showFirstLastButtons></mat-paginator>\n</div>\n@if (selectOrCreateMode) {\n <div class=\"base-entity-list-actions\">\n <button id=\"cancel\" [attr.data-testid]=\"entityDescriptor().createTestId('cancel')\" type=\"button\" mat-raised-button color=\"secondary\" (click)=\"onCancelSelectOrCreate()\">Cancel</button>\n <button id=\"select\" [attr.data-testid]=\"entityDescriptor().createTestId( 'select')\" type=\"button\" mat-raised-button color=\"primary\" [disabled]=\"!canSelectEntity()\" (click)=\"onSelectEntity()\">Select</button>\n </div>\n}\n", styles: [".base-entity-list{display:flex;flex-direction:column;max-height:500px;min-width:300px}.mat-table{overflow:auto;max-height:500px}.mat-column-select{overflow:visible}.mat-column-select{overflow:initial}.mat-mdc-row:hover{background-color:#6495ed;cursor:pointer}.base-entity-list-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:16px}\n"] }]
2171
2320
  }], ctorParameters: () => [], propDecorators: { sort: [{
2172
2321
  type: ViewChild,
2173
2322
  args: [MatSort]
@@ -2183,6 +2332,20 @@ var OrderByDirection;
2183
2332
  })(OrderByDirection || (OrderByDirection = {}));
2184
2333
 
2185
2334
  const BASE_ENTITY_MAPPER = new InjectionToken('BASE_ENTITY_MAPPER');
2335
+ class SimpleEntityMapper {
2336
+ entityType;
2337
+ constructor(entityType) {
2338
+ this.entityType = entityType;
2339
+ }
2340
+ fromDto(dto) {
2341
+ const entity = new this.entityType();
2342
+ Object.assign(entity, dto);
2343
+ return entity;
2344
+ }
2345
+ toDto(entity) {
2346
+ return { ...entity };
2347
+ }
2348
+ }
2186
2349
  function getEnumKeyByValue(myEnum, enumValue) {
2187
2350
  return Object.values(myEnum)[enumValue];
2188
2351
  }
@@ -2190,60 +2353,149 @@ function getEnumValueByKey(myEnum, enumKey) {
2190
2353
  return myEnum[enumKey];
2191
2354
  }
2192
2355
 
2193
- const INITIAL_TABS_STATE = {
2194
- activeTabs: [],
2195
- currentTab: undefined,
2196
- };
2197
- function BaseEntityTabsStore() {
2198
- return signalStoreFeature(withState(INITIAL_TABS_STATE), withMethods((store) => {
2199
- function reset() {
2200
- const activeTabs = [];
2201
- patchState(store, { activeTabs, currentTab: undefined });
2202
- }
2203
- function tabIsActive(tabName) {
2204
- let activeTabs;
2205
- if (store.activeTabs().indexOf(tabName) == -1) {
2206
- activeTabs = store.activeTabs().concat([tabName]);
2207
- }
2208
- else {
2209
- activeTabs = store.activeTabs();
2210
- }
2211
- patchState(store, { activeTabs, currentTab: tabName });
2356
+ let BaseEntityFirestoreService = class BaseEntityFirestoreService {
2357
+ entityMapper;
2358
+ collectionName;
2359
+ collection;
2360
+ firestore = inject(Firestore);
2361
+ constructor(entityMapper, collectionName) {
2362
+ this.entityMapper = entityMapper;
2363
+ this.collectionName = collectionName;
2364
+ this.collection = collection(this.firestore, collectionName);
2365
+ }
2366
+ // region public accessors and mutators
2367
+ add(entity) {
2368
+ if (!entity)
2369
+ throw new Error('Entity cant be undefined');
2370
+ return from(this.addAsync(entity));
2371
+ }
2372
+ delete(id) {
2373
+ const docRef = doc(this.firestore, this.collectionName, id);
2374
+ return from(deleteDoc(docRef));
2375
+ }
2376
+ deleteAll() {
2377
+ return of(undefined);
2378
+ }
2379
+ findAll(page, pageSize) {
2380
+ return this.findByQuery({ page, pageSize });
2381
+ }
2382
+ findById(id) {
2383
+ const docRef = doc(this.firestore, this.collectionName, id);
2384
+ return from(getDoc(docRef)
2385
+ .then((document) => {
2386
+ return this.mapDocument(document.data());
2387
+ })
2388
+ .catch((error) => {
2389
+ throw new Error(`Error: ${error} occurred while finding document by id: ${id}`);
2390
+ }));
2391
+ }
2392
+ findByQuery(queryCondition) {
2393
+ return from(this.findByQueryAsync(queryCondition));
2394
+ }
2395
+ update(entity) {
2396
+ return from(this.updateAsync(entity));
2397
+ }
2398
+ // endregion
2399
+ // protected, private helper methods
2400
+ async addAsync(entity) {
2401
+ const newDoc = doc(this.collection, entity.id);
2402
+ await setDoc(newDoc, this.mapEntity(entity));
2403
+ return new Promise((resolve, reject) => {
2404
+ resolve(entity);
2405
+ reject(new Error('Failed to update entity: ' + entity));
2406
+ });
2407
+ }
2408
+ createQuery(queryCondition) {
2409
+ let orderBys = [];
2410
+ if (queryCondition.orderBys && queryCondition.orderBys?.length > 0) {
2411
+ orderBys = queryCondition.orderBys?.map((orderByCondition) => {
2412
+ const name = Object.keys(OrderByDirection).filter((key) => key === orderByCondition.direction);
2413
+ const direction = Object.values(OrderByDirection).filter((value) => value === name[0]);
2414
+ return orderBy(orderByCondition.property, direction[0]);
2415
+ });
2212
2416
  }
2213
- function tabIsInactive(tabName) {
2214
- const activeTabs = store.activeTabs().filter((tab) => tab !== tabName);
2215
- patchState(store, { activeTabs, currentTab: undefined });
2417
+ let wheres = [];
2418
+ if (queryCondition.filters && queryCondition.filters?.length > 0) {
2419
+ wheres =
2420
+ queryCondition.filters?.map((filter) => {
2421
+ return where(filter.property, filter.operator, filter.value);
2422
+ }) ?? [];
2216
2423
  }
2217
- return { reset, tabIsActive, tabIsInactive };
2218
- }));
2219
- }
2220
-
2221
- const BASE_ENTITY_SERVICE = new InjectionToken('BASE_ENTITY_SERVICE');
2424
+ return query(this.collection, ...wheres, ...orderBys, limit(queryCondition.pageSize ?? 99));
2425
+ }
2426
+ async findByQueryAsync(queryCondition) {
2427
+ const query = this.createQuery(queryCondition);
2428
+ const results = await getDocs(query);
2429
+ const content = [];
2430
+ results.docs.forEach((doc) => {
2431
+ content.push(this.mapDocument({ id: doc.id, ...doc.data() }));
2432
+ });
2433
+ return Promise.resolve({
2434
+ page: queryCondition.page,
2435
+ pageSize: queryCondition.pageSize,
2436
+ totalPageCount: 1,
2437
+ content,
2438
+ });
2439
+ }
2440
+ mapCollection(collection) {
2441
+ const entities = [];
2442
+ collection.pipe(map((documents) => {
2443
+ documents.forEach((document) => entities.push(this.entityMapper.fromDto(document)));
2444
+ }));
2445
+ return entities;
2446
+ }
2447
+ mapDocument(document) {
2448
+ return this.entityMapper.fromDto(document);
2449
+ }
2450
+ mapEntity(entity) {
2451
+ return this.entityMapper.toDto(entity);
2452
+ }
2453
+ async updateAsync(entity) {
2454
+ if (!entity)
2455
+ throw new Error('Entity cant be undefined');
2456
+ const docRef = doc(this.firestore, this.collectionName, entity.id);
2457
+ await updateDoc(docRef, this.mapEntity(entity));
2458
+ return Promise.resolve(entity);
2459
+ }
2460
+ };
2461
+ BaseEntityFirestoreService = __decorate([
2462
+ __param(0, Inject('entityMapper'))
2463
+ ], BaseEntityFirestoreService);
2222
2464
 
2223
2465
  const addEntity = (store, repository) => {
2224
- return rxMethod(pipe(switchMap((entity) => {
2466
+ return async (entity) => {
2225
2467
  patchState(store, { isLoading: true, error: undefined });
2226
- return repository.add(entity).pipe(tapResponse({
2227
- next: (savedEntity) => {
2228
- patchState(store, { entities: store.entities().concat([savedEntity]), isLoading: false });
2229
- },
2230
- error: (error) => patchState(store, { error: error.message }),
2231
- finalize: () => patchState(store, { isLoading: false }),
2232
- }));
2233
- })));
2468
+ try {
2469
+ const savedEntity = await firstValueFrom(repository.add(entity));
2470
+ patchState(store, { entities: store.entities().concat([savedEntity]), isLoading: false });
2471
+ return savedEntity;
2472
+ }
2473
+ catch (error) {
2474
+ patchState(store, { error: error.message, isLoading: false });
2475
+ return undefined;
2476
+ }
2477
+ };
2234
2478
  };
2235
2479
 
2236
2480
  const deleteEntity = (store, repository) => {
2237
- return rxMethod(pipe(tap(() => patchState(store, { isLoading: true, error: undefined })), switchMap((id) => {
2238
- return repository.delete(id).pipe(tapResponse({
2239
- next: () => {
2240
- const remainingEntities = store.entities().filter((entity) => entity.id !== id);
2241
- patchState(store, { entities: remainingEntities, isLoading: false });
2242
- },
2243
- error: (error) => patchState(store, { error: error.message }),
2244
- finalize: () => patchState(store, { isLoading: false }),
2245
- }));
2246
- })));
2481
+ return async (id) => {
2482
+ patchState(store, { isLoading: true, error: undefined });
2483
+ try {
2484
+ await firstValueFrom(repository.delete(id));
2485
+ const remainingEntities = store.entities().filter((entity) => entity.id !== id);
2486
+ const remainingSelectedEntities = store.selectedEntities().filter((entity) => entity.id !== id);
2487
+ patchState(store, {
2488
+ currentEntity: undefined,
2489
+ currentId: undefined,
2490
+ entities: remainingEntities,
2491
+ selectedEntities: remainingSelectedEntities,
2492
+ isLoading: false,
2493
+ });
2494
+ }
2495
+ catch (error) {
2496
+ patchState(store, { error: error.message, isLoading: false });
2497
+ }
2498
+ };
2247
2499
  };
2248
2500
 
2249
2501
  const deleteAllEntities = (store, repository) => {
@@ -2258,19 +2510,22 @@ const deleteAllEntities = (store, repository) => {
2258
2510
  };
2259
2511
 
2260
2512
  const updateEntity = (store, repository) => {
2261
- return rxMethod(pipe(switchMap((entity) => {
2513
+ return async (entity) => {
2262
2514
  patchState(store, { isLoading: true, error: undefined });
2263
- return repository.update(entity).pipe(tapResponse({
2264
- next: (updatedEntity) => {
2265
- const currentEntities = store.entities();
2266
- const indexToUpdate = currentEntities.findIndex((item) => item.id === entity.id);
2515
+ try {
2516
+ const updatedEntity = await firstValueFrom(repository.update(entity));
2517
+ const currentEntities = [...store.entities()];
2518
+ const indexToUpdate = currentEntities.findIndex((item) => item.id === entity.id);
2519
+ if (indexToUpdate >= 0)
2267
2520
  currentEntities[indexToUpdate] = updatedEntity;
2268
- patchState(store, { entities: [...currentEntities], isLoading: false });
2269
- },
2270
- error: (error) => patchState(store, { error: error.message }),
2271
- finalize: () => patchState(store, { isLoading: false }),
2272
- }));
2273
- })));
2521
+ patchState(store, { entities: currentEntities, isLoading: false });
2522
+ return updatedEntity;
2523
+ }
2524
+ catch (error) {
2525
+ patchState(store, { error: error.message, isLoading: false });
2526
+ return undefined;
2527
+ }
2528
+ };
2274
2529
  };
2275
2530
 
2276
2531
  const findByQuery = (store, repository) => {
@@ -2306,10 +2561,7 @@ const findByQuery = (store, repository) => {
2306
2561
  };
2307
2562
 
2308
2563
  const BASE_ENTITY_STORE = new InjectionToken('BASE_ENTITY_STORE');
2309
- function entityNameFromType(entityType) {
2310
- return entityType.name ?? 'base-entity';
2311
- }
2312
- function BaseEntityStore(entityType, repositoryType) {
2564
+ function BaseEntityStore(entityType, getRepository) {
2313
2565
  return signalStoreFeature(withState({
2314
2566
  entities: [],
2315
2567
  page: 0,
@@ -2320,7 +2572,7 @@ function BaseEntityStore(entityType, repositoryType) {
2320
2572
  isLoading: false,
2321
2573
  error: undefined,
2322
2574
  selectedEntities: [],
2323
- }), withDevtools(entityNameFromType(entityType)), withMethods((store, repository = inject(repositoryType)) => ({
2575
+ }), withDevtools(entityNameFromType(entityType)), withMethods((store, repository = getRepository()) => ({
2324
2576
  clearCurrentEntity: () => patchState(store, { currentEntity: undefined }),
2325
2577
  createEntity: () => new entityType(),
2326
2578
  add: addEntity(store, repository),
@@ -2375,114 +2627,99 @@ function BaseEntityStore(entityType, repositoryType) {
2375
2627
  })));
2376
2628
  }
2377
2629
 
2378
- let BaseEntityFirestoreService = class BaseEntityFirestoreService {
2379
- entityMapper;
2380
- collectionName;
2381
- collection;
2382
- firestore = inject(Firestore);
2383
- constructor(entityMapper, collectionName) {
2384
- this.entityMapper = entityMapper;
2385
- this.collectionName = collectionName;
2386
- this.collection = collection(this.firestore, collectionName);
2387
- }
2388
- // region public accessors and mutators
2389
- add(entity) {
2390
- if (!entity)
2391
- throw new Error('Entity cant be undefined');
2392
- return from(this.addAsync(entity));
2393
- }
2394
- delete(id) {
2395
- const docRef = doc(this.firestore, this.collectionName, id);
2396
- return from(deleteDoc(docRef));
2397
- }
2398
- deleteAll() {
2399
- return of(undefined);
2400
- }
2401
- findAll(page, pageSize) {
2402
- return this.findByQuery({ page, pageSize });
2403
- }
2404
- findById(id) {
2405
- const docRef = doc(this.firestore, this.collectionName, id);
2406
- return from(getDoc(docRef)
2407
- .then((document) => {
2408
- return this.mapDocument(document.data());
2409
- })
2410
- .catch((error) => {
2411
- throw new Error(`Error: ${error} occurred while finding document by id: ${id}`);
2412
- }));
2413
- }
2414
- findByQuery(queryCondition) {
2415
- return from(this.findByQueryAsync(queryCondition));
2416
- }
2417
- update(entity) {
2418
- return from(this.updateAsync(entity));
2419
- }
2420
- // endregion
2421
- // protected, private helper methods
2422
- async addAsync(entity) {
2423
- const newDoc = doc(this.collection, entity.id);
2424
- await setDoc(newDoc, this.mapEntity(entity));
2425
- return new Promise((resolve, reject) => {
2426
- resolve(entity);
2427
- reject(new Error('Failed to update entity: ' + entity));
2428
- });
2429
- }
2430
- createQuery(queryCondition) {
2431
- let orderBys = [];
2432
- if (queryCondition.orderBys && queryCondition.orderBys?.length > 0) {
2433
- orderBys = queryCondition.orderBys?.map((orderByCondition) => {
2434
- const name = Object.keys(OrderByDirection).filter((key) => key === orderByCondition.direction);
2435
- const direction = Object.values(OrderByDirection).filter((value) => value === name[0]);
2436
- return orderBy(orderByCondition.property, direction[0]);
2437
- });
2630
+ const INITIAL_TABS_STATE = {
2631
+ activeTabs: [],
2632
+ currentTab: undefined,
2633
+ };
2634
+ function BaseEntityTabsStore() {
2635
+ return signalStoreFeature(withState(INITIAL_TABS_STATE), withMethods((store) => {
2636
+ function reset() {
2637
+ const activeTabs = [];
2638
+ patchState(store, { activeTabs, currentTab: undefined });
2438
2639
  }
2439
- let wheres = [];
2440
- if (queryCondition.filters && queryCondition.filters?.length > 0) {
2441
- wheres =
2442
- queryCondition.filters?.map((filter) => {
2443
- return where(filter.property, filter.operator, filter.value);
2444
- }) ?? [];
2640
+ function tabIsActive(tabName) {
2641
+ let activeTabs;
2642
+ if (store.activeTabs().indexOf(tabName) == -1) {
2643
+ activeTabs = store.activeTabs().concat([tabName]);
2644
+ }
2645
+ else {
2646
+ activeTabs = store.activeTabs();
2647
+ }
2648
+ patchState(store, { activeTabs, currentTab: tabName });
2445
2649
  }
2446
- return query(this.collection, ...wheres, ...orderBys, limit(queryCondition.pageSize ?? 99));
2447
- }
2448
- async findByQueryAsync(queryCondition) {
2449
- const query = this.createQuery(queryCondition);
2450
- const results = await getDocs(query);
2451
- const content = [];
2452
- results.docs.forEach((doc) => {
2453
- content.push(this.mapDocument({ id: doc.id, ...doc.data() }));
2454
- });
2455
- return Promise.resolve({
2456
- page: queryCondition.page,
2457
- pageSize: queryCondition.pageSize,
2458
- totalPageCount: 1,
2459
- content,
2650
+ function tabIsInactive(tabName) {
2651
+ const activeTabs = store.activeTabs().filter((tab) => tab !== tabName);
2652
+ patchState(store, { activeTabs, currentTab: undefined });
2653
+ }
2654
+ return { reset, tabIsActive, tabIsInactive };
2655
+ }));
2656
+ }
2657
+
2658
+ class BaseEntityFacade {
2659
+ entityTitle = "this.store.currentEntity() ? this.store.currentEntity().name : ''";
2660
+ serviceKind = 'rest';
2661
+ endpoint;
2662
+ backendRoot;
2663
+ injector = inject(Injector);
2664
+ _mapper;
2665
+ _service;
2666
+ _storeClass;
2667
+ _storeInstance;
2668
+ _descriptor;
2669
+ get mapper() {
2670
+ return (this._mapper ??= this.createMapper());
2671
+ }
2672
+ get service() {
2673
+ return (this._service ??= this.createService(this.mapper));
2674
+ }
2675
+ get storeClass() {
2676
+ return (this._storeClass ??= this.createStoreClass());
2677
+ }
2678
+ get store() {
2679
+ return (this._storeInstance ??= runInInjectionContext(this.injector, () => inject(this.storeClass)));
2680
+ }
2681
+ get descriptor() {
2682
+ if (!this._descriptor) {
2683
+ this._descriptor = this.createDescriptor();
2684
+ this._descriptor.store = this.store;
2685
+ }
2686
+ return this._descriptor;
2687
+ }
2688
+ createMapper() {
2689
+ return new SimpleEntityMapper(this.entityType);
2690
+ }
2691
+ createService(mapper) {
2692
+ return runInInjectionContext(this.injector, () => {
2693
+ if (this.serviceKind === 'rest') {
2694
+ if (!this.backendRoot || !this.endpoint) {
2695
+ throw new Error(`${this.constructor.name}: REST facade requires backendRoot and endpoint`);
2696
+ }
2697
+ return new BaseEntityRestService(mapper, this.backendRoot, this.endpoint);
2698
+ }
2699
+ if (!this.endpoint) {
2700
+ throw new Error(`${this.constructor.name}: Firestore facade requires endpoint (collection name)`);
2701
+ }
2702
+ return new BaseEntityFirestoreService(mapper, this.endpoint);
2460
2703
  });
2461
2704
  }
2462
- mapCollection(collection) {
2463
- const entities = [];
2464
- collection.pipe(map((documents) => {
2465
- documents.forEach((document) => entities.push(this.entityMapper.fromDto(document)));
2466
- }));
2467
- return entities;
2468
- }
2469
- mapDocument(document) {
2470
- return this.entityMapper.fromDto(document);
2705
+ createStoreClass() {
2706
+ return signalStore({ providedIn: 'root' }, BaseEntityStore(this.entityType, () => this.service), BaseEntityTabsStore(), BaseEntityContainerStore());
2471
2707
  }
2472
- mapEntity(entity) {
2473
- return this.entityMapper.toDto(entity);
2474
- }
2475
- async updateAsync(entity) {
2476
- if (!entity)
2477
- throw new Error('Entity cant be undefined');
2478
- const docRef = doc(this.firestore, this.collectionName, entity.id);
2479
- await updateDoc(docRef, this.mapEntity(entity));
2480
- return Promise.resolve(entity);
2708
+ createDescriptor() {
2709
+ return new BaseEntityDescriptor({
2710
+ entityName: this.entityName,
2711
+ entityTitle: this.entityTitle,
2712
+ attrDescriptors: this.attrDescriptors,
2713
+ });
2481
2714
  }
2482
- };
2483
- BaseEntityFirestoreService = __decorate([
2484
- __param(0, Inject('entityMapper'))
2485
- ], BaseEntityFirestoreService);
2715
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: BaseEntityFacade, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2716
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: BaseEntityFacade });
2717
+ }
2718
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: BaseEntityFacade, decorators: [{
2719
+ type: Injectable
2720
+ }] });
2721
+
2722
+ const BASE_ENTITY_SERVICE = new InjectionToken('BASE_ENTITY_SERVICE');
2486
2723
 
2487
2724
  // Symbol to store entity options on instance
2488
2725
  const ENTITY_OPTIONS_KEY = Symbol('entityOptions');
@@ -2572,5 +2809,5 @@ const BASE_ENTITY_ROUTES = [
2572
2809
  * Generated bundle index. Do not edit.
2573
2810
  */
2574
2811
 
2575
- export { AbstractAttrDescriptor, BASE_ENTITY_ROUTES, BASE_ENTITY_SERVICE, BASE_ENTITY_STORE, BASE_ENTITY_STORE_REGISTRY, BASE_LIST_DESCRIPTORS, BaseEntityAttrDescriptor, BaseEntityContainerComponent, BaseEntityContainerStore, BaseEntityDescriptor, BaseEntityFirestoreService, BaseEntityFormComponent, BaseEntityListComponent, BaseEntityRestService, BaseEntityStore, BaseEntityTabsStore, BaseFormHostDirective, BaseFormNavigatorSingletonStore, BaseFormNavigatorStore, Entity, FlexDirection, FlexboxDescriptor, FormControlType, Id, OrderByDirection, RouteSegments, getEntityIds, getEntityOptions, getEnumKeyByValue, getEnumValueByKey };
2812
+ export { ACTIVE_ENTITY_FACADE, AbstractAttrDescriptor, BASE_ENTITY_FACADE_REGISTRY, BASE_ENTITY_ROUTES, BASE_ENTITY_SERVICE, BASE_ENTITY_STORE, BASE_LIST_DESCRIPTORS, BaseEntityAttrDescriptor, BaseEntityContainerComponent, BaseEntityContainerStore, BaseEntityDescriptor, BaseEntityFacade, BaseEntityFirestoreService, BaseEntityFormComponent, BaseEntityListComponent, BaseEntityRestService, BaseEntityStore, BaseEntityTabsStore, BaseFormHostDirective, BaseFormNavigatorSingletonStore, BaseFormNavigatorStore, Entity, EntityRegistryComponent, FlexDirection, FlexboxDescriptor, FormControlType, Id, OrderByDirection, RouteSegments, SimpleEntityMapper, getEntityIds, getEntityOptions, getEnumKeyByValue, getEnumValueByKey };
2576
2813
  //# sourceMappingURL=processpuzzle-base-entity.mjs.map