ngx-material-entity 0.1.0 → 0.1.3
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/CONTRIBUTING.md +7 -1
- package/README.md +3 -2
- package/classes/base-builder.class.d.ts +35 -0
- package/classes/entity-model.class.d.ts +1 -1
- package/classes/entity-service.class.d.ts +27 -17
- package/classes/entity-utilities.class.d.ts +96 -46
- package/components/confirm-dialog/confirm-dialog-data.builder.d.ts +23 -0
- package/components/confirm-dialog/confirm-dialog-data.d.ts +18 -8
- package/components/confirm-dialog/confirm-dialog.component.d.ts +15 -5
- package/components/get-validation-error-message.function.d.ts +3 -2
- package/components/input/add-array-item-dialog-data.builder.d.ts +21 -0
- package/components/input/add-array-item-dialog-data.d.ts +20 -0
- package/components/input/input.component.d.ts +116 -26
- package/components/input/input.module.d.ts +6 -4
- package/components/table/create-dialog/create-dialog-data.builder.d.ts +21 -0
- package/components/table/create-dialog/create-entity-dialog-data.builder.d.ts +22 -0
- package/components/table/create-dialog/create-entity-dialog-data.d.ts +2 -2
- package/components/table/create-dialog/create-entity-dialog.component.d.ts +19 -5
- package/components/table/edit-dialog/edit-dialog-data.builder.d.ts +25 -0
- package/components/table/edit-dialog/edit-entity-dialog-data.d.ts +5 -5
- package/components/table/edit-dialog/edit-entity-dialog.builder.d.ts +23 -0
- package/components/table/edit-dialog/edit-entity-dialog.component.d.ts +23 -5
- package/components/table/table-data.builder.d.ts +51 -0
- package/components/table/table-data.d.ts +40 -24
- package/components/table/table.component.d.ts +52 -5
- package/components/table/table.module.d.ts +3 -1
- package/decorators/array/array-decorator-internal.data.d.ts +45 -0
- package/decorators/array/array-decorator.data.d.ts +129 -0
- package/decorators/array/array.decorator.d.ts +10 -0
- package/decorators/base/base-property.decorator.d.ts +7 -6
- package/decorators/base/decorator-types.enum.d.ts +7 -7
- package/decorators/base/property-decorator-internal.data.d.ts +24 -0
- package/decorators/base/property-decorator.data.d.ts +70 -0
- package/decorators/boolean/boolean-decorator-internal.data.d.ts +25 -0
- package/decorators/boolean/boolean-decorator.data.d.ts +37 -0
- package/decorators/boolean/boolean.decorator.d.ts +8 -0
- package/decorators/number/number-decorator-internal.data.d.ts +22 -0
- package/decorators/number/number-decorator.data.d.ts +38 -0
- package/decorators/number/number.decorator.d.ts +8 -0
- package/decorators/object/object-decorator-internal.data.d.ts +11 -0
- package/decorators/object/object-decorator.data.d.ts +25 -0
- package/decorators/object/object.decorator.d.ts +9 -0
- package/decorators/string/string-decorator-internal.data.d.ts +43 -0
- package/decorators/string/string-decorator.data.d.ts +79 -0
- package/decorators/string/string.decorator.d.ts +8 -0
- package/esm2020/classes/base-builder.class.mjs +43 -0
- package/esm2020/classes/entity-model.class.mjs +2 -2
- package/esm2020/classes/entity-service.class.mjs +20 -14
- package/esm2020/classes/entity-utilities.class.mjs +182 -101
- package/esm2020/components/confirm-dialog/confirm-dialog-data.builder.mjs +44 -0
- package/esm2020/components/confirm-dialog/confirm-dialog-data.mjs +1 -1
- package/esm2020/components/confirm-dialog/confirm-dialog.component.mjs +18 -22
- package/esm2020/components/get-validation-error-message.function.mjs +8 -3
- package/esm2020/components/input/add-array-item-dialog-data.builder.mjs +30 -0
- package/esm2020/components/input/add-array-item-dialog-data.mjs +2 -0
- package/esm2020/components/input/input.component.mjs +168 -32
- package/esm2020/components/input/input.module.mjs +19 -9
- package/esm2020/components/table/create-dialog/create-dialog-data.builder.mjs +32 -0
- package/esm2020/components/table/create-dialog/create-entity-dialog-data.builder.mjs +26 -0
- package/esm2020/components/table/create-dialog/create-entity-dialog-data.mjs +1 -1
- package/esm2020/components/table/create-dialog/create-entity-dialog.component.mjs +30 -30
- package/esm2020/components/table/create-dialog/create-entity-dialog.module.mjs +20 -4
- package/esm2020/components/table/edit-dialog/edit-dialog-data.builder.mjs +41 -0
- package/esm2020/components/table/edit-dialog/edit-entity-dialog-data.mjs +1 -1
- package/esm2020/components/table/edit-dialog/edit-entity-dialog.builder.mjs +27 -0
- package/esm2020/components/table/edit-dialog/edit-entity-dialog.component.mjs +43 -47
- package/esm2020/components/table/table-data.builder.mjs +105 -0
- package/esm2020/components/table/table-data.mjs +1 -1
- package/esm2020/components/table/table.component.mjs +90 -82
- package/esm2020/components/table/table.module.mjs +12 -4
- package/esm2020/decorators/array/array-decorator-internal.data.mjs +51 -0
- package/esm2020/decorators/array/array-decorator.data.mjs +7 -0
- package/esm2020/decorators/array/array.decorator.mjs +24 -0
- package/esm2020/decorators/base/base-property.decorator.mjs +6 -5
- package/esm2020/decorators/base/decorator-types.enum.mjs +1 -1
- package/esm2020/decorators/base/property-decorator-internal.data.mjs +38 -0
- package/esm2020/decorators/base/property-decorator.data.mjs +6 -0
- package/esm2020/decorators/boolean/boolean-decorator-internal.data.mjs +33 -0
- package/esm2020/decorators/boolean/boolean-decorator.data.mjs +7 -0
- package/esm2020/decorators/boolean/boolean.decorator.mjs +21 -0
- package/esm2020/decorators/number/number-decorator-internal.data.mjs +23 -0
- package/esm2020/decorators/number/number-decorator.data.mjs +7 -0
- package/esm2020/decorators/number/number.decorator.mjs +18 -0
- package/esm2020/decorators/object/object-decorator-internal.data.mjs +12 -0
- package/esm2020/decorators/object/object-decorator.data.mjs +7 -0
- package/esm2020/decorators/object/object.decorator.mjs +13 -0
- package/esm2020/decorators/string/string-decorator-internal.data.mjs +48 -0
- package/esm2020/decorators/string/string-decorator.data.mjs +7 -0
- package/esm2020/decorators/string/string.decorator.mjs +24 -0
- package/esm2020/public-api.mjs +15 -10
- package/fesm2015/ngx-material-entity.mjs +1221 -880
- package/fesm2015/ngx-material-entity.mjs.map +1 -1
- package/fesm2020/ngx-material-entity.mjs +1225 -877
- package/fesm2020/ngx-material-entity.mjs.map +1 -1
- package/package.json +2 -1
- package/public-api.d.ts +15 -7
- package/components/input/array-table/add-array-item-dialog/add-array-item-dialog.component.d.ts +0 -35
- package/components/input/array-table/add-array-item-dialog/add-array-item-dialog.module.d.ts +0 -12
- package/components/input/array-table/array-table.component.d.ts +0 -34
- package/components/input/array-table/array-table.module.d.ts +0 -19
- package/components/input/internal-input/internal-input.component.d.ts +0 -57
- package/components/input/internal-input/internal-input.module.d.ts +0 -16
- package/decorators/array.decorator.d.ts +0 -125
- package/decorators/base/property-decorator-config.interface.d.ts +0 -50
- package/decorators/boolean.decorator.d.ts +0 -42
- package/decorators/number.decorator.d.ts +0 -40
- package/decorators/object.decorator.d.ts +0 -27
- package/decorators/string.decorator.d.ts +0 -76
- package/esm2020/components/input/array-table/add-array-item-dialog/add-array-item-dialog.component.mjs +0 -43
- package/esm2020/components/input/array-table/add-array-item-dialog/add-array-item-dialog.module.mjs +0 -22
- package/esm2020/components/input/array-table/array-table.component.mjs +0 -116
- package/esm2020/components/input/array-table/array-table.module.mjs +0 -66
- package/esm2020/components/input/internal-input/internal-input.component.mjs +0 -73
- package/esm2020/components/input/internal-input/internal-input.module.mjs +0 -54
- package/esm2020/decorators/array.decorator.mjs +0 -70
- package/esm2020/decorators/base/property-decorator-config.interface.mjs +0 -31
- package/esm2020/decorators/boolean.decorator.mjs +0 -44
- package/esm2020/decorators/number.decorator.mjs +0 -36
- package/esm2020/decorators/object.decorator.mjs +0 -23
- package/esm2020/decorators/string.decorator.mjs +0 -61
|
@@ -11,64 +11,69 @@ export interface DisplayColumn<EntityType extends Entity> {
|
|
|
11
11
|
*/
|
|
12
12
|
displayName: string;
|
|
13
13
|
/**
|
|
14
|
-
* A method to get the value inside an row
|
|
14
|
+
* A method to get the value inside an row.
|
|
15
15
|
*/
|
|
16
16
|
value: (entity: EntityType) => string;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* The Definition of an Action that can be run on multiple selected entities
|
|
19
|
+
* The Definition of an Action that can be run on multiple selected entities.
|
|
20
20
|
*/
|
|
21
21
|
export interface MultiSelectAction<EntityType extends Entity> {
|
|
22
22
|
/**
|
|
23
|
-
* The name of the action
|
|
23
|
+
* The name of the action.
|
|
24
24
|
*/
|
|
25
25
|
displayName: string;
|
|
26
26
|
/**
|
|
27
|
-
* The action itself
|
|
27
|
+
* The action itself.
|
|
28
28
|
*/
|
|
29
29
|
action: (selectedEntities: EntityType[]) => unknown;
|
|
30
30
|
/**
|
|
31
31
|
* A method that defines whether or not the action can be used.
|
|
32
|
+
*
|
|
32
33
|
* @default true
|
|
33
34
|
*/
|
|
34
35
|
enabled?: (selectedEntities: EntityType[]) => boolean;
|
|
35
36
|
/**
|
|
36
|
-
* A method that defines whether or not a confirm dialog is needed to run the action
|
|
37
|
+
* A method that defines whether or not a confirm dialog is needed to run the action.
|
|
38
|
+
*
|
|
37
39
|
* @default false
|
|
38
40
|
*/
|
|
39
41
|
requireConfirmDialog?: (selectedEntities: EntityType[]) => boolean;
|
|
40
42
|
/**
|
|
41
|
-
* The data used to generate a confirmation dialog for the
|
|
43
|
+
* The data used to generate a confirmation dialog for the multiSelect action.
|
|
42
44
|
*/
|
|
43
45
|
confirmDialogData?: ConfirmDialogData;
|
|
44
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* The base data of the ngx-mat-entity-table.
|
|
49
|
+
*/
|
|
45
50
|
export interface BaseData<EntityType extends Entity> {
|
|
46
51
|
/**
|
|
47
|
-
* The title of the table
|
|
52
|
+
* The title of the table.
|
|
48
53
|
*/
|
|
49
54
|
title: string;
|
|
50
55
|
/**
|
|
51
56
|
* The definition of the columns to display. Consists of the displayName to show in the header of the row
|
|
52
|
-
* and the value, which is a function that generates the value to display inside a column
|
|
57
|
+
* and the value, which is a function that generates the value to display inside a column.
|
|
53
58
|
*/
|
|
54
59
|
displayColumns: DisplayColumn<EntityType>[];
|
|
55
60
|
/**
|
|
56
|
-
* The
|
|
61
|
+
* The Class of the service that handles the entities.
|
|
62
|
+
* Needs to be injectable and an extension of the "EntityService"-Class.
|
|
57
63
|
*/
|
|
58
|
-
|
|
64
|
+
EntityServiceClass: new (httpClient: HttpClient) => EntityService<EntityType>;
|
|
59
65
|
/**
|
|
60
|
-
* The
|
|
66
|
+
* The Class of the entities to manage.
|
|
61
67
|
*/
|
|
62
|
-
|
|
68
|
+
EntityClass?: new (entity?: EntityType) => EntityType;
|
|
63
69
|
/**
|
|
64
|
-
* The
|
|
70
|
+
* The label on the search bar. Defaults to "Search".
|
|
65
71
|
*/
|
|
66
|
-
|
|
72
|
+
searchLabel?: string;
|
|
67
73
|
/**
|
|
68
|
-
* The
|
|
69
|
-
* Needs to be injectable and an extension of the "EntityService"-Class
|
|
74
|
+
* The label on the button for adding new entities. Defaults to "Create".
|
|
70
75
|
*/
|
|
71
|
-
|
|
76
|
+
createButtonLabel?: string;
|
|
72
77
|
/**
|
|
73
78
|
* Takes a custom edit method which runs when you click on a entity.
|
|
74
79
|
* If you don't need any special editing of entries you can also omit this.
|
|
@@ -84,24 +89,26 @@ export interface BaseData<EntityType extends Entity> {
|
|
|
84
89
|
/**
|
|
85
90
|
* Defines how the search string of entities is generated.
|
|
86
91
|
*/
|
|
87
|
-
searchString?: (
|
|
92
|
+
searchString?: (entity: EntityType) => string;
|
|
88
93
|
/**
|
|
89
94
|
* Defines whether or not the user can add new entities.
|
|
95
|
+
*
|
|
90
96
|
* @default true
|
|
91
97
|
*/
|
|
92
98
|
allowCreate?: boolean;
|
|
93
99
|
/**
|
|
94
100
|
* Defines whether or not the user can edit entities.
|
|
101
|
+
*
|
|
95
102
|
* @default () => true
|
|
96
103
|
*/
|
|
97
104
|
allowEdit?: (entity: EntityType) => boolean;
|
|
98
105
|
/**
|
|
99
|
-
* Whether or not the user can delete this specific entity
|
|
106
|
+
* Whether or not the user can delete this specific entity.
|
|
100
107
|
*/
|
|
101
108
|
allowDelete?: (entity: EntityType) => boolean;
|
|
102
109
|
/**
|
|
103
110
|
* All Actions that you want to run on multiple entities can be defined here.
|
|
104
|
-
* (e.g.
|
|
111
|
+
* (e.g. Download as zip-file or mass delete).
|
|
105
112
|
*/
|
|
106
113
|
multiSelectActions?: MultiSelectAction<EntityType>[];
|
|
107
114
|
/**
|
|
@@ -109,11 +116,14 @@ export interface BaseData<EntityType extends Entity> {
|
|
|
109
116
|
*/
|
|
110
117
|
multiSelectLabel?: string;
|
|
111
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* The data of the default create-dialog.
|
|
121
|
+
*/
|
|
112
122
|
export interface CreateDialogData {
|
|
113
123
|
/**
|
|
114
124
|
* The title of the default create-dialog.
|
|
115
125
|
*/
|
|
116
|
-
title
|
|
126
|
+
title?: string;
|
|
117
127
|
/**
|
|
118
128
|
* The label on the create-button of the default create-dialog. Defaults to "Create".
|
|
119
129
|
*/
|
|
@@ -131,11 +141,14 @@ export interface CreateDialogData {
|
|
|
131
141
|
*/
|
|
132
142
|
confirmCreateDialogData?: ConfirmDialogData;
|
|
133
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* The data of the default edit-dialog.
|
|
146
|
+
*/
|
|
134
147
|
export interface EditDialogData<EntityType extends Entity> {
|
|
135
148
|
/**
|
|
136
149
|
* The title of the default edit-dialog.
|
|
137
150
|
*/
|
|
138
|
-
title
|
|
151
|
+
title?: (entity: EntityType) => string;
|
|
139
152
|
/**
|
|
140
153
|
* The label on the confirm-button of the default edit-dialog. Defaults to "Save".
|
|
141
154
|
*/
|
|
@@ -165,9 +178,12 @@ export interface EditDialogData<EntityType extends Entity> {
|
|
|
165
178
|
*/
|
|
166
179
|
confirmEditDialogData?: ConfirmDialogData;
|
|
167
180
|
}
|
|
168
|
-
|
|
181
|
+
/**
|
|
182
|
+
* All the configuration data required to display a ngx-mat-entity-table.
|
|
183
|
+
*/
|
|
184
|
+
export interface TableData<EntityType extends Entity> {
|
|
169
185
|
/**
|
|
170
|
-
* The base data for the
|
|
186
|
+
* The base data for the table-component.
|
|
171
187
|
* Includes stuff like the title for the table, what to display inside the rows etc.
|
|
172
188
|
*/
|
|
173
189
|
baseData: BaseData<EntityType>;
|
|
@@ -5,15 +5,23 @@ import { MatTableDataSource } from '@angular/material/table';
|
|
|
5
5
|
import { Entity } from '../../classes/entity-model.class';
|
|
6
6
|
import { SelectionModel } from '@angular/cdk/collections';
|
|
7
7
|
import { MatDialog } from '@angular/material/dialog';
|
|
8
|
-
import { MultiSelectAction,
|
|
8
|
+
import { MultiSelectAction, TableData } from './table-data';
|
|
9
|
+
import { TableDataInternal } from './table-data.builder';
|
|
9
10
|
import * as i0 from "@angular/core";
|
|
11
|
+
/**
|
|
12
|
+
* Generates a fully functional table for displaying, creating, updating and deleting entities
|
|
13
|
+
* based on the configuration passed in the @Input "tableData".
|
|
14
|
+
*
|
|
15
|
+
* It offers a lot of customization options which can be found in "TableData".
|
|
16
|
+
*/
|
|
10
17
|
export declare class NgxMatEntityTableComponent<EntityType extends Entity> implements OnInit, OnDestroy {
|
|
11
18
|
private readonly dialog;
|
|
12
19
|
private readonly injector;
|
|
13
20
|
/**
|
|
14
|
-
* The configuration for the
|
|
21
|
+
* The configuration for the component.
|
|
15
22
|
*/
|
|
16
|
-
|
|
23
|
+
tableData: TableData<EntityType>;
|
|
24
|
+
data: TableDataInternal<EntityType>;
|
|
17
25
|
private entityService;
|
|
18
26
|
private readonly onDestroy;
|
|
19
27
|
paginator: MatPaginator;
|
|
@@ -23,19 +31,58 @@ export declare class NgxMatEntityTableComponent<EntityType extends Entity> imple
|
|
|
23
31
|
dataSource: MatTableDataSource<EntityType>;
|
|
24
32
|
selection: SelectionModel<EntityType>;
|
|
25
33
|
constructor(dialog: MatDialog, injector: Injector);
|
|
34
|
+
/**
|
|
35
|
+
* Sets up all the configuration for the table and the EntityService.
|
|
36
|
+
*/
|
|
26
37
|
ngOnInit(): void;
|
|
27
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Edits an entity. This either calls the edit-Method provided by the user or uses a default edit-dialog.
|
|
40
|
+
*
|
|
41
|
+
* @param entity - The entity that should be updated.
|
|
42
|
+
* @throws When no EntityClass was provided, as a new call is needed to initialize metadata.
|
|
43
|
+
*/
|
|
28
44
|
editEntity(entity: EntityType): void;
|
|
29
45
|
private editDefault;
|
|
46
|
+
/**
|
|
47
|
+
* Creates a new Entity. This either calls the create-Method provided by the user or uses a default create-dialog.
|
|
48
|
+
*
|
|
49
|
+
* @throws When no EntityClass was provided, as a new call is needed to initialize metadata.
|
|
50
|
+
*/
|
|
30
51
|
createEntity(): void;
|
|
31
52
|
private createDefault;
|
|
53
|
+
/**
|
|
54
|
+
* Runs the MultiAction for all selected entries.
|
|
55
|
+
* Also handles confirmation with an additional dialog if configured.
|
|
56
|
+
*
|
|
57
|
+
* @param action - The MultiAction to run.
|
|
58
|
+
*/
|
|
32
59
|
runMultiAction(action: MultiSelectAction<EntityType>): void;
|
|
33
60
|
private confirmRunMultiAction;
|
|
61
|
+
/**
|
|
62
|
+
* Checks if an MultiAction is disabled (e.g. Because no entries have been selected).
|
|
63
|
+
*
|
|
64
|
+
* @param action - The MultiAction to check.
|
|
65
|
+
* @returns Whether or not the Action can be used.
|
|
66
|
+
*/
|
|
34
67
|
multiActionDisabled(action: MultiSelectAction<EntityType>): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Toggles all entries in the table.
|
|
70
|
+
*/
|
|
35
71
|
masterToggle(): void;
|
|
72
|
+
/**
|
|
73
|
+
* Checks if all entries in the table have been selected.
|
|
74
|
+
* This is needed to display the "masterToggle"-checkbox correctly.
|
|
75
|
+
*
|
|
76
|
+
* @returns Whether or not all entries in the table have been selected.
|
|
77
|
+
*/
|
|
36
78
|
isAllSelected(): boolean;
|
|
37
79
|
ngOnDestroy(): void;
|
|
80
|
+
/**
|
|
81
|
+
* Applies the search input to filter the table entries.
|
|
82
|
+
*
|
|
83
|
+
* @param event - The keyup-event which contains the search-string of the user.
|
|
84
|
+
*/
|
|
38
85
|
applyFilter(event: Event): void;
|
|
39
86
|
static ɵfac: i0.ɵɵFactoryDeclaration<NgxMatEntityTableComponent<any>, never>;
|
|
40
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<NgxMatEntityTableComponent<any>, "ngx-mat-entity-table", never, { "
|
|
87
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<NgxMatEntityTableComponent<any>, "ngx-mat-entity-table", never, { "tableData": "tableData"; }, {}, never, never>;
|
|
41
88
|
}
|
|
@@ -10,8 +10,10 @@ import * as i8 from "@angular/material/paginator";
|
|
|
10
10
|
import * as i9 from "@angular/material/button";
|
|
11
11
|
import * as i10 from "@angular/material/menu";
|
|
12
12
|
import * as i11 from "@angular/material/dialog";
|
|
13
|
+
import * as i12 from "./create-dialog/create-entity-dialog.module";
|
|
14
|
+
import * as i13 from "./edit-dialog/edit-entity-dialog.module";
|
|
13
15
|
export declare class NgxMatEntityTableModule {
|
|
14
16
|
static ɵfac: i0.ɵɵFactoryDeclaration<NgxMatEntityTableModule, never>;
|
|
15
|
-
static ɵmod: i0.ɵɵNgModuleDeclaration<NgxMatEntityTableModule, [typeof i1.NgxMatEntityTableComponent], [typeof i2.CommonModule, typeof i3.MatInputModule, typeof i4.FormsModule, typeof i5.MatFormFieldModule, typeof i6.MatCheckboxModule, typeof i7.MatTableModule, typeof i8.MatPaginatorModule, typeof i9.MatButtonModule, typeof i10.MatMenuModule, typeof i11.MatDialogModule], [typeof i1.NgxMatEntityTableComponent]>;
|
|
17
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<NgxMatEntityTableModule, [typeof i1.NgxMatEntityTableComponent], [typeof i2.CommonModule, typeof i3.MatInputModule, typeof i4.FormsModule, typeof i5.MatFormFieldModule, typeof i6.MatCheckboxModule, typeof i7.MatTableModule, typeof i8.MatPaginatorModule, typeof i9.MatButtonModule, typeof i10.MatMenuModule, typeof i11.MatDialogModule, typeof i12.NgxMatEntityCreateDialogModule, typeof i13.NgxMatEntityEditDialogModule], [typeof i1.NgxMatEntityTableComponent]>;
|
|
16
18
|
static ɵinj: i0.ɵɵInjectorDeclaration<NgxMatEntityTableModule>;
|
|
17
19
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Entity } from '../../classes/entity-model.class';
|
|
2
|
+
import { CreateDialogData } from '../../components/table/table-data';
|
|
3
|
+
import { DecoratorTypes } from '../base/decorator-types.enum';
|
|
4
|
+
import { PropertyDecoratorConfigInternal } from '../base/property-decorator-internal.data';
|
|
5
|
+
import { ArrayTableDisplayColumn, AutocompleteStringChipsArrayDecoratorConfig, EntityArrayDecoratorConfig, StringChipsArrayDecoratorConfig } from './array-decorator.data';
|
|
6
|
+
/**
|
|
7
|
+
* The internal EntityArrayDecoratorConfig. Sets default values.
|
|
8
|
+
*/
|
|
9
|
+
export declare class EntityArrayDecoratorConfigInternal<EntityType extends Entity> extends PropertyDecoratorConfigInternal implements EntityArrayDecoratorConfig<EntityType> {
|
|
10
|
+
itemType: DecoratorTypes.OBJECT;
|
|
11
|
+
displayStyle: 'table';
|
|
12
|
+
EntityClass: new (entity?: EntityType) => EntityType;
|
|
13
|
+
displayColumns: ArrayTableDisplayColumn<EntityType>[];
|
|
14
|
+
createDialogData?: CreateDialogData;
|
|
15
|
+
createInline: boolean;
|
|
16
|
+
missingErrorMessage: string;
|
|
17
|
+
addButtonLabel: string;
|
|
18
|
+
removeButtonLabel: string;
|
|
19
|
+
constructor(data: EntityArrayDecoratorConfig<EntityType>);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The internal StringChipsArrayDecoratorConfig. Sets default values.
|
|
23
|
+
*/
|
|
24
|
+
export declare class StringChipsArrayDecoratorConfigInternal extends PropertyDecoratorConfigInternal implements StringChipsArrayDecoratorConfig {
|
|
25
|
+
itemType: DecoratorTypes.STRING;
|
|
26
|
+
displayStyle: 'chips';
|
|
27
|
+
deleteIcon: string;
|
|
28
|
+
minLength?: number;
|
|
29
|
+
maxLength?: number;
|
|
30
|
+
regex?: RegExp;
|
|
31
|
+
constructor(data: StringChipsArrayDecoratorConfig);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The internal AutocompleteStringChipsArrayDecoratorConfig. Sets default values.
|
|
35
|
+
*/
|
|
36
|
+
export declare class AutocompleteStringChipsArrayDecoratorConfigInternal extends PropertyDecoratorConfigInternal implements AutocompleteStringChipsArrayDecoratorConfig {
|
|
37
|
+
autocompleteValues: string[];
|
|
38
|
+
itemType: DecoratorTypes.STRING_AUTOCOMPLETE;
|
|
39
|
+
displayStyle: 'chips';
|
|
40
|
+
deleteIcon: string;
|
|
41
|
+
minLength?: number;
|
|
42
|
+
maxLength?: number;
|
|
43
|
+
regex?: RegExp;
|
|
44
|
+
constructor(data: AutocompleteStringChipsArrayDecoratorConfig);
|
|
45
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { Entity } from '../../classes/entity-model.class';
|
|
2
|
+
import { CreateDialogData } from '../../components/table/table-data';
|
|
3
|
+
import { DecoratorTypes } from '../base/decorator-types.enum';
|
|
4
|
+
import { PropertyDecoratorConfig } from '../base/property-decorator.data';
|
|
5
|
+
/**
|
|
6
|
+
* The configuration options for an array property displayed as a table.
|
|
7
|
+
*/
|
|
8
|
+
export interface ArrayTableDisplayColumn<EntityType extends Entity> {
|
|
9
|
+
/**
|
|
10
|
+
* The name inside the header.
|
|
11
|
+
*/
|
|
12
|
+
displayName: string;
|
|
13
|
+
/**
|
|
14
|
+
* A method to get the value inside an row.
|
|
15
|
+
*/
|
|
16
|
+
value: (entity: EntityType) => string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Interface definition for the @array metadata.
|
|
20
|
+
*/
|
|
21
|
+
declare abstract class ArrayDecoratorConfig extends PropertyDecoratorConfig {
|
|
22
|
+
/**
|
|
23
|
+
* How to display the string.
|
|
24
|
+
*/
|
|
25
|
+
displayStyle: 'table' | 'chips';
|
|
26
|
+
/**
|
|
27
|
+
* The type of the items inside the array.
|
|
28
|
+
*/
|
|
29
|
+
itemType: DecoratorTypes;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Definition for an array of Entities.
|
|
33
|
+
*/
|
|
34
|
+
export interface EntityArrayDecoratorConfig<EntityType extends Entity> extends ArrayDecoratorConfig {
|
|
35
|
+
itemType: DecoratorTypes.OBJECT;
|
|
36
|
+
displayStyle: 'table';
|
|
37
|
+
/**
|
|
38
|
+
* The EntityClass used for generating the create inputs.
|
|
39
|
+
*/
|
|
40
|
+
EntityClass: new (entity?: EntityType) => EntityType;
|
|
41
|
+
/**
|
|
42
|
+
* The definition of the columns to display. Consists of the displayName to show in the header of the row
|
|
43
|
+
* and the value, which is a function that generates the value to display inside a column.
|
|
44
|
+
*/
|
|
45
|
+
displayColumns: ArrayTableDisplayColumn<EntityType>[];
|
|
46
|
+
/**
|
|
47
|
+
* The data for the add-item-dialog.
|
|
48
|
+
* Can be omitted when adding items inline.
|
|
49
|
+
*/
|
|
50
|
+
createDialogData?: CreateDialogData;
|
|
51
|
+
/**
|
|
52
|
+
* Whether or not the form for adding items to the array
|
|
53
|
+
* should be displayed inline.
|
|
54
|
+
*
|
|
55
|
+
* @default true
|
|
56
|
+
*/
|
|
57
|
+
createInline?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* The label for the add button when createInline is true.
|
|
60
|
+
*
|
|
61
|
+
* @default 'Add'
|
|
62
|
+
*/
|
|
63
|
+
addButtonLabel?: string;
|
|
64
|
+
/**
|
|
65
|
+
* The label for the remove button when createInline is true.
|
|
66
|
+
*
|
|
67
|
+
* @default 'Remove'
|
|
68
|
+
*/
|
|
69
|
+
removeButtonLabel?: string;
|
|
70
|
+
/**
|
|
71
|
+
* The error-message to display when the array is required but contains no values.
|
|
72
|
+
*/
|
|
73
|
+
missingErrorMessage?: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Definition for an array of strings displayed as a chips list.
|
|
77
|
+
*/
|
|
78
|
+
export interface StringChipsArrayDecoratorConfig extends ArrayDecoratorConfig {
|
|
79
|
+
itemType: DecoratorTypes.STRING;
|
|
80
|
+
displayStyle: 'chips';
|
|
81
|
+
/**
|
|
82
|
+
* The class for the <i> tag used to remove an entry from the array.
|
|
83
|
+
*
|
|
84
|
+
* @default 'fas fa-circle-minus'
|
|
85
|
+
*/
|
|
86
|
+
deleteIcon?: string;
|
|
87
|
+
/**
|
|
88
|
+
* The minimum required length of the string.
|
|
89
|
+
*/
|
|
90
|
+
minLength?: number;
|
|
91
|
+
/**
|
|
92
|
+
* The maximum required length of the string.
|
|
93
|
+
*/
|
|
94
|
+
maxLength?: number;
|
|
95
|
+
/**
|
|
96
|
+
* A regex used for validation.
|
|
97
|
+
*/
|
|
98
|
+
regex?: RegExp;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Definition for an array of autocomplete strings displayed as a chips list.
|
|
102
|
+
*/
|
|
103
|
+
export interface AutocompleteStringChipsArrayDecoratorConfig extends ArrayDecoratorConfig {
|
|
104
|
+
itemType: DecoratorTypes.STRING_AUTOCOMPLETE;
|
|
105
|
+
displayStyle: 'chips';
|
|
106
|
+
/**
|
|
107
|
+
* The class for the <i> tag used to remove an entry from the array.
|
|
108
|
+
*
|
|
109
|
+
* @default 'fas fa-circle-minus'
|
|
110
|
+
*/
|
|
111
|
+
deleteIcon?: string;
|
|
112
|
+
/**
|
|
113
|
+
* The autocomplete values.
|
|
114
|
+
*/
|
|
115
|
+
autocompleteValues: string[];
|
|
116
|
+
/**
|
|
117
|
+
* The minimum required length of the string.
|
|
118
|
+
*/
|
|
119
|
+
minLength?: number;
|
|
120
|
+
/**
|
|
121
|
+
* The maximum required length of the string.
|
|
122
|
+
*/
|
|
123
|
+
maxLength?: number;
|
|
124
|
+
/**
|
|
125
|
+
* A regex used for validation.
|
|
126
|
+
*/
|
|
127
|
+
regex?: RegExp;
|
|
128
|
+
}
|
|
129
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Entity } from '../../classes/entity-model.class';
|
|
2
|
+
import { AutocompleteStringChipsArrayDecoratorConfig, EntityArrayDecoratorConfig, StringChipsArrayDecoratorConfig } from './array-decorator.data';
|
|
3
|
+
/**
|
|
4
|
+
* Decorator for setting and getting array property metadata.
|
|
5
|
+
*
|
|
6
|
+
* @param metadata - The metadata of the array property.
|
|
7
|
+
* @returns The method that defines the metadata.
|
|
8
|
+
* @throws When the given type of the array-items is unknown.
|
|
9
|
+
*/
|
|
10
|
+
export declare function array<EntityType extends Entity>(metadata: EntityArrayDecoratorConfig<EntityType> | StringChipsArrayDecoratorConfig | AutocompleteStringChipsArrayDecoratorConfig): (target: object, propertyKey: string) => void;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { DecoratorTypes } from './decorator-types.enum';
|
|
2
|
-
import {
|
|
2
|
+
import { PropertyDecoratorConfigInternal } from './property-decorator-internal.data';
|
|
3
3
|
/**
|
|
4
|
-
* The base decorator for setting metadata on properties
|
|
5
|
-
*
|
|
6
|
-
* @param
|
|
7
|
-
* @
|
|
4
|
+
* The base decorator for setting metadata on properties.
|
|
5
|
+
*
|
|
6
|
+
* @param metadata - The metadata to define.
|
|
7
|
+
* @param type - The type of metadata.
|
|
8
|
+
* @returns The method that sets the metadata.
|
|
8
9
|
*/
|
|
9
|
-
export declare function baseProperty(metadata:
|
|
10
|
+
export declare function baseProperty(metadata: PropertyDecoratorConfigInternal, type: DecoratorTypes): (target: object, propertyKey: string) => void;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { StringChipsArrayDecoratorConfig, EntityArrayDecoratorConfig, AutocompleteStringChipsArrayDecoratorConfig } from '../array.decorator';
|
|
2
1
|
import { Entity } from '../../classes/entity-model.class';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { AutocompleteStringChipsArrayDecoratorConfigInternal, EntityArrayDecoratorConfigInternal, StringChipsArrayDecoratorConfigInternal } from '../array/array-decorator-internal.data';
|
|
3
|
+
import { CheckboxBooleanDecoratorConfigInternal, DropdownBooleanDecoratorConfigInternal, ToggleBooleanDecoratorConfigInternal } from '../boolean/boolean-decorator-internal.data';
|
|
4
|
+
import { DefaultNumberDecoratorConfigInternal, DropdownNumberDecoratorConfigInternal } from '../number/number-decorator-internal.data';
|
|
5
|
+
import { DefaultObjectDecoratorConfigInternal } from '../object/object-decorator-internal.data';
|
|
6
|
+
import { AutocompleteStringDecoratorConfigInternal, DefaultStringDecoratorConfigInternal, DropdownStringDecoratorConfigInternal, TextboxStringDecoratorConfigInternal } from '../string/string-decorator-internal.data';
|
|
7
7
|
/**
|
|
8
8
|
* The enum Values for all the different DecoratorTypes.
|
|
9
9
|
*/
|
|
@@ -23,6 +23,6 @@ export declare enum DecoratorTypes {
|
|
|
23
23
|
ARRAY_STRING_AUTOCOMPLETE_CHIPS = "arrayStringAutocompleteChips"
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* Gives the metadata-config Type based
|
|
26
|
+
* Gives the metadata-config Type based on the DecoratorTypes enum.
|
|
27
27
|
*/
|
|
28
|
-
export declare type DecoratorType<T> = T extends DecoratorTypes.STRING ?
|
|
28
|
+
export declare type DecoratorType<T> = T extends DecoratorTypes.STRING ? DefaultStringDecoratorConfigInternal : T extends DecoratorTypes.STRING_TEXTBOX ? TextboxStringDecoratorConfigInternal : T extends DecoratorTypes.STRING_DROPDOWN ? DropdownStringDecoratorConfigInternal : T extends DecoratorTypes.STRING_AUTOCOMPLETE ? AutocompleteStringDecoratorConfigInternal : T extends DecoratorTypes.NUMBER ? DefaultNumberDecoratorConfigInternal : T extends DecoratorTypes.NUMBER_DROPDOWN ? DropdownNumberDecoratorConfigInternal : T extends DecoratorTypes.BOOLEAN_CHECKBOX ? CheckboxBooleanDecoratorConfigInternal : T extends DecoratorTypes.BOOLEAN_TOGGLE ? ToggleBooleanDecoratorConfigInternal : T extends DecoratorTypes.BOOLEAN_DROPDOWN ? DropdownBooleanDecoratorConfigInternal : T extends DecoratorTypes.OBJECT ? DefaultObjectDecoratorConfigInternal<Entity> : T extends DecoratorTypes.ARRAY ? EntityArrayDecoratorConfigInternal<Entity> : T extends DecoratorTypes.ARRAY_STRING_CHIPS ? StringChipsArrayDecoratorConfigInternal : T extends DecoratorTypes.ARRAY_STRING_AUTOCOMPLETE_CHIPS ? AutocompleteStringChipsArrayDecoratorConfigInternal : never;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Col, Position, PropertyDecoratorConfig } from './property-decorator.data';
|
|
2
|
+
/**
|
|
3
|
+
* The internal Position. Sets default values and validates user input.
|
|
4
|
+
*/
|
|
5
|
+
declare class PositionInternal implements Position {
|
|
6
|
+
row: number;
|
|
7
|
+
order: number;
|
|
8
|
+
constructor(data?: Position);
|
|
9
|
+
private validateInput;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The internal PropertyDecoratorConfig. Sets default values.
|
|
13
|
+
*/
|
|
14
|
+
export declare abstract class PropertyDecoratorConfigInternal implements PropertyDecoratorConfig {
|
|
15
|
+
display: boolean;
|
|
16
|
+
displayName: string;
|
|
17
|
+
required: boolean;
|
|
18
|
+
omitForCreate: boolean;
|
|
19
|
+
omitForUpdate: boolean;
|
|
20
|
+
defaultWidths: [Col, Col, Col];
|
|
21
|
+
position: PositionInternal;
|
|
22
|
+
constructor(data: PropertyDecoratorConfig);
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A bootstrap column value (a range from 1 - 12).
|
|
3
|
+
*/
|
|
4
|
+
export declare type Col = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
|
5
|
+
/**
|
|
6
|
+
* The base options for all propertyDecorators.
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class PropertyDecoratorConfig {
|
|
9
|
+
/**
|
|
10
|
+
* Whether or not the Property is displayed at all.
|
|
11
|
+
*
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
14
|
+
display?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The name of the property used as a label for form fields.
|
|
17
|
+
*/
|
|
18
|
+
displayName: string;
|
|
19
|
+
/**
|
|
20
|
+
* Whether or not the Property is required.
|
|
21
|
+
*
|
|
22
|
+
* @default true
|
|
23
|
+
*/
|
|
24
|
+
required?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Whether or not the property gets omitted when creating new Entities.
|
|
27
|
+
*
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
omitForCreate?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Whether or not the property gets omitted when updating Entities.
|
|
33
|
+
*
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
36
|
+
omitForUpdate?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Defines the width of the input property when used inside the default create or edit dialog.
|
|
39
|
+
* Has 3 bootstrap values for different breakpoints for simple responsive design.
|
|
40
|
+
* The first value sets the columns for the screen size lg, the second for md and the third for sm.
|
|
41
|
+
*
|
|
42
|
+
* @default [6, 6, 12]
|
|
43
|
+
*/
|
|
44
|
+
defaultWidths?: [Col, Col, Col];
|
|
45
|
+
/**
|
|
46
|
+
* Specifies the how to position this property when using default create/edit dialogs.
|
|
47
|
+
*
|
|
48
|
+
* @default { row: -1, order: -1} (Adds the property at the end)
|
|
49
|
+
*/
|
|
50
|
+
position?: Position;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The options for positioning a property when using default create/edit dialogs.
|
|
54
|
+
*/
|
|
55
|
+
export interface Position {
|
|
56
|
+
/**
|
|
57
|
+
* Specifies the (bootstrap)-row in which this property is displayed.
|
|
58
|
+
* Ordering is ascending.
|
|
59
|
+
*
|
|
60
|
+
* @default -1 (sets this property after the last row)
|
|
61
|
+
*/
|
|
62
|
+
row?: number;
|
|
63
|
+
/**
|
|
64
|
+
* Specifies order of the input property inside the specified row.
|
|
65
|
+
* Ordering is ascending.
|
|
66
|
+
*
|
|
67
|
+
* @default -1 (sets this property at the end of the row)
|
|
68
|
+
*/
|
|
69
|
+
order?: number;
|
|
70
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { PropertyDecoratorConfigInternal } from '../base/property-decorator-internal.data';
|
|
2
|
+
import { CheckboxBooleanDecoratorConfig, DropdownBooleanDecoratorConfig, ToggleBooleanDecoratorConfig } from './boolean-decorator.data';
|
|
3
|
+
/**
|
|
4
|
+
* The internal DropdownBooleanDecoratorConfig. Sets default values.
|
|
5
|
+
*/
|
|
6
|
+
export declare class DropdownBooleanDecoratorConfigInternal extends PropertyDecoratorConfigInternal implements DropdownBooleanDecoratorConfig {
|
|
7
|
+
displayStyle: 'dropdown';
|
|
8
|
+
dropdownTrue: string;
|
|
9
|
+
dropdownFalse: string;
|
|
10
|
+
constructor(data: DropdownBooleanDecoratorConfig);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The internal CheckboxBooleanDecoratorConfig. Sets default values.
|
|
14
|
+
*/
|
|
15
|
+
export declare class CheckboxBooleanDecoratorConfigInternal extends PropertyDecoratorConfigInternal implements CheckboxBooleanDecoratorConfig {
|
|
16
|
+
displayStyle: 'checkbox';
|
|
17
|
+
constructor(data: CheckboxBooleanDecoratorConfig);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The internal ToggleBooleanDecoratorConfig. Sets default values.
|
|
21
|
+
*/
|
|
22
|
+
export declare class ToggleBooleanDecoratorConfigInternal extends PropertyDecoratorConfigInternal implements ToggleBooleanDecoratorConfig {
|
|
23
|
+
displayStyle: 'toggle';
|
|
24
|
+
constructor(data: ToggleBooleanDecoratorConfig);
|
|
25
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { PropertyDecoratorConfig } from '../base/property-decorator.data';
|
|
2
|
+
/**
|
|
3
|
+
* The Definition for the @boolean metadata.
|
|
4
|
+
*/
|
|
5
|
+
declare abstract class BooleanDecoratorConfig extends PropertyDecoratorConfig {
|
|
6
|
+
/**
|
|
7
|
+
* Whether to display the booleans as a checkbox, a toggle button or as a dropdown.
|
|
8
|
+
*/
|
|
9
|
+
displayStyle: 'checkbox' | 'dropdown' | 'toggle';
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The configuration options for a boolean property displayed in a dropdown.
|
|
13
|
+
*/
|
|
14
|
+
export interface DropdownBooleanDecoratorConfig extends BooleanDecoratorConfig {
|
|
15
|
+
displayStyle: 'dropdown';
|
|
16
|
+
/**
|
|
17
|
+
* The name of the true value if displayStyle dropdown is used.
|
|
18
|
+
*/
|
|
19
|
+
dropdownTrue: string;
|
|
20
|
+
/**
|
|
21
|
+
* The name of the false value if displayStyle dropdown is used.
|
|
22
|
+
*/
|
|
23
|
+
dropdownFalse: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The configuration options for a boolean property displayed as a checkbox.
|
|
27
|
+
*/
|
|
28
|
+
export interface CheckboxBooleanDecoratorConfig extends BooleanDecoratorConfig {
|
|
29
|
+
displayStyle: 'checkbox';
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The configuration options for a boolean property displayed as a mat-toggle.
|
|
33
|
+
*/
|
|
34
|
+
export interface ToggleBooleanDecoratorConfig extends BooleanDecoratorConfig {
|
|
35
|
+
displayStyle: 'toggle';
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CheckboxBooleanDecoratorConfig, DropdownBooleanDecoratorConfig, ToggleBooleanDecoratorConfig } from './boolean-decorator.data';
|
|
2
|
+
/**
|
|
3
|
+
* Decorator for setting and getting boolean property metadata.
|
|
4
|
+
*
|
|
5
|
+
* @param metadata - The metadata of the boolean property.
|
|
6
|
+
* @returns The method that defines the metadata.
|
|
7
|
+
*/
|
|
8
|
+
export declare function boolean(metadata: CheckboxBooleanDecoratorConfig | ToggleBooleanDecoratorConfig | DropdownBooleanDecoratorConfig): (target: object, propertyKey: string) => void;
|