ngx-material-entity 0.1.1 → 0.1.2

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 (105) hide show
  1. package/CONTRIBUTING.md +7 -1
  2. package/README.md +3 -2
  3. package/classes/entity-model.class.d.ts +1 -1
  4. package/classes/entity-service.class.d.ts +27 -17
  5. package/classes/entity-utilities.class.d.ts +62 -45
  6. package/components/confirm-dialog/confirm-dialog-data.builder.d.ts +24 -0
  7. package/components/confirm-dialog/confirm-dialog-data.d.ts +14 -8
  8. package/components/confirm-dialog/confirm-dialog.component.d.ts +4 -5
  9. package/components/get-validation-error-message.function.d.ts +3 -2
  10. package/components/input/array-table/add-array-item-dialog/add-array-item-dialog-data.builder.d.ts +17 -0
  11. package/components/input/array-table/add-array-item-dialog/add-array-item-dialog-data.d.ts +17 -0
  12. package/components/input/array-table/add-array-item-dialog/add-array-item-dialog.component.d.ts +5 -18
  13. package/components/input/array-table/array-table.component.d.ts +3 -3
  14. package/components/input/input.component.d.ts +18 -21
  15. package/components/input/internal-input/internal-input.component.d.ts +14 -17
  16. package/components/table/create-dialog/create-dialog-data.builder.d.ts +20 -0
  17. package/components/table/create-dialog/create-entity-dialog-data.builder.d.ts +16 -0
  18. package/components/table/create-dialog/create-entity-dialog-data.d.ts +2 -2
  19. package/components/table/create-dialog/create-entity-dialog.component.d.ts +4 -2
  20. package/components/table/edit-dialog/edit-dialog-data.builder.d.ts +27 -0
  21. package/components/table/edit-dialog/edit-entity-dialog-data.d.ts +5 -5
  22. package/components/table/edit-dialog/edit-entity-dialog.builder.d.ts +17 -0
  23. package/components/table/edit-dialog/edit-entity-dialog.component.d.ts +4 -2
  24. package/components/table/table-data.builder.d.ts +40 -0
  25. package/components/table/table-data.d.ts +26 -22
  26. package/components/table/table.component.d.ts +6 -5
  27. package/decorators/array/array-decorator-internal.data.d.ts +34 -0
  28. package/decorators/{array.decorator.d.ts → array/array-decorator.data.d.ts} +32 -37
  29. package/decorators/array/array.decorator.d.ts +10 -0
  30. package/decorators/base/base-property.decorator.d.ts +7 -6
  31. package/decorators/base/decorator-types.enum.d.ts +7 -7
  32. package/decorators/base/property-decorator-internal.data.d.ts +11 -0
  33. package/decorators/base/{property-decorator-config.interface.d.ts → property-decorator.data.d.ts} +11 -12
  34. package/decorators/boolean/boolean-decorator-internal.data.d.ts +16 -0
  35. package/decorators/boolean/boolean-decorator.data.d.ts +28 -0
  36. package/decorators/boolean/boolean.decorator.d.ts +8 -0
  37. package/decorators/number/number-decorator-internal.data.d.ts +16 -0
  38. package/decorators/number/number-decorator.data.d.ts +32 -0
  39. package/decorators/number/number.decorator.d.ts +8 -0
  40. package/decorators/object/object-decorator-internal.data.d.ts +8 -0
  41. package/decorators/object/object-decorator.data.d.ts +22 -0
  42. package/decorators/object/object.decorator.d.ts +9 -0
  43. package/decorators/string/string-decorator-internal.data.d.ts +31 -0
  44. package/decorators/string/string-decorator.data.d.ts +67 -0
  45. package/decorators/string/string.decorator.d.ts +8 -0
  46. package/esm2020/classes/entity-model.class.mjs +2 -2
  47. package/esm2020/classes/entity-service.class.mjs +20 -14
  48. package/esm2020/classes/entity-utilities.class.mjs +108 -75
  49. package/esm2020/components/confirm-dialog/confirm-dialog-data.builder.mjs +77 -0
  50. package/esm2020/components/confirm-dialog/confirm-dialog-data.mjs +1 -1
  51. package/esm2020/components/confirm-dialog/confirm-dialog.component.mjs +7 -22
  52. package/esm2020/components/get-validation-error-message.function.mjs +4 -3
  53. package/esm2020/components/input/array-table/add-array-item-dialog/add-array-item-dialog-data.builder.mjs +33 -0
  54. package/esm2020/components/input/array-table/add-array-item-dialog/add-array-item-dialog-data.mjs +2 -0
  55. package/esm2020/components/input/array-table/add-array-item-dialog/add-array-item-dialog.component.mjs +7 -5
  56. package/esm2020/components/input/array-table/array-table.component.mjs +14 -11
  57. package/esm2020/components/input/input.component.mjs +3 -6
  58. package/esm2020/components/input/internal-input/internal-input.component.mjs +1 -4
  59. package/esm2020/components/table/create-dialog/create-dialog-data.builder.mjs +54 -0
  60. package/esm2020/components/table/create-dialog/create-entity-dialog-data.builder.mjs +18 -0
  61. package/esm2020/components/table/create-dialog/create-entity-dialog-data.mjs +1 -1
  62. package/esm2020/components/table/create-dialog/create-entity-dialog.component.mjs +14 -21
  63. package/esm2020/components/table/edit-dialog/edit-dialog-data.builder.mjs +81 -0
  64. package/esm2020/components/table/edit-dialog/edit-entity-dialog-data.mjs +1 -1
  65. package/esm2020/components/table/edit-dialog/edit-entity-dialog.builder.mjs +19 -0
  66. package/esm2020/components/table/edit-dialog/edit-entity-dialog.component.mjs +21 -36
  67. package/esm2020/components/table/table-data.builder.mjs +89 -0
  68. package/esm2020/components/table/table-data.mjs +1 -1
  69. package/esm2020/components/table/table.component.mjs +41 -80
  70. package/esm2020/decorators/array/array-decorator-internal.data.mjs +40 -0
  71. package/esm2020/decorators/array/array-decorator.data.mjs +7 -0
  72. package/esm2020/decorators/array/array.decorator.mjs +24 -0
  73. package/esm2020/decorators/base/base-property.decorator.mjs +6 -5
  74. package/esm2020/decorators/base/decorator-types.enum.mjs +1 -1
  75. package/esm2020/decorators/base/property-decorator-internal.data.mjs +15 -0
  76. package/esm2020/decorators/base/property-decorator.data.mjs +6 -0
  77. package/esm2020/decorators/boolean/boolean-decorator-internal.data.mjs +22 -0
  78. package/esm2020/decorators/boolean/boolean-decorator.data.mjs +7 -0
  79. package/esm2020/decorators/boolean/boolean.decorator.mjs +21 -0
  80. package/esm2020/decorators/number/number-decorator-internal.data.mjs +17 -0
  81. package/esm2020/decorators/number/number-decorator.data.mjs +7 -0
  82. package/esm2020/decorators/number/number.decorator.mjs +18 -0
  83. package/esm2020/decorators/object/object-decorator-internal.data.mjs +9 -0
  84. package/esm2020/decorators/object/object-decorator.data.mjs +7 -0
  85. package/esm2020/decorators/object/object.decorator.mjs +13 -0
  86. package/esm2020/decorators/string/string-decorator-internal.data.mjs +36 -0
  87. package/esm2020/decorators/string/string-decorator.data.mjs +7 -0
  88. package/esm2020/decorators/string/string.decorator.mjs +24 -0
  89. package/esm2020/public-api.mjs +15 -10
  90. package/fesm2015/ngx-material-entity.mjs +1019 -683
  91. package/fesm2015/ngx-material-entity.mjs.map +1 -1
  92. package/fesm2020/ngx-material-entity.mjs +1005 -684
  93. package/fesm2020/ngx-material-entity.mjs.map +1 -1
  94. package/package.json +1 -1
  95. package/public-api.d.ts +16 -7
  96. package/decorators/boolean.decorator.d.ts +0 -42
  97. package/decorators/number.decorator.d.ts +0 -40
  98. package/decorators/object.decorator.d.ts +0 -27
  99. package/decorators/string.decorator.d.ts +0 -76
  100. package/esm2020/decorators/array.decorator.mjs +0 -70
  101. package/esm2020/decorators/base/property-decorator-config.interface.mjs +0 -31
  102. package/esm2020/decorators/boolean.decorator.mjs +0 -44
  103. package/esm2020/decorators/number.decorator.mjs +0 -36
  104. package/esm2020/decorators/object.decorator.mjs +0 -23
  105. package/esm2020/decorators/string.decorator.mjs +0 -61
@@ -0,0 +1,16 @@
1
+ import { EntityService } from '../../../classes/entity-service.class';
2
+ import { Entity } from '../../../classes/entity-model.class';
3
+ import { CreateEntityDialogData } from './create-entity-dialog-data';
4
+ import { HttpClient } from '@angular/common/http';
5
+ import { CreateDialogDataInternal } from './create-dialog-data.builder';
6
+ export declare class CreateEntityDialogDataInternal<EntityType extends Entity> implements CreateEntityDialogData<EntityType> {
7
+ entity: EntityType;
8
+ EntityServiceClass: new (httpClient: HttpClient) => EntityService<EntityType>;
9
+ createDialogData: CreateDialogDataInternal;
10
+ constructor(entity: EntityType, EntityServiceClass: new (httpClient: HttpClient) => EntityService<EntityType>, createDialogData: CreateDialogDataInternal);
11
+ }
12
+ export declare class CreateEntityDialogDataBuilder<EntityType extends Entity> {
13
+ createDialogData: CreateEntityDialogDataInternal<EntityType>;
14
+ private readonly dataInput;
15
+ constructor(data: CreateEntityDialogData<EntityType>);
16
+ }
@@ -3,7 +3,7 @@ import { EntityService } from '../../../classes/entity-service.class';
3
3
  import { Entity } from '../../../classes/entity-model.class';
4
4
  import { CreateDialogData } from '../table-data';
5
5
  /**
6
- * The Definition of the Create Entity Dialog Data
6
+ * The Definition of the Create Entity Dialog Data.
7
7
  */
8
8
  export interface CreateEntityDialogData<EntityType extends Entity> {
9
9
  /**
@@ -17,5 +17,5 @@ export interface CreateEntityDialogData<EntityType extends Entity> {
17
17
  /**
18
18
  * The info of the generic create-dialog.
19
19
  */
20
- createDialogData: CreateDialogData;
20
+ createDialogData?: CreateDialogData;
21
21
  }
@@ -3,18 +3,20 @@ import { MatDialog, MatDialogRef } from '@angular/material/dialog';
3
3
  import { EntityService } from '../../../classes/entity-service.class';
4
4
  import { Entity } from '../../../classes/entity-model.class';
5
5
  import { EntityUtilities } from '../../../classes/entity-utilities.class';
6
+ import { CreateEntityDialogDataInternal } from './create-entity-dialog-data.builder';
6
7
  import { CreateEntityDialogData } from './create-entity-dialog-data';
7
8
  import * as i0 from "@angular/core";
8
9
  export declare class NgxMatEntityCreateDialogComponent<EntityType extends Entity> implements OnInit {
9
- data: CreateEntityDialogData<EntityType>;
10
+ private readonly inputData;
10
11
  dialogRef: MatDialogRef<NgxMatEntityCreateDialogComponent<EntityType>>;
11
12
  private readonly injector;
12
13
  private readonly dialog;
13
14
  EntityUtilities: typeof EntityUtilities;
14
15
  entityKeys: (keyof EntityType)[];
15
16
  entityService: EntityService<EntityType>;
17
+ data: CreateEntityDialogDataInternal<EntityType>;
16
18
  getWidth: typeof EntityUtilities.getWidth;
17
- constructor(data: CreateEntityDialogData<EntityType>, dialogRef: MatDialogRef<NgxMatEntityCreateDialogComponent<EntityType>>, injector: Injector, dialog: MatDialog);
19
+ constructor(inputData: CreateEntityDialogData<EntityType>, dialogRef: MatDialogRef<NgxMatEntityCreateDialogComponent<EntityType>>, injector: Injector, dialog: MatDialog);
18
20
  ngOnInit(): void;
19
21
  private setEntityKeys;
20
22
  create(): void;
@@ -0,0 +1,27 @@
1
+ import { Entity } from '../../../classes/entity-model.class';
2
+ import { ConfirmDialogData } from '../../confirm-dialog/confirm-dialog-data';
3
+ import { EditDialogData } from '../table-data';
4
+ export declare class EditDialogDataInternal<EntityType extends Entity> implements EditDialogData<EntityType> {
5
+ title: (entity: EntityType) => string;
6
+ confirmButtonLabel: string;
7
+ deleteButtonLabel: string;
8
+ cancelButtonLabel: string;
9
+ deleteRequiresConfirmDialog: boolean;
10
+ editRequiresConfirmDialog: boolean;
11
+ confirmDeleteDialogData: ConfirmDialogData;
12
+ confirmEditDialogData: ConfirmDialogData;
13
+ constructor(title: (entity: EntityType) => string, confirmButtonLabel: string, deleteButtonLabel: string, cancelButtonLabel: string, deleteRequiresConfirmDialog: boolean, editRequiresConfirmDialog: boolean, confirmDeleteDialogData: ConfirmDialogData, confirmEditDialogData: ConfirmDialogData);
14
+ }
15
+ export declare class EditDialogDataBuilder<EntityType extends Entity> {
16
+ editDialogData: EditDialogDataInternal<EntityType>;
17
+ private readonly dataInput?;
18
+ constructor(data?: EditDialogData<EntityType>);
19
+ withDefaultTitle(title: (entity: EntityType) => string): EditDialogDataBuilder<EntityType>;
20
+ withDefaultConfirmButtonLabel(label: string): EditDialogDataBuilder<EntityType>;
21
+ withDefaultDeleteButtonLabel(label: string): EditDialogDataBuilder<EntityType>;
22
+ withDefaultCancelButtonLabel(label: string): EditDialogDataBuilder<EntityType>;
23
+ withDefaultDeleteRequiresConfirmDialog(deleteRequiresConfirmDialog: boolean): EditDialogDataBuilder<EntityType>;
24
+ withDefaultEditRequiresConfirmDialog(editRequiresConfirmDialog: boolean): EditDialogDataBuilder<EntityType>;
25
+ withDefaultConfirmDeleteDialogData(confirmDeleteDialogData: ConfirmDialogData): EditDialogDataBuilder<EntityType>;
26
+ withDefaultConfirmEditDialogData(confirmEditDialogData: ConfirmDialogData): EditDialogDataBuilder<EntityType>;
27
+ }
@@ -3,11 +3,11 @@ import { EntityService } from '../../../classes/entity-service.class';
3
3
  import { Entity } from '../../../classes/entity-model.class';
4
4
  import { EditDialogData } from '../table-data';
5
5
  /**
6
- * The Definition of the Edit Entity Dialog Data
6
+ * The Definition of the Edit Entity Dialog Data.
7
7
  */
8
8
  export interface EditEntityDialogData<EntityType extends Entity> {
9
9
  /**
10
- * The entity to edit
10
+ * The entity to edit.
11
11
  */
12
12
  entity: EntityType;
13
13
  /**
@@ -17,9 +17,9 @@ export interface EditEntityDialogData<EntityType extends Entity> {
17
17
  /**
18
18
  * The info of the generic edit-dialog.
19
19
  */
20
- editDialogData: EditDialogData<EntityType>;
20
+ editDialogData?: EditDialogData<EntityType>;
21
21
  /**
22
- * Whether or not the user can delete this specific entity
22
+ * Whether or not the user can delete this specific entity.
23
23
  */
24
- allowDelete: (entity: EntityType) => boolean;
24
+ allowDelete?: (entity: EntityType) => boolean;
25
25
  }
@@ -0,0 +1,17 @@
1
+ import { EntityService } from '../../../classes/entity-service.class';
2
+ import { Entity } from '../../../classes/entity-model.class';
3
+ import { HttpClient } from '@angular/common/http';
4
+ import { EditEntityDialogData } from './edit-entity-dialog-data';
5
+ import { EditDialogDataInternal } from './edit-dialog-data.builder';
6
+ export declare class EditEntityDialogDataInternal<EntityType extends Entity> implements EditEntityDialogData<EntityType> {
7
+ entity: EntityType;
8
+ EntityServiceClass: new (httpClient: HttpClient) => EntityService<EntityType>;
9
+ editDialogData: EditDialogDataInternal<EntityType>;
10
+ allowDelete: (entity: EntityType) => boolean;
11
+ constructor(entity: EntityType, EntityServiceClass: new (httpClient: HttpClient) => EntityService<EntityType>, editDialogData: EditDialogDataInternal<EntityType>, allowDelete: (entity: EntityType) => boolean);
12
+ }
13
+ export declare class EditEntityDialogDataBuilder<EntityType extends Entity> {
14
+ editDialogData: EditEntityDialogDataInternal<EntityType>;
15
+ private readonly dataInput;
16
+ constructor(data: EditEntityDialogData<EntityType>);
17
+ }
@@ -4,9 +4,10 @@ import { EntityService } from '../../../classes/entity-service.class';
4
4
  import { Entity } from '../../../classes/entity-model.class';
5
5
  import { EntityUtilities } from '../../../classes/entity-utilities.class';
6
6
  import { EditEntityDialogData } from './edit-entity-dialog-data';
7
+ import { EditEntityDialogDataInternal } from './edit-entity-dialog.builder';
7
8
  import * as i0 from "@angular/core";
8
9
  export declare class NgxMatEntityEditDialogComponent<EntityType extends Entity> implements OnInit {
9
- data: EditEntityDialogData<EntityType>;
10
+ private readonly inputData;
10
11
  dialogRef: MatDialogRef<NgxMatEntityEditDialogComponent<EntityType>>;
11
12
  private readonly injector;
12
13
  private readonly dialog;
@@ -14,8 +15,9 @@ export declare class NgxMatEntityEditDialogComponent<EntityType extends Entity>
14
15
  entityKeys: (keyof EntityType)[];
15
16
  entityService: EntityService<EntityType>;
16
17
  entityPriorChanges: EntityType;
18
+ data: EditEntityDialogDataInternal<EntityType>;
17
19
  getWidth: typeof EntityUtilities.getWidth;
18
- constructor(data: EditEntityDialogData<EntityType>, dialogRef: MatDialogRef<NgxMatEntityEditDialogComponent<EntityType>>, injector: Injector, dialog: MatDialog);
20
+ constructor(inputData: EditEntityDialogData<EntityType>, dialogRef: MatDialogRef<NgxMatEntityEditDialogComponent<EntityType>>, injector: Injector, dialog: MatDialog);
19
21
  ngOnInit(): void;
20
22
  private setEntityKeys;
21
23
  edit(): void;
@@ -0,0 +1,40 @@
1
+ import { EntityService } from '../../classes/entity-service.class';
2
+ import { Entity } from '../../classes/entity-model.class';
3
+ import { CreateDialogDataInternal } from './create-dialog/create-dialog-data.builder';
4
+ import { EditDialogDataInternal } from './edit-dialog/edit-dialog-data.builder';
5
+ import { BaseData, DisplayColumn, MultiSelectAction, TableData } from './table-data';
6
+ import { HttpClient } from '@angular/common/http';
7
+ export declare class TableDataInternal<EntityType extends Entity> implements TableData<EntityType> {
8
+ baseData: BaseDataInternal<EntityType>;
9
+ createDialogData: CreateDialogDataInternal;
10
+ editDialogData: EditDialogDataInternal<EntityType>;
11
+ constructor(baseData: BaseDataInternal<EntityType>, createDialogData: CreateDialogDataInternal, editDialogData: EditDialogDataInternal<EntityType>);
12
+ }
13
+ export declare class BaseDataBuilder<EntityType extends Entity> {
14
+ baseData: BaseDataInternal<EntityType>;
15
+ private readonly dataInput;
16
+ constructor(data: BaseData<EntityType>);
17
+ }
18
+ export declare class BaseDataInternal<EntityType extends Entity> implements BaseData<EntityType> {
19
+ title: string;
20
+ displayColumns: DisplayColumn<EntityType>[];
21
+ EntityServiceClass: new (httpClient: HttpClient) => EntityService<EntityType>;
22
+ searchLabel: string;
23
+ createButtonLabel: string;
24
+ searchString: (enity: EntityType) => string;
25
+ allowCreate: boolean;
26
+ allowEdit: (entity: EntityType) => boolean;
27
+ allowDelete: (entity: EntityType) => boolean;
28
+ multiSelectActions: MultiSelectAction<EntityType>[];
29
+ multiSelectLabel: string;
30
+ EntityClass?: new (entity?: EntityType) => EntityType;
31
+ edit?: (entity: EntityType) => unknown;
32
+ create?: (entity: EntityType) => unknown;
33
+ constructor(title: string, displayColumns: DisplayColumn<EntityType>[], EntityServiceClass: new (httpClient: HttpClient) => EntityService<EntityType>, searchLabel: string, createButtonLabel: string, searchString: (enity: EntityType) => string, allowCreate: boolean, allowEdit: (entity: EntityType) => boolean, allowDelete: (entity: EntityType) => boolean, multiSelectActions: MultiSelectAction<EntityType>[], multiSelectLabel: string, EntityClass?: new (entity?: EntityType) => EntityType, edit?: (entity: EntityType) => unknown, create?: (entity: EntityType) => unknown);
34
+ }
35
+ export declare class TableDataBuilder<EntityType extends Entity> {
36
+ tableData: TableDataInternal<EntityType>;
37
+ private readonly dataInput;
38
+ constructor(data: TableData<EntityType>);
39
+ private validateInput;
40
+ }
@@ -11,29 +11,31 @@ 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;
@@ -44,31 +46,31 @@ export interface MultiSelectAction<EntityType extends Entity> {
44
46
  }
45
47
  export interface BaseData<EntityType extends Entity> {
46
48
  /**
47
- * The title of the table
49
+ * The title of the table.
48
50
  */
49
51
  title: string;
50
52
  /**
51
53
  * 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
54
+ * and the value, which is a function that generates the value to display inside a column.
53
55
  */
54
56
  displayColumns: DisplayColumn<EntityType>[];
55
57
  /**
56
- * The label on the search bar. Defaults to "Search".
58
+ * The Class of the service that handles the entities.
59
+ * Needs to be injectable and an extension of the "EntityService"-Class.
57
60
  */
58
- searchLabel?: string;
61
+ EntityServiceClass: new (httpClient: HttpClient) => EntityService<EntityType>;
59
62
  /**
60
- * The label on the button for adding new entities. Defaults to "Create".
63
+ * The Class of the entities to manage.
61
64
  */
62
- createButtonLabel?: string;
65
+ EntityClass?: new (entity?: EntityType) => EntityType;
63
66
  /**
64
- * The Class of the entities to manage
67
+ * The label on the search bar. Defaults to "Search".
65
68
  */
66
- EntityClass: new (entity?: EntityType) => EntityType;
69
+ searchLabel?: string;
67
70
  /**
68
- * The Class of the service that handles the entities.
69
- * Needs to be injectable and an extension of the "EntityService"-Class
71
+ * The label on the button for adding new entities. Defaults to "Create".
70
72
  */
71
- EntityServiceClass: new (httpClient: HttpClient) => EntityService<EntityType>;
73
+ createButtonLabel?: string;
72
74
  /**
73
75
  * Takes a custom edit method which runs when you click on a entity.
74
76
  * If you don't need any special editing of entries you can also omit this.
@@ -87,21 +89,23 @@ export interface BaseData<EntityType extends Entity> {
87
89
  searchString?: (enity: EntityType) => string;
88
90
  /**
89
91
  * Defines whether or not the user can add new entities.
92
+ *
90
93
  * @default true
91
94
  */
92
95
  allowCreate?: boolean;
93
96
  /**
94
97
  * Defines whether or not the user can edit entities.
98
+ *
95
99
  * @default () => true
96
100
  */
97
101
  allowEdit?: (entity: EntityType) => boolean;
98
102
  /**
99
- * Whether or not the user can delete this specific entity
103
+ * Whether or not the user can delete this specific entity.
100
104
  */
101
105
  allowDelete?: (entity: EntityType) => boolean;
102
106
  /**
103
107
  * All Actions that you want to run on multiple entities can be defined here.
104
- * (e.g. download as zip-file or mass delete)
108
+ * (e.g. Download as zip-file or mass delete).
105
109
  */
106
110
  multiSelectActions?: MultiSelectAction<EntityType>[];
107
111
  /**
@@ -113,7 +117,7 @@ export interface CreateDialogData {
113
117
  /**
114
118
  * The title of the default create-dialog.
115
119
  */
116
- title: string;
120
+ title?: string;
117
121
  /**
118
122
  * The label on the create-button of the default create-dialog. Defaults to "Create".
119
123
  */
@@ -135,7 +139,7 @@ export interface EditDialogData<EntityType extends Entity> {
135
139
  /**
136
140
  * The title of the default edit-dialog.
137
141
  */
138
- title: (entity: EntityType) => string;
142
+ title?: (entity: EntityType) => string;
139
143
  /**
140
144
  * The label on the confirm-button of the default edit-dialog. Defaults to "Save".
141
145
  */
@@ -165,9 +169,9 @@ export interface EditDialogData<EntityType extends Entity> {
165
169
  */
166
170
  confirmEditDialogData?: ConfirmDialogData;
167
171
  }
168
- export interface EntitiesData<EntityType extends Entity> {
172
+ export interface TableData<EntityType extends Entity> {
169
173
  /**
170
- * The base data for the entities-component.
174
+ * The base data for the table-component.
171
175
  * Includes stuff like the title for the table, what to display inside the rows etc.
172
176
  */
173
177
  baseData: BaseData<EntityType>;
@@ -5,15 +5,17 @@ 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, EntitiesData } from './table-data';
8
+ import { MultiSelectAction, TableData } from './table-data';
9
+ import { TableDataInternal } from './table-data.builder';
9
10
  import * as i0 from "@angular/core";
10
11
  export declare class NgxMatEntityTableComponent<EntityType extends Entity> implements OnInit, OnDestroy {
11
12
  private readonly dialog;
12
13
  private readonly injector;
13
14
  /**
14
- * The configuration for the entities-component
15
+ * The configuration for the component.
15
16
  */
16
- entitiesData: EntitiesData<EntityType>;
17
+ tableData: TableData<EntityType>;
18
+ data: TableDataInternal<EntityType>;
17
19
  private entityService;
18
20
  private readonly onDestroy;
19
21
  paginator: MatPaginator;
@@ -24,7 +26,6 @@ export declare class NgxMatEntityTableComponent<EntityType extends Entity> imple
24
26
  selection: SelectionModel<EntityType>;
25
27
  constructor(dialog: MatDialog, injector: Injector);
26
28
  ngOnInit(): void;
27
- private validateInput;
28
29
  editEntity(entity: EntityType): void;
29
30
  private editDefault;
30
31
  createEntity(): void;
@@ -37,5 +38,5 @@ export declare class NgxMatEntityTableComponent<EntityType extends Entity> imple
37
38
  ngOnDestroy(): void;
38
39
  applyFilter(event: Event): void;
39
40
  static ɵfac: i0.ɵɵFactoryDeclaration<NgxMatEntityTableComponent<any>, never>;
40
- static ɵcmp: i0.ɵɵComponentDeclaration<NgxMatEntityTableComponent<any>, "ngx-mat-entity-table", never, { "entitiesData": "entitiesData"; }, {}, never, never>;
41
+ static ɵcmp: i0.ɵɵComponentDeclaration<NgxMatEntityTableComponent<any>, "ngx-mat-entity-table", never, { "tableData": "tableData"; }, {}, never, never>;
41
42
  }
@@ -0,0 +1,34 @@
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
+ export declare class EntityArrayDecoratorConfigInternal<EntityType extends Entity> extends PropertyDecoratorConfigInternal implements EntityArrayDecoratorConfig<EntityType> {
7
+ itemType: DecoratorTypes.OBJECT;
8
+ displayStyle: 'table';
9
+ EntityClass: new (entity?: EntityType) => EntityType;
10
+ displayColumns: ArrayTableDisplayColumn<EntityType>[];
11
+ createDialogData?: CreateDialogData;
12
+ createInline: boolean;
13
+ missingErrorMessage: string;
14
+ constructor(data: EntityArrayDecoratorConfig<EntityType>);
15
+ }
16
+ export declare class StringChipsArrayDecoratorConfigInternal extends PropertyDecoratorConfigInternal implements StringChipsArrayDecoratorConfig {
17
+ itemType: DecoratorTypes.STRING;
18
+ displayStyle: 'chips';
19
+ deleteHtml?: string;
20
+ minLength?: number;
21
+ maxLength?: number;
22
+ regex?: RegExp;
23
+ constructor(data: StringChipsArrayDecoratorConfig);
24
+ }
25
+ export declare class AutocompleteStringChipsArrayDecoratorConfigInternal extends PropertyDecoratorConfigInternal implements AutocompleteStringChipsArrayDecoratorConfig {
26
+ autocompleteValues: string[];
27
+ itemType: DecoratorTypes.STRING_AUTOCOMPLETE;
28
+ displayStyle: 'chips';
29
+ deleteHtml?: string;
30
+ minLength?: number;
31
+ maxLength?: number;
32
+ regex?: RegExp;
33
+ constructor(data: AutocompleteStringChipsArrayDecoratorConfig);
34
+ }
@@ -1,52 +1,43 @@
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;
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';
10
5
  export interface ArrayTableDisplayColumn<EntityType extends Entity> {
11
6
  /**
12
7
  * The name inside the header.
13
8
  */
14
9
  displayName: string;
15
10
  /**
16
- * A method to get the value inside an row
11
+ * A method to get the value inside an row.
17
12
  */
18
13
  value: (entity: EntityType) => string;
19
14
  }
20
15
  /**
21
- * Interface definition for the @array metadata
16
+ * Interface definition for the @array metadata.
22
17
  */
23
18
  declare abstract class ArrayDecoratorConfig extends PropertyDecoratorConfig {
24
19
  /**
25
- * How to display the string
20
+ * How to display the string.
26
21
  */
27
22
  displayStyle: 'table' | 'chips';
28
23
  /**
29
- * The type of the items inside the array
24
+ * The type of the items inside the array.
30
25
  */
31
26
  itemType: DecoratorTypes;
32
- /**
33
- * The error-message to display when the array is required but contains no values
34
- */
35
- missingErrorMessage?: string;
36
27
  }
37
28
  /**
38
- * Definition for an array of Entities
29
+ * Definition for an array of Entities.
39
30
  */
40
- export declare class EntityArrayDecoratorConfig<EntityType extends Entity> extends ArrayDecoratorConfig {
31
+ export interface EntityArrayDecoratorConfig<EntityType extends Entity> extends ArrayDecoratorConfig {
41
32
  itemType: DecoratorTypes.OBJECT;
42
33
  displayStyle: 'table';
43
34
  /**
44
- * The EntityClass used for generating the create inputs
35
+ * The EntityClass used for generating the create inputs.
45
36
  */
46
37
  EntityClass: new (entity?: EntityType) => EntityType;
47
38
  /**
48
39
  * 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
40
+ * and the value, which is a function that generates the value to display inside a column.
50
41
  */
51
42
  displayColumns: ArrayTableDisplayColumn<EntityType>[];
52
43
  /**
@@ -57,69 +48,73 @@ export declare class EntityArrayDecoratorConfig<EntityType extends Entity> exten
57
48
  /**
58
49
  * Whether or not the form for adding items to the array
59
50
  * should be displayed inline.
51
+ *
60
52
  * @default true
61
53
  */
62
54
  createInline?: boolean;
63
- constructor(metadata: EntityArrayDecoratorConfig<EntityType>);
55
+ /**
56
+ * The error-message to display when the array is required but contains no values.
57
+ */
58
+ missingErrorMessage?: string;
64
59
  }
65
60
  /**
66
- * Definition for an array of strings displayed as a chips list
61
+ * Definition for an array of strings displayed as a chips list.
67
62
  */
68
- export declare class StringChipsArrayDecoratorConfig extends ArrayDecoratorConfig {
63
+ export interface StringChipsArrayDecoratorConfig extends ArrayDecoratorConfig {
69
64
  itemType: DecoratorTypes.STRING;
70
65
  displayStyle: 'chips';
71
66
  /**
72
67
  * The html inside the delete-button.
73
68
  * Please note that custom tags such as <mat-icon></mat-icon>
74
69
  * 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>`
70
+ * You can however work around this by using `<span class="material-icons"></span>`.
71
+ *
76
72
  * @default <mat-icon>cancel</mat-icon>
77
73
  */
78
74
  deleteHtml?: string;
79
75
  /**
80
- * (optional) The minimum required length of the string
76
+ * The minimum required length of the string.
81
77
  */
82
78
  minLength?: number;
83
79
  /**
84
- * (optional) The maximum required length of the string
80
+ * The maximum required length of the string.
85
81
  */
86
82
  maxLength?: number;
87
83
  /**
88
- * (optional) A regex used for validation
84
+ * A regex used for validation.
89
85
  */
90
86
  regex?: RegExp;
91
- constructor(metadata: StringChipsArrayDecoratorConfig);
92
87
  }
93
88
  /**
94
- * Definition for an array of autocomplete strings displayed as a chips list
89
+ * Definition for an array of autocomplete strings displayed as a chips list.
95
90
  */
96
- export declare class AutocompleteStringChipsArrayDecoratorConfig extends ArrayDecoratorConfig {
91
+ export interface AutocompleteStringChipsArrayDecoratorConfig extends ArrayDecoratorConfig {
97
92
  itemType: DecoratorTypes.STRING_AUTOCOMPLETE;
98
93
  displayStyle: 'chips';
99
94
  /**
100
95
  * The html inside the delete-button.
101
96
  * Please note that custom tags such as <mat-icon></mat-icon>
102
97
  * 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>`
98
+ * You can however work around this by using `<span class="material-icons"></span>`.
99
+ *
104
100
  * @default <mat-icon>cancel</mat-icon>
105
101
  */
106
102
  deleteHtml?: string;
107
103
  /**
108
- * The autocomplete values
104
+ * The autocomplete values.
109
105
  */
110
106
  autocompleteValues: string[];
111
107
  /**
112
- * (optional) The minimum required length of the string
108
+ * The minimum required length of the string.
113
109
  */
114
110
  minLength?: number;
115
111
  /**
116
- * (optional) The maximum required length of the string
112
+ * The maximum required length of the string.
117
113
  */
118
114
  maxLength?: number;
119
115
  /**
120
- * (optional) A regex used for validation
116
+ * A regex used for validation.
121
117
  */
122
118
  regex?: RegExp;
123
- constructor(metadata: AutocompleteStringChipsArrayDecoratorConfig);
124
119
  }
125
120
  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 propery 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 { 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
1
  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';
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 ont the DecoratorTypes enum
26
+ * Gives the metadata-config Type based on the DecoratorTypes enum.
27
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;
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,11 @@
1
+ import { cols, PropertyDecoratorConfig } from './property-decorator.data';
2
+ export declare abstract class PropertyDecoratorConfigInternal implements PropertyDecoratorConfig {
3
+ display: boolean;
4
+ displayName: string;
5
+ required: boolean;
6
+ omitForCreate: boolean;
7
+ omitForUpdate: boolean;
8
+ defaultWidths: [cols, cols, cols];
9
+ order: number;
10
+ constructor(data: PropertyDecoratorConfig);
11
+ }