@processpuzzle/base-entity 0.7.3 → 0.7.5

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,5 +1,5 @@
1
1
  import * as i0 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';
2
+ import { inject, input, computed, Component, 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';
@@ -335,6 +335,8 @@ class BaseEntityToolbarComponent {
335
335
  layoutService = inject(LayoutService);
336
336
  formNavigator = inject(BaseFormNavigatorSingletonStore);
337
337
  store;
338
+ isDeleteEnabled = computed(() => this.store.selectedEntities().length != 0 && !this.entityDescriptor().isAbstract, ...(ngDevMode ? [{ debugName: "isDeleteEnabled" }] : /* istanbul ignore next */ []));
339
+ isEditEnabled = computed(() => this.store.selectedEntities().length == 1 && !this.entityDescriptor().isAbstract, ...(ngDevMode ? [{ debugName: "isEditEnabled" }] : /* istanbul ignore next */ []));
338
340
  // region Angular lifecycle hooks
339
341
  ngOnInit() {
340
342
  this.store = this.entityDescriptor().store;
@@ -370,11 +372,11 @@ class BaseEntityToolbarComponent {
370
372
  // protected, private helper methods
371
373
  RouteSegments = RouteSegments;
372
374
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: BaseEntityToolbarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
373
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.13", 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"] }] });
375
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.13", 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]=\"!isEditEnabled()\" (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]=\"!isDeleteEnabled()\" (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]=\"!isEditEnabled()\" (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]=\"!isDeleteEnabled()\" (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"] }] });
374
376
  }
375
377
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: BaseEntityToolbarComponent, decorators: [{
376
378
  type: Component,
377
- 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" }]
379
+ 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]=\"!isEditEnabled()\" (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]=\"!isDeleteEnabled()\" (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]=\"!isEditEnabled()\" (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]=\"!isDeleteEnabled()\" (click)=\"onDeleteEntities()\"><mat-icon>delete</mat-icon> Delete</button>\n </div>\n }\n</mat-toolbar>\n" }]
378
380
  }], propDecorators: { entityDescriptor: [{ type: i0.Input, args: [{ isSignal: true, alias: "entityDescriptor", required: true }] }] } });
379
381
 
380
382
  class BaseEntityStatusbarComponent {
@@ -588,6 +590,11 @@ function BaseEntityContainerStore() {
588
590
  }));
589
591
  }
590
592
 
593
+ function assertPersistedEntity(entity) {
594
+ if (typeof entity.id !== 'string')
595
+ throw new Error('Persisted entity must have an id');
596
+ }
597
+
591
598
  let BaseEntityRestService = class BaseEntityRestService {
592
599
  entityMapper;
593
600
  urlProperty;
@@ -639,7 +646,7 @@ let BaseEntityRestService = class BaseEntityRestService {
639
646
  const fullUrl = this.buildFullUrl(this.resourceUrl, queryCondition);
640
647
  if (fullUrl) {
641
648
  return this.httpClient.get(fullUrl, { headers: this.headers }).pipe(map((httpResponse) => {
642
- return this.mapSimpleResponse(httpResponse);
649
+ return this.mapEntityResponse(httpResponse);
643
650
  }));
644
651
  }
645
652
  else
@@ -650,7 +657,7 @@ let BaseEntityRestService = class BaseEntityRestService {
650
657
  const fullUrl = this.buildFullUrl(this.resourceUrl, {});
651
658
  if (fullUrl) {
652
659
  return this.httpClient.post(fullUrl, dto, { headers: this.headers }).pipe(map((response) => {
653
- return this.entityMapper.fromDto(response, id);
660
+ return this.mapEntityResponse(response, id);
654
661
  }));
655
662
  }
656
663
  else
@@ -662,7 +669,7 @@ let BaseEntityRestService = class BaseEntityRestService {
662
669
  const fullUrl = this.buildFullUrl(this.resourceUrl + '/%{id}', { pathParams });
663
670
  if (fullUrl) {
664
671
  return this.httpClient.put(fullUrl, dto, { headers: this.headers }).pipe(map((response) => {
665
- return this.entityMapper.fromDto(response);
672
+ return this.mapEntityResponse(response);
666
673
  }));
667
674
  }
668
675
  else
@@ -701,7 +708,7 @@ let BaseEntityRestService = class BaseEntityRestService {
701
708
  mapPagedResponse(response) {
702
709
  const subjectPage = response[0];
703
710
  const content = subjectPage.content.map((dto, index) => {
704
- return this.entityMapper.fromDto(dto, index);
711
+ return this.mapEntityResponse(dto, index);
705
712
  });
706
713
  return {
707
714
  page: subjectPage.page,
@@ -713,13 +720,18 @@ let BaseEntityRestService = class BaseEntityRestService {
713
720
  mapSimpleResponse(response) {
714
721
  if (Object.prototype.toString.call(response) === '[object Array]') {
715
722
  return response.map((dto, index) => {
716
- return this.entityMapper.fromDto(dto, index);
723
+ return this.mapEntityResponse(dto, index);
717
724
  });
718
725
  }
719
726
  else {
720
- return new Array(this.entityMapper.fromDto(response));
727
+ return new Array(this.mapEntityResponse(response));
721
728
  }
722
729
  }
730
+ mapEntityResponse(response, index) {
731
+ const entity = this.entityMapper.fromDto(response, index);
732
+ assertPersistedEntity(entity);
733
+ return entity;
734
+ }
723
735
  };
724
736
  BaseEntityRestService = __decorate([
725
737
  __param(0, Inject('entityMapper'))
@@ -827,6 +839,8 @@ class EntityRegistryComponent {
827
839
  return {
828
840
  entityName: descriptor.entityName,
829
841
  entityTitle: descriptor.entityTitle,
842
+ isAbstract: descriptor.isAbstract,
843
+ parentEntityName: descriptor.parentEntity,
830
844
  attrDescriptors: attrDescriptors.map((attr) => this.serializeAttr(attr)),
831
845
  };
832
846
  });
@@ -1717,7 +1731,11 @@ class EntityComponentsListComponent extends BaseFormControlComponent {
1717
1731
  }
1718
1732
  components() {
1719
1733
  const value = this.formGroup.get(this.config().attrName)?.value ?? this.value();
1720
- return Array.isArray(value) ? value : [];
1734
+ if (!Array.isArray(value)) {
1735
+ return [];
1736
+ }
1737
+ value.forEach((component) => assertPersistedEntity(component));
1738
+ return value;
1721
1739
  }
1722
1740
  addComponentTitle() {
1723
1741
  return 'Add ' + this.linkedEntityType().entityName;
@@ -1738,7 +1756,9 @@ class EntityComponentsListComponent extends BaseFormControlComponent {
1738
1756
  if (!responsePayload?.payload) {
1739
1757
  return;
1740
1758
  }
1741
- const components = [...this.components(), responsePayload.payload];
1759
+ const selectedComponent = responsePayload.payload;
1760
+ assertPersistedEntity(selectedComponent);
1761
+ const components = [...this.components(), selectedComponent];
1742
1762
  const attrName = this.config().attrName;
1743
1763
  const entity = this.entity();
1744
1764
  entity[attrName] = components;
@@ -2158,11 +2178,14 @@ class BaseEntityDescriptor {
2158
2178
  attrDescriptors;
2159
2179
  entityName;
2160
2180
  entityTitle;
2161
- constructor({ store, attrDescriptors, entityName, entityTitle }) {
2181
+ parentEntity;
2182
+ isAbstract;
2183
+ constructor({ store, attrDescriptors, entityName, entityTitle }, isAbstract) {
2162
2184
  this.store = store;
2163
2185
  this.attrDescriptors = attrDescriptors;
2164
2186
  this.entityName = entityName;
2165
2187
  this.entityTitle = entityTitle ?? '';
2188
+ this.isAbstract = isAbstract ?? false;
2166
2189
  }
2167
2190
  createTestId(suffix) {
2168
2191
  return createTestId(this.entityName, suffix);
@@ -2226,8 +2249,8 @@ class BaseEntityListComponent {
2226
2249
  onChangeSelection(entity) {
2227
2250
  if (entity && this.isSelected(entity))
2228
2251
  this.store.selectEntity(entity.id);
2229
- else
2230
- this.store.deselectEntity(entity);
2252
+ else if (entity)
2253
+ this.store.deselectEntity(entity.id);
2231
2254
  if (this.selection.selected.length === 1)
2232
2255
  this.store.setCurrentEntity(this.selection.selected[0].id);
2233
2256
  else
@@ -2412,7 +2435,7 @@ let BaseEntityFirestoreService = class BaseEntityFirestoreService {
2412
2435
  const docRef = doc(this.firestore, this.collectionName, id);
2413
2436
  return from(getDoc(docRef)
2414
2437
  .then((document) => {
2415
- return this.mapDocument(document.data());
2438
+ return document.exists() ? this.mapDocument({ id: document.id, ...document.data() }) : undefined;
2416
2439
  })
2417
2440
  .catch((error) => {
2418
2441
  throw new Error(`Error: ${error} occurred while finding document by id: ${id}`);
@@ -2427,10 +2450,11 @@ let BaseEntityFirestoreService = class BaseEntityFirestoreService {
2427
2450
  // endregion
2428
2451
  // protected, private helper methods
2429
2452
  async addAsync(entity) {
2430
- const newDoc = doc(this.collection, entity.id);
2453
+ const newDoc = entity.id ? doc(this.collection, entity.id) : doc(this.collection);
2431
2454
  await setDoc(newDoc, this.mapEntity(entity));
2455
+ const savedEntity = { ...entity, id: newDoc.id };
2432
2456
  return new Promise((resolve, reject) => {
2433
- resolve(entity);
2457
+ resolve(this.mapDocument(savedEntity));
2434
2458
  reject(new Error('Failed to update entity: ' + entity));
2435
2459
  });
2436
2460
  }
@@ -2469,12 +2493,14 @@ let BaseEntityFirestoreService = class BaseEntityFirestoreService {
2469
2493
  mapCollection(collection) {
2470
2494
  const entities = [];
2471
2495
  collection.pipe(map((documents) => {
2472
- documents.forEach((document) => entities.push(this.entityMapper.fromDto(document)));
2496
+ documents.forEach((document) => entities.push(this.mapDocument(document)));
2473
2497
  }));
2474
2498
  return entities;
2475
2499
  }
2476
2500
  mapDocument(document) {
2477
- return this.entityMapper.fromDto(document);
2501
+ const entity = this.entityMapper.fromDto(document);
2502
+ assertPersistedEntity(entity);
2503
+ return entity;
2478
2504
  }
2479
2505
  mapEntity(entity) {
2480
2506
  return this.entityMapper.toDto(entity);