ngx-material-entity 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +93 -0
- package/LICENSE.md +21 -0
- package/README.md +691 -0
- package/classes/entity-model.class.d.ts +9 -0
- package/classes/entity-service.class.d.ts +56 -0
- package/classes/entity-utilities.class.d.ts +95 -0
- package/components/confirm-dialog/confirm-dialog-data.d.ts +41 -0
- package/components/confirm-dialog/confirm-dialog.component.d.ts +18 -0
- package/components/confirm-dialog/confirm-dialog.module.d.ts +12 -0
- package/components/get-validation-error-message.function.d.ts +7 -0
- package/components/input/array-table/add-array-item-dialog/add-array-item-dialog.component.d.ts +35 -0
- package/components/input/array-table/add-array-item-dialog/add-array-item-dialog.module.d.ts +12 -0
- package/components/input/array-table/array-table.component.d.ts +34 -0
- package/components/input/array-table/array-table.module.d.ts +19 -0
- package/components/input/input.component.d.ts +73 -0
- package/components/input/input.module.d.ts +18 -0
- package/components/input/internal-input/internal-input.component.d.ts +57 -0
- package/components/input/internal-input/internal-input.module.d.ts +16 -0
- package/components/table/create-dialog/create-entity-dialog-data.d.ts +21 -0
- package/components/table/create-dialog/create-entity-dialog.component.d.ts +25 -0
- package/components/table/create-dialog/create-entity-dialog.module.d.ts +12 -0
- package/components/table/edit-dialog/edit-entity-dialog-data.d.ts +25 -0
- package/components/table/edit-dialog/edit-entity-dialog.component.d.ts +28 -0
- package/components/table/edit-dialog/edit-entity-dialog.module.d.ts +13 -0
- package/components/table/table-data.d.ts +184 -0
- package/components/table/table.component.d.ts +41 -0
- package/components/table/table.module.d.ts +17 -0
- package/decorators/array.decorator.d.ts +125 -0
- package/decorators/base/base-property.decorator.d.ts +9 -0
- package/decorators/base/decorator-types.enum.d.ts +28 -0
- package/decorators/base/property-decorator-config.interface.d.ts +50 -0
- package/decorators/boolean.decorator.d.ts +42 -0
- package/decorators/number.decorator.d.ts +40 -0
- package/decorators/object.decorator.d.ts +27 -0
- package/decorators/string.decorator.d.ts +76 -0
- package/esm2020/classes/entity-model.class.mjs +19 -0
- package/esm2020/classes/entity-service.class.mjs +70 -0
- package/esm2020/classes/entity-utilities.class.mjs +296 -0
- package/esm2020/components/confirm-dialog/confirm-dialog-data.mjs +2 -0
- package/esm2020/components/confirm-dialog/confirm-dialog.component.mjs +51 -0
- package/esm2020/components/confirm-dialog/confirm-dialog.module.mjs +22 -0
- package/esm2020/components/get-validation-error-message.function.mjs +32 -0
- package/esm2020/components/input/array-table/add-array-item-dialog/add-array-item-dialog.component.mjs +43 -0
- package/esm2020/components/input/array-table/add-array-item-dialog/add-array-item-dialog.module.mjs +22 -0
- package/esm2020/components/input/array-table/array-table.component.mjs +116 -0
- package/esm2020/components/input/array-table/array-table.module.mjs +66 -0
- package/esm2020/components/input/input.component.mjs +158 -0
- package/esm2020/components/input/input.module.mjs +62 -0
- package/esm2020/components/input/internal-input/internal-input.component.mjs +73 -0
- package/esm2020/components/input/internal-input/internal-input.module.mjs +54 -0
- package/esm2020/components/table/create-dialog/create-entity-dialog-data.mjs +2 -0
- package/esm2020/components/table/create-dialog/create-entity-dialog.component.mjs +77 -0
- package/esm2020/components/table/create-dialog/create-entity-dialog.module.mjs +22 -0
- package/esm2020/components/table/edit-dialog/edit-entity-dialog-data.mjs +2 -0
- package/esm2020/components/table/edit-dialog/edit-entity-dialog.component.mjs +112 -0
- package/esm2020/components/table/edit-dialog/edit-entity-dialog.module.mjs +42 -0
- package/esm2020/components/table/table-data.mjs +2 -0
- package/esm2020/components/table/table.component.mjs +232 -0
- package/esm2020/components/table/table.module.mjs +58 -0
- package/esm2020/decorators/array.decorator.mjs +70 -0
- package/esm2020/decorators/base/base-property.decorator.mjs +13 -0
- package/esm2020/decorators/base/decorator-types.enum.mjs +20 -0
- package/esm2020/decorators/base/property-decorator-config.interface.mjs +31 -0
- package/esm2020/decorators/boolean.decorator.mjs +44 -0
- package/esm2020/decorators/number.decorator.mjs +36 -0
- package/esm2020/decorators/object.decorator.mjs +23 -0
- package/esm2020/decorators/string.decorator.mjs +61 -0
- package/esm2020/ngx-material-entity.mjs +5 -0
- package/esm2020/public-api.mjs +32 -0
- package/fesm2015/ngx-material-entity.mjs +1786 -0
- package/fesm2015/ngx-material-entity.mjs.map +1 -0
- package/fesm2020/ngx-material-entity.mjs +1760 -0
- package/fesm2020/ngx-material-entity.mjs.map +1 -0
- package/ngx-material-entity.d.ts +5 -0
- package/package.json +40 -0
- package/public-api.d.ts +25 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { HttpClient } from '@angular/common/http';
|
|
2
|
+
import { Entity } from '../../classes/entity-model.class';
|
|
3
|
+
import { EntityService } from '../../classes/entity-service.class';
|
|
4
|
+
import { ConfirmDialogData } from '../confirm-dialog/confirm-dialog-data';
|
|
5
|
+
/**
|
|
6
|
+
* The Definition of a Column inside the table.
|
|
7
|
+
*/
|
|
8
|
+
export interface DisplayColumn<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
|
+
* The Definition of an Action that can be run on multiple selected entities
|
|
20
|
+
*/
|
|
21
|
+
export interface MultiSelectAction<EntityType extends Entity> {
|
|
22
|
+
/**
|
|
23
|
+
* The name of the action
|
|
24
|
+
*/
|
|
25
|
+
displayName: string;
|
|
26
|
+
/**
|
|
27
|
+
* The action itself
|
|
28
|
+
*/
|
|
29
|
+
action: (selectedEntities: EntityType[]) => unknown;
|
|
30
|
+
/**
|
|
31
|
+
* A method that defines whether or not the action can be used.
|
|
32
|
+
* @default true
|
|
33
|
+
*/
|
|
34
|
+
enabled?: (selectedEntities: EntityType[]) => boolean;
|
|
35
|
+
/**
|
|
36
|
+
* A method that defines whether or not a confirm dialog is needed to run the action
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
requireConfirmDialog?: (selectedEntities: EntityType[]) => boolean;
|
|
40
|
+
/**
|
|
41
|
+
* The data used to generate a confirmation dialog for the multiselect action.
|
|
42
|
+
*/
|
|
43
|
+
confirmDialogData?: ConfirmDialogData;
|
|
44
|
+
}
|
|
45
|
+
export interface BaseData<EntityType extends Entity> {
|
|
46
|
+
/**
|
|
47
|
+
* The title of the table
|
|
48
|
+
*/
|
|
49
|
+
title: string;
|
|
50
|
+
/**
|
|
51
|
+
* 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
|
|
53
|
+
*/
|
|
54
|
+
displayColumns: DisplayColumn<EntityType>[];
|
|
55
|
+
/**
|
|
56
|
+
* The label on the search bar. Defaults to "Search".
|
|
57
|
+
*/
|
|
58
|
+
searchLabel?: string;
|
|
59
|
+
/**
|
|
60
|
+
* The label on the button for adding new entities. Defaults to "Create".
|
|
61
|
+
*/
|
|
62
|
+
createButtonLabel?: string;
|
|
63
|
+
/**
|
|
64
|
+
* The Class of the entities to manage
|
|
65
|
+
*/
|
|
66
|
+
EntityClass: new (entity?: EntityType) => EntityType;
|
|
67
|
+
/**
|
|
68
|
+
* The Class of the service that handles the entities.
|
|
69
|
+
* Needs to be injectable and an extension of the "EntityService"-Class
|
|
70
|
+
*/
|
|
71
|
+
EntityServiceClass: new (httpClient: HttpClient) => EntityService<EntityType>;
|
|
72
|
+
/**
|
|
73
|
+
* Takes a custom edit method which runs when you click on a entity.
|
|
74
|
+
* If you don't need any special editing of entries you can also omit this.
|
|
75
|
+
* In that case a default edit dialog is generated.
|
|
76
|
+
*/
|
|
77
|
+
edit?: (entity: EntityType) => unknown;
|
|
78
|
+
/**
|
|
79
|
+
* Takes a method to run when you click on the new button.
|
|
80
|
+
* If you don't need anything special you can also omit this.
|
|
81
|
+
* In that case a default create dialog is generated.
|
|
82
|
+
*/
|
|
83
|
+
create?: (entity: EntityType) => unknown;
|
|
84
|
+
/**
|
|
85
|
+
* Defines how the search string of entities is generated.
|
|
86
|
+
*/
|
|
87
|
+
searchString?: (enity: EntityType) => string;
|
|
88
|
+
/**
|
|
89
|
+
* Defines whether or not the user can add new entities.
|
|
90
|
+
* @default true
|
|
91
|
+
*/
|
|
92
|
+
allowCreate?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Defines whether or not the user can edit entities.
|
|
95
|
+
* @default () => true
|
|
96
|
+
*/
|
|
97
|
+
allowEdit?: (entity: EntityType) => boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Whether or not the user can delete this specific entity
|
|
100
|
+
*/
|
|
101
|
+
allowDelete?: (entity: EntityType) => boolean;
|
|
102
|
+
/**
|
|
103
|
+
* All Actions that you want to run on multiple entities can be defined here.
|
|
104
|
+
* (e.g. download as zip-file or mass delete)
|
|
105
|
+
*/
|
|
106
|
+
multiSelectActions?: MultiSelectAction<EntityType>[];
|
|
107
|
+
/**
|
|
108
|
+
* The Label for the button that opens all multi-actions.
|
|
109
|
+
*/
|
|
110
|
+
multiSelectLabel?: string;
|
|
111
|
+
}
|
|
112
|
+
export interface CreateDialogData {
|
|
113
|
+
/**
|
|
114
|
+
* The title of the default create-dialog.
|
|
115
|
+
*/
|
|
116
|
+
title: string;
|
|
117
|
+
/**
|
|
118
|
+
* The label on the create-button of the default create-dialog. Defaults to "Create".
|
|
119
|
+
*/
|
|
120
|
+
createButtonLabel?: string;
|
|
121
|
+
/**
|
|
122
|
+
* The label on the cancel-button for the default create-dialog. Defaults to "Cancel".
|
|
123
|
+
*/
|
|
124
|
+
cancelButtonLabel?: string;
|
|
125
|
+
/**
|
|
126
|
+
* Whether or not the creation of an entry should require a confirm dialog.
|
|
127
|
+
*/
|
|
128
|
+
createRequiresConfirmDialog?: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* The data used to generate a confirmation dialog for the create action.
|
|
131
|
+
*/
|
|
132
|
+
confirmCreateDialogData?: ConfirmDialogData;
|
|
133
|
+
}
|
|
134
|
+
export interface EditDialogData<EntityType extends Entity> {
|
|
135
|
+
/**
|
|
136
|
+
* The title of the default edit-dialog.
|
|
137
|
+
*/
|
|
138
|
+
title: (entity: EntityType) => string;
|
|
139
|
+
/**
|
|
140
|
+
* The label on the confirm-button of the default edit-dialog. Defaults to "Save".
|
|
141
|
+
*/
|
|
142
|
+
confirmButtonLabel?: string;
|
|
143
|
+
/**
|
|
144
|
+
* The label on the delete-button of the default edit-dialog. Defaults to "Delete".
|
|
145
|
+
*/
|
|
146
|
+
deleteButtonLabel?: string;
|
|
147
|
+
/**
|
|
148
|
+
* The label on the cancel-button for the default edit-dialog. Defaults to "Cancel".
|
|
149
|
+
*/
|
|
150
|
+
cancelButtonLabel?: string;
|
|
151
|
+
/**
|
|
152
|
+
* Whether or not the deletion of an entry should require a confirm dialog.
|
|
153
|
+
*/
|
|
154
|
+
deleteRequiresConfirmDialog?: boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Whether or not the editing of an entry should require a confirm dialog.
|
|
157
|
+
*/
|
|
158
|
+
editRequiresConfirmDialog?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* The data used to generate a confirmation dialog for the delete action.
|
|
161
|
+
*/
|
|
162
|
+
confirmDeleteDialogData?: ConfirmDialogData;
|
|
163
|
+
/**
|
|
164
|
+
* The data used to generate a confirmation dialog for the delete action.
|
|
165
|
+
*/
|
|
166
|
+
confirmEditDialogData?: ConfirmDialogData;
|
|
167
|
+
}
|
|
168
|
+
export interface EntitiesData<EntityType extends Entity> {
|
|
169
|
+
/**
|
|
170
|
+
* The base data for the entities-component.
|
|
171
|
+
* Includes stuff like the title for the table, what to display inside the rows etc.
|
|
172
|
+
*/
|
|
173
|
+
baseData: BaseData<EntityType>;
|
|
174
|
+
/**
|
|
175
|
+
* The data for the default create-dialog.
|
|
176
|
+
* Can be omitted when specifying a custom "create" method inside the baseData.
|
|
177
|
+
*/
|
|
178
|
+
createDialogData?: CreateDialogData;
|
|
179
|
+
/**
|
|
180
|
+
* The data for the default edit-dialog.
|
|
181
|
+
* Can be omitted when specifying a custom "edit" method inside the baseData.
|
|
182
|
+
*/
|
|
183
|
+
editDialogData?: EditDialogData<EntityType>;
|
|
184
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Injector, OnDestroy, OnInit } from '@angular/core';
|
|
2
|
+
import { MatPaginator } from '@angular/material/paginator';
|
|
3
|
+
import { MatSort } from '@angular/material/sort';
|
|
4
|
+
import { MatTableDataSource } from '@angular/material/table';
|
|
5
|
+
import { Entity } from '../../classes/entity-model.class';
|
|
6
|
+
import { SelectionModel } from '@angular/cdk/collections';
|
|
7
|
+
import { MatDialog } from '@angular/material/dialog';
|
|
8
|
+
import { MultiSelectAction, EntitiesData } from './table-data';
|
|
9
|
+
import * as i0 from "@angular/core";
|
|
10
|
+
export declare class NgxMatEntityTableComponent<EntityType extends Entity> implements OnInit, OnDestroy {
|
|
11
|
+
private readonly dialog;
|
|
12
|
+
private readonly injector;
|
|
13
|
+
/**
|
|
14
|
+
* The configuration for the entities-component
|
|
15
|
+
*/
|
|
16
|
+
entitiesData: EntitiesData<EntityType>;
|
|
17
|
+
private entityService;
|
|
18
|
+
private readonly onDestroy;
|
|
19
|
+
paginator: MatPaginator;
|
|
20
|
+
sort: MatSort;
|
|
21
|
+
filter: string;
|
|
22
|
+
displayedColumns: string[];
|
|
23
|
+
dataSource: MatTableDataSource<EntityType>;
|
|
24
|
+
selection: SelectionModel<EntityType>;
|
|
25
|
+
constructor(dialog: MatDialog, injector: Injector);
|
|
26
|
+
ngOnInit(): void;
|
|
27
|
+
private validateInput;
|
|
28
|
+
editEntity(entity: EntityType): void;
|
|
29
|
+
private editDefault;
|
|
30
|
+
createEntity(): void;
|
|
31
|
+
private createDefault;
|
|
32
|
+
runMultiAction(action: MultiSelectAction<EntityType>): void;
|
|
33
|
+
private confirmRunMultiAction;
|
|
34
|
+
multiActionDisabled(action: MultiSelectAction<EntityType>): boolean;
|
|
35
|
+
masterToggle(): void;
|
|
36
|
+
isAllSelected(): boolean;
|
|
37
|
+
ngOnDestroy(): void;
|
|
38
|
+
applyFilter(event: Event): void;
|
|
39
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NgxMatEntityTableComponent<any>, never>;
|
|
40
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<NgxMatEntityTableComponent<any>, "ngx-mat-entity-table", never, { "entitiesData": "entitiesData"; }, {}, never, never>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import * as i1 from "./table.component";
|
|
3
|
+
import * as i2 from "@angular/common";
|
|
4
|
+
import * as i3 from "@angular/material/input";
|
|
5
|
+
import * as i4 from "@angular/forms";
|
|
6
|
+
import * as i5 from "@angular/material/form-field";
|
|
7
|
+
import * as i6 from "@angular/material/checkbox";
|
|
8
|
+
import * as i7 from "@angular/material/table";
|
|
9
|
+
import * as i8 from "@angular/material/paginator";
|
|
10
|
+
import * as i9 from "@angular/material/button";
|
|
11
|
+
import * as i10 from "@angular/material/menu";
|
|
12
|
+
import * as i11 from "@angular/material/dialog";
|
|
13
|
+
export declare class NgxMatEntityTableModule {
|
|
14
|
+
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]>;
|
|
16
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<NgxMatEntityTableModule>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
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-config.interface';
|
|
5
|
+
/**
|
|
6
|
+
* Decorator for setting and getting array propery metadata
|
|
7
|
+
* @param metadata The metadata of the array property
|
|
8
|
+
*/
|
|
9
|
+
export declare function array<EntityType extends Entity>(metadata: EntityArrayDecoratorConfig<EntityType> | StringChipsArrayDecoratorConfig | AutocompleteStringChipsArrayDecoratorConfig): (target: object, propertyKey: string) => void;
|
|
10
|
+
export interface ArrayTableDisplayColumn<EntityType extends Entity> {
|
|
11
|
+
/**
|
|
12
|
+
* The name inside the header.
|
|
13
|
+
*/
|
|
14
|
+
displayName: string;
|
|
15
|
+
/**
|
|
16
|
+
* A method to get the value inside an row
|
|
17
|
+
*/
|
|
18
|
+
value: (entity: EntityType) => string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Interface definition for the @array metadata
|
|
22
|
+
*/
|
|
23
|
+
declare abstract class ArrayDecoratorConfig extends PropertyDecoratorConfig {
|
|
24
|
+
/**
|
|
25
|
+
* How to display the string
|
|
26
|
+
*/
|
|
27
|
+
displayStyle: 'table' | 'chips';
|
|
28
|
+
/**
|
|
29
|
+
* The type of the items inside the array
|
|
30
|
+
*/
|
|
31
|
+
itemType: DecoratorTypes;
|
|
32
|
+
/**
|
|
33
|
+
* The error-message to display when the array is required but contains no values
|
|
34
|
+
*/
|
|
35
|
+
missingErrorMessage?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Definition for an array of Entities
|
|
39
|
+
*/
|
|
40
|
+
export declare class EntityArrayDecoratorConfig<EntityType extends Entity> extends ArrayDecoratorConfig {
|
|
41
|
+
itemType: DecoratorTypes.OBJECT;
|
|
42
|
+
displayStyle: 'table';
|
|
43
|
+
/**
|
|
44
|
+
* The EntityClass used for generating the create inputs
|
|
45
|
+
*/
|
|
46
|
+
EntityClass: new (entity?: EntityType) => EntityType;
|
|
47
|
+
/**
|
|
48
|
+
* The definition of the columns to display. Consists of the displayName to show in the header of the row
|
|
49
|
+
* and the value, which is a function that generates the value to display inside a column
|
|
50
|
+
*/
|
|
51
|
+
displayColumns: ArrayTableDisplayColumn<EntityType>[];
|
|
52
|
+
/**
|
|
53
|
+
* The data for the add-item-dialog.
|
|
54
|
+
* Can be omitted when adding items inline.
|
|
55
|
+
*/
|
|
56
|
+
createDialogData?: CreateDialogData;
|
|
57
|
+
/**
|
|
58
|
+
* Whether or not the form for adding items to the array
|
|
59
|
+
* should be displayed inline.
|
|
60
|
+
* @default true
|
|
61
|
+
*/
|
|
62
|
+
createInline?: boolean;
|
|
63
|
+
constructor(metadata: EntityArrayDecoratorConfig<EntityType>);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Definition for an array of strings displayed as a chips list
|
|
67
|
+
*/
|
|
68
|
+
export declare class StringChipsArrayDecoratorConfig extends ArrayDecoratorConfig {
|
|
69
|
+
itemType: DecoratorTypes.STRING;
|
|
70
|
+
displayStyle: 'chips';
|
|
71
|
+
/**
|
|
72
|
+
* The html inside the delete-button.
|
|
73
|
+
* Please note that custom tags such as <mat-icon></mat-icon>
|
|
74
|
+
* need to be defined as known elements, otherwise the sanitizer will remove them.
|
|
75
|
+
* You can however work around this by using `<span class="material-icons"></span>`
|
|
76
|
+
* @default <mat-icon>cancel</mat-icon>
|
|
77
|
+
*/
|
|
78
|
+
deleteHtml?: string;
|
|
79
|
+
/**
|
|
80
|
+
* (optional) The minimum required length of the string
|
|
81
|
+
*/
|
|
82
|
+
minLength?: number;
|
|
83
|
+
/**
|
|
84
|
+
* (optional) The maximum required length of the string
|
|
85
|
+
*/
|
|
86
|
+
maxLength?: number;
|
|
87
|
+
/**
|
|
88
|
+
* (optional) A regex used for validation
|
|
89
|
+
*/
|
|
90
|
+
regex?: RegExp;
|
|
91
|
+
constructor(metadata: StringChipsArrayDecoratorConfig);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Definition for an array of autocomplete strings displayed as a chips list
|
|
95
|
+
*/
|
|
96
|
+
export declare class AutocompleteStringChipsArrayDecoratorConfig extends ArrayDecoratorConfig {
|
|
97
|
+
itemType: DecoratorTypes.STRING_AUTOCOMPLETE;
|
|
98
|
+
displayStyle: 'chips';
|
|
99
|
+
/**
|
|
100
|
+
* The html inside the delete-button.
|
|
101
|
+
* Please note that custom tags such as <mat-icon></mat-icon>
|
|
102
|
+
* need to be defined as known elements, otherwise the sanitizer will remove them.
|
|
103
|
+
* You can however work around this by using `<span class="material-icons"></span>`
|
|
104
|
+
* @default <mat-icon>cancel</mat-icon>
|
|
105
|
+
*/
|
|
106
|
+
deleteHtml?: string;
|
|
107
|
+
/**
|
|
108
|
+
* The autocomplete values
|
|
109
|
+
*/
|
|
110
|
+
autocompleteValues: string[];
|
|
111
|
+
/**
|
|
112
|
+
* (optional) The minimum required length of the string
|
|
113
|
+
*/
|
|
114
|
+
minLength?: number;
|
|
115
|
+
/**
|
|
116
|
+
* (optional) The maximum required length of the string
|
|
117
|
+
*/
|
|
118
|
+
maxLength?: number;
|
|
119
|
+
/**
|
|
120
|
+
* (optional) A regex used for validation
|
|
121
|
+
*/
|
|
122
|
+
regex?: RegExp;
|
|
123
|
+
constructor(metadata: AutocompleteStringChipsArrayDecoratorConfig);
|
|
124
|
+
}
|
|
125
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DecoratorTypes } from './decorator-types.enum';
|
|
2
|
+
import { PropertyDecoratorConfig } from './property-decorator-config.interface';
|
|
3
|
+
/**
|
|
4
|
+
* The base decorator for setting metadata on properties
|
|
5
|
+
* @param metadata The metadata to define
|
|
6
|
+
* @param type The type of metadata
|
|
7
|
+
* @returns The function that sets the metadata
|
|
8
|
+
*/
|
|
9
|
+
export declare function baseProperty(metadata: PropertyDecoratorConfig, type: DecoratorTypes): (target: object, propertyKey: string) => void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { StringChipsArrayDecoratorConfig, EntityArrayDecoratorConfig, AutocompleteStringChipsArrayDecoratorConfig } from '../array.decorator';
|
|
2
|
+
import { Entity } from '../../classes/entity-model.class';
|
|
3
|
+
import { CheckboxBooleanDecoratorConfig, DropdownBooleanDecoratorConfig } from '../boolean.decorator';
|
|
4
|
+
import { DefaultNumberDecoratorConfig, DropdownNumberDecoratorConfig } from '../number.decorator';
|
|
5
|
+
import { DefaultObjectDecoratorConfig } from '../object.decorator';
|
|
6
|
+
import { DefaultStringDecoratorConfig, DropdownStringDecoratorConfig, AutocompleteStringDecoratorConfig, TextboxStringDecoratorConfig } from '../string.decorator';
|
|
7
|
+
/**
|
|
8
|
+
* The enum Values for all the different DecoratorTypes.
|
|
9
|
+
*/
|
|
10
|
+
export declare enum DecoratorTypes {
|
|
11
|
+
STRING = "string",
|
|
12
|
+
STRING_DROPDOWN = "stringDropdown",
|
|
13
|
+
STRING_AUTOCOMPLETE = "stringAutocomplete",
|
|
14
|
+
STRING_TEXTBOX = "stringTextbox",
|
|
15
|
+
NUMBER = "number",
|
|
16
|
+
NUMBER_DROPDOWN = "numberDropdown",
|
|
17
|
+
BOOLEAN_CHECKBOX = "boolean",
|
|
18
|
+
BOOLEAN_TOGGLE = "booleanToggle",
|
|
19
|
+
BOOLEAN_DROPDOWN = "booleanDropdown",
|
|
20
|
+
OBJECT = "object",
|
|
21
|
+
ARRAY = "array",
|
|
22
|
+
ARRAY_STRING_CHIPS = "arrayStringChips",
|
|
23
|
+
ARRAY_STRING_AUTOCOMPLETE_CHIPS = "arrayStringAutocompleteChips"
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Gives the metadata-config Type based ont the DecoratorTypes enum
|
|
27
|
+
*/
|
|
28
|
+
export declare type DecoratorType<T> = T extends DecoratorTypes.STRING ? DefaultStringDecoratorConfig : T extends DecoratorTypes.STRING_TEXTBOX ? TextboxStringDecoratorConfig : T extends DecoratorTypes.STRING_DROPDOWN ? DropdownStringDecoratorConfig : T extends DecoratorTypes.STRING_AUTOCOMPLETE ? AutocompleteStringDecoratorConfig : T extends DecoratorTypes.NUMBER ? DefaultNumberDecoratorConfig : T extends DecoratorTypes.NUMBER_DROPDOWN ? DropdownNumberDecoratorConfig : T extends DecoratorTypes.BOOLEAN_CHECKBOX ? CheckboxBooleanDecoratorConfig : T extends DecoratorTypes.BOOLEAN_TOGGLE ? CheckboxBooleanDecoratorConfig : T extends DecoratorTypes.BOOLEAN_DROPDOWN ? DropdownBooleanDecoratorConfig : T extends DecoratorTypes.OBJECT ? DefaultObjectDecoratorConfig : T extends DecoratorTypes.ARRAY ? EntityArrayDecoratorConfig<Entity> : T extends DecoratorTypes.ARRAY_STRING_CHIPS ? StringChipsArrayDecoratorConfig : T extends DecoratorTypes.ARRAY_STRING_AUTOCOMPLETE_CHIPS ? AutocompleteStringChipsArrayDecoratorConfig : never;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
declare type cols = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
|
2
|
+
/**
|
|
3
|
+
* The base options for all propertyDecorators
|
|
4
|
+
*/
|
|
5
|
+
export declare abstract class PropertyDecoratorConfig {
|
|
6
|
+
/**
|
|
7
|
+
* Whether or not the Property is displayed at all.
|
|
8
|
+
* @default true
|
|
9
|
+
*/
|
|
10
|
+
display?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* The name of the property used as a label for form fields.
|
|
13
|
+
*/
|
|
14
|
+
displayName: string;
|
|
15
|
+
/**
|
|
16
|
+
* Whether or not the Property is required.
|
|
17
|
+
* @default true
|
|
18
|
+
*/
|
|
19
|
+
required?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Whether or not the property gets omitted when creating new Entities.
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
omitForCreate?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Whether or not the property gets omitted when updating Entities.
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
omitForUpdate?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Defines the width of the input property when used inside the default create or edit dialog.
|
|
32
|
+
* Has 3 bootstrap values for different breakpoints for simple responsive design.
|
|
33
|
+
* @var firstValue: col-lg-{{firstValue}}
|
|
34
|
+
* @var secondValue: col-md-{{secondValue}}
|
|
35
|
+
* @var thirdValue: col-sm-{{thirdValue}}
|
|
36
|
+
*/
|
|
37
|
+
defaultWidths?: [cols, cols, cols];
|
|
38
|
+
/**
|
|
39
|
+
* Specifies order of the input property when used inside the default create or edit dialog.
|
|
40
|
+
* Ordering is ascending
|
|
41
|
+
* @default -1 (sets this property at the end)
|
|
42
|
+
*/
|
|
43
|
+
order?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Defines, Whether or not there should be a line break after this input.
|
|
46
|
+
* Is used inside the default create and edit dialogs.
|
|
47
|
+
*/
|
|
48
|
+
constructor(displayName: string, display?: boolean, required?: boolean, omitForCreate?: boolean, omitForUpdate?: boolean, defaultWidths?: [cols, cols, cols], order?: number);
|
|
49
|
+
}
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { PropertyDecoratorConfig } from './base/property-decorator-config.interface';
|
|
2
|
+
/**
|
|
3
|
+
* Decorator for setting and getting string propery metadata
|
|
4
|
+
* @param metadata The metadata of the string property
|
|
5
|
+
*/
|
|
6
|
+
export declare function boolean(metadata: CheckboxBooleanDecoratorConfig | ToggleBooleanDecoratorConfig | DropdownBooleanDecoratorConfig): (target: object, propertyKey: string) => void;
|
|
7
|
+
/**
|
|
8
|
+
* The Definition for the @boolean metadata
|
|
9
|
+
*/
|
|
10
|
+
declare abstract class BooleanDecoratorConfig extends PropertyDecoratorConfig {
|
|
11
|
+
/**
|
|
12
|
+
* Whether to display the booleans as a checkbox, a toggle button or as a dropdown
|
|
13
|
+
*/
|
|
14
|
+
displayStyle: 'checkbox' | 'dropdown' | 'toggle';
|
|
15
|
+
}
|
|
16
|
+
export declare class DropdownBooleanDecoratorConfig extends BooleanDecoratorConfig {
|
|
17
|
+
displayStyle: 'dropdown';
|
|
18
|
+
/**
|
|
19
|
+
* The name of the true value if displayStyle dropdown is used.
|
|
20
|
+
* Can also receive a function to determine the name.
|
|
21
|
+
*/
|
|
22
|
+
dropdownTrue: string | {
|
|
23
|
+
(args: unknown): string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The name of the false value if displayStyle dropdown is used.
|
|
27
|
+
* Can also receive a function to determine the name,
|
|
28
|
+
*/
|
|
29
|
+
dropdownFalse: string | {
|
|
30
|
+
(args: unknown): string;
|
|
31
|
+
};
|
|
32
|
+
constructor(metadata: DropdownBooleanDecoratorConfig);
|
|
33
|
+
}
|
|
34
|
+
export declare class CheckboxBooleanDecoratorConfig extends BooleanDecoratorConfig {
|
|
35
|
+
displayStyle: 'checkbox';
|
|
36
|
+
constructor(metadata: CheckboxBooleanDecoratorConfig);
|
|
37
|
+
}
|
|
38
|
+
export declare class ToggleBooleanDecoratorConfig extends BooleanDecoratorConfig {
|
|
39
|
+
displayStyle: 'toggle';
|
|
40
|
+
constructor(metadata: ToggleBooleanDecoratorConfig);
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { PropertyDecoratorConfig } from './base/property-decorator-config.interface';
|
|
2
|
+
/**
|
|
3
|
+
* Decorator for setting and getting string propery metadata
|
|
4
|
+
* @param metadata The metadata of the string property
|
|
5
|
+
*/
|
|
6
|
+
export declare function number(metadata: DefaultNumberDecoratorConfig | DropdownNumberDecoratorConfig): (target: object, propertyKey: string) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Interface definition for the @number metadata
|
|
9
|
+
*/
|
|
10
|
+
declare abstract class NumberDecoratorConfig extends PropertyDecoratorConfig {
|
|
11
|
+
/**
|
|
12
|
+
* Whether to display the number in a single line or as a dropdown
|
|
13
|
+
*/
|
|
14
|
+
displayStyle: 'line' | 'dropdown';
|
|
15
|
+
}
|
|
16
|
+
export declare class DefaultNumberDecoratorConfig extends NumberDecoratorConfig {
|
|
17
|
+
displayStyle: 'line';
|
|
18
|
+
/**
|
|
19
|
+
* (optional) The minimum value of the number
|
|
20
|
+
*/
|
|
21
|
+
min?: number;
|
|
22
|
+
/**
|
|
23
|
+
* (optional) The maximum value of the number
|
|
24
|
+
*/
|
|
25
|
+
max?: number;
|
|
26
|
+
constructor(metadata: DefaultNumberDecoratorConfig);
|
|
27
|
+
}
|
|
28
|
+
export declare class DropdownNumberDecoratorConfig extends NumberDecoratorConfig {
|
|
29
|
+
displayStyle: 'dropdown';
|
|
30
|
+
/**
|
|
31
|
+
* The values of the dropdown, consisting of a name to display and the actual value
|
|
32
|
+
* Can also receive a function to determine the values
|
|
33
|
+
*/
|
|
34
|
+
dropdownValues?: {
|
|
35
|
+
displayName: string;
|
|
36
|
+
value: number;
|
|
37
|
+
}[];
|
|
38
|
+
constructor(metadata: DropdownNumberDecoratorConfig);
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PropertyDecoratorConfig } from './base/property-decorator-config.interface';
|
|
2
|
+
import { Entity } from '../classes/entity-model.class';
|
|
3
|
+
/**
|
|
4
|
+
* Decorator for setting and getting object propery metadata.
|
|
5
|
+
* @param metadata The metadata of the object property
|
|
6
|
+
*/
|
|
7
|
+
export declare function object(metadata: DefaultObjectDecoratorConfig): (target: object, propertyKey: string) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Interface definition for the @object metadata
|
|
10
|
+
*/
|
|
11
|
+
declare abstract class ObjectDecoratorConfig extends PropertyDecoratorConfig {
|
|
12
|
+
/**
|
|
13
|
+
* The entity type of the object
|
|
14
|
+
*/
|
|
15
|
+
type: typeof Entity;
|
|
16
|
+
/**
|
|
17
|
+
* How to display the object.
|
|
18
|
+
* @inline The objects properties are added as input fields in an section of the entity.
|
|
19
|
+
* Useful if the object only contains a few properties (e.g. a address on a user).
|
|
20
|
+
*/
|
|
21
|
+
displayStyle: 'inline';
|
|
22
|
+
}
|
|
23
|
+
export declare class DefaultObjectDecoratorConfig extends ObjectDecoratorConfig {
|
|
24
|
+
displayStyle: 'inline';
|
|
25
|
+
constructor(metadata: DefaultObjectDecoratorConfig);
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { PropertyDecoratorConfig } from './base/property-decorator-config.interface';
|
|
2
|
+
/**
|
|
3
|
+
* Decorator for setting and getting string propery metadata
|
|
4
|
+
* @param metadata The metadata of the string property
|
|
5
|
+
*/
|
|
6
|
+
export declare function string(metadata: DropdownStringDecoratorConfig | AutocompleteStringDecoratorConfig | DefaultStringDecoratorConfig | TextboxStringDecoratorConfig): (target: object, propertyKey: string) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Interface definition for the @string metadata
|
|
9
|
+
*/
|
|
10
|
+
declare abstract class StringDecoratorConfig extends PropertyDecoratorConfig {
|
|
11
|
+
/**
|
|
12
|
+
* How to display the string
|
|
13
|
+
*/
|
|
14
|
+
displayStyle: 'line' | 'textbox' | 'autocomplete' | 'dropdown';
|
|
15
|
+
}
|
|
16
|
+
export declare class DropdownStringDecoratorConfig extends StringDecoratorConfig {
|
|
17
|
+
displayStyle: 'dropdown';
|
|
18
|
+
/**
|
|
19
|
+
* The values of the dropdown, consisting of a name to display and the actual value
|
|
20
|
+
* Can also receive a function to determine the values
|
|
21
|
+
*/
|
|
22
|
+
dropdownValues: {
|
|
23
|
+
displayName: string;
|
|
24
|
+
value: string;
|
|
25
|
+
}[];
|
|
26
|
+
constructor(metadata: DropdownStringDecoratorConfig);
|
|
27
|
+
}
|
|
28
|
+
export declare class DefaultStringDecoratorConfig extends StringDecoratorConfig {
|
|
29
|
+
displayStyle: 'line';
|
|
30
|
+
/**
|
|
31
|
+
* (optional) The minimum required length of the string
|
|
32
|
+
*/
|
|
33
|
+
minLength?: number;
|
|
34
|
+
/**
|
|
35
|
+
* (optional) The maximum required length of the string
|
|
36
|
+
*/
|
|
37
|
+
maxLength?: number;
|
|
38
|
+
/**
|
|
39
|
+
* (optional) A regex used for validation
|
|
40
|
+
*/
|
|
41
|
+
regex?: RegExp;
|
|
42
|
+
constructor(metadata: DefaultStringDecoratorConfig);
|
|
43
|
+
}
|
|
44
|
+
export declare class TextboxStringDecoratorConfig extends StringDecoratorConfig {
|
|
45
|
+
displayStyle: 'textbox';
|
|
46
|
+
/**
|
|
47
|
+
* (optional) The minimum required length of the string
|
|
48
|
+
*/
|
|
49
|
+
minLength?: number;
|
|
50
|
+
/**
|
|
51
|
+
* (optional) The maximum required length of the string
|
|
52
|
+
*/
|
|
53
|
+
maxLength?: number;
|
|
54
|
+
constructor(metadata: TextboxStringDecoratorConfig);
|
|
55
|
+
}
|
|
56
|
+
export declare class AutocompleteStringDecoratorConfig extends StringDecoratorConfig {
|
|
57
|
+
displayStyle: 'autocomplete';
|
|
58
|
+
/**
|
|
59
|
+
* The autocomplete values
|
|
60
|
+
*/
|
|
61
|
+
autocompleteValues: string[];
|
|
62
|
+
/**
|
|
63
|
+
* (optional) The minimum required length of the string
|
|
64
|
+
*/
|
|
65
|
+
minLength?: number;
|
|
66
|
+
/**
|
|
67
|
+
* (optional) The maximum required length of the string
|
|
68
|
+
*/
|
|
69
|
+
maxLength?: number;
|
|
70
|
+
/**
|
|
71
|
+
* (optional) A regex used for validation
|
|
72
|
+
*/
|
|
73
|
+
regex?: RegExp;
|
|
74
|
+
constructor(metadata: AutocompleteStringDecoratorConfig);
|
|
75
|
+
}
|
|
76
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { string } from '../decorators/string.decorator';
|
|
3
|
+
/**
|
|
4
|
+
* The base Entity class.
|
|
5
|
+
*/
|
|
6
|
+
export class Entity {
|
|
7
|
+
}
|
|
8
|
+
__decorate([
|
|
9
|
+
string({
|
|
10
|
+
omitForCreate: true,
|
|
11
|
+
omitForUpdate: true,
|
|
12
|
+
display: false,
|
|
13
|
+
displayStyle: 'line',
|
|
14
|
+
displayName: 'ID',
|
|
15
|
+
required: true
|
|
16
|
+
}),
|
|
17
|
+
__metadata("design:type", String)
|
|
18
|
+
], Entity.prototype, "id", void 0);
|
|
19
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW50aXR5LW1vZGVsLmNsYXNzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vcHJvamVjdHMvbmd4LW1hdGVyaWFsLWVudGl0eS9zcmMvY2xhc3Nlcy9lbnRpdHktbW9kZWwuY2xhc3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE9BQU8sRUFBRSxNQUFNLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUV4RDs7R0FFRztBQUNILE1BQU0sT0FBZ0IsTUFBTTtDQWEzQjtBQURHO0lBUkMsTUFBTSxDQUFDO1FBQ0osYUFBYSxFQUFFLElBQUk7UUFDbkIsYUFBYSxFQUFFLElBQUk7UUFDbkIsT0FBTyxFQUFFLEtBQUs7UUFDZCxZQUFZLEVBQUUsTUFBTTtRQUNwQixXQUFXLEVBQUUsSUFBSTtRQUNqQixRQUFRLEVBQUUsSUFBSTtLQUNqQixDQUFDOztrQ0FDVSIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IHN0cmluZyB9IGZyb20gJy4uL2RlY29yYXRvcnMvc3RyaW5nLmRlY29yYXRvcic7XG5cbi8qKlxuICogVGhlIGJhc2UgRW50aXR5IGNsYXNzLlxuICovXG5leHBvcnQgYWJzdHJhY3QgY2xhc3MgRW50aXR5IHtcbiAgICAvKipcbiAgICAgKiBBIHVuaXF1ZSBpZGVudGlmaWVyIGZvciB0aGUgRW50aXR5XG4gICAgICovXG4gICAgQHN0cmluZyh7XG4gICAgICAgIG9taXRGb3JDcmVhdGU6IHRydWUsXG4gICAgICAgIG9taXRGb3JVcGRhdGU6IHRydWUsXG4gICAgICAgIGRpc3BsYXk6IGZhbHNlLFxuICAgICAgICBkaXNwbGF5U3R5bGU6ICdsaW5lJyxcbiAgICAgICAgZGlzcGxheU5hbWU6ICdJRCcsXG4gICAgICAgIHJlcXVpcmVkOiB0cnVlXG4gICAgfSlcbiAgICBpZCE6IHN0cmluZztcbn0iXX0=
|