ngx-material-entity 0.1.1 → 0.1.4

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.
Files changed (133) hide show
  1. package/CONTRIBUTING.md +7 -1
  2. package/README.md +536 -328
  3. package/classes/base.builder.d.ts +35 -0
  4. package/classes/date.utilities.d.ts +58 -0
  5. package/classes/entity.model.d.ts +13 -0
  6. package/classes/{entity-service.class.d.ts → entity.service.d.ts} +35 -20
  7. package/classes/entity.utilities.d.ts +153 -0
  8. package/components/confirm-dialog/confirm-dialog-data.builder.d.ts +23 -0
  9. package/components/confirm-dialog/confirm-dialog-data.d.ts +18 -8
  10. package/components/confirm-dialog/confirm-dialog.component.d.ts +15 -5
  11. package/components/get-validation-error-message.function.d.ts +3 -2
  12. package/components/input/add-array-item-dialog-data.builder.d.ts +20 -0
  13. package/components/input/add-array-item-dialog-data.d.ts +19 -0
  14. package/components/input/input.component.d.ts +151 -30
  15. package/components/input/input.module.d.ts +7 -4
  16. package/components/table/create-dialog/create-dialog-data.builder.d.ts +21 -0
  17. package/components/table/create-dialog/create-entity-dialog-data.builder.d.ts +21 -0
  18. package/components/table/create-dialog/create-entity-dialog-data.d.ts +4 -5
  19. package/components/table/create-dialog/create-entity-dialog.component.d.ts +21 -8
  20. package/components/table/edit-dialog/edit-dialog-data.builder.d.ts +24 -0
  21. package/components/table/edit-dialog/edit-entity-dialog-data.d.ts +7 -8
  22. package/components/table/edit-dialog/edit-entity-dialog.builder.d.ts +22 -0
  23. package/components/table/edit-dialog/edit-entity-dialog.component.d.ts +25 -8
  24. package/components/table/table-data.builder.d.ts +51 -0
  25. package/components/table/table-data.d.ts +46 -30
  26. package/components/table/table.component.d.ts +53 -7
  27. package/components/table/table.module.d.ts +3 -1
  28. package/decorators/array/array-decorator-internal.data.d.ts +45 -0
  29. package/decorators/array/array-decorator.data.d.ts +129 -0
  30. package/decorators/array/array.decorator.d.ts +9 -0
  31. package/decorators/base/base-property.decorator.d.ts +7 -6
  32. package/decorators/base/decorator-types.enum.d.ts +12 -9
  33. package/decorators/base/dropdown-value.interface.d.ts +14 -0
  34. package/decorators/base/property-decorator-internal.data.d.ts +24 -0
  35. package/decorators/base/property-decorator.data.d.ts +70 -0
  36. package/decorators/boolean/boolean-decorator-internal.data.d.ts +25 -0
  37. package/decorators/boolean/boolean-decorator.data.d.ts +37 -0
  38. package/decorators/boolean/boolean.decorator.d.ts +8 -0
  39. package/decorators/date/date-decorator-internal.data.d.ts +44 -0
  40. package/decorators/date/date-decorator.data.d.ts +129 -0
  41. package/decorators/number/number-decorator-internal.data.d.ts +20 -0
  42. package/decorators/number/number-decorator.data.d.ts +36 -0
  43. package/decorators/number/number.decorator.d.ts +8 -0
  44. package/decorators/object/object-decorator-internal.data.d.ts +11 -0
  45. package/decorators/object/object-decorator.data.d.ts +25 -0
  46. package/decorators/object/object.decorator.d.ts +8 -0
  47. package/decorators/string/string-decorator-internal.data.d.ts +41 -0
  48. package/decorators/string/string-decorator.data.d.ts +77 -0
  49. package/decorators/string/string.decorator.d.ts +8 -0
  50. package/esm2020/classes/base.builder.mjs +43 -0
  51. package/esm2020/classes/date.utilities.mjs +138 -0
  52. package/esm2020/classes/entity.model.mjs +19 -0
  53. package/esm2020/classes/entity.service.mjs +83 -0
  54. package/esm2020/classes/entity.utilities.mjs +538 -0
  55. package/esm2020/components/confirm-dialog/confirm-dialog-data.builder.mjs +44 -0
  56. package/esm2020/components/confirm-dialog/confirm-dialog-data.mjs +1 -1
  57. package/esm2020/components/confirm-dialog/confirm-dialog.component.mjs +18 -22
  58. package/esm2020/components/get-validation-error-message.function.mjs +8 -3
  59. package/esm2020/components/input/add-array-item-dialog-data.builder.mjs +30 -0
  60. package/esm2020/components/input/add-array-item-dialog-data.mjs +2 -0
  61. package/esm2020/components/input/input.component.mjs +240 -36
  62. package/esm2020/components/input/input.module.mjs +23 -9
  63. package/esm2020/components/table/create-dialog/create-dialog-data.builder.mjs +32 -0
  64. package/esm2020/components/table/create-dialog/create-entity-dialog-data.builder.mjs +26 -0
  65. package/esm2020/components/table/create-dialog/create-entity-dialog-data.mjs +1 -1
  66. package/esm2020/components/table/create-dialog/create-entity-dialog.component.mjs +31 -31
  67. package/esm2020/components/table/create-dialog/create-entity-dialog.module.mjs +20 -4
  68. package/esm2020/components/table/edit-dialog/edit-dialog-data.builder.mjs +41 -0
  69. package/esm2020/components/table/edit-dialog/edit-entity-dialog-data.mjs +1 -1
  70. package/esm2020/components/table/edit-dialog/edit-entity-dialog.builder.mjs +27 -0
  71. package/esm2020/components/table/edit-dialog/edit-entity-dialog.component.mjs +45 -49
  72. package/esm2020/components/table/table-data.builder.mjs +105 -0
  73. package/esm2020/components/table/table-data.mjs +1 -1
  74. package/esm2020/components/table/table.component.mjs +91 -83
  75. package/esm2020/components/table/table.module.mjs +12 -4
  76. package/esm2020/decorators/array/array-decorator-internal.data.mjs +51 -0
  77. package/esm2020/decorators/array/array-decorator.data.mjs +7 -0
  78. package/esm2020/decorators/array/array.decorator.mjs +24 -0
  79. package/esm2020/decorators/base/base-property.decorator.mjs +6 -5
  80. package/esm2020/decorators/base/decorator-types.enum.mjs +4 -1
  81. package/esm2020/decorators/base/dropdown-value.interface.mjs +2 -0
  82. package/esm2020/decorators/base/property-decorator-internal.data.mjs +38 -0
  83. package/esm2020/decorators/base/property-decorator.data.mjs +6 -0
  84. package/esm2020/decorators/boolean/boolean-decorator-internal.data.mjs +33 -0
  85. package/esm2020/decorators/boolean/boolean-decorator.data.mjs +7 -0
  86. package/esm2020/decorators/boolean/boolean.decorator.mjs +21 -0
  87. package/esm2020/decorators/date/date-decorator-internal.data.mjs +48 -0
  88. package/esm2020/decorators/date/date-decorator.data.mjs +7 -0
  89. package/esm2020/decorators/number/number-decorator-internal.data.mjs +23 -0
  90. package/esm2020/decorators/number/number-decorator.data.mjs +7 -0
  91. package/esm2020/decorators/number/number.decorator.mjs +18 -0
  92. package/esm2020/decorators/object/object-decorator-internal.data.mjs +12 -0
  93. package/esm2020/decorators/object/object-decorator.data.mjs +7 -0
  94. package/esm2020/decorators/object/object.decorator.mjs +13 -0
  95. package/esm2020/decorators/string/string-decorator-internal.data.mjs +48 -0
  96. package/esm2020/decorators/string/string-decorator.data.mjs +7 -0
  97. package/esm2020/decorators/string/string.decorator.mjs +24 -0
  98. package/esm2020/public-api.mjs +20 -13
  99. package/fesm2015/ngx-material-entity.mjs +1664 -944
  100. package/fesm2015/ngx-material-entity.mjs.map +1 -1
  101. package/fesm2020/ngx-material-entity.mjs +1667 -941
  102. package/fesm2020/ngx-material-entity.mjs.map +1 -1
  103. package/package.json +7 -1
  104. package/public-api.d.ts +21 -10
  105. package/classes/entity-model.class.d.ts +0 -9
  106. package/classes/entity-utilities.class.d.ts +0 -95
  107. package/components/input/array-table/add-array-item-dialog/add-array-item-dialog.component.d.ts +0 -35
  108. package/components/input/array-table/add-array-item-dialog/add-array-item-dialog.module.d.ts +0 -12
  109. package/components/input/array-table/array-table.component.d.ts +0 -34
  110. package/components/input/array-table/array-table.module.d.ts +0 -19
  111. package/components/input/internal-input/internal-input.component.d.ts +0 -57
  112. package/components/input/internal-input/internal-input.module.d.ts +0 -16
  113. package/decorators/array.decorator.d.ts +0 -125
  114. package/decorators/base/property-decorator-config.interface.d.ts +0 -50
  115. package/decorators/boolean.decorator.d.ts +0 -42
  116. package/decorators/number.decorator.d.ts +0 -40
  117. package/decorators/object.decorator.d.ts +0 -27
  118. package/decorators/string.decorator.d.ts +0 -76
  119. package/esm2020/classes/entity-model.class.mjs +0 -19
  120. package/esm2020/classes/entity-service.class.mjs +0 -70
  121. package/esm2020/classes/entity-utilities.class.mjs +0 -296
  122. package/esm2020/components/input/array-table/add-array-item-dialog/add-array-item-dialog.component.mjs +0 -43
  123. package/esm2020/components/input/array-table/add-array-item-dialog/add-array-item-dialog.module.mjs +0 -22
  124. package/esm2020/components/input/array-table/array-table.component.mjs +0 -116
  125. package/esm2020/components/input/array-table/array-table.module.mjs +0 -66
  126. package/esm2020/components/input/internal-input/internal-input.component.mjs +0 -73
  127. package/esm2020/components/input/internal-input/internal-input.module.mjs +0 -54
  128. package/esm2020/decorators/array.decorator.mjs +0 -70
  129. package/esm2020/decorators/base/property-decorator-config.interface.mjs +0 -31
  130. package/esm2020/decorators/boolean.decorator.mjs +0 -44
  131. package/esm2020/decorators/number.decorator.mjs +0 -36
  132. package/esm2020/decorators/object.decorator.mjs +0 -23
  133. package/esm2020/decorators/string.decorator.mjs +0 -61
@@ -1,74 +1,79 @@
1
1
  import { HttpClient } from '@angular/common/http';
2
- import { Entity } from '../../classes/entity-model.class';
3
- import { EntityService } from '../../classes/entity-service.class';
2
+ import { EntityService } from '../../classes/entity.service';
3
+ import { EntityClassNewable } from '../../classes/entity.model';
4
4
  import { ConfirmDialogData } from '../confirm-dialog/confirm-dialog-data';
5
5
  /**
6
6
  * The Definition of a Column inside the table.
7
7
  */
8
- export interface DisplayColumn<EntityType extends Entity> {
8
+ export interface DisplayColumn<EntityType extends object> {
9
9
  /**
10
10
  * The name inside the header.
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
- export interface MultiSelectAction<EntityType extends Entity> {
21
+ export interface MultiSelectAction<EntityType extends object> {
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 multiselect action.
43
+ * The data used to generate a confirmation dialog for the multiSelect action.
42
44
  */
43
45
  confirmDialogData?: ConfirmDialogData;
44
46
  }
45
- export interface BaseData<EntityType extends Entity> {
47
+ /**
48
+ * The base data of the ngx-mat-entity-table.
49
+ */
50
+ export interface BaseData<EntityType extends object> {
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 label on the search bar. Defaults to "Search".
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
- searchLabel?: string;
64
+ EntityServiceClass: new (httpClient: HttpClient) => EntityService<EntityType>;
59
65
  /**
60
- * The label on the button for adding new entities. Defaults to "Create".
66
+ * The Class of the entities to manage.
61
67
  */
62
- createButtonLabel?: string;
68
+ EntityClass?: EntityClassNewable<EntityType>;
63
69
  /**
64
- * The Class of the entities to manage
70
+ * The label on the search bar. Defaults to "Search".
65
71
  */
66
- EntityClass: new (entity?: EntityType) => EntityType;
72
+ searchLabel?: string;
67
73
  /**
68
- * The Class of the service that handles the entities.
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
- EntityServiceClass: new (httpClient: HttpClient) => EntityService<EntityType>;
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?: (enity: EntityType) => string;
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. download as zip-file or mass delete)
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: string;
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
  }
134
- export interface EditDialogData<EntityType extends Entity> {
144
+ /**
145
+ * The data of the default edit-dialog.
146
+ */
147
+ export interface EditDialogData<EntityType extends object> {
135
148
  /**
136
149
  * The title of the default edit-dialog.
137
150
  */
138
- title: (entity: EntityType) => string;
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
- export interface EntitiesData<EntityType extends Entity> {
181
+ /**
182
+ * All the configuration data required to display a ngx-mat-entity-table.
183
+ */
184
+ export interface TableData<EntityType extends object> {
169
185
  /**
170
- * The base data for the entities-component.
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>;
@@ -2,18 +2,25 @@ import { Injector, OnDestroy, OnInit } from '@angular/core';
2
2
  import { MatPaginator } from '@angular/material/paginator';
3
3
  import { MatSort } from '@angular/material/sort';
4
4
  import { MatTableDataSource } from '@angular/material/table';
5
- import { Entity } from '../../classes/entity-model.class';
6
5
  import { SelectionModel } from '@angular/cdk/collections';
7
6
  import { MatDialog } from '@angular/material/dialog';
8
- import { MultiSelectAction, EntitiesData } from './table-data';
7
+ import { MultiSelectAction, TableData } from './table-data';
8
+ import { TableDataInternal } from './table-data.builder';
9
9
  import * as i0 from "@angular/core";
10
- export declare class NgxMatEntityTableComponent<EntityType extends Entity> implements OnInit, OnDestroy {
10
+ /**
11
+ * Generates a fully functional table for displaying, creating, updating and deleting entities
12
+ * based on the configuration passed in the @Input "tableData".
13
+ *
14
+ * It offers a lot of customization options which can be found in "TableData".
15
+ */
16
+ export declare class NgxMatEntityTableComponent<EntityType extends object> implements OnInit, OnDestroy {
11
17
  private readonly dialog;
12
18
  private readonly injector;
13
19
  /**
14
- * The configuration for the entities-component
20
+ * The configuration for the component.
15
21
  */
16
- entitiesData: EntitiesData<EntityType>;
22
+ tableData: TableData<EntityType>;
23
+ data: TableDataInternal<EntityType>;
17
24
  private entityService;
18
25
  private readonly onDestroy;
19
26
  paginator: MatPaginator;
@@ -23,19 +30,58 @@ export declare class NgxMatEntityTableComponent<EntityType extends Entity> imple
23
30
  dataSource: MatTableDataSource<EntityType>;
24
31
  selection: SelectionModel<EntityType>;
25
32
  constructor(dialog: MatDialog, injector: Injector);
33
+ /**
34
+ * Sets up all the configuration for the table and the EntityService.
35
+ */
26
36
  ngOnInit(): void;
27
- private validateInput;
37
+ /**
38
+ * Edits an entity. This either calls the edit-Method provided by the user or uses a default edit-dialog.
39
+ *
40
+ * @param entity - The entity that should be updated.
41
+ * @throws When no EntityClass was provided, as a new call is needed to initialize metadata.
42
+ */
28
43
  editEntity(entity: EntityType): void;
29
44
  private editDefault;
45
+ /**
46
+ * Creates a new Entity. This either calls the create-Method provided by the user or uses a default create-dialog.
47
+ *
48
+ * @throws When no EntityClass was provided, as a new call is needed to initialize metadata.
49
+ */
30
50
  createEntity(): void;
31
51
  private createDefault;
52
+ /**
53
+ * Runs the MultiAction for all selected entries.
54
+ * Also handles confirmation with an additional dialog if configured.
55
+ *
56
+ * @param action - The MultiAction to run.
57
+ */
32
58
  runMultiAction(action: MultiSelectAction<EntityType>): void;
33
59
  private confirmRunMultiAction;
60
+ /**
61
+ * Checks if an MultiAction is disabled (e.g. Because no entries have been selected).
62
+ *
63
+ * @param action - The MultiAction to check.
64
+ * @returns Whether or not the Action can be used.
65
+ */
34
66
  multiActionDisabled(action: MultiSelectAction<EntityType>): boolean;
67
+ /**
68
+ * Toggles all entries in the table.
69
+ */
35
70
  masterToggle(): void;
71
+ /**
72
+ * Checks if all entries in the table have been selected.
73
+ * This is needed to display the "masterToggle"-checkbox correctly.
74
+ *
75
+ * @returns Whether or not all entries in the table have been selected.
76
+ */
36
77
  isAllSelected(): boolean;
37
78
  ngOnDestroy(): void;
79
+ /**
80
+ * Applies the search input to filter the table entries.
81
+ *
82
+ * @param event - The keyup-event which contains the search-string of the user.
83
+ */
38
84
  applyFilter(event: Event): void;
39
85
  static ɵfac: i0.ɵɵFactoryDeclaration<NgxMatEntityTableComponent<any>, never>;
40
- static ɵcmp: i0.ɵɵComponentDeclaration<NgxMatEntityTableComponent<any>, "ngx-mat-entity-table", never, { "entitiesData": "entitiesData"; }, {}, never, never>;
86
+ static ɵcmp: i0.ɵɵComponentDeclaration<NgxMatEntityTableComponent<any>, "ngx-mat-entity-table", never, { "tableData": "tableData"; }, {}, never, never>;
41
87
  }
@@ -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 { CreateDialogData } from '../../components/table/table-data';
2
+ import { EntityClassNewable } from '../../classes/entity.model';
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 object> extends PropertyDecoratorConfigInternal implements EntityArrayDecoratorConfig<EntityType> {
10
+ itemType: DecoratorTypes.OBJECT;
11
+ displayStyle: 'table';
12
+ EntityClass: EntityClassNewable<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 { CreateDialogData } from '../../components/table/table-data';
2
+ import { EntityClassNewable } from '../../classes/entity.model';
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 object> {
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 object> extends ArrayDecoratorConfig {
35
+ itemType: DecoratorTypes.OBJECT;
36
+ displayStyle: 'table';
37
+ /**
38
+ * The EntityClass used for generating the create inputs.
39
+ */
40
+ EntityClass: EntityClassNewable<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,9 @@
1
+ import { AutocompleteStringChipsArrayDecoratorConfig, EntityArrayDecoratorConfig, StringChipsArrayDecoratorConfig } from './array-decorator.data';
2
+ /**
3
+ * Decorator for setting and getting array property metadata.
4
+ *
5
+ * @param metadata - The metadata of the array property.
6
+ * @returns The method that defines the metadata.
7
+ * @throws When the given type of the array-items is unknown.
8
+ */
9
+ export declare function array<EntityType extends object>(metadata: EntityArrayDecoratorConfig<EntityType> | StringChipsArrayDecoratorConfig | AutocompleteStringChipsArrayDecoratorConfig): (target: object, propertyKey: string) => void;
@@ -1,9 +1,10 @@
1
1
  import { DecoratorTypes } from './decorator-types.enum';
2
- import { PropertyDecoratorConfig } from './property-decorator-config.interface';
2
+ import { PropertyDecoratorConfigInternal } from './property-decorator-internal.data';
3
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
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: PropertyDecoratorConfig, type: DecoratorTypes): (target: object, propertyKey: string) => void;
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
- 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';
1
+ import { AutocompleteStringChipsArrayDecoratorConfigInternal, EntityArrayDecoratorConfigInternal, StringChipsArrayDecoratorConfigInternal } from '../array/array-decorator-internal.data';
2
+ import { CheckboxBooleanDecoratorConfigInternal, DropdownBooleanDecoratorConfigInternal, ToggleBooleanDecoratorConfigInternal } from '../boolean/boolean-decorator-internal.data';
3
+ import { DateRangeDateDecoratorConfigInternal, DateTimeDateDecoratorConfigInternal, DefaultDateDecoratorConfigInternal } from '../date/date-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
  */
@@ -20,9 +20,12 @@ export declare enum DecoratorTypes {
20
20
  OBJECT = "object",
21
21
  ARRAY = "array",
22
22
  ARRAY_STRING_CHIPS = "arrayStringChips",
23
- ARRAY_STRING_AUTOCOMPLETE_CHIPS = "arrayStringAutocompleteChips"
23
+ ARRAY_STRING_AUTOCOMPLETE_CHIPS = "arrayStringAutocompleteChips",
24
+ DATE = "date",
25
+ DATE_RANGE = "dateRange",
26
+ DATE_TIME = "dateTime"
24
27
  }
25
28
  /**
26
- * Gives the metadata-config Type based ont the DecoratorTypes enum
29
+ * Gives the metadata-config Type based on the DecoratorTypes enum.
27
30
  */
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;
31
+ 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<object> : T extends DecoratorTypes.ARRAY ? EntityArrayDecoratorConfigInternal<object> : T extends DecoratorTypes.ARRAY_STRING_CHIPS ? StringChipsArrayDecoratorConfigInternal : T extends DecoratorTypes.ARRAY_STRING_AUTOCOMPLETE_CHIPS ? AutocompleteStringChipsArrayDecoratorConfigInternal : T extends DecoratorTypes.DATE ? DefaultDateDecoratorConfigInternal : T extends DecoratorTypes.DATE_RANGE ? DateRangeDateDecoratorConfigInternal : T extends DecoratorTypes.DATE_TIME ? DateTimeDateDecoratorConfigInternal : never;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The definition for a dropdown value.
3
+ * Consists of the name to display in the dropdown and the actual value.
4
+ */
5
+ export interface DropdownValue<T> {
6
+ /**
7
+ * The name to display in the dropdown.
8
+ */
9
+ displayName: string;
10
+ /**
11
+ * The actual value.
12
+ */
13
+ value: T;
14
+ }
@@ -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
+ }