ngx-material-entity 0.1.0 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/CONTRIBUTING.md +7 -1
  2. package/README.md +3 -2
  3. package/classes/base-builder.class.d.ts +35 -0
  4. package/classes/entity-model.class.d.ts +1 -1
  5. package/classes/entity-service.class.d.ts +27 -17
  6. package/classes/entity-utilities.class.d.ts +96 -46
  7. package/components/confirm-dialog/confirm-dialog-data.builder.d.ts +23 -0
  8. package/components/confirm-dialog/confirm-dialog-data.d.ts +18 -8
  9. package/components/confirm-dialog/confirm-dialog.component.d.ts +15 -5
  10. package/components/get-validation-error-message.function.d.ts +3 -2
  11. package/components/input/add-array-item-dialog-data.builder.d.ts +21 -0
  12. package/components/input/add-array-item-dialog-data.d.ts +20 -0
  13. package/components/input/input.component.d.ts +116 -26
  14. package/components/input/input.module.d.ts +6 -4
  15. package/components/table/create-dialog/create-dialog-data.builder.d.ts +21 -0
  16. package/components/table/create-dialog/create-entity-dialog-data.builder.d.ts +22 -0
  17. package/components/table/create-dialog/create-entity-dialog-data.d.ts +2 -2
  18. package/components/table/create-dialog/create-entity-dialog.component.d.ts +19 -5
  19. package/components/table/edit-dialog/edit-dialog-data.builder.d.ts +25 -0
  20. package/components/table/edit-dialog/edit-entity-dialog-data.d.ts +5 -5
  21. package/components/table/edit-dialog/edit-entity-dialog.builder.d.ts +23 -0
  22. package/components/table/edit-dialog/edit-entity-dialog.component.d.ts +23 -5
  23. package/components/table/table-data.builder.d.ts +51 -0
  24. package/components/table/table-data.d.ts +40 -24
  25. package/components/table/table.component.d.ts +52 -5
  26. package/components/table/table.module.d.ts +3 -1
  27. package/decorators/array/array-decorator-internal.data.d.ts +45 -0
  28. package/decorators/array/array-decorator.data.d.ts +129 -0
  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 +24 -0
  33. package/decorators/base/property-decorator.data.d.ts +70 -0
  34. package/decorators/boolean/boolean-decorator-internal.data.d.ts +25 -0
  35. package/decorators/boolean/boolean-decorator.data.d.ts +37 -0
  36. package/decorators/boolean/boolean.decorator.d.ts +8 -0
  37. package/decorators/number/number-decorator-internal.data.d.ts +22 -0
  38. package/decorators/number/number-decorator.data.d.ts +38 -0
  39. package/decorators/number/number.decorator.d.ts +8 -0
  40. package/decorators/object/object-decorator-internal.data.d.ts +11 -0
  41. package/decorators/object/object-decorator.data.d.ts +25 -0
  42. package/decorators/object/object.decorator.d.ts +9 -0
  43. package/decorators/string/string-decorator-internal.data.d.ts +43 -0
  44. package/decorators/string/string-decorator.data.d.ts +79 -0
  45. package/decorators/string/string.decorator.d.ts +8 -0
  46. package/esm2020/classes/base-builder.class.mjs +43 -0
  47. package/esm2020/classes/entity-model.class.mjs +2 -2
  48. package/esm2020/classes/entity-service.class.mjs +20 -14
  49. package/esm2020/classes/entity-utilities.class.mjs +182 -101
  50. package/esm2020/components/confirm-dialog/confirm-dialog-data.builder.mjs +44 -0
  51. package/esm2020/components/confirm-dialog/confirm-dialog-data.mjs +1 -1
  52. package/esm2020/components/confirm-dialog/confirm-dialog.component.mjs +18 -22
  53. package/esm2020/components/get-validation-error-message.function.mjs +8 -3
  54. package/esm2020/components/input/add-array-item-dialog-data.builder.mjs +30 -0
  55. package/esm2020/components/input/add-array-item-dialog-data.mjs +2 -0
  56. package/esm2020/components/input/input.component.mjs +168 -32
  57. package/esm2020/components/input/input.module.mjs +19 -9
  58. package/esm2020/components/table/create-dialog/create-dialog-data.builder.mjs +32 -0
  59. package/esm2020/components/table/create-dialog/create-entity-dialog-data.builder.mjs +26 -0
  60. package/esm2020/components/table/create-dialog/create-entity-dialog-data.mjs +1 -1
  61. package/esm2020/components/table/create-dialog/create-entity-dialog.component.mjs +30 -30
  62. package/esm2020/components/table/create-dialog/create-entity-dialog.module.mjs +20 -4
  63. package/esm2020/components/table/edit-dialog/edit-dialog-data.builder.mjs +41 -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 +27 -0
  66. package/esm2020/components/table/edit-dialog/edit-entity-dialog.component.mjs +43 -47
  67. package/esm2020/components/table/table-data.builder.mjs +105 -0
  68. package/esm2020/components/table/table-data.mjs +1 -1
  69. package/esm2020/components/table/table.component.mjs +90 -82
  70. package/esm2020/components/table/table.module.mjs +12 -4
  71. package/esm2020/decorators/array/array-decorator-internal.data.mjs +51 -0
  72. package/esm2020/decorators/array/array-decorator.data.mjs +7 -0
  73. package/esm2020/decorators/array/array.decorator.mjs +24 -0
  74. package/esm2020/decorators/base/base-property.decorator.mjs +6 -5
  75. package/esm2020/decorators/base/decorator-types.enum.mjs +1 -1
  76. package/esm2020/decorators/base/property-decorator-internal.data.mjs +38 -0
  77. package/esm2020/decorators/base/property-decorator.data.mjs +6 -0
  78. package/esm2020/decorators/boolean/boolean-decorator-internal.data.mjs +33 -0
  79. package/esm2020/decorators/boolean/boolean-decorator.data.mjs +7 -0
  80. package/esm2020/decorators/boolean/boolean.decorator.mjs +21 -0
  81. package/esm2020/decorators/number/number-decorator-internal.data.mjs +23 -0
  82. package/esm2020/decorators/number/number-decorator.data.mjs +7 -0
  83. package/esm2020/decorators/number/number.decorator.mjs +18 -0
  84. package/esm2020/decorators/object/object-decorator-internal.data.mjs +12 -0
  85. package/esm2020/decorators/object/object-decorator.data.mjs +7 -0
  86. package/esm2020/decorators/object/object.decorator.mjs +13 -0
  87. package/esm2020/decorators/string/string-decorator-internal.data.mjs +48 -0
  88. package/esm2020/decorators/string/string-decorator.data.mjs +7 -0
  89. package/esm2020/decorators/string/string.decorator.mjs +24 -0
  90. package/esm2020/public-api.mjs +15 -10
  91. package/fesm2015/ngx-material-entity.mjs +1221 -880
  92. package/fesm2015/ngx-material-entity.mjs.map +1 -1
  93. package/fesm2020/ngx-material-entity.mjs +1225 -877
  94. package/fesm2020/ngx-material-entity.mjs.map +1 -1
  95. package/package.json +2 -1
  96. package/public-api.d.ts +15 -7
  97. package/components/input/array-table/add-array-item-dialog/add-array-item-dialog.component.d.ts +0 -35
  98. package/components/input/array-table/add-array-item-dialog/add-array-item-dialog.module.d.ts +0 -12
  99. package/components/input/array-table/array-table.component.d.ts +0 -34
  100. package/components/input/array-table/array-table.module.d.ts +0 -19
  101. package/components/input/internal-input/internal-input.component.d.ts +0 -57
  102. package/components/input/internal-input/internal-input.module.d.ts +0 -16
  103. package/decorators/array.decorator.d.ts +0 -125
  104. package/decorators/base/property-decorator-config.interface.d.ts +0 -50
  105. package/decorators/boolean.decorator.d.ts +0 -42
  106. package/decorators/number.decorator.d.ts +0 -40
  107. package/decorators/object.decorator.d.ts +0 -27
  108. package/decorators/string.decorator.d.ts +0 -76
  109. package/esm2020/components/input/array-table/add-array-item-dialog/add-array-item-dialog.component.mjs +0 -43
  110. package/esm2020/components/input/array-table/add-array-item-dialog/add-array-item-dialog.module.mjs +0 -22
  111. package/esm2020/components/input/array-table/array-table.component.mjs +0 -116
  112. package/esm2020/components/input/array-table/array-table.module.mjs +0 -66
  113. package/esm2020/components/input/internal-input/internal-input.component.mjs +0 -73
  114. package/esm2020/components/input/internal-input/internal-input.module.mjs +0 -54
  115. package/esm2020/decorators/array.decorator.mjs +0 -70
  116. package/esm2020/decorators/base/property-decorator-config.interface.mjs +0 -31
  117. package/esm2020/decorators/boolean.decorator.mjs +0 -44
  118. package/esm2020/decorators/number.decorator.mjs +0 -36
  119. package/esm2020/decorators/object.decorator.mjs +0 -23
  120. package/esm2020/decorators/string.decorator.mjs +0 -61
@@ -1,25 +1,39 @@
1
- import { OnInit } from '@angular/core';
1
+ import { OnInit, TemplateRef } from '@angular/core';
2
2
  import { NgModel } from '@angular/forms';
3
- import { EntityUtilities } from '../../classes/entity-utilities.class';
3
+ import { EntityRow, EntityUtilities } from '../../classes/entity-utilities.class';
4
4
  import { Entity } from '../../classes/entity-model.class';
5
5
  import { DecoratorTypes } from '../../decorators/base/decorator-types.enum';
6
- import { PropertyDecoratorConfig } from '../../decorators/base/property-decorator-config.interface';
7
- import { AutocompleteStringDecoratorConfig, DefaultStringDecoratorConfig, DropdownStringDecoratorConfig, TextboxStringDecoratorConfig } from '../../decorators/string.decorator';
8
- import { DropdownBooleanDecoratorConfig } from '../../decorators/boolean.decorator';
9
- import { DefaultNumberDecoratorConfig, DropdownNumberDecoratorConfig } from '../../decorators/number.decorator';
10
- import { DefaultObjectDecoratorConfig } from '../../decorators/object.decorator';
11
- import { AutocompleteStringChipsArrayDecoratorConfig, EntityArrayDecoratorConfig, StringChipsArrayDecoratorConfig } from '../../decorators/array.decorator';
12
6
  import { MatChipInputEvent } from '@angular/material/chips';
13
7
  import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
8
+ import { AutocompleteStringChipsArrayDecoratorConfigInternal, EntityArrayDecoratorConfigInternal, StringChipsArrayDecoratorConfigInternal } from '../../decorators/array/array-decorator-internal.data';
9
+ import { DropdownBooleanDecoratorConfigInternal } from '../../decorators/boolean/boolean-decorator-internal.data';
10
+ import { DefaultNumberDecoratorConfigInternal, DropdownNumberDecoratorConfigInternal } from '../../decorators/number/number-decorator-internal.data';
11
+ import { DefaultObjectDecoratorConfigInternal } from '../../decorators/object/object-decorator-internal.data';
12
+ import { AutocompleteStringDecoratorConfigInternal, DefaultStringDecoratorConfigInternal, DropdownStringDecoratorConfigInternal, TextboxStringDecoratorConfigInternal } from '../../decorators/string/string-decorator-internal.data';
13
+ import { PropertyDecoratorConfigInternal } from '../../decorators/base/property-decorator-internal.data';
14
+ import { MatTableDataSource } from '@angular/material/table';
15
+ import { SelectionModel } from '@angular/cdk/collections';
16
+ import { AddArrayItemDialogDataInternal } from './add-array-item-dialog-data.builder';
17
+ import { AddArrayItemDialogData } from './add-array-item-dialog-data';
18
+ import { MatDialog, MatDialogRef } from '@angular/material/dialog';
14
19
  import * as i0 from "@angular/core";
20
+ /**
21
+ * The default input component. It gets the metadata of the property from the given @Input "entity" and @Input "propertyKey"
22
+ * and displays the input field accordingly.
23
+ *
24
+ * You can also define a method that generates error-messages and if the input should be hidden when its metadata says
25
+ * that it should be omitted for creating or updating.
26
+ * The last part being mostly relevant if you want to use this component inside an ngFor.
27
+ */
15
28
  export declare class NgxMatEntityInputComponent<EntityType extends Entity> implements OnInit {
29
+ private readonly dialog;
16
30
  /**
17
- * The entity on which the property exists. Used in conjuction with the "propertyKey"
31
+ * The entity on which the property exists. Used in conjunction with the "propertyKey"
18
32
  * to determine the property for which the input should be generated.
19
33
  */
20
34
  entity: EntityType;
21
35
  /**
22
- * The name of the property to generate the input for. Used in conjuction with the "entity".
36
+ * The name of the property to generate the input for. Used in conjunction with the "entity".
23
37
  */
24
38
  propertyKey: keyof EntityType;
25
39
  /**
@@ -36,37 +50,113 @@ export declare class NgxMatEntityInputComponent<EntityType extends Entity> imple
36
50
  * Is used internally for the object property.
37
51
  */
38
52
  hideOmitForEdit?: boolean;
53
+ addArrayItemDialog: TemplateRef<unknown>;
54
+ addArrayItemDialogRef: MatDialogRef<unknown>;
39
55
  type: DecoratorTypes;
40
- metadata: PropertyDecoratorConfig;
41
- metadataDefaultString: DefaultStringDecoratorConfig;
42
- metadataTextboxString: TextboxStringDecoratorConfig;
43
- metadataAutocompleteString: AutocompleteStringDecoratorConfig;
56
+ metadata: PropertyDecoratorConfigInternal;
57
+ metadataDefaultString: DefaultStringDecoratorConfigInternal;
58
+ metadataTextboxString: TextboxStringDecoratorConfigInternal;
59
+ metadataAutocompleteString: AutocompleteStringDecoratorConfigInternal;
44
60
  autocompleteStrings: string[];
45
61
  filteredAutocompleteStrings: string[];
46
- metadataDropdownString: DropdownStringDecoratorConfig;
47
- metadataDropdownBoolean: DropdownBooleanDecoratorConfig;
48
- metadataDefaultNumber: DefaultNumberDecoratorConfig;
49
- metadataDropdownNumber: DropdownNumberDecoratorConfig;
50
- metadataDefaultObject: DefaultObjectDecoratorConfig;
62
+ metadataDropdownString: DropdownStringDecoratorConfigInternal;
63
+ metadataDropdownBoolean: DropdownBooleanDecoratorConfigInternal;
64
+ metadataDefaultNumber: DefaultNumberDecoratorConfigInternal;
65
+ metadataDropdownNumber: DropdownNumberDecoratorConfigInternal;
66
+ metadataDefaultObject: DefaultObjectDecoratorConfigInternal<EntityType>;
51
67
  objectProperty: Entity;
52
- metadataEntityArray: EntityArrayDecoratorConfig<Entity>;
53
- entityArrayValues: Entity[];
54
- metadataStringChipsArray: StringChipsArrayDecoratorConfig;
68
+ objectPropertyRows: EntityRow<Entity>[];
69
+ metadataEntityArray: EntityArrayDecoratorConfigInternal<Entity>;
70
+ entityArrayValues: EntityType[];
71
+ metadataStringChipsArray: StringChipsArrayDecoratorConfigInternal;
55
72
  stringChipsArrayValues: string[];
56
73
  chipsInput: string;
57
- metadataAutocompleteStringChipsArray: AutocompleteStringChipsArrayDecoratorConfig;
74
+ metadataAutocompleteStringChipsArray: AutocompleteStringChipsArrayDecoratorConfigInternal;
75
+ arrayItem: EntityType;
76
+ private arrayItemPriorChanges;
77
+ arrayItemInlineRows: EntityRow<EntityType>[];
78
+ dataSource: MatTableDataSource<EntityType>;
79
+ selection: SelectionModel<EntityType>;
80
+ displayedColumns: string[];
81
+ dialogInputData: AddArrayItemDialogData<EntityType>;
82
+ dialogData: AddArrayItemDialogDataInternal<EntityType>;
83
+ arrayItemDialogRows: EntityRow<EntityType>[];
58
84
  readonly DecoratorTypes: typeof DecoratorTypes;
85
+ EntityUtilities: typeof EntityUtilities;
59
86
  getWidth: typeof EntityUtilities.getWidth;
60
- constructor();
87
+ constructor(dialog: MatDialog);
61
88
  /**
62
- * Helper method needed to recursively generate property input components (used eg. with the object)
89
+ * This is needed for the inputs to work inside an ngFor.
90
+ *
91
+ * @param index - The index of the element in the ngFor.
92
+ * @returns The index.
63
93
  */
64
94
  trackByFn(index: unknown): unknown;
65
95
  ngOnInit(): void;
66
- getObjectProperties(): (keyof Entity)[];
96
+ /**
97
+ * Tries to add an item to the array.
98
+ * Does this either inline if the "createInline"-metadata is set to true
99
+ * or in a separate dialog if it is set to false.
100
+ */
101
+ add(): void;
102
+ /**
103
+ * Adds the array item defined in the dialog.
104
+ */
105
+ addArrayItem(): void;
106
+ /**
107
+ * Cancels adding the array item defined in the dialog.
108
+ */
109
+ cancelAddArrayItem(): void;
110
+ /**
111
+ * Removes all selected entries from the array.
112
+ */
113
+ remove(): void;
114
+ /**
115
+ * Toggles all array-items in the table.
116
+ */
117
+ masterToggle(): void;
118
+ /**
119
+ * Checks if all array-items in the table have been selected.
120
+ * This is needed to display the "masterToggle"-checkbox correctly.
121
+ *
122
+ * @returns Whether or not all array-items in the table have been selected.
123
+ */
124
+ isAllSelected(): boolean;
125
+ /**
126
+ * Handles adding strings to the chipsArray.
127
+ * Checks validation and also creates a new array if it is undefined.
128
+ * This is needed because two things are validated: The array itself
129
+ * and the contents of the array. And we need a way to display an
130
+ * mat-error. As the only validation for the array is whether or not
131
+ * it contains values, we can set it to undefined when the last element is removed
132
+ * (removeStringChipArrayValue). That way we can use the "required" validator.
133
+ *
134
+ * @param event - The event that fires when a new chip is completed.
135
+ */
67
136
  addStringChipArrayValue(event: MatChipInputEvent): void;
137
+ /**
138
+ * Removes the given value from the array.
139
+ * Sets the array to undefined if it is now empty.
140
+ * This is needed because two things are validated: The array itself
141
+ * and the contents of the array. And we need a way to display an
142
+ * mat-error. As the only validation for the array is whether or not
143
+ * it is empty, setting it to undefined here enables us to use the "required" validator.
144
+ *
145
+ * @param value - The string to remove from the array.
146
+ */
68
147
  removeStringChipArrayValue(value: string): void;
148
+ /**
149
+ * Handles adding a string to the array when an autocomplete value has been selected.
150
+ *
151
+ * @param event - The autocomplete selected event.
152
+ * @param chipsInput - The element where the user typed the value.
153
+ */
69
154
  selected(event: MatAutocompleteSelectedEvent, chipsInput: HTMLInputElement): void;
155
+ /**
156
+ * Dynamically filters the Autocomplete options when the user inputs something.
157
+ *
158
+ * @param input - The input of the user.
159
+ */
70
160
  filterAutocompleteStrings(input: unknown): void;
71
161
  static ɵfac: i0.ɵɵFactoryDeclaration<NgxMatEntityInputComponent<any>, never>;
72
162
  static ɵcmp: i0.ɵɵComponentDeclaration<NgxMatEntityInputComponent<any>, "ngx-mat-entity-input", never, { "entity": "entity"; "propertyKey": "propertyKey"; "getValidationErrorMessage": "getValidationErrorMessage"; "hideOmitForCreate": "hideOmitForCreate"; "hideOmitForEdit": "hideOmitForEdit"; }, {}, never, never>;
@@ -8,11 +8,13 @@ import * as i6 from "@angular/material/select";
8
8
  import * as i7 from "@angular/material/autocomplete";
9
9
  import * as i8 from "@angular/material/checkbox";
10
10
  import * as i9 from "@angular/material/slide-toggle";
11
- import * as i10 from "./array-table/array-table.module";
12
- import * as i11 from "@angular/material/chips";
13
- import * as i12 from "@angular/material/icon";
11
+ import * as i10 from "@angular/material/chips";
12
+ import * as i11 from "@angular/material/icon";
13
+ import * as i12 from "@angular/material/table";
14
+ import * as i13 from "@angular/material/dialog";
15
+ import * as i14 from "@angular/material/button";
14
16
  export declare class NgxMatEntityInputModule {
15
17
  static ɵfac: i0.ɵɵFactoryDeclaration<NgxMatEntityInputModule, never>;
16
- static ɵmod: i0.ɵɵNgModuleDeclaration<NgxMatEntityInputModule, [typeof i1.NgxMatEntityInputComponent], [typeof i2.CommonModule, typeof i3.MatInputModule, typeof i4.FormsModule, typeof i5.MatFormFieldModule, typeof i6.MatSelectModule, typeof i7.MatAutocompleteModule, typeof i8.MatCheckboxModule, typeof i9.MatSlideToggleModule, typeof i10.NgxMatEntityArrayTableModule, typeof i11.MatChipsModule, typeof i12.MatIconModule], [typeof i1.NgxMatEntityInputComponent]>;
18
+ static ɵmod: i0.ɵɵNgModuleDeclaration<NgxMatEntityInputModule, [typeof i1.NgxMatEntityInputComponent], [typeof i2.CommonModule, typeof i3.MatInputModule, typeof i4.FormsModule, typeof i5.MatFormFieldModule, typeof i6.MatSelectModule, typeof i7.MatAutocompleteModule, typeof i8.MatCheckboxModule, typeof i9.MatSlideToggleModule, typeof i10.MatChipsModule, typeof i11.MatIconModule, typeof i12.MatTableModule, typeof i13.MatDialogModule, typeof i14.MatButtonModule], [typeof i1.NgxMatEntityInputComponent]>;
17
19
  static ɵinj: i0.ɵɵInjectorDeclaration<NgxMatEntityInputModule>;
18
20
  }
@@ -0,0 +1,21 @@
1
+ import { BaseBuilder } from '../../../classes/base-builder.class';
2
+ import { ConfirmDialogDataInternal } from '../../confirm-dialog/confirm-dialog-data.builder';
3
+ import { CreateDialogData } from '../table-data';
4
+ /**
5
+ * The internal CreateDialogData. Requires all default values the user can leave out.
6
+ */
7
+ export declare class CreateDialogDataInternal implements CreateDialogData {
8
+ title: string;
9
+ createButtonLabel: string;
10
+ cancelButtonLabel: string;
11
+ createRequiresConfirmDialog: boolean;
12
+ confirmCreateDialogData: ConfirmDialogDataInternal;
13
+ constructor(title: string, createButtonLabel: string, cancelButtonLabel: string, createRequiresConfirmDialog: boolean, confirmCreateDialogData: ConfirmDialogDataInternal);
14
+ }
15
+ /**
16
+ * The Builder for the CreateDialogData. Sets default values.
17
+ */
18
+ export declare class CreateDialogDataBuilder extends BaseBuilder<CreateDialogDataInternal, CreateDialogData> {
19
+ constructor(data?: CreateDialogData);
20
+ protected generateBaseData(data?: CreateDialogData): CreateDialogDataInternal;
21
+ }
@@ -0,0 +1,22 @@
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
+ import { BaseBuilder } from '../../../classes/base-builder.class';
7
+ /**
8
+ * The internal CreateEntityDialogData. Requires all default values the user can leave out.
9
+ */
10
+ export declare class CreateEntityDialogDataInternal<EntityType extends Entity> implements CreateEntityDialogData<EntityType> {
11
+ entity: EntityType;
12
+ EntityServiceClass: new (httpClient: HttpClient) => EntityService<EntityType>;
13
+ createDialogData: CreateDialogDataInternal;
14
+ constructor(entity: EntityType, EntityServiceClass: new (httpClient: HttpClient) => EntityService<EntityType>, createDialogData: CreateDialogDataInternal);
15
+ }
16
+ /**
17
+ * The Builder for the CreateEntityDialogData. Sets default values.
18
+ */
19
+ export declare class CreateEntityDialogDataBuilder<EntityType extends Entity> extends BaseBuilder<CreateEntityDialogDataInternal<EntityType>, CreateEntityDialogData<EntityType>> {
20
+ constructor(data: CreateEntityDialogData<EntityType>);
21
+ protected generateBaseData(data: CreateEntityDialogData<EntityType>): CreateEntityDialogDataInternal<EntityType>;
22
+ }
@@ -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
  }
@@ -2,23 +2,37 @@ import { Injector, OnInit } from '@angular/core';
2
2
  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
- import { EntityUtilities } from '../../../classes/entity-utilities.class';
5
+ import { EntityRow, 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";
9
+ /**
10
+ * The default dialog used to create new entities based on the configuration passed in the MAT_DIALOG_DATA "inputData".
11
+ * Used by the ngx-mat-entity-table.
12
+ *
13
+ * It offers a lot of customization options which can be found in "CreateEntityDialogData".
14
+ */
8
15
  export declare class NgxMatEntityCreateDialogComponent<EntityType extends Entity> implements OnInit {
9
- data: CreateEntityDialogData<EntityType>;
16
+ private readonly inputData;
10
17
  dialogRef: MatDialogRef<NgxMatEntityCreateDialogComponent<EntityType>>;
11
18
  private readonly injector;
12
19
  private readonly dialog;
13
20
  EntityUtilities: typeof EntityUtilities;
14
- entityKeys: (keyof EntityType)[];
21
+ entityRows: EntityRow<EntityType>[];
15
22
  entityService: EntityService<EntityType>;
23
+ data: CreateEntityDialogDataInternal<EntityType>;
16
24
  getWidth: typeof EntityUtilities.getWidth;
17
- constructor(data: CreateEntityDialogData<EntityType>, dialogRef: MatDialogRef<NgxMatEntityCreateDialogComponent<EntityType>>, injector: Injector, dialog: MatDialog);
25
+ constructor(inputData: CreateEntityDialogData<EntityType>, dialogRef: MatDialogRef<NgxMatEntityCreateDialogComponent<EntityType>>, injector: Injector, dialog: MatDialog);
18
26
  ngOnInit(): void;
19
- private setEntityKeys;
27
+ /**
28
+ * Tries add the new entity and close the dialog afterwards.
29
+ * Also handles the confirmation if required.
30
+ */
20
31
  create(): void;
21
32
  private confirmCreate;
33
+ /**
34
+ * Closes the dialog.
35
+ */
22
36
  cancel(): void;
23
37
  static ɵfac: i0.ɵɵFactoryDeclaration<NgxMatEntityCreateDialogComponent<any>, never>;
24
38
  static ɵcmp: i0.ɵɵComponentDeclaration<NgxMatEntityCreateDialogComponent<any>, "ngx-mat-entity-create-dialog", never, {}, {}, never, never>;
@@ -0,0 +1,25 @@
1
+ import { BaseBuilder } from '../../../classes/base-builder.class';
2
+ import { Entity } from '../../../classes/entity-model.class';
3
+ import { ConfirmDialogData } from '../../confirm-dialog/confirm-dialog-data';
4
+ import { EditDialogData } from '../table-data';
5
+ /**
6
+ * The internal EditDialogData. Requires all default values the user can leave out.
7
+ */
8
+ export declare class EditDialogDataInternal<EntityType extends Entity> implements EditDialogData<EntityType> {
9
+ title: (entity: EntityType) => string;
10
+ confirmButtonLabel: string;
11
+ deleteButtonLabel: string;
12
+ cancelButtonLabel: string;
13
+ deleteRequiresConfirmDialog: boolean;
14
+ editRequiresConfirmDialog: boolean;
15
+ confirmDeleteDialogData: ConfirmDialogData;
16
+ confirmEditDialogData: ConfirmDialogData;
17
+ constructor(title: (entity: EntityType) => string, confirmButtonLabel: string, deleteButtonLabel: string, cancelButtonLabel: string, deleteRequiresConfirmDialog: boolean, editRequiresConfirmDialog: boolean, confirmDeleteDialogData: ConfirmDialogData, confirmEditDialogData: ConfirmDialogData);
18
+ }
19
+ /**
20
+ * The Builder for the EditDialogData. Sets default values.
21
+ */
22
+ export declare class EditDialogDataBuilder<EntityType extends Entity> extends BaseBuilder<EditDialogDataInternal<EntityType>, EditDialogData<EntityType>> {
23
+ constructor(data?: EditDialogData<EntityType>);
24
+ protected generateBaseData(data?: EditDialogData<EntityType>): EditDialogDataInternal<EntityType>;
25
+ }
@@ -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,23 @@
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
+ import { BaseBuilder } from '../../../classes/base-builder.class';
7
+ /**
8
+ * The internal EditEntityDialogData. Requires all default values the user can leave out.
9
+ */
10
+ export declare class EditEntityDialogDataInternal<EntityType extends Entity> implements EditEntityDialogData<EntityType> {
11
+ entity: EntityType;
12
+ EntityServiceClass: new (httpClient: HttpClient) => EntityService<EntityType>;
13
+ editDialogData: EditDialogDataInternal<EntityType>;
14
+ allowDelete: (entity: EntityType) => boolean;
15
+ constructor(entity: EntityType, EntityServiceClass: new (httpClient: HttpClient) => EntityService<EntityType>, editDialogData: EditDialogDataInternal<EntityType>, allowDelete: (entity: EntityType) => boolean);
16
+ }
17
+ /**
18
+ * The Builder for the EditEntityDialogData. Sets default values.
19
+ */
20
+ export declare class EditEntityDialogDataBuilder<EntityType extends Entity> extends BaseBuilder<EditEntityDialogDataInternal<EntityType>, EditEntityDialogData<EntityType>> {
21
+ constructor(data: EditEntityDialogData<EntityType>);
22
+ protected generateBaseData(data: EditEntityDialogData<EntityType>): EditEntityDialogDataInternal<EntityType>;
23
+ }
@@ -2,26 +2,44 @@ import { Injector, OnInit } from '@angular/core';
2
2
  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
- import { EntityUtilities } from '../../../classes/entity-utilities.class';
5
+ import { EntityRow, 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";
9
+ /**
10
+ * The default dialog used to edit an existing entity based on the configuration passed in the MAT_DIALOG_DATA "inputData".
11
+ * Used by the ngx-mat-entity-table.
12
+ *
13
+ * It offers a lot of customization options which can be found in "EditEntityDialogData".
14
+ */
8
15
  export declare class NgxMatEntityEditDialogComponent<EntityType extends Entity> implements OnInit {
9
- data: EditEntityDialogData<EntityType>;
16
+ private readonly inputData;
10
17
  dialogRef: MatDialogRef<NgxMatEntityEditDialogComponent<EntityType>>;
11
18
  private readonly injector;
12
19
  private readonly dialog;
13
20
  EntityUtilities: typeof EntityUtilities;
14
- entityKeys: (keyof EntityType)[];
21
+ entityRows: EntityRow<EntityType>[];
15
22
  entityService: EntityService<EntityType>;
16
23
  entityPriorChanges: EntityType;
24
+ data: EditEntityDialogDataInternal<EntityType>;
17
25
  getWidth: typeof EntityUtilities.getWidth;
18
- constructor(data: EditEntityDialogData<EntityType>, dialogRef: MatDialogRef<NgxMatEntityEditDialogComponent<EntityType>>, injector: Injector, dialog: MatDialog);
26
+ constructor(inputData: EditEntityDialogData<EntityType>, dialogRef: MatDialogRef<NgxMatEntityEditDialogComponent<EntityType>>, injector: Injector, dialog: MatDialog);
19
27
  ngOnInit(): void;
20
- private setEntityKeys;
28
+ /**
29
+ * Tries to save the changes and close the dialog afterwards.
30
+ * Also handles the confirmation if required.
31
+ */
21
32
  edit(): void;
22
33
  private confirmEdit;
34
+ /**
35
+ * Tries to delete the entity and close the dialog afterwards.
36
+ * Also handles the confirmation if required.
37
+ */
23
38
  delete(): void;
24
39
  private confirmDelete;
40
+ /**
41
+ * Reverts all changes made and closes the dialog.
42
+ */
25
43
  cancel(): void;
26
44
  static ɵfac: i0.ɵɵFactoryDeclaration<NgxMatEntityEditDialogComponent<any>, never>;
27
45
  static ɵcmp: i0.ɵɵComponentDeclaration<NgxMatEntityEditDialogComponent<any>, "ngx-mat-entity-edit-dialog", never, {}, {}, never, never>;
@@ -0,0 +1,51 @@
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
+ import { BaseBuilder } from '../../classes/base-builder.class';
8
+ /**
9
+ * The internal TableData. Requires all default values the user can leave out.
10
+ */
11
+ export declare class TableDataInternal<EntityType extends Entity> implements TableData<EntityType> {
12
+ baseData: BaseDataInternal<EntityType>;
13
+ createDialogData: CreateDialogDataInternal;
14
+ editDialogData: EditDialogDataInternal<EntityType>;
15
+ constructor(baseData: BaseDataInternal<EntityType>, createDialogData: CreateDialogDataInternal, editDialogData: EditDialogDataInternal<EntityType>);
16
+ }
17
+ /**
18
+ * The Builder for the table BaseData. Sets default values.
19
+ */
20
+ export declare class BaseDataBuilder<EntityType extends Entity> extends BaseBuilder<BaseDataInternal<EntityType>, BaseData<EntityType>> {
21
+ constructor(data: BaseData<EntityType>);
22
+ protected generateBaseData(data: BaseData<EntityType>): BaseDataInternal<EntityType>;
23
+ }
24
+ /**
25
+ * The internal TableData. Requires all default values the user can leave out.
26
+ */
27
+ export declare class BaseDataInternal<EntityType extends Entity> implements BaseData<EntityType> {
28
+ title: string;
29
+ displayColumns: DisplayColumn<EntityType>[];
30
+ EntityServiceClass: new (httpClient: HttpClient) => EntityService<EntityType>;
31
+ searchLabel: string;
32
+ createButtonLabel: string;
33
+ searchString: (entity: EntityType) => string;
34
+ allowCreate: boolean;
35
+ allowEdit: (entity: EntityType) => boolean;
36
+ allowDelete: (entity: EntityType) => boolean;
37
+ multiSelectActions: MultiSelectAction<EntityType>[];
38
+ multiSelectLabel: string;
39
+ EntityClass?: new (entity?: EntityType) => EntityType;
40
+ edit?: (entity: EntityType) => unknown;
41
+ create?: (entity: EntityType) => unknown;
42
+ constructor(title: string, displayColumns: DisplayColumn<EntityType>[], EntityServiceClass: new (httpClient: HttpClient) => EntityService<EntityType>, searchLabel: string, createButtonLabel: string, searchString: (entity: 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);
43
+ }
44
+ /**
45
+ * The Builder for the complete TableData. Sets default values and validates user input.
46
+ */
47
+ export declare class TableDataBuilder<EntityType extends Entity> extends BaseBuilder<TableDataInternal<EntityType>, TableData<EntityType>> {
48
+ constructor(data: TableData<EntityType>);
49
+ protected generateBaseData(data: TableData<EntityType>): TableDataInternal<EntityType>;
50
+ protected validateInput(data: TableData<EntityType>): void;
51
+ }