@processpuzzle/base-entity 0.2.0 → 0.3.1
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.
- package/README.md +129 -63
- package/fesm2022/processpuzzle-base-entity.mjs +653 -351
- package/fesm2022/processpuzzle-base-entity.mjs.map +1 -1
- package/index.d.ts +378 -3
- package/package.json +27 -17
- package/lib/base-entity/base-entity-attr.descriptor.d.ts +0 -43
- package/lib/base-entity/base-entity.d.ts +0 -3
- package/lib/base-entity/base-entity.descriptor.d.ts +0 -7
- package/lib/base-entity-container.component.d.ts +0 -15
- package/lib/base-entity-container.store.d.ts +0 -12
- package/lib/base-entity-load-response.d.ts +0 -7
- package/lib/base-entity.mapper.d.ts +0 -7
- package/lib/base-entity.routes.d.ts +0 -2
- package/lib/base-entity.service.d.ts +0 -25
- package/lib/base-entity.store.d.ts +0 -85
- package/lib/base-form/base-entity-form.component.d.ts +0 -25
- package/lib/base-form/base-form-control.component.d.ts +0 -14
- package/lib/base-form/base-form-host.directive.d.ts +0 -8
- package/lib/base-form/checkbox/checkbox.component.d.ts +0 -7
- package/lib/base-form/datepicker/datepicker.component.d.ts +0 -7
- package/lib/base-form/dropdown/dropdown.component.d.ts +0 -7
- package/lib/base-form/foreign-key/foreign-key.component.d.ts +0 -8
- package/lib/base-form/label/label.component.d.ts +0 -7
- package/lib/base-form/radio/radio.component.d.ts +0 -7
- package/lib/base-form/textarea/textarea.component.d.ts +0 -7
- package/lib/base-form/textbox/textbox.component.d.ts +0 -7
- package/lib/base-form-navigator/base-form-navigator.store.d.ts +0 -33
- package/lib/base-form-navigator/base-url-segments.d.ts +0 -7
- package/lib/base-list/base-entity-list.component.d.ts +0 -38
- package/lib/base-statusbar/base-entity-statusbar.component.d.ts +0 -12
- package/lib/base-tabs/base-entity-tabs.component.d.ts +0 -18
- package/lib/base-tabs/base-entity-tabs.store.d.ts +0 -16
- package/lib/base-toolbar/base-entity-toolbar.component.d.ts +0 -19
- package/public-api.d.ts +0 -16
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Directive, input,
|
|
3
|
-
import * as i1 from '@angular/forms';
|
|
4
|
-
import { ReactiveFormsModule, FormsModule,
|
|
2
|
+
import { Directive, input, computed, Component, ViewChild, signal, Injectable, inject, effect, untracked, InjectionToken, Inject } from '@angular/core';
|
|
3
|
+
import * as i1$1 from '@angular/forms';
|
|
4
|
+
import { ReactiveFormsModule, FormsModule, FormControl, Validators, FormBuilder } from '@angular/forms';
|
|
5
5
|
import { ROUTER_OUTLET_DATA, Router, ActivatedRoute, RouterOutlet } from '@angular/router';
|
|
6
|
-
import * as i1$1 from '@angular/common';
|
|
7
|
-
import { NgIf, NgStyle, NgClass, NgForOf, CommonModule } from '@angular/common';
|
|
8
|
-
import * as i3$1 from '@angular/material/form-field';
|
|
9
|
-
import { MatFormField, MatLabel, MatFormFieldModule, MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
|
|
10
|
-
import * as i4 from '@angular/material/input';
|
|
11
|
-
import { MatInput, MatInputModule } from '@angular/material/input';
|
|
12
|
-
import * as i2 from '@angular/material/select';
|
|
13
|
-
import { MatSelectModule } from '@angular/material/select';
|
|
14
|
-
import * as i3 from '@angular/material/core';
|
|
15
|
-
import { MatCheckbox } from '@angular/material/checkbox';
|
|
16
6
|
import { MatCard, MatCardContent, MatCardActions } from '@angular/material/card';
|
|
7
|
+
import * as i3 from '@angular/material/form-field';
|
|
8
|
+
import { MatFormFieldModule, MatLabel, MatFormField, MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
|
|
9
|
+
import { MatButton } from '@angular/material/button';
|
|
10
|
+
import * as i1 from '@angular/common';
|
|
11
|
+
import { NgIf, NgStyle, CommonModule, NgClass, NgForOf } from '@angular/common';
|
|
17
12
|
import * as i5 from '@angular/material/datepicker';
|
|
18
13
|
import { MatDatepickerModule } from '@angular/material/datepicker';
|
|
19
|
-
import
|
|
14
|
+
import * as i4 from '@angular/material/input';
|
|
15
|
+
import { MatInputModule, MatInput } from '@angular/material/input';
|
|
20
16
|
import { MatIcon } from '@angular/material/icon';
|
|
17
|
+
import * as i2 from '@angular/material/select';
|
|
18
|
+
import { MatSelectModule } from '@angular/material/select';
|
|
19
|
+
import { MatCheckbox } from '@angular/material/checkbox';
|
|
21
20
|
import { MatTableDataSource, MatTable, MatHeaderCell, MatHeaderRow, MatRow, MatCell, MatColumnDef, MatHeaderCellDef, MatCellDef, MatHeaderRowDef, MatRowDef } from '@angular/material/table';
|
|
22
21
|
import { MatSort, MatSortHeader } from '@angular/material/sort';
|
|
23
22
|
import { MatPaginator } from '@angular/material/paginator';
|
|
@@ -30,237 +29,282 @@ import { MatMenu, MatMenuItem, MatMenuTrigger } from '@angular/material/menu';
|
|
|
30
29
|
import { LayoutService, RUNTIME_CONFIGURATION } from '@processpuzzle/util';
|
|
31
30
|
import { MatSnackBar } from '@angular/material/snack-bar';
|
|
32
31
|
import { __decorate, __param, __metadata } from 'tslib';
|
|
33
|
-
import { map, pipe, tap,
|
|
32
|
+
import { map, pipe, switchMap, tap, from, of } from 'rxjs';
|
|
34
33
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
|
35
|
-
import buildUrl from 'build-url-ts';
|
|
36
|
-
import { rxMethod } from '@ngrx/signals/rxjs-interop';
|
|
34
|
+
import { buildUrl } from 'build-url-ts';
|
|
37
35
|
import { tapResponse } from '@ngrx/operators';
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
constructor(viewContainerRef) {
|
|
42
|
-
this.viewContainerRef = viewContainerRef;
|
|
43
|
-
}
|
|
44
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.4", ngImport: i0, type: BaseFormHostDirective, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
45
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.4", type: BaseFormHostDirective, isStandalone: true, selector: "[baseFormHost]", ngImport: i0 });
|
|
46
|
-
}
|
|
47
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.4", ngImport: i0, type: BaseFormHostDirective, decorators: [{
|
|
48
|
-
type: Directive,
|
|
49
|
-
args: [{
|
|
50
|
-
standalone: true,
|
|
51
|
-
selector: '[baseFormHost]',
|
|
52
|
-
}]
|
|
53
|
-
}], ctorParameters: () => [{ type: i0.ViewContainerRef }] });
|
|
36
|
+
import { rxMethod } from '@ngrx/signals/rxjs-interop';
|
|
37
|
+
import { Firestore, collection, doc, deleteDoc, getDoc, setDoc, orderBy, where, query, limit, getDocs, updateDoc } from '@angular/fire/firestore';
|
|
38
|
+
import 'reflect-metadata';
|
|
54
39
|
|
|
55
40
|
var FormControlType;
|
|
56
41
|
(function (FormControlType) {
|
|
42
|
+
FormControlType["CHECKBOX"] = "CHECKBOX";
|
|
57
43
|
FormControlType["DATE"] = "DATE";
|
|
44
|
+
FormControlType["DROPDOWN"] = "DROPDOWN";
|
|
45
|
+
FormControlType["FLEX_BOX"] = "FLEX_BOX";
|
|
46
|
+
FormControlType["FOREIGN_KEY"] = "FOREIGN_KEY";
|
|
58
47
|
FormControlType["LABEL"] = "LABEL";
|
|
48
|
+
FormControlType["RADIO"] = "RADIO";
|
|
59
49
|
FormControlType["TITLE"] = "TITLE";
|
|
60
50
|
FormControlType["TEXT_BOX"] = "TEXT_BOX";
|
|
61
|
-
FormControlType["DROPDOWN"] = "DROPDOWN";
|
|
62
|
-
FormControlType["CHECKBOX"] = "CHECKBOX";
|
|
63
|
-
FormControlType["RADIO"] = "RADIO";
|
|
64
51
|
FormControlType["TEXTAREA"] = "TEXTAREA";
|
|
65
|
-
FormControlType["FOREIGN_KEY"] = "FOREIGN_KEY";
|
|
66
52
|
})(FormControlType || (FormControlType = {}));
|
|
67
|
-
class
|
|
53
|
+
class AbstractAttrDescriptor {
|
|
68
54
|
attrName;
|
|
69
|
-
description;
|
|
70
|
-
styleClass = '';
|
|
71
|
-
labelClass = '';
|
|
72
|
-
format;
|
|
73
|
-
isLinkToDetails;
|
|
74
55
|
formControlType;
|
|
75
|
-
selectables;
|
|
76
|
-
visible = true;
|
|
77
56
|
disabled = false;
|
|
78
|
-
isHeading;
|
|
79
57
|
style;
|
|
80
|
-
|
|
81
|
-
lines;
|
|
82
|
-
options;
|
|
83
|
-
_label;
|
|
84
|
-
_linkedEntityType;
|
|
85
|
-
constructor(attrName, formControlType, label, isLinkToDetails, options) {
|
|
58
|
+
constructor(attrName, formControlType) {
|
|
86
59
|
this.attrName = attrName;
|
|
87
60
|
this.formControlType = formControlType;
|
|
88
|
-
this._label = label;
|
|
89
|
-
this.isLinkToDetails = isLinkToDetails;
|
|
90
|
-
this.options = { inputType: 'text', ...options };
|
|
91
|
-
}
|
|
92
|
-
// region properties
|
|
93
|
-
get label() {
|
|
94
|
-
return this._label ? this._label : this.attrName;
|
|
95
|
-
}
|
|
96
|
-
set label(label) {
|
|
97
|
-
this._label = label;
|
|
98
|
-
}
|
|
99
|
-
get linkedEntityType() {
|
|
100
|
-
return this._linkedEntityType;
|
|
101
61
|
}
|
|
102
|
-
|
|
103
|
-
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
class BaseFormHostDirective {
|
|
65
|
+
viewContainerRef;
|
|
66
|
+
constructor(viewContainerRef) {
|
|
67
|
+
this.viewContainerRef = viewContainerRef;
|
|
104
68
|
}
|
|
69
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: BaseFormHostDirective, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
70
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.9", type: BaseFormHostDirective, isStandalone: true, selector: "[baseFormHost]", ngImport: i0 });
|
|
105
71
|
}
|
|
72
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: BaseFormHostDirective, decorators: [{
|
|
73
|
+
type: Directive,
|
|
74
|
+
args: [{
|
|
75
|
+
standalone: true,
|
|
76
|
+
selector: '[baseFormHost]',
|
|
77
|
+
}]
|
|
78
|
+
}], ctorParameters: () => [{ type: i0.ViewContainerRef }] });
|
|
79
|
+
|
|
80
|
+
var BaseUrlSegments;
|
|
81
|
+
(function (BaseUrlSegments) {
|
|
82
|
+
BaseUrlSegments["DetailsForm"] = "details";
|
|
83
|
+
BaseUrlSegments["Feed"] = "feed";
|
|
84
|
+
BaseUrlSegments["ListForm"] = "list";
|
|
85
|
+
BaseUrlSegments["NewEntity"] = "new";
|
|
86
|
+
BaseUrlSegments["UnknownEntity"] = "unknown";
|
|
87
|
+
})(BaseUrlSegments || (BaseUrlSegments = {}));
|
|
106
88
|
|
|
107
89
|
class BaseFormControlComponent {
|
|
108
|
-
config = input.required();
|
|
109
|
-
entity = input.required();
|
|
90
|
+
config = input.required(...(ngDevMode ? [{ debugName: "config" }] : []));
|
|
91
|
+
entity = input.required(...(ngDevMode ? [{ debugName: "entity" }] : []));
|
|
110
92
|
formGroup;
|
|
111
93
|
store;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
static
|
|
94
|
+
style = computed(() => this.config().style, ...(ngDevMode ? [{ debugName: "style" }] : []));
|
|
95
|
+
value = input.required(...(ngDevMode ? [{ debugName: "value" }] : []));
|
|
96
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: BaseFormControlComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
97
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.3.9", 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 }] });
|
|
115
98
|
}
|
|
116
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
99
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: BaseFormControlComponent, decorators: [{
|
|
117
100
|
type: Component,
|
|
118
101
|
args: [{
|
|
119
102
|
standalone: true,
|
|
120
103
|
template: ``,
|
|
121
104
|
imports: [ReactiveFormsModule],
|
|
122
105
|
}]
|
|
123
|
-
}] });
|
|
106
|
+
}], 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 }] }] } });
|
|
124
107
|
|
|
125
108
|
class LabelComponent extends BaseFormControlComponent {
|
|
126
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
127
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
109
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: LabelComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
110
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.9", type: LabelComponent, isStandalone: true, selector: "base-label", usesInheritance: true, ngImport: i0, template: "<ng-container *ngIf=\"config().visible\">\n <ng-container *ngIf=\"config().isHeading; else normalText\">\n <h3 [id]=\"config().attrName\">{{value()}}</h3>\n </ng-container>\n\n <ng-template #normalText>\n <p [id]=\"config().attrName\" [ngStyle]=\"config().style\">{{value()}}</p>\n </ng-template>\n</ng-container>", dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
|
|
128
111
|
}
|
|
129
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
112
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: LabelComponent, decorators: [{
|
|
130
113
|
type: Component,
|
|
131
114
|
args: [{ selector: 'base-label', standalone: true, imports: [NgIf, NgStyle], template: "<ng-container *ngIf=\"config().visible\">\n <ng-container *ngIf=\"config().isHeading; else normalText\">\n <h3 [id]=\"config().attrName\">{{value()}}</h3>\n </ng-container>\n\n <ng-template #normalText>\n <p [id]=\"config().attrName\" [ngStyle]=\"config().style\">{{value()}}</p>\n </ng-template>\n</ng-container>" }]
|
|
132
115
|
}] });
|
|
133
116
|
|
|
117
|
+
class DatepickerComponent extends BaseFormControlComponent {
|
|
118
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: DatepickerComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
119
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.9", type: DatepickerComponent, isStandalone: true, selector: "base-datepicker", usesInheritance: true, ngImport: i0, template: "<ng-container *ngIf=\"config().visible\">\n <div class=\"row\" style=\"margin-bottom: 10px\" [formGroup]=\"formGroup\">\n <mat-form-field>\n <mat-label>{{config().label}}</mat-label>\n <input matInput [matDatepicker]=\"picker\" formControlName=\"{{config().attrName}}\">\n <mat-hint>MM-DD-YYYY</mat-hint>\n <mat-datepicker-toggle matIconSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-datepicker #picker></mat-datepicker>\n </mat-form-field>\n </div>\n</ng-container>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: FormsModule }, { 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],form:not([ngNoForm]),[ngForm]" }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i3.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3.MatLabel, selector: "mat-label" }, { kind: "directive", type: i3.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: i3.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i4.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: MatDatepickerModule }, { kind: "component", type: i5.MatDatepicker, selector: "mat-datepicker", exportAs: ["matDatepicker"] }, { kind: "directive", type: i5.MatDatepickerInput, selector: "input[matDatepicker]", inputs: ["matDatepicker", "min", "max", "matDatepickerFilter"], exportAs: ["matDatepickerInput"] }, { kind: "component", type: i5.MatDatepickerToggle, selector: "mat-datepicker-toggle", inputs: ["for", "tabIndex", "aria-label", "disabled", "disableRipple"], exportAs: ["matDatepickerToggle"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { 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"] }] });
|
|
120
|
+
}
|
|
121
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: DatepickerComponent, decorators: [{
|
|
122
|
+
type: Component,
|
|
123
|
+
args: [{ selector: 'base-datepicker', standalone: true, imports: [CommonModule, FormsModule, MatFormFieldModule, MatInputModule, MatDatepickerModule, ReactiveFormsModule], template: "<ng-container *ngIf=\"config().visible\">\n <div class=\"row\" style=\"margin-bottom: 10px\" [formGroup]=\"formGroup\">\n <mat-form-field>\n <mat-label>{{config().label}}</mat-label>\n <input matInput [matDatepicker]=\"picker\" formControlName=\"{{config().attrName}}\">\n <mat-hint>MM-DD-YYYY</mat-hint>\n <mat-datepicker-toggle matIconSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-datepicker #picker></mat-datepicker>\n </mat-form-field>\n </div>\n</ng-container>\n" }]
|
|
124
|
+
}] });
|
|
125
|
+
|
|
126
|
+
class ForeignKeyComponent extends BaseFormControlComponent {
|
|
127
|
+
// region event handling methods
|
|
128
|
+
navigateToRelated() {
|
|
129
|
+
this.store.navigateToRelated(this.config().linkedEntityType, this.value());
|
|
130
|
+
}
|
|
131
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: ForeignKeyComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
132
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.9", type: ForeignKeyComponent, isStandalone: true, selector: "base-foreign-key", usesInheritance: true, ngImport: i0, template: "<ng-container *ngIf=\"config().visible\">\n <div class=\"row\" [formGroup]=\"formGroup\">\n <mat-form-field>\n <mat-label>{{ config().attrName }}</mat-label>\n <input matInput formControlName=\"{{config().attrName}}\">\n </mat-form-field>\n <a (click)=\"navigateToRelated()\" aria-label=\"Related entity\">\n <mat-icon>link</mat-icon>\n </a>\n </div>\n</ng-container>", dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { 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: 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],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"] }] });
|
|
133
|
+
}
|
|
134
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: ForeignKeyComponent, decorators: [{
|
|
135
|
+
type: Component,
|
|
136
|
+
args: [{ selector: 'base-foreign-key', standalone: true, imports: [NgIf, MatIcon, MatLabel, MatFormField, MatInput, ReactiveFormsModule], template: "<ng-container *ngIf=\"config().visible\">\n <div class=\"row\" [formGroup]=\"formGroup\">\n <mat-form-field>\n <mat-label>{{ config().attrName }}</mat-label>\n <input matInput formControlName=\"{{config().attrName}}\">\n </mat-form-field>\n <a (click)=\"navigateToRelated()\" aria-label=\"Related entity\">\n <mat-icon>link</mat-icon>\n </a>\n </div>\n</ng-container>" }]
|
|
137
|
+
}] });
|
|
138
|
+
|
|
134
139
|
class TextboxComponent extends BaseFormControlComponent {
|
|
135
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
136
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
140
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: TextboxComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
141
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.9", type: TextboxComponent, isStandalone: true, selector: "base-textbox", 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 <input matInput formControlName=\"{{config().attrName}}\">\n </mat-form-field>\n </div>\n</ng-container>", dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { 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: "directive", type: MatLabel, selector: "mat-label" }, { kind: "ngmodule", type: FormsModule }, { 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],form:not([ngNoForm]),[ngForm]" }, { kind: "ngmodule", type: ReactiveFormsModule }, { 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"] }] });
|
|
137
142
|
}
|
|
138
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
143
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: TextboxComponent, decorators: [{
|
|
139
144
|
type: Component,
|
|
140
145
|
args: [{ selector: 'base-textbox', standalone: true, imports: [NgIf, MatFormField, MatInput, MatLabel, FormsModule, ReactiveFormsModule], template: "<ng-container *ngIf=\"config().visible\">\n <div class=\"row\" [formGroup]=\"formGroup\">\n <mat-form-field>\n <mat-label>{{config().label}}</mat-label>\n <input matInput formControlName=\"{{config().attrName}}\">\n </mat-form-field>\n </div>\n</ng-container>" }]
|
|
141
146
|
}] });
|
|
142
147
|
|
|
143
148
|
class DropdownComponent extends BaseFormControlComponent {
|
|
144
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
145
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
149
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: DropdownComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
150
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.9", 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],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"] }] });
|
|
146
151
|
}
|
|
147
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
152
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: DropdownComponent, decorators: [{
|
|
148
153
|
type: Component,
|
|
149
154
|
args: [{ selector: 'base-dropdown', standalone: true, imports: [NgIf, ReactiveFormsModule, MatLabel, MatFormField, MatSelectModule], 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>" }]
|
|
150
155
|
}] });
|
|
151
156
|
|
|
152
157
|
class CheckboxComponent extends BaseFormControlComponent {
|
|
153
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
154
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
158
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: CheckboxComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
159
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.9", type: CheckboxComponent, isStandalone: true, selector: "base-checkbox", usesInheritance: true, ngImport: i0, template: "<ng-container *ngIf=\"config().visible\">\n <div [formGroup]=\"formGroup\" class=\"row\">\n <mat-checkbox [ngClass]=\"config().labelClass\" formControlName=\"{{config().attrName}}\">{{config().label}}</mat-checkbox>\n </div>\n</ng-container>", styles: ["mat-checkbox{margin-bottom:12px}\n"], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { 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: "ngmodule", type: FormsModule }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "ngmodule", type: ReactiveFormsModule }, { 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"] }] });
|
|
155
160
|
}
|
|
156
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
161
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: CheckboxComponent, decorators: [{
|
|
157
162
|
type: Component,
|
|
158
163
|
args: [{ selector: 'base-checkbox', standalone: true, imports: [NgClass, NgIf, MatCheckbox, FormsModule, ReactiveFormsModule], template: "<ng-container *ngIf=\"config().visible\">\n <div [formGroup]=\"formGroup\" class=\"row\">\n <mat-checkbox [ngClass]=\"config().labelClass\" formControlName=\"{{config().attrName}}\">{{config().label}}</mat-checkbox>\n </div>\n</ng-container>", styles: ["mat-checkbox{margin-bottom:12px}\n"] }]
|
|
159
164
|
}] });
|
|
160
165
|
|
|
161
166
|
class RadioComponent extends BaseFormControlComponent {
|
|
162
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
163
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
167
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: RadioComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
168
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.9", type: RadioComponent, isStandalone: true, selector: "base-radio", usesInheritance: true, ngImport: i0, template: "<ng-container *ngIf=\"config().visible\">\n <div class=\"row\" [formGroup]=\"formGroup\">\n <ng-container *ngIf=\"config().label\">\n <label [for]=\"config().attrName\">{{config().label}}</label>\n </ng-container>\n <div \n [ngClass]=\"config().styleClass ? config().styleClass : ''\"\n *ngFor=\"let radio of config().selectables; let i = index\">\n <input type=\"radio\"\n class=\"form-check-input\"\n [name]=\"config().attrName\"\n [id]=\"config().attrName + i\"\n [value]=\"radio.value\"\n [checked]=\"radio.key === value()\"\n [disabled]=\"config().disabled\"\n >\n <label [for]=\"config().attrName\" [ngClass]=\"config().labelClass ? config().labelClass : ''\">{{radio.value}}</label>\n </div>\n </div>\n</ng-container>", dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }] });
|
|
164
169
|
}
|
|
165
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
170
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: RadioComponent, decorators: [{
|
|
166
171
|
type: Component,
|
|
167
172
|
args: [{ selector: 'base-radio', standalone: true, imports: [NgIf, NgClass, NgForOf, ReactiveFormsModule], template: "<ng-container *ngIf=\"config().visible\">\n <div class=\"row\" [formGroup]=\"formGroup\">\n <ng-container *ngIf=\"config().label\">\n <label [for]=\"config().attrName\">{{config().label}}</label>\n </ng-container>\n <div \n [ngClass]=\"config().styleClass ? config().styleClass : ''\"\n *ngFor=\"let radio of config().selectables; let i = index\">\n <input type=\"radio\"\n class=\"form-check-input\"\n [name]=\"config().attrName\"\n [id]=\"config().attrName + i\"\n [value]=\"radio.value\"\n [checked]=\"radio.key === value()\"\n [disabled]=\"config().disabled\"\n >\n <label [for]=\"config().attrName\" [ngClass]=\"config().labelClass ? config().labelClass : ''\">{{radio.value}}</label>\n </div>\n </div>\n</ng-container>" }]
|
|
168
173
|
}] });
|
|
169
174
|
|
|
170
175
|
class TextareaComponent extends BaseFormControlComponent {
|
|
171
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
172
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
176
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: TextareaComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
177
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.9", type: TextareaComponent, isStandalone: true, selector: "base-textarea", usesInheritance: true, ngImport: i0, template: "<ng-container *ngIf=\"config().visible\">\n <div class=\"row\" [formGroup]=\"formGroup\">\n <mat-form-field [ngClass]=\"config().styleClass\">\n <mat-label [ngClass]=\"config().labelClass\">{{config().label}}</mat-label>\n <textarea matInput formControlName=\"{{config().attrName}}\" placeholder=\"Ex. It makes me feel...\"></textarea>\n </mat-form-field>\n </div>\n</ng-container>", dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { 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: "directive", type: MatLabel, selector: "mat-label" }, { 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],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"] }] });
|
|
173
178
|
}
|
|
174
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
179
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: TextareaComponent, decorators: [{
|
|
175
180
|
type: Component,
|
|
176
181
|
args: [{ selector: 'base-textarea', standalone: true, imports: [NgIf, NgClass, MatFormField, MatInput, MatLabel, ReactiveFormsModule], template: "<ng-container *ngIf=\"config().visible\">\n <div class=\"row\" [formGroup]=\"formGroup\">\n <mat-form-field [ngClass]=\"config().styleClass\">\n <mat-label [ngClass]=\"config().labelClass\">{{config().label}}</mat-label>\n <textarea matInput formControlName=\"{{config().attrName}}\" placeholder=\"Ex. It makes me feel...\"></textarea>\n </mat-form-field>\n </div>\n</ng-container>" }]
|
|
177
182
|
}] });
|
|
178
183
|
|
|
179
|
-
class
|
|
180
|
-
|
|
181
|
-
|
|
184
|
+
class FlexBoxHostDirective {
|
|
185
|
+
viewContainerRef;
|
|
186
|
+
constructor(viewContainerRef) {
|
|
187
|
+
this.viewContainerRef = viewContainerRef;
|
|
188
|
+
}
|
|
189
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: FlexBoxHostDirective, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
190
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.9", type: FlexBoxHostDirective, isStandalone: true, selector: "[flexBoxHost]", ngImport: i0 });
|
|
182
191
|
}
|
|
183
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
184
|
-
type:
|
|
185
|
-
args: [{
|
|
186
|
-
|
|
192
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: FlexBoxHostDirective, decorators: [{
|
|
193
|
+
type: Directive,
|
|
194
|
+
args: [{
|
|
195
|
+
standalone: true,
|
|
196
|
+
selector: '[flexBoxHost]',
|
|
197
|
+
}]
|
|
198
|
+
}], ctorParameters: () => [{ type: i0.ViewContainerRef }] });
|
|
187
199
|
|
|
188
|
-
var
|
|
189
|
-
(function (
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
200
|
+
var FlexDirection;
|
|
201
|
+
(function (FlexDirection) {
|
|
202
|
+
FlexDirection[FlexDirection["CONTAINER"] = 0] = "CONTAINER";
|
|
203
|
+
FlexDirection[FlexDirection["COLUMN"] = 1] = "COLUMN";
|
|
204
|
+
FlexDirection[FlexDirection["ROW"] = 2] = "ROW";
|
|
205
|
+
})(FlexDirection || (FlexDirection = {}));
|
|
206
|
+
class FlexboxDescriptor extends AbstractAttrDescriptor {
|
|
207
|
+
attrDescriptors;
|
|
208
|
+
direction;
|
|
209
|
+
constructor(attrDescriptors, direction) {
|
|
210
|
+
super('dummy', FormControlType.FLEX_BOX);
|
|
211
|
+
this.attrDescriptors = attrDescriptors;
|
|
212
|
+
this.direction = direction;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
196
215
|
|
|
197
|
-
class
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
216
|
+
class FlexBoxComponent extends BaseFormControlComponent {
|
|
217
|
+
flexBoxHost;
|
|
218
|
+
flexBoxClass = computed(() => this.calculateFlexStyle(this.config().direction), ...(ngDevMode ? [{ debugName: "flexBoxClass" }] : []));
|
|
219
|
+
// region protected, private helper methods
|
|
220
|
+
calculateFlexStyle(direction) {
|
|
221
|
+
switch (direction) {
|
|
222
|
+
case FlexDirection.CONTAINER:
|
|
223
|
+
return 'flex-box-container';
|
|
224
|
+
case FlexDirection.COLUMN:
|
|
225
|
+
return 'flex-box-container-columns';
|
|
226
|
+
case FlexDirection.ROW:
|
|
227
|
+
return 'flex-box-container-rows';
|
|
228
|
+
default:
|
|
229
|
+
throw new Error('Unknown flex direction');
|
|
230
|
+
}
|
|
201
231
|
}
|
|
202
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
203
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
232
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: FlexBoxComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
233
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.9", type: FlexBoxComponent, isStandalone: true, selector: "flex-box", viewQueries: [{ propertyName: "flexBoxHost", first: true, predicate: FlexBoxHostDirective, descendants: true, read: FlexBoxHostDirective, static: true }], usesInheritance: true, ngImport: i0, template: "<div [ngClass]=\"flexBoxClass()\" [ngStyle]=\"style()\">\n <ng-template flexBoxHost></ng-template>\n</div>\n", styles: [".flex-box-container{display:flex}.flex-box-container-columns{display:flex;flex-direction:column}.flex-box-container-rows{display:flex;flex-direction:row}\n"], dependencies: [{ kind: "directive", type: FlexBoxHostDirective, selector: "[flexBoxHost]" }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
|
|
204
234
|
}
|
|
205
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
235
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: FlexBoxComponent, decorators: [{
|
|
206
236
|
type: Component,
|
|
207
|
-
args: [{ selector: '
|
|
208
|
-
}]
|
|
237
|
+
args: [{ selector: 'flex-box', imports: [FlexBoxHostDirective, NgClass, NgStyle], template: "<div [ngClass]=\"flexBoxClass()\" [ngStyle]=\"style()\">\n <ng-template flexBoxHost></ng-template>\n</div>\n", styles: [".flex-box-container{display:flex}.flex-box-container-columns{display:flex;flex-direction:column}.flex-box-container-rows{display:flex;flex-direction:row}\n"] }]
|
|
238
|
+
}], propDecorators: { flexBoxHost: [{
|
|
239
|
+
type: ViewChild,
|
|
240
|
+
args: [FlexBoxHostDirective, { static: true, read: FlexBoxHostDirective }]
|
|
241
|
+
}] } });
|
|
209
242
|
|
|
210
|
-
class
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
243
|
+
class BaseEntityAttrDescriptor extends AbstractAttrDescriptor {
|
|
244
|
+
description;
|
|
245
|
+
styleClass = '';
|
|
246
|
+
labelClass = '';
|
|
247
|
+
format;
|
|
248
|
+
isLinkToDetails;
|
|
249
|
+
selectables;
|
|
250
|
+
visible = true;
|
|
251
|
+
isHeading;
|
|
252
|
+
placeholder;
|
|
253
|
+
lines;
|
|
254
|
+
options;
|
|
255
|
+
_label;
|
|
256
|
+
_linkedEntityType;
|
|
257
|
+
constructor(attrName, formControlType, label, selectables, isLinkToDetails, options) {
|
|
258
|
+
super(attrName, formControlType);
|
|
259
|
+
this.attrName = attrName;
|
|
260
|
+
this._label = label;
|
|
261
|
+
this.selectables = selectables;
|
|
262
|
+
this.isLinkToDetails = isLinkToDetails;
|
|
263
|
+
this.options = { inputType: 'text', ...options };
|
|
221
264
|
}
|
|
222
|
-
// region
|
|
223
|
-
|
|
224
|
-
this.
|
|
225
|
-
this.baseEntityForm = this.formBuilder.group({});
|
|
265
|
+
// region properties
|
|
266
|
+
get label() {
|
|
267
|
+
return this._label ? this._label : this.attrName;
|
|
226
268
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
async onCancel() {
|
|
230
|
-
this.store().setCurrentEntity(undefined);
|
|
231
|
-
await this.store().navigateBack();
|
|
269
|
+
set label(label) {
|
|
270
|
+
this._label = label;
|
|
232
271
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
if (this.isNewObject()) {
|
|
236
|
-
this.store().save(objectToSave);
|
|
237
|
-
}
|
|
238
|
-
else {
|
|
239
|
-
this.store().update(objectToSave, objectToSave.id);
|
|
240
|
-
}
|
|
241
|
-
this.store().setCurrentEntity(undefined);
|
|
242
|
-
await this.store().navigateBack();
|
|
272
|
+
get linkedEntityType() {
|
|
273
|
+
return this._linkedEntityType;
|
|
243
274
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
275
|
+
set linkedEntityType(linkedEntityType) {
|
|
276
|
+
this._linkedEntityType = linkedEntityType;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
class BaseEntityFormBuilder {
|
|
281
|
+
// region public methods
|
|
282
|
+
buildForm(viewContainerRef, baseEntityForm, store, attrDescriptors, entity) {
|
|
283
|
+
viewContainerRef.clear();
|
|
284
|
+
attrDescriptors.forEach((column) => {
|
|
250
285
|
const formControlType = this.createFormControl(column);
|
|
251
|
-
const currentAttrValue = Reflect.get(this.entity(), column.attrName);
|
|
252
286
|
if (formControlType) {
|
|
253
287
|
const componentRef = viewContainerRef.createComponent(formControlType);
|
|
254
|
-
componentRef.instance.config = signal(column);
|
|
255
|
-
componentRef.instance.entity =
|
|
256
|
-
componentRef.instance.formGroup =
|
|
257
|
-
componentRef.instance.store =
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
288
|
+
componentRef.instance.config = signal(column, ...(ngDevMode ? [{ debugName: "config" }] : []));
|
|
289
|
+
componentRef.instance.entity = entity;
|
|
290
|
+
componentRef.instance.formGroup = baseEntityForm;
|
|
291
|
+
componentRef.instance.store = store;
|
|
292
|
+
if (column instanceof BaseEntityAttrDescriptor) {
|
|
293
|
+
const currentAttrValue = Reflect.get(entity(), column.attrName);
|
|
294
|
+
componentRef.instance.value = signal(currentAttrValue, ...(ngDevMode ? [{ debugName: "value" }] : []));
|
|
295
|
+
const formControl = new FormControl({ value: currentAttrValue, disabled: column.disabled }, Validators.required);
|
|
296
|
+
baseEntityForm.addControl(column.attrName, formControl);
|
|
297
|
+
}
|
|
298
|
+
else if (column instanceof FlexboxDescriptor) {
|
|
299
|
+
this.buildForm(componentRef.instance.flexBoxHost.viewContainerRef, baseEntityForm, store, column.attrDescriptors, entity);
|
|
300
|
+
}
|
|
301
|
+
else
|
|
302
|
+
throw Error('Undefined subclass of AbstractAttrDescriptor');
|
|
261
303
|
}
|
|
262
304
|
});
|
|
263
305
|
}
|
|
306
|
+
// endregion
|
|
307
|
+
// region protected, private helper methods
|
|
264
308
|
createFormControl(column) {
|
|
265
309
|
if (column.formControlType === FormControlType.LABEL) {
|
|
266
310
|
return LabelComponent;
|
|
@@ -268,6 +312,9 @@ class BaseEntityFormComponent {
|
|
|
268
312
|
else if (column.formControlType === FormControlType.DATE) {
|
|
269
313
|
return DatepickerComponent;
|
|
270
314
|
}
|
|
315
|
+
else if (column.formControlType === FormControlType.FLEX_BOX) {
|
|
316
|
+
return FlexBoxComponent;
|
|
317
|
+
}
|
|
271
318
|
else if (column.formControlType === FormControlType.FOREIGN_KEY) {
|
|
272
319
|
return ForeignKeyComponent;
|
|
273
320
|
}
|
|
@@ -289,11 +336,56 @@ class BaseEntityFormComponent {
|
|
|
289
336
|
else
|
|
290
337
|
throw Error('Undefined form control type');
|
|
291
338
|
}
|
|
339
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: BaseEntityFormBuilder, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
340
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: BaseEntityFormBuilder, providedIn: 'root' });
|
|
341
|
+
}
|
|
342
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: BaseEntityFormBuilder, decorators: [{
|
|
343
|
+
type: Injectable,
|
|
344
|
+
args: [{ providedIn: 'root' }]
|
|
345
|
+
}] });
|
|
346
|
+
|
|
347
|
+
class BaseEntityFormComponent {
|
|
348
|
+
baseEntityForm;
|
|
349
|
+
baseEntityListOptions = inject(ROUTER_OUTLET_DATA);
|
|
350
|
+
entity = computed(() => (this.isNewObject() ? this.store().createEntity() : this.store().loadById(this.entityId())), ...(ngDevMode ? [{ debugName: "entity" }] : []));
|
|
351
|
+
entityId = input.required(...(ngDevMode ? [{ debugName: "entityId" }] : []));
|
|
352
|
+
componentHost;
|
|
353
|
+
store = computed(() => this.baseEntityListOptions().store, ...(ngDevMode ? [{ debugName: "store" }] : []));
|
|
354
|
+
entityFormBuilder = inject((BaseEntityFormBuilder));
|
|
355
|
+
formBuilder = inject(FormBuilder);
|
|
356
|
+
isNewObject = computed(() => this.entityId() === BaseUrlSegments.NewEntity, ...(ngDevMode ? [{ debugName: "isNewObject" }] : []));
|
|
357
|
+
constructor() {
|
|
358
|
+
this.registerEffects();
|
|
359
|
+
}
|
|
360
|
+
// region angular lifecycle hooks
|
|
361
|
+
ngOnInit() {
|
|
362
|
+
this.store().determineActiveRouteSegment();
|
|
363
|
+
this.baseEntityForm = this.formBuilder.group({});
|
|
364
|
+
}
|
|
365
|
+
// endregion
|
|
366
|
+
// region event handlers
|
|
367
|
+
async onCancel() {
|
|
368
|
+
this.store().setCurrentEntity(undefined);
|
|
369
|
+
await this.store().navigateBack();
|
|
370
|
+
}
|
|
371
|
+
async onSubmit() {
|
|
372
|
+
const objectToSave = { ...this.entity(), ...this.baseEntityForm.value };
|
|
373
|
+
if (this.isNewObject()) {
|
|
374
|
+
this.store().add(objectToSave);
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
this.store().update(objectToSave, objectToSave.id);
|
|
378
|
+
}
|
|
379
|
+
this.store().setCurrentEntity(undefined);
|
|
380
|
+
await this.store().navigateBack();
|
|
381
|
+
}
|
|
382
|
+
// endregion
|
|
383
|
+
// region protected, private helper methods
|
|
292
384
|
registerEffects() {
|
|
293
385
|
effect(() => {
|
|
294
386
|
if (this.entityId() && this.baseEntityListOptions() && this.entity())
|
|
295
387
|
untracked(() => {
|
|
296
|
-
this.buildForm();
|
|
388
|
+
this.entityFormBuilder.buildForm(this.componentHost.viewContainerRef, this.baseEntityForm, this.store(), this.baseEntityListOptions().attrDescriptors, this.entity);
|
|
297
389
|
});
|
|
298
390
|
});
|
|
299
391
|
effect(() => {
|
|
@@ -301,64 +393,48 @@ class BaseEntityFormComponent {
|
|
|
301
393
|
this.store().setCurrentEntity(this.entity().id);
|
|
302
394
|
});
|
|
303
395
|
}
|
|
304
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
305
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "
|
|
306
|
-
<mat-card appearance="outlined" class="dense-3">
|
|
307
|
-
<mat-card-content>
|
|
308
|
-
<form [formGroup]="baseEntityForm" (ngSubmit)="onSubmit()">
|
|
309
|
-
<ng-template baseFormHost></ng-template>
|
|
310
|
-
</form>
|
|
311
|
-
</mat-card-content>
|
|
312
|
-
<mat-card-actions>
|
|
313
|
-
<button id="cancel" mat-raised-button color="secondary" (click)="onCancel()">Cancel</button>
|
|
314
|
-
<button id="submit" mat-raised-button color="primary" type="submit" [disabled]="baseEntityForm.invalid || !baseEntityForm.dirty" (click)="onSubmit()">Save</button>
|
|
315
|
-
</mat-card-actions>
|
|
316
|
-
</mat-card>
|
|
317
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: BaseFormHostDirective, selector: "[baseFormHost]" }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.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[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", exportAs: ["matButton"] }] });
|
|
396
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: BaseEntityFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
397
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.3.9", 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],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"] }] });
|
|
318
398
|
}
|
|
319
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
399
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: BaseEntityFormComponent, decorators: [{
|
|
320
400
|
type: Component,
|
|
321
|
-
args: [{
|
|
322
|
-
|
|
323
|
-
standalone: true,
|
|
324
|
-
template: `
|
|
325
|
-
<mat-card appearance="outlined" class="dense-3">
|
|
326
|
-
<mat-card-content>
|
|
327
|
-
<form [formGroup]="baseEntityForm" (ngSubmit)="onSubmit()">
|
|
328
|
-
<ng-template baseFormHost></ng-template>
|
|
329
|
-
</form>
|
|
330
|
-
</mat-card-content>
|
|
331
|
-
<mat-card-actions>
|
|
332
|
-
<button id="cancel" mat-raised-button color="secondary" (click)="onCancel()">Cancel</button>
|
|
333
|
-
<button id="submit" mat-raised-button color="primary" type="submit" [disabled]="baseEntityForm.invalid || !baseEntityForm.dirty" (click)="onSubmit()">Save</button>
|
|
334
|
-
</mat-card-actions>
|
|
335
|
-
</mat-card>
|
|
336
|
-
`,
|
|
337
|
-
imports: [BaseFormHostDirective, ReactiveFormsModule, MatCard, MatCardContent, MatCardActions, MatButton],
|
|
338
|
-
providers: [{ provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: { appearance: 'outline' } }],
|
|
339
|
-
}]
|
|
340
|
-
}], ctorParameters: () => [], propDecorators: { componentHost: [{
|
|
401
|
+
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" }]
|
|
402
|
+
}], ctorParameters: () => [], propDecorators: { entityId: [{ type: i0.Input, args: [{ isSignal: true, alias: "entityId", required: true }] }], componentHost: [{
|
|
341
403
|
type: ViewChild,
|
|
342
404
|
args: [BaseFormHostDirective, { static: true, read: BaseFormHostDirective }]
|
|
343
405
|
}] } });
|
|
344
406
|
|
|
407
|
+
function filterAttributeDescriptors(descriptors) {
|
|
408
|
+
let attrDescriptors = [];
|
|
409
|
+
descriptors.forEach((descriptor) => {
|
|
410
|
+
if (descriptor instanceof BaseEntityAttrDescriptor)
|
|
411
|
+
attrDescriptors.push(descriptor);
|
|
412
|
+
else if (descriptor instanceof FlexboxDescriptor) {
|
|
413
|
+
attrDescriptors = attrDescriptors.concat(filterAttributeDescriptors(descriptor.attrDescriptors));
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
return attrDescriptors;
|
|
417
|
+
}
|
|
418
|
+
|
|
345
419
|
const BASE_LIST_DESCRIPTORS = new InjectionToken('BASE_TABLE_DISPLAYED_COLUMNS');
|
|
346
420
|
class BaseEntityListComponent {
|
|
347
421
|
dataSource = new MatTableDataSource();
|
|
348
422
|
selection = new SelectionModel(true, []);
|
|
349
|
-
|
|
350
|
-
columnDescriptors = computed(() =>
|
|
423
|
+
entityDescriptor = inject(ROUTER_OUTLET_DATA);
|
|
424
|
+
columnDescriptors = computed(() => {
|
|
425
|
+
return filterAttributeDescriptors(this.entityDescriptor().attrDescriptors);
|
|
426
|
+
}, ...(ngDevMode ? [{ debugName: "columnDescriptors" }] : []));
|
|
351
427
|
displayedColumns = computed(() => {
|
|
352
428
|
const columns = this.columnDescriptors().map((column) => column.attrName);
|
|
353
429
|
columns.unshift('select');
|
|
354
430
|
return columns;
|
|
355
|
-
});
|
|
431
|
+
}, ...(ngDevMode ? [{ debugName: "displayedColumns" }] : []));
|
|
356
432
|
sort = {};
|
|
357
433
|
paginator = {};
|
|
358
434
|
store;
|
|
359
435
|
router = inject(Router);
|
|
360
436
|
constructor() {
|
|
361
|
-
this.store = this.
|
|
437
|
+
this.store = this.entityDescriptor().store;
|
|
362
438
|
this.registerEffects();
|
|
363
439
|
}
|
|
364
440
|
// region Angular lifecycle events
|
|
@@ -418,9 +494,9 @@ class BaseEntityListComponent {
|
|
|
418
494
|
return Reflect.get(entity, property);
|
|
419
495
|
}
|
|
420
496
|
loadAllData() {
|
|
421
|
-
const
|
|
422
|
-
const
|
|
423
|
-
this.store.load({
|
|
497
|
+
const pathParams = new Map([]);
|
|
498
|
+
const filters = [];
|
|
499
|
+
this.store.load({ pathParams, filters });
|
|
424
500
|
}
|
|
425
501
|
registerEffects() {
|
|
426
502
|
effect(() => (this.dataSource.data = this.store.entities()));
|
|
@@ -439,10 +515,10 @@ class BaseEntityListComponent {
|
|
|
439
515
|
isSelected(row) {
|
|
440
516
|
return this.selection.isSelected(row);
|
|
441
517
|
}
|
|
442
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
443
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
518
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: BaseEntityListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
519
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.9", 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<table mat-table [dataSource]=\"dataSource\" class=\"mat-elevation-z8 demo-table\" matSort aria-describedby=\"base-entity-list\">\n <!-- Checkbox Column -->\n <ng-container matColumnDef=\"select\">\n <th mat-header-cell *matHeaderCellDef>\n <mat-checkbox (change)=\"$event ? onToggleAllRows() : null\" [checked]=\"selection.hasValue() && isAllSelected()\" [indeterminate]=\"selection.hasValue() && !isAllSelected()\"> </mat-checkbox>\n </th>\n <td 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 </td>\n </ng-container>\n\n <ng-container *ngFor=\"let colDescriptor of columnDescriptors(); index as i\" [matColumnDef]=\"colDescriptor.attrName\">\n <th mat-header-cell *matHeaderCellDef mat-sort-header>{{ colDescriptor.label }}</th>\n <!-- //NOSONAR --><td (click)=\"onRowClick(element)\" *matCellDef=\"let element\" mat-cell>\n @if (colDescriptor.isLinkToDetails === true) {\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 {\n {{ element[colDescriptor.attrName] }}\n }\n </td>\n </ng-container>\n <tr mat-header-row *matHeaderRowDef=\"displayedColumns()\"></tr>\n <tr mat-row *matRowDef=\"let row; columns: displayedColumns()\"></tr>\n</table>\n<mat-paginator [pageSizeOptions]=\"[3, 5, 8]\" showFirstLastButtons></mat-paginator>\n", styles: [".mat-column-select{overflow:initial}.mat-mdc-row:hover{background-color:#6495ed;cursor:pointer}\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: NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { 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"] }] });
|
|
444
520
|
}
|
|
445
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
521
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: BaseEntityListComponent, decorators: [{
|
|
446
522
|
type: Component,
|
|
447
523
|
args: [{ selector: 'base-list', standalone: true, imports: [
|
|
448
524
|
MatTable,
|
|
@@ -461,7 +537,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.4", ngImpor
|
|
|
461
537
|
MatSortHeader,
|
|
462
538
|
MatProgressBar,
|
|
463
539
|
MatCheckbox,
|
|
464
|
-
], template: "@if (store.isLoading()) {\
|
|
540
|
+
], template: "@if (store.isLoading()) {\n <mat-progress-bar mode=\"query\"></mat-progress-bar>\n}\n<table mat-table [dataSource]=\"dataSource\" class=\"mat-elevation-z8 demo-table\" matSort aria-describedby=\"base-entity-list\">\n <!-- Checkbox Column -->\n <ng-container matColumnDef=\"select\">\n <th mat-header-cell *matHeaderCellDef>\n <mat-checkbox (change)=\"$event ? onToggleAllRows() : null\" [checked]=\"selection.hasValue() && isAllSelected()\" [indeterminate]=\"selection.hasValue() && !isAllSelected()\"> </mat-checkbox>\n </th>\n <td 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 </td>\n </ng-container>\n\n <ng-container *ngFor=\"let colDescriptor of columnDescriptors(); index as i\" [matColumnDef]=\"colDescriptor.attrName\">\n <th mat-header-cell *matHeaderCellDef mat-sort-header>{{ colDescriptor.label }}</th>\n <!-- //NOSONAR --><td (click)=\"onRowClick(element)\" *matCellDef=\"let element\" mat-cell>\n @if (colDescriptor.isLinkToDetails === true) {\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 {\n {{ element[colDescriptor.attrName] }}\n }\n </td>\n </ng-container>\n <tr mat-header-row *matHeaderRowDef=\"displayedColumns()\"></tr>\n <tr mat-row *matRowDef=\"let row; columns: displayedColumns()\"></tr>\n</table>\n<mat-paginator [pageSizeOptions]=\"[3, 5, 8]\" showFirstLastButtons></mat-paginator>\n", styles: [".mat-column-select{overflow:initial}.mat-mdc-row:hover{background-color:#6495ed;cursor:pointer}\n"] }]
|
|
465
541
|
}], ctorParameters: () => [], propDecorators: { sort: [{
|
|
466
542
|
type: ViewChild,
|
|
467
543
|
args: [MatSort]
|
|
@@ -495,21 +571,17 @@ var RouteSegments;
|
|
|
495
571
|
})(RouteSegments || (RouteSegments = {}));
|
|
496
572
|
const INITIAL_NAVIGATION_STATE = {
|
|
497
573
|
activeRouteSegment: RouteSegments.LIST_ROUTE,
|
|
574
|
+
entityName: '',
|
|
498
575
|
navigateTo: '',
|
|
499
576
|
returnTo: '',
|
|
500
577
|
};
|
|
501
|
-
function entityName
|
|
502
|
-
|
|
503
|
-
return entity.constructor.name;
|
|
504
|
-
}
|
|
505
|
-
function snakeCaseName(entityType) {
|
|
506
|
-
const nameOfEntity = entityName(entityType);
|
|
507
|
-
return nameOfEntity
|
|
578
|
+
function snakeCaseName(entityName) {
|
|
579
|
+
return entityName
|
|
508
580
|
.split(/(?=[A-Z])/)
|
|
509
581
|
.join('-')
|
|
510
582
|
.toLowerCase();
|
|
511
583
|
}
|
|
512
|
-
function BaseFormNavigatorStore(
|
|
584
|
+
function BaseFormNavigatorStore(entityName) {
|
|
513
585
|
return signalStoreFeature(withState(INITIAL_NAVIGATION_STATE), withMethods((store, router = inject(Router), route = inject(ActivatedRoute)) => {
|
|
514
586
|
function determineActiveRouteSegment() {
|
|
515
587
|
const currentUrl = Reflect.get(route, '_routerState').snapshot.url;
|
|
@@ -534,7 +606,7 @@ function BaseFormNavigatorStore(entityType) {
|
|
|
534
606
|
function levelUpUrl(currentUrl) {
|
|
535
607
|
return currentUrl.substring(0, currentUrl.lastIndexOf('/'));
|
|
536
608
|
}
|
|
537
|
-
function navigateBack(defaultUrl) {
|
|
609
|
+
async function navigateBack(defaultUrl) {
|
|
538
610
|
const goTo = store.returnTo() ? store.returnTo() : defaultUrl;
|
|
539
611
|
patchState(store, { returnTo: '' });
|
|
540
612
|
if (goTo) {
|
|
@@ -544,26 +616,26 @@ function BaseFormNavigatorStore(entityType) {
|
|
|
544
616
|
.catch((error) => patchState(store, { navigationError: error.message }));
|
|
545
617
|
}
|
|
546
618
|
else
|
|
547
|
-
navigateToList();
|
|
619
|
+
await navigateToList();
|
|
548
620
|
}
|
|
549
621
|
async function navigateToDetails(id, returnTo) {
|
|
550
622
|
if (store.activeRouteSegment() != RouteSegments.DETAILS_ROUTE) {
|
|
551
|
-
const snakeCaseEntityName = snakeCaseName(
|
|
623
|
+
const snakeCaseEntityName = snakeCaseName(entityName);
|
|
552
624
|
const baseUrl = determineBaseUrl();
|
|
553
625
|
const detailsFormPath = baseUrl + '/' + snakeCaseEntityName + '/' + id + '/details';
|
|
554
626
|
await navigateToUrl(detailsFormPath, returnTo);
|
|
555
627
|
}
|
|
556
628
|
}
|
|
557
629
|
async function navigateToList(returnTo) {
|
|
558
|
-
const snakeCaseEntityName = snakeCaseName(
|
|
630
|
+
const snakeCaseEntityName = snakeCaseName(entityName);
|
|
559
631
|
const baseUrl = determineBaseUrl();
|
|
560
632
|
const goToUrl = baseUrl + '/' + snakeCaseEntityName + '/list';
|
|
561
633
|
if (store.activeRouteSegment() != RouteSegments.LIST_ROUTE) {
|
|
562
634
|
await navigateToUrl(goToUrl, returnTo);
|
|
563
635
|
}
|
|
564
636
|
}
|
|
565
|
-
async function navigateToRelated(
|
|
566
|
-
const snakeCaseEntityName = snakeCaseName(
|
|
637
|
+
async function navigateToRelated(relatedTypeName, id, returnTo) {
|
|
638
|
+
const snakeCaseEntityName = snakeCaseName(relatedTypeName);
|
|
567
639
|
const baseUrl = determineBaseUrl();
|
|
568
640
|
const detailsFormPath = baseUrl + '/' + snakeCaseEntityName + '/' + id + '/details';
|
|
569
641
|
await navigateToUrl(detailsFormPath, returnTo);
|
|
@@ -588,7 +660,7 @@ function BaseFormNavigatorStore(entityType) {
|
|
|
588
660
|
}
|
|
589
661
|
|
|
590
662
|
class BaseEntityToolbarComponent {
|
|
591
|
-
baseEntityListOptions = input.required();
|
|
663
|
+
baseEntityListOptions = input.required(...(ngDevMode ? [{ debugName: "baseEntityListOptions" }] : []));
|
|
592
664
|
layoutService = inject(LayoutService);
|
|
593
665
|
store;
|
|
594
666
|
// region Angular lifecycle hooks
|
|
@@ -615,37 +687,44 @@ class BaseEntityToolbarComponent {
|
|
|
615
687
|
// endregion
|
|
616
688
|
// protected, private helper methods
|
|
617
689
|
RouteSegments = RouteSegments;
|
|
618
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
619
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
690
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: BaseEntityToolbarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
691
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.9", type: BaseEntityToolbarComponent, isStandalone: true, selector: "base-entity-toolbar", inputs: { baseEntityListOptions: { classPropertyName: "baseEntityListOptions", publicName: "baseEntityListOptions", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "<mat-toolbar *ngIf=\"store.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>", 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"] }] });
|
|
620
692
|
}
|
|
621
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
693
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: BaseEntityToolbarComponent, decorators: [{
|
|
622
694
|
type: Component,
|
|
623
695
|
args: [{ selector: 'base-entity-toolbar', standalone: true, imports: [CommonModule, MatToolbar, MatIcon, MatFormField, MatInput, MatButton, MatMenu, MatMenuItem, MatMenuTrigger], template: "<mat-toolbar *ngIf=\"store.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>" }]
|
|
624
|
-
}] });
|
|
696
|
+
}], propDecorators: { baseEntityListOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "baseEntityListOptions", required: true }] }] } });
|
|
625
697
|
|
|
626
698
|
class BaseEntityStatusbarComponent {
|
|
627
699
|
store;
|
|
628
|
-
baseEntityListOptions = input.required();
|
|
629
|
-
entityTitle = computed(() =>
|
|
630
|
-
isVisible = computed(() => this.store.currentEntity() != undefined || this.store.selectedEntities().length == 1);
|
|
700
|
+
baseEntityListOptions = input.required(...(ngDevMode ? [{ debugName: "baseEntityListOptions" }] : []));
|
|
701
|
+
entityTitle = computed(() => this.evaluateEntityTitle(this.baseEntityListOptions().entityTitle), ...(ngDevMode ? [{ debugName: "entityTitle" }] : []));
|
|
702
|
+
isVisible = computed(() => this.store.currentEntity() != undefined || this.store.selectedEntities().length == 1, ...(ngDevMode ? [{ debugName: "isVisible" }] : []));
|
|
631
703
|
// region Angular lifecycle hooks
|
|
632
704
|
ngOnInit() {
|
|
633
705
|
this.store = this.baseEntityListOptions().store;
|
|
634
706
|
}
|
|
635
|
-
|
|
636
|
-
|
|
707
|
+
// endregion
|
|
708
|
+
// event handling methods
|
|
709
|
+
// endregion
|
|
710
|
+
// protected, private helper methods
|
|
711
|
+
evaluateEntityTitle(title) {
|
|
712
|
+
return eval(title); //NOSONAR the value title comes from a trusted source
|
|
713
|
+
}
|
|
714
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: BaseEntityStatusbarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
715
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.3.9", type: BaseEntityStatusbarComponent, isStandalone: true, selector: "base-entity-statusbar", inputs: { baseEntityListOptions: { classPropertyName: "baseEntityListOptions", publicName: "baseEntityListOptions", 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"] }] });
|
|
637
716
|
}
|
|
638
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
717
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: BaseEntityStatusbarComponent, decorators: [{
|
|
639
718
|
type: Component,
|
|
640
719
|
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>" }]
|
|
641
|
-
}] });
|
|
720
|
+
}], propDecorators: { baseEntityListOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "baseEntityListOptions", required: true }] }] } });
|
|
642
721
|
|
|
643
722
|
class BaseEntityTabsComponent {
|
|
644
723
|
store;
|
|
645
|
-
baseEntityListOptions = input.required();
|
|
646
|
-
selectedEntityId = computed(() => (this.store.currentId() ? this.store.currentId() : BaseUrlSegments.NewEntity));
|
|
647
|
-
detailsTabName = computed(() => this.baseEntityListOptions().entityName + ' - details');
|
|
648
|
-
listTabName = computed(() => this.baseEntityListOptions().entityName + ' - list');
|
|
724
|
+
baseEntityListOptions = input.required(...(ngDevMode ? [{ debugName: "baseEntityListOptions" }] : []));
|
|
725
|
+
selectedEntityId = computed(() => (this.store.currentId() ? this.store.currentId() : BaseUrlSegments.NewEntity), ...(ngDevMode ? [{ debugName: "selectedEntityId" }] : []));
|
|
726
|
+
detailsTabName = computed(() => this.baseEntityListOptions().entityName + ' - details', ...(ngDevMode ? [{ debugName: "detailsTabName" }] : []));
|
|
727
|
+
listTabName = computed(() => this.baseEntityListOptions().entityName + ' - list', ...(ngDevMode ? [{ debugName: "listTabName" }] : []));
|
|
649
728
|
constructor() {
|
|
650
729
|
this.registerEffects();
|
|
651
730
|
}
|
|
@@ -684,16 +763,16 @@ class BaseEntityTabsComponent {
|
|
|
684
763
|
}
|
|
685
764
|
});
|
|
686
765
|
}
|
|
687
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
688
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "
|
|
766
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: BaseEntityTabsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
767
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.3.9", type: BaseEntityTabsComponent, isStandalone: true, selector: "base-entity-tabs", inputs: { baseEntityListOptions: { classPropertyName: "baseEntityListOptions", publicName: "baseEntityListOptions", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "<nav mat-tab-nav-bar [tabPanel]=\"tabPanel\">\n <a mat-tab-link (click)=\"onShowList()\" [active]=\"store.currentTab() === listTabName()\">{{listTabName()}}</a>\n <a mat-tab-link [disabled]=\"store.currentEntity() === undefined\" (click)=\"onShowDetails()\" [active]=\"store.currentTab() === detailsTabName()\">{{detailsTabName()}}</a>\n</nav>\n\n<mat-tab-nav-panel #tabPanel>\n <base-entity-statusbar [baseEntityListOptions]=\"baseEntityListOptions()\"/>\n <base-entity-toolbar [baseEntityListOptions]=\"baseEntityListOptions()\"/>\n <router-outlet [routerOutletData]=\"baseEntityListOptions()\"/>\n</mat-tab-nav-panel>", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: MatTabNav, selector: "[mat-tab-nav-bar]", inputs: ["fitInkBarToContent", "mat-stretch-tabs", "animationDuration", "backgroundColor", "disableRipple", "color", "tabPanel"], exportAs: ["matTabNavBar", "matTabNav"] }, { kind: "component", type: MatTabLink, selector: "[mat-tab-link], [matTabLink]", inputs: ["active", "disabled", "disableRipple", "tabIndex", "id"], exportAs: ["matTabLink"] }, { kind: "component", type: MatTabNavPanel, selector: "mat-tab-nav-panel", inputs: ["id"], exportAs: ["matTabNavPanel"] }, { kind: "directive", type: RouterOutlet, selector: "router-outlet", inputs: ["name", "routerOutletData"], outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }, { kind: "component", type: BaseEntityToolbarComponent, selector: "base-entity-toolbar", inputs: ["baseEntityListOptions"] }, { kind: "component", type: BaseEntityStatusbarComponent, selector: "base-entity-statusbar", inputs: ["baseEntityListOptions"] }] });
|
|
689
768
|
}
|
|
690
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
769
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: BaseEntityTabsComponent, decorators: [{
|
|
691
770
|
type: Component,
|
|
692
771
|
args: [{ selector: 'base-entity-tabs', standalone: true, imports: [CommonModule, MatTabNav, MatTabLink, MatTabNavPanel, RouterOutlet, BaseEntityToolbarComponent, BaseEntityStatusbarComponent], template: "<nav mat-tab-nav-bar [tabPanel]=\"tabPanel\">\n <a mat-tab-link (click)=\"onShowList()\" [active]=\"store.currentTab() === listTabName()\">{{listTabName()}}</a>\n <a mat-tab-link [disabled]=\"store.currentEntity() === undefined\" (click)=\"onShowDetails()\" [active]=\"store.currentTab() === detailsTabName()\">{{detailsTabName()}}</a>\n</nav>\n\n<mat-tab-nav-panel #tabPanel>\n <base-entity-statusbar [baseEntityListOptions]=\"baseEntityListOptions()\"/>\n <base-entity-toolbar [baseEntityListOptions]=\"baseEntityListOptions()\"/>\n <router-outlet [routerOutletData]=\"baseEntityListOptions()\"/>\n</mat-tab-nav-panel>" }]
|
|
693
|
-
}], ctorParameters: () => [] });
|
|
772
|
+
}], ctorParameters: () => [], propDecorators: { baseEntityListOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "baseEntityListOptions", required: true }] }] } });
|
|
694
773
|
|
|
695
774
|
class BaseEntityContainerComponent {
|
|
696
|
-
baseEntityListOptions = input.required();
|
|
775
|
+
baseEntityListOptions = input.required(...(ngDevMode ? [{ debugName: "baseEntityListOptions" }] : []));
|
|
697
776
|
snackBar = inject(MatSnackBar);
|
|
698
777
|
store;
|
|
699
778
|
constructor() {
|
|
@@ -716,24 +795,34 @@ class BaseEntityContainerComponent {
|
|
|
716
795
|
}
|
|
717
796
|
});
|
|
718
797
|
}
|
|
719
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
720
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "
|
|
798
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: BaseEntityContainerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
799
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.3.9", type: BaseEntityContainerComponent, isStandalone: true, selector: "base-entity-container", inputs: { baseEntityListOptions: { classPropertyName: "baseEntityListOptions", publicName: "baseEntityListOptions", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: `
|
|
721
800
|
<div>
|
|
722
801
|
<base-entity-tabs [baseEntityListOptions]="baseEntityListOptions()"></base-entity-tabs>
|
|
723
802
|
</div>
|
|
724
|
-
`, isInline: true,
|
|
803
|
+
`, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: BaseEntityTabsComponent, selector: "base-entity-tabs", inputs: ["baseEntityListOptions"] }] });
|
|
725
804
|
}
|
|
726
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
805
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: BaseEntityContainerComponent, decorators: [{
|
|
727
806
|
type: Component,
|
|
728
|
-
args: [{
|
|
807
|
+
args: [{
|
|
808
|
+
selector: 'base-entity-container',
|
|
809
|
+
standalone: true,
|
|
810
|
+
imports: [CommonModule, BaseEntityTabsComponent],
|
|
811
|
+
template: `
|
|
729
812
|
<div>
|
|
730
813
|
<base-entity-tabs [baseEntityListOptions]="baseEntityListOptions()"></base-entity-tabs>
|
|
731
814
|
</div>
|
|
732
|
-
|
|
733
|
-
|
|
815
|
+
`,
|
|
816
|
+
}]
|
|
817
|
+
}], ctorParameters: () => [], propDecorators: { baseEntityListOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "baseEntityListOptions", required: true }] }] } });
|
|
734
818
|
|
|
735
|
-
|
|
736
|
-
|
|
819
|
+
var OrderByDirection;
|
|
820
|
+
(function (OrderByDirection) {
|
|
821
|
+
OrderByDirection["ASC"] = "asc";
|
|
822
|
+
OrderByDirection["DESC"] = "desc";
|
|
823
|
+
})(OrderByDirection || (OrderByDirection = {}));
|
|
824
|
+
|
|
825
|
+
let BaseEntityRestService = class BaseEntityRestService {
|
|
737
826
|
entityMapper;
|
|
738
827
|
urlProperty;
|
|
739
828
|
resourceUrl;
|
|
@@ -760,19 +849,33 @@ let BaseEntityService = class BaseEntityService {
|
|
|
760
849
|
deleteAll() {
|
|
761
850
|
return this.httpClient.delete(this.resourceUrl, { headers: this.headers });
|
|
762
851
|
}
|
|
763
|
-
findAll(
|
|
764
|
-
|
|
852
|
+
findAll(page) {
|
|
853
|
+
return this.findByQuery({ page });
|
|
854
|
+
}
|
|
855
|
+
findByQuery(queryCondition) {
|
|
856
|
+
const fullUrl = this.buildFullUrl(this.resourceUrl, queryCondition);
|
|
857
|
+
if (fullUrl) {
|
|
858
|
+
return this.httpClient.get(fullUrl, { headers: this.headers }).pipe(map((httpResponse) => {
|
|
859
|
+
return queryCondition.page ? this.mapPagedResponse(httpResponse) : this.mapSimpleResponse(httpResponse);
|
|
860
|
+
}));
|
|
861
|
+
}
|
|
862
|
+
else
|
|
863
|
+
throw new Error('Could not determine the full url');
|
|
864
|
+
}
|
|
865
|
+
findById(id) {
|
|
866
|
+
const queryCondition = { pathParams: new Map([['id', id]]) };
|
|
867
|
+
const fullUrl = this.buildFullUrl(this.resourceUrl, queryCondition);
|
|
765
868
|
if (fullUrl) {
|
|
766
869
|
return this.httpClient.get(fullUrl, { headers: this.headers }).pipe(map((httpResponse) => {
|
|
767
|
-
return
|
|
870
|
+
return this.mapSimpleResponse(httpResponse);
|
|
768
871
|
}));
|
|
769
872
|
}
|
|
770
873
|
else
|
|
771
874
|
throw new Error('Could not determine the full url');
|
|
772
875
|
}
|
|
773
|
-
|
|
876
|
+
add(entity, id) {
|
|
774
877
|
const dto = this.entityMapper.toDto(entity);
|
|
775
|
-
const fullUrl = this.buildFullUrl(this.resourceUrl);
|
|
878
|
+
const fullUrl = this.buildFullUrl(this.resourceUrl, {});
|
|
776
879
|
if (fullUrl) {
|
|
777
880
|
return this.httpClient.post(fullUrl, dto, { headers: this.headers }).pipe(map((response) => {
|
|
778
881
|
return this.entityMapper.fromDto(response, id);
|
|
@@ -783,9 +886,8 @@ let BaseEntityService = class BaseEntityService {
|
|
|
783
886
|
}
|
|
784
887
|
update(entity) {
|
|
785
888
|
const dto = this.entityMapper.toDto(entity);
|
|
786
|
-
const
|
|
787
|
-
const
|
|
788
|
-
const fullUrl = this.buildFullUrl(this.resourceUrl + '/%{id}', path, filter);
|
|
889
|
+
const pathParams = new Map([['id', String(entity.id)]]);
|
|
890
|
+
const fullUrl = this.buildFullUrl(this.resourceUrl + '/%{id}', { pathParams });
|
|
789
891
|
if (fullUrl) {
|
|
790
892
|
return this.httpClient.put(fullUrl, dto, { headers: this.headers }).pipe(map((response) => {
|
|
791
893
|
return this.entityMapper.fromDto(response);
|
|
@@ -796,14 +898,12 @@ let BaseEntityService = class BaseEntityService {
|
|
|
796
898
|
}
|
|
797
899
|
// endregion
|
|
798
900
|
// region protected, private helper methods
|
|
799
|
-
buildFullUrl(resourceUri,
|
|
800
|
-
const
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
else {
|
|
806
|
-
queryParams = new Map([...Array.from(pageParam)]);
|
|
901
|
+
buildFullUrl(resourceUri, queryCondition) {
|
|
902
|
+
const queryParams = new Map();
|
|
903
|
+
if (queryCondition.page)
|
|
904
|
+
queryParams.set('page', queryCondition.page.toString());
|
|
905
|
+
if (queryCondition.filters !== undefined && queryCondition.filters.length != 0) {
|
|
906
|
+
queryCondition.filters.forEach((filter) => queryParams.set(filter.property, filter.value));
|
|
807
907
|
}
|
|
808
908
|
let params = {};
|
|
809
909
|
if (queryParams.size > 0) {
|
|
@@ -813,15 +913,15 @@ let BaseEntityService = class BaseEntityService {
|
|
|
813
913
|
}
|
|
814
914
|
else
|
|
815
915
|
params = null;
|
|
816
|
-
if (
|
|
817
|
-
|
|
916
|
+
if (queryCondition.pathParams !== undefined && queryCondition.pathParams.size != 0) {
|
|
917
|
+
queryCondition.pathParams.forEach((value, key) => {
|
|
818
918
|
const pathParam = '%{' + key + '}';
|
|
819
919
|
resourceUri = resourceUri.replace(pathParam, value);
|
|
820
920
|
});
|
|
821
921
|
}
|
|
822
922
|
const urlOptions = {
|
|
823
923
|
path: resourceUri,
|
|
824
|
-
hash: hash,
|
|
924
|
+
hash: queryCondition.hash,
|
|
825
925
|
queryParams: params,
|
|
826
926
|
};
|
|
827
927
|
return buildUrl(this.baseUrl, urlOptions);
|
|
@@ -849,10 +949,10 @@ let BaseEntityService = class BaseEntityService {
|
|
|
849
949
|
}
|
|
850
950
|
}
|
|
851
951
|
};
|
|
852
|
-
|
|
952
|
+
BaseEntityRestService = __decorate([
|
|
853
953
|
__param(0, Inject('entityMapper')),
|
|
854
954
|
__metadata("design:paramtypes", [Object, String, String])
|
|
855
|
-
],
|
|
955
|
+
], BaseEntityRestService);
|
|
856
956
|
|
|
857
957
|
const INITIAL_TABS_STATE = {
|
|
858
958
|
activeTabs: [],
|
|
@@ -882,6 +982,93 @@ function BaseEntityTabsStore() {
|
|
|
882
982
|
}));
|
|
883
983
|
}
|
|
884
984
|
|
|
985
|
+
const BASE_ENTITY_SERVICE = new InjectionToken('BASE_ENTITY_SERVICE');
|
|
986
|
+
|
|
987
|
+
const addEntity = (store, repository) => {
|
|
988
|
+
return rxMethod(pipe(switchMap((entity) => {
|
|
989
|
+
patchState(store, { isLoading: true, error: undefined });
|
|
990
|
+
return repository.add(entity).pipe(tapResponse({
|
|
991
|
+
next: (savedEntity) => {
|
|
992
|
+
patchState(store, { entities: store.entities().concat([savedEntity]), isLoading: false });
|
|
993
|
+
},
|
|
994
|
+
error: (error) => patchState(store, { error: error.message }),
|
|
995
|
+
finalize: () => patchState(store, { isLoading: false }),
|
|
996
|
+
}));
|
|
997
|
+
})));
|
|
998
|
+
};
|
|
999
|
+
|
|
1000
|
+
const deleteEntity = (store, repository) => {
|
|
1001
|
+
return rxMethod(pipe(tap(() => patchState(store, { isLoading: true, error: undefined })), switchMap((id) => {
|
|
1002
|
+
return repository.delete(id).pipe(tapResponse({
|
|
1003
|
+
next: () => {
|
|
1004
|
+
const remainingEntities = store.entities().filter((entity) => entity.id !== id);
|
|
1005
|
+
patchState(store, { entities: remainingEntities, isLoading: false });
|
|
1006
|
+
},
|
|
1007
|
+
error: (error) => patchState(store, { error: error.message }),
|
|
1008
|
+
finalize: () => patchState(store, { isLoading: false }),
|
|
1009
|
+
}));
|
|
1010
|
+
})));
|
|
1011
|
+
};
|
|
1012
|
+
|
|
1013
|
+
const deleteAllEntities = (store, repository) => {
|
|
1014
|
+
return rxMethod(pipe(switchMap(() => {
|
|
1015
|
+
patchState(store, { isLoading: true, error: undefined });
|
|
1016
|
+
return repository.deleteAll().pipe(tapResponse({
|
|
1017
|
+
next: () => patchState(store, { entities: [], isLoading: false }),
|
|
1018
|
+
error: (error) => patchState(store, { error: error.message }),
|
|
1019
|
+
finalize: () => patchState(store, { isLoading: false }),
|
|
1020
|
+
}));
|
|
1021
|
+
})));
|
|
1022
|
+
};
|
|
1023
|
+
|
|
1024
|
+
const updateEntity = (store, repository) => {
|
|
1025
|
+
return rxMethod(pipe(switchMap((entity) => {
|
|
1026
|
+
patchState(store, { isLoading: true, error: undefined });
|
|
1027
|
+
return repository.update(entity).pipe(tapResponse({
|
|
1028
|
+
next: (updatedEntity) => {
|
|
1029
|
+
const currentEntities = store.entities();
|
|
1030
|
+
const indexToUpdate = currentEntities.findIndex((item) => item.id === entity.id);
|
|
1031
|
+
currentEntities[indexToUpdate] = updatedEntity;
|
|
1032
|
+
patchState(store, { entities: [...currentEntities], isLoading: false });
|
|
1033
|
+
},
|
|
1034
|
+
error: (error) => patchState(store, { error: error.message }),
|
|
1035
|
+
finalize: () => patchState(store, { isLoading: false }),
|
|
1036
|
+
}));
|
|
1037
|
+
})));
|
|
1038
|
+
};
|
|
1039
|
+
|
|
1040
|
+
const findByQuery = (store, repository) => {
|
|
1041
|
+
return rxMethod(pipe(tap((query) => patchState(store, { page: query.page, isLoading: true, error: undefined })),
|
|
1042
|
+
// debounceTime(1000),
|
|
1043
|
+
// distinctUntilChanged(),
|
|
1044
|
+
switchMap((parameters) => repository.findByQuery(parameters).pipe(tapResponse({
|
|
1045
|
+
next: (response) => {
|
|
1046
|
+
if (Object.prototype.hasOwnProperty.call(response, 'content')) {
|
|
1047
|
+
const baseEntityResponse = response;
|
|
1048
|
+
patchState(store, {
|
|
1049
|
+
entities: baseEntityResponse.content,
|
|
1050
|
+
page: baseEntityResponse.page,
|
|
1051
|
+
pageSize: baseEntityResponse.pageSize,
|
|
1052
|
+
totalPageCount: baseEntityResponse.totalPageCount,
|
|
1053
|
+
isLoading: false,
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1056
|
+
else {
|
|
1057
|
+
const entities = response.slice();
|
|
1058
|
+
patchState(store, {
|
|
1059
|
+
entities,
|
|
1060
|
+
page: undefined,
|
|
1061
|
+
pageSize: entities.length,
|
|
1062
|
+
totalPageCount: undefined,
|
|
1063
|
+
isLoading: false,
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
},
|
|
1067
|
+
error: (error) => patchState(store, { error: error.message }),
|
|
1068
|
+
finalize: () => patchState(store, { isLoading: false }),
|
|
1069
|
+
})))));
|
|
1070
|
+
};
|
|
1071
|
+
|
|
885
1072
|
const BASE_ENTITY_STORE = new InjectionToken('BASE_ENTITY_STORE');
|
|
886
1073
|
function BaseEntityStore(entityType, repositoryType) {
|
|
887
1074
|
return signalStoreFeature(withState({
|
|
@@ -896,27 +1083,10 @@ function BaseEntityStore(entityType, repositoryType) {
|
|
|
896
1083
|
selectedEntities: [],
|
|
897
1084
|
}), withMethods((store, repository = inject(repositoryType)) => ({
|
|
898
1085
|
clearCurrentEntity: () => patchState(store, { currentEntity: undefined }),
|
|
899
|
-
createEntity: () =>
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
return repository.delete(id).pipe(tapResponse({
|
|
904
|
-
next: () => {
|
|
905
|
-
const remainingEntities = store.entities().filter((entity) => entity.id !== id);
|
|
906
|
-
patchState(store, { entities: remainingEntities, isLoading: false });
|
|
907
|
-
},
|
|
908
|
-
error: (error) => patchState(store, { error: error.message }),
|
|
909
|
-
finalize: () => patchState(store, { isLoading: false }),
|
|
910
|
-
}));
|
|
911
|
-
}))),
|
|
912
|
-
deleteAll: rxMethod(pipe(switchMap(() => {
|
|
913
|
-
patchState(store, { isLoading: true, error: undefined });
|
|
914
|
-
return repository.deleteAll().pipe(tapResponse({
|
|
915
|
-
next: () => patchState(store, { entities: [], isLoading: false }),
|
|
916
|
-
error: (error) => patchState(store, { error: error.message }),
|
|
917
|
-
finalize: () => patchState(store, { isLoading: false }),
|
|
918
|
-
}));
|
|
919
|
-
}))),
|
|
1086
|
+
createEntity: () => new entityType(),
|
|
1087
|
+
add: addEntity(store, repository),
|
|
1088
|
+
delete: deleteEntity(store, repository),
|
|
1089
|
+
deleteAll: deleteAllEntities(store, repository),
|
|
920
1090
|
deselectAll: () => {
|
|
921
1091
|
patchState(store, { selectedEntities: [] });
|
|
922
1092
|
},
|
|
@@ -931,49 +1101,11 @@ function BaseEntityStore(entityType, repositoryType) {
|
|
|
931
1101
|
}
|
|
932
1102
|
}
|
|
933
1103
|
},
|
|
934
|
-
load:
|
|
935
|
-
// debounceTime(1000),
|
|
936
|
-
// distinctUntilChanged(),
|
|
937
|
-
switchMap((parameters) => repository.findAll(parameters.path, parameters.filter, parameters.page).pipe(tapResponse({
|
|
938
|
-
next: (response) => {
|
|
939
|
-
if (Object.prototype.hasOwnProperty.call(response, 'content')) {
|
|
940
|
-
const baseEntityResponse = response;
|
|
941
|
-
patchState(store, {
|
|
942
|
-
entities: baseEntityResponse.content,
|
|
943
|
-
page: baseEntityResponse.page,
|
|
944
|
-
pageSize: baseEntityResponse.pageSize,
|
|
945
|
-
totalPageCount: baseEntityResponse.totalPageCount,
|
|
946
|
-
isLoading: false,
|
|
947
|
-
});
|
|
948
|
-
}
|
|
949
|
-
else {
|
|
950
|
-
const entities = response.slice();
|
|
951
|
-
patchState(store, {
|
|
952
|
-
entities,
|
|
953
|
-
page: undefined,
|
|
954
|
-
pageSize: entities.length,
|
|
955
|
-
totalPageCount: undefined,
|
|
956
|
-
isLoading: false,
|
|
957
|
-
});
|
|
958
|
-
}
|
|
959
|
-
},
|
|
960
|
-
error: (error) => patchState(store, { error: error.message }),
|
|
961
|
-
finalize: () => patchState(store, { isLoading: false }),
|
|
962
|
-
}))))),
|
|
1104
|
+
load: findByQuery(store, repository),
|
|
963
1105
|
loadById: (id) => {
|
|
964
1106
|
return store.entities().find((entity) => entity.id === id);
|
|
965
1107
|
},
|
|
966
1108
|
resetErrorState: () => patchState(store, { error: undefined }),
|
|
967
|
-
save: rxMethod(pipe(switchMap((entity) => {
|
|
968
|
-
patchState(store, { isLoading: true, error: undefined });
|
|
969
|
-
return repository.save(entity).pipe(tapResponse({
|
|
970
|
-
next: (savedEntity) => {
|
|
971
|
-
patchState(store, { entities: store.entities().concat([savedEntity]), isLoading: false });
|
|
972
|
-
},
|
|
973
|
-
error: (error) => patchState(store, { error: error.message }),
|
|
974
|
-
finalize: () => patchState(store, { isLoading: false }),
|
|
975
|
-
}));
|
|
976
|
-
}))),
|
|
977
1109
|
selectEntity: (id) => {
|
|
978
1110
|
const foundEntity = store.entities() && store.entities().length > 0 ? store.entities().filter((entity) => entity.id === id) : undefined;
|
|
979
1111
|
if (foundEntity && foundEntity.length == 1 && store.selectedEntities().indexOf(foundEntity[0]) == -1) {
|
|
@@ -988,24 +1120,10 @@ function BaseEntityStore(entityType, repositoryType) {
|
|
|
988
1120
|
else
|
|
989
1121
|
patchState(store, { currentEntity: undefined, currentId: undefined });
|
|
990
1122
|
},
|
|
991
|
-
update:
|
|
992
|
-
patchState(store, { isLoading: true, error: undefined });
|
|
993
|
-
return repository.update(entity).pipe(tapResponse({
|
|
994
|
-
next: (updatedEntity) => {
|
|
995
|
-
const currentEntities = store.entities();
|
|
996
|
-
const indexToUpdate = currentEntities.findIndex((item) => item.id === entity.id);
|
|
997
|
-
currentEntities[indexToUpdate] = updatedEntity;
|
|
998
|
-
patchState(store, { entities: [...currentEntities], isLoading: false });
|
|
999
|
-
},
|
|
1000
|
-
error: (error) => patchState(store, { error: error.message }),
|
|
1001
|
-
finalize: () => patchState(store, { isLoading: false }),
|
|
1002
|
-
}));
|
|
1003
|
-
}))),
|
|
1123
|
+
update: updateEntity(store, repository),
|
|
1004
1124
|
})), withHooks((store) => ({
|
|
1005
1125
|
onInit: () => {
|
|
1006
|
-
|
|
1007
|
-
const filter = new Map([]);
|
|
1008
|
-
store.load({ path, filter });
|
|
1126
|
+
store.load({});
|
|
1009
1127
|
},
|
|
1010
1128
|
})), withComputed((store) => ({
|
|
1011
1129
|
countOfEntities: computed(() => store.entities().length),
|
|
@@ -1013,13 +1131,197 @@ function BaseEntityStore(entityType, repositoryType) {
|
|
|
1013
1131
|
})));
|
|
1014
1132
|
}
|
|
1015
1133
|
|
|
1016
|
-
|
|
1017
|
-
|
|
1134
|
+
let BaseEntityFirestoreService = class BaseEntityFirestoreService {
|
|
1135
|
+
entityMapper;
|
|
1136
|
+
collectionName;
|
|
1137
|
+
collection;
|
|
1138
|
+
firestore = inject(Firestore);
|
|
1139
|
+
constructor(entityMapper, collectionName) {
|
|
1140
|
+
this.entityMapper = entityMapper;
|
|
1141
|
+
this.collectionName = collectionName;
|
|
1142
|
+
this.collection = collection(this.firestore, collectionName);
|
|
1143
|
+
}
|
|
1144
|
+
// region public accessors and mutators
|
|
1145
|
+
add(entity) {
|
|
1146
|
+
if (!entity)
|
|
1147
|
+
throw new Error('Entity cant be undefined');
|
|
1148
|
+
return from(this.addAsync(entity));
|
|
1149
|
+
}
|
|
1150
|
+
delete(id) {
|
|
1151
|
+
const docRef = doc(this.firestore, this.collectionName, id);
|
|
1152
|
+
return from(deleteDoc(docRef));
|
|
1153
|
+
}
|
|
1154
|
+
deleteAll() {
|
|
1155
|
+
return of(undefined);
|
|
1156
|
+
}
|
|
1157
|
+
findAll(page, pageSize) {
|
|
1158
|
+
return this.findByQuery({ page, pageSize });
|
|
1159
|
+
}
|
|
1160
|
+
findById(id) {
|
|
1161
|
+
const docRef = doc(this.firestore, this.collectionName, id);
|
|
1162
|
+
return from(getDoc(docRef)
|
|
1163
|
+
.then((document) => {
|
|
1164
|
+
return this.mapDocument(document.data());
|
|
1165
|
+
})
|
|
1166
|
+
.catch((error) => {
|
|
1167
|
+
throw new Error(`Error: ${error} occurred while finding document by id: ${id}`);
|
|
1168
|
+
}));
|
|
1169
|
+
}
|
|
1170
|
+
findByQuery(queryCondition) {
|
|
1171
|
+
return from(this.findByQueryAsync(queryCondition));
|
|
1172
|
+
}
|
|
1173
|
+
update(entity) {
|
|
1174
|
+
return from(this.updateAsync(entity));
|
|
1175
|
+
}
|
|
1176
|
+
// endregion
|
|
1177
|
+
// protected, private helper methods
|
|
1178
|
+
async addAsync(entity) {
|
|
1179
|
+
const newDoc = doc(this.collection, entity.id);
|
|
1180
|
+
await setDoc(newDoc, this.mapEntity(entity));
|
|
1181
|
+
return new Promise((resolve, reject) => {
|
|
1182
|
+
resolve(entity);
|
|
1183
|
+
reject(new Error('Failed to update entity: ' + entity));
|
|
1184
|
+
});
|
|
1185
|
+
}
|
|
1186
|
+
createQuery(queryCondition) {
|
|
1187
|
+
let orderBys = [];
|
|
1188
|
+
if (queryCondition.orderBys && queryCondition.orderBys?.length > 0) {
|
|
1189
|
+
orderBys = queryCondition.orderBys?.map((orderByCondition) => {
|
|
1190
|
+
const name = Object.keys(OrderByDirection).filter((key) => key === orderByCondition.direction);
|
|
1191
|
+
const direction = Object.values(OrderByDirection).filter((value) => value === name[0]);
|
|
1192
|
+
return orderBy(orderByCondition.property, direction[0]);
|
|
1193
|
+
});
|
|
1194
|
+
}
|
|
1195
|
+
let wheres = [];
|
|
1196
|
+
if (queryCondition.filters && queryCondition.filters?.length > 0) {
|
|
1197
|
+
wheres =
|
|
1198
|
+
queryCondition.filters?.map((filter) => {
|
|
1199
|
+
return where(filter.property, filter.operator, filter.value);
|
|
1200
|
+
}) ?? [];
|
|
1201
|
+
}
|
|
1202
|
+
return query(this.collection, ...wheres, ...orderBys, limit(queryCondition.pageSize ?? 99));
|
|
1203
|
+
}
|
|
1204
|
+
async findByQueryAsync(queryCondition) {
|
|
1205
|
+
const query = this.createQuery(queryCondition);
|
|
1206
|
+
const results = await getDocs(query);
|
|
1207
|
+
const content = [];
|
|
1208
|
+
results.docs.forEach((doc) => {
|
|
1209
|
+
content.push(this.mapDocument({ id: doc.id, ...doc.data() }));
|
|
1210
|
+
});
|
|
1211
|
+
return Promise.resolve({
|
|
1212
|
+
page: queryCondition.page,
|
|
1213
|
+
pageSize: queryCondition.pageSize,
|
|
1214
|
+
totalPageCount: 1,
|
|
1215
|
+
content,
|
|
1216
|
+
});
|
|
1217
|
+
}
|
|
1218
|
+
mapCollection(collection) {
|
|
1219
|
+
const entities = [];
|
|
1220
|
+
collection.pipe(map((documents) => {
|
|
1221
|
+
documents.forEach((document) => entities.push(this.entityMapper.fromDto(document)));
|
|
1222
|
+
}));
|
|
1223
|
+
return entities;
|
|
1224
|
+
}
|
|
1225
|
+
mapDocument(document) {
|
|
1226
|
+
return this.entityMapper.fromDto(document);
|
|
1227
|
+
}
|
|
1228
|
+
mapEntity(entity) {
|
|
1229
|
+
return this.entityMapper.toDto(entity);
|
|
1230
|
+
}
|
|
1231
|
+
async updateAsync(entity) {
|
|
1232
|
+
if (!entity)
|
|
1233
|
+
throw new Error('Entity cant be undefined');
|
|
1234
|
+
const docRef = doc(this.firestore, this.collectionName, entity.id);
|
|
1235
|
+
await updateDoc(docRef, this.mapEntity(entity));
|
|
1236
|
+
return Promise.resolve(entity);
|
|
1237
|
+
}
|
|
1238
|
+
};
|
|
1239
|
+
BaseEntityFirestoreService = __decorate([
|
|
1240
|
+
__param(0, Inject('entityMapper')),
|
|
1241
|
+
__metadata("design:paramtypes", [Object, String])
|
|
1242
|
+
], BaseEntityFirestoreService);
|
|
1243
|
+
|
|
1244
|
+
// Symbol to store entity options on instance
|
|
1245
|
+
const ENTITY_OPTIONS_KEY = Symbol('entityOptions');
|
|
1246
|
+
// Metadata key for storing ID properties
|
|
1247
|
+
const ENTITY_ID_PROPERTIES_KEY = 'entity:idProperties';
|
|
1248
|
+
/**
|
|
1249
|
+
* Class decorator for entity classes
|
|
1250
|
+
* @param options Configuration options for the entity
|
|
1251
|
+
* @returns Class decorator function
|
|
1252
|
+
*/
|
|
1253
|
+
function Entity(options) {
|
|
1254
|
+
return function (target) {
|
|
1255
|
+
// Store metadata on the class (for backward compatibility)
|
|
1256
|
+
Reflect.defineMetadata('entity:options', options, target);
|
|
1257
|
+
// Add a property to the prototype to make options accessible from instances
|
|
1258
|
+
Object.defineProperty(target.prototype, ENTITY_OPTIONS_KEY, {
|
|
1259
|
+
value: options,
|
|
1260
|
+
writable: false,
|
|
1261
|
+
enumerable: false,
|
|
1262
|
+
configurable: false
|
|
1263
|
+
});
|
|
1264
|
+
return target;
|
|
1265
|
+
};
|
|
1266
|
+
}
|
|
1267
|
+
/**
|
|
1268
|
+
* Gets entity options from an entity instance
|
|
1269
|
+
* @param instance An instance of a class decorated with @Entity
|
|
1270
|
+
* @returns The entity options or undefined if not found
|
|
1018
1271
|
*/
|
|
1272
|
+
function getEntityOptions(instance) {
|
|
1273
|
+
if (!instance)
|
|
1274
|
+
return undefined;
|
|
1275
|
+
// Try to get options from the instance
|
|
1276
|
+
const options = instance[ENTITY_OPTIONS_KEY];
|
|
1277
|
+
if (options)
|
|
1278
|
+
return options;
|
|
1279
|
+
// Fallback to class metadata (for backward compatibility)
|
|
1280
|
+
const constructor = Object.getPrototypeOf(instance)?.constructor;
|
|
1281
|
+
if (constructor) {
|
|
1282
|
+
return Reflect.getMetadata('entity:options', constructor);
|
|
1283
|
+
}
|
|
1284
|
+
return undefined;
|
|
1285
|
+
}
|
|
1286
|
+
/**
|
|
1287
|
+
* Property decorator for marking entity properties as ID fields
|
|
1288
|
+
* @returns PropertyDecorator function
|
|
1289
|
+
*/
|
|
1290
|
+
function Id() {
|
|
1291
|
+
return function (target, propertyKey) {
|
|
1292
|
+
// Get the constructor of the class
|
|
1293
|
+
const constructor = target.constructor;
|
|
1294
|
+
// Get existing ID properties or initialize empty array
|
|
1295
|
+
const existingIdProps = Reflect.getMetadata(ENTITY_ID_PROPERTIES_KEY, constructor) || [];
|
|
1296
|
+
// Add the current property to the list if it's not already there
|
|
1297
|
+
if (!existingIdProps.includes(propertyKey.toString())) {
|
|
1298
|
+
existingIdProps.push(propertyKey.toString());
|
|
1299
|
+
}
|
|
1300
|
+
// Update the metadata with the new list
|
|
1301
|
+
Reflect.defineMetadata(ENTITY_ID_PROPERTIES_KEY, existingIdProps, constructor);
|
|
1302
|
+
};
|
|
1303
|
+
}
|
|
1304
|
+
/**
|
|
1305
|
+
* Gets all property names marked with @Id decorator from an entity instance
|
|
1306
|
+
* @param instance An instance of a class with properties decorated with @Id
|
|
1307
|
+
* @returns Array of property names marked as IDs or empty array if none found
|
|
1308
|
+
*/
|
|
1309
|
+
function getEntityIds(instance) {
|
|
1310
|
+
if (!instance)
|
|
1311
|
+
return [];
|
|
1312
|
+
// Get the constructor from the instance
|
|
1313
|
+
const constructor = Object.getPrototypeOf(instance)?.constructor;
|
|
1314
|
+
if (!constructor)
|
|
1315
|
+
return [];
|
|
1316
|
+
// Return the ID properties from metadata or empty array if none found
|
|
1317
|
+
return Reflect.getMetadata(ENTITY_ID_PROPERTIES_KEY, constructor) || [];
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
// Public API Surface of @processpuzzle/base-entity
|
|
1019
1321
|
|
|
1020
1322
|
/**
|
|
1021
1323
|
* Generated bundle index. Do not edit.
|
|
1022
1324
|
*/
|
|
1023
1325
|
|
|
1024
|
-
export { BASE_ENTITY_ROUTES, BASE_ENTITY_SERVICE, BASE_ENTITY_STORE, BASE_LIST_DESCRIPTORS, BaseEntityAttrDescriptor, BaseEntityContainerComponent, BaseEntityContainerStore, BaseEntityFormComponent, BaseEntityListComponent,
|
|
1326
|
+
export { AbstractAttrDescriptor, BASE_ENTITY_ROUTES, BASE_ENTITY_SERVICE, BASE_ENTITY_STORE, BASE_LIST_DESCRIPTORS, BaseEntityAttrDescriptor, BaseEntityContainerComponent, BaseEntityContainerStore, BaseEntityFirestoreService, BaseEntityFormComponent, BaseEntityListComponent, BaseEntityRestService, BaseEntityStore, BaseEntityTabsStore, BaseFormHostDirective, BaseFormNavigatorStore, Entity, FlexDirection, FlexboxDescriptor, FormControlType, Id, OrderByDirection, RouteSegments, getEntityIds, getEntityOptions };
|
|
1025
1327
|
//# sourceMappingURL=processpuzzle-base-entity.mjs.map
|