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
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The abstract BaseBuilder class.
3
+ */
4
+ export declare abstract class BaseBuilder<InternalType extends InputType, InputType extends object> {
5
+ private readonly data;
6
+ private readonly inputData?;
7
+ protected constructor(data?: InputType);
8
+ /**
9
+ * Generates the internal data from the given user inputs.
10
+ *
11
+ * @param data - The input from the user.
12
+ * @returns The internal data.
13
+ */
14
+ protected abstract generateBaseData(data?: InputType): InternalType;
15
+ /**
16
+ * Used to validate the user input in the constructor.
17
+ *
18
+ * @param data - The user input.
19
+ */
20
+ protected validateInput(data?: InputType): void;
21
+ /**
22
+ * Sets the value for the given key if no user value was provided.
23
+ *
24
+ * @param key - The key to set the default value for.
25
+ * @param value - The value to set when nothing was provided.
26
+ * @returns The Builder.
27
+ */
28
+ withDefault(key: keyof InputType, value: Omit<InternalType[keyof InputType], 'undefined'>): BaseBuilder<InternalType, InputType>;
29
+ /**
30
+ * Method used to get the final build value after applying all chaining.
31
+ *
32
+ * @returns The build value.
33
+ */
34
+ getResult(): InternalType;
35
+ }
@@ -0,0 +1,58 @@
1
+ import { Time } from '@angular/common';
2
+ import { DropdownValue } from '../decorators/base/dropdown-value.interface';
3
+ import { DateRangeDateDecoratorConfigInternal } from '../decorators/date/date-decorator-internal.data';
4
+ /**
5
+ * Valid steps from one time value to the next. Needs to be able to divide 60 minutes without remainder.
6
+ */
7
+ declare type MinuteSteps = 1 | 2 | 3 | 4 | 5 | 6 | 10 | 12 | 15 | 20 | 30 | 60;
8
+ /**
9
+ * Contains Helper Functions for handling date properties.
10
+ */
11
+ export declare abstract class DateUtilities {
12
+ /**
13
+ * Gets the given value as a date value.
14
+ *
15
+ * @param value - The value to get as a date.
16
+ * @returns The given value as a date.
17
+ */
18
+ static asDate(value: unknown): Date;
19
+ /**
20
+ * Gets the default times used by the DateTime picker when nothing is specified by the user.
21
+ *
22
+ * @param format - The time format. Defaults to 24.
23
+ * @param minuteSteps - The steps from one time value to the next. Defaults to 30.
24
+ * @returns Times in the 24 hour format from 0:00 until 23:30 in 30 minute steps.
25
+ */
26
+ static getDefaultTimes(format?: 12 | 24, minuteSteps?: MinuteSteps): DropdownValue<Time>[];
27
+ private static getTimeDropdownValue;
28
+ private static getFormattedHour;
29
+ private static getFormattedMinute;
30
+ /**
31
+ * Gets the Time object from the given date.
32
+ *
33
+ * @param value - The date to get the time object from.
34
+ * @returns The Time object build from the date value.
35
+ */
36
+ static getTimeFromDate(value: Date): Time;
37
+ /**
38
+ * Gets the dates between the two given gates. Does additional filtering based on the provided DateRange metadata.
39
+ *
40
+ * @param startDate - The start date.
41
+ * @param endDate - The end date.
42
+ * @param metadataDateRangeDate - The metadata.
43
+ * @returns All dates between the two provided dates. Includes start and end date.
44
+ */
45
+ static getDatesBetween(startDate: Date, endDate: Date, metadataDateRangeDate: DateRangeDateDecoratorConfigInternal): Date[];
46
+ /**
47
+ * Get all valid times for the dropdown of a datetime property.
48
+ *
49
+ * @param date - The date of the datetime.
50
+ * @param times - All given times to filter.
51
+ * @param min - The function that defines the minimum time.
52
+ * @param max - The function that defines the maximum time.
53
+ * @param filter - A filter function to do more specific time filtering. This could be e.g. The removal of lunch breaks.
54
+ * @returns All valid dropdown values for the datetime property.
55
+ */
56
+ static getValidTimesForDropdown(date: Date, times: DropdownValue<Time>[], min?: (date?: Date) => Time, max?: (date?: Date) => Time, filter?: ((time: Time) => boolean) | (() => boolean)): DropdownValue<Time>[];
57
+ }
58
+ export {};
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The newable type used whenever an entity class is passed to create an entity and initialize its metadata.
3
+ */
4
+ export declare type EntityClassNewable<EntityType extends object> = new (data?: EntityType) => EntityType;
5
+ /**
6
+ * A base Entity class with a builtin id.
7
+ */
8
+ export declare abstract class Entity {
9
+ /**
10
+ * A unique identifier for the Entity.
11
+ */
12
+ id: string;
13
+ }
@@ -1,4 +1,3 @@
1
- import { Entity } from './entity-model.class';
2
1
  import { HttpClient } from '@angular/common/http';
3
2
  import { BehaviorSubject } from 'rxjs';
4
3
  /**
@@ -7,50 +6,66 @@ import { BehaviorSubject } from 'rxjs';
7
6
  * You should create a service for every Entity you have.
8
7
  * If you extend from this you need to make sure that the extended Service can be injected.
9
8
  */
10
- export declare abstract class EntityService<EntityType extends Entity> {
9
+ export declare abstract class EntityService<EntityType extends object> {
11
10
  private readonly http;
12
11
  /**
13
12
  * The base url used for api requests. If u want to have more control over this,
14
13
  * you can override the create, read, update and delete methods.
15
- * @create Sends a POST-Request to baseUrl
16
- * @read Sends a GET-Request to baseUrl
17
- * @update Sends a PATCH-Request to baseUrl/{id}
18
- * @delete Sends a DEL-Request to baseUrl/{id}
14
+ *
15
+ * Create Sends a POST-Request to baseUrl.
16
+ *
17
+ * Read Sends a GET-Request to baseUrl.
18
+ *
19
+ * Update Sends a PATCH-Request to baseUrl/{id}.
20
+ *
21
+ * Delete Sends a DEL-Request to baseUrl/{id}.
19
22
  */
20
23
  abstract readonly baseUrl: string;
21
24
  /**
22
- * a subject of all the entity values.
25
+ * The key which holds the id value.
26
+ *
27
+ * @default 'id'
28
+ */
29
+ readonly idKey: keyof EntityType;
30
+ /**
31
+ * A subject of all the entity values.
23
32
  * Can be subscribed to when you want to do a specific thing whenever the entities change.
24
33
  */
25
34
  readonly entitiesSubject: BehaviorSubject<EntityType[]>;
26
35
  /**
27
- * gets the entities in an array from the internal entitiesSubject
36
+ * Gets the entities in an array from the internal entitiesSubject.
37
+ *
38
+ * @returns The current entities in form of an array.
28
39
  */
29
40
  get entities(): EntityType[];
30
41
  constructor(http: HttpClient);
31
42
  /**
32
- * Creates a new Entity and pushes it to the entities array
33
- * @param entity The data of the entity to create.
43
+ * Creates a new Entity and pushes it to the entities array.
44
+ *
45
+ * @param entity - The data of the entity to create.
34
46
  * All values that should be omitted will be removed from it inside this method.
35
- * @returns A Promise of the created entity
47
+ * @returns A Promise of the created entity.
36
48
  */
37
49
  create(entity: EntityType): Promise<EntityType>;
38
50
  /**
39
- * Gets all existing entities and pushes them to the entites array
40
- * @returns A Promise of all received Entities
51
+ * Gets all existing entities and pushes them to the entities array.
52
+ *
53
+ * @returns A Promise of all received Entities.
41
54
  */
42
55
  read(): Promise<EntityType[]>;
43
56
  /**
44
- * Updates a specific Entity
45
- * @param entity The updated Entity
57
+ * Updates a specific Entity.
58
+ *
59
+ * @param entity - The updated Entity
46
60
  * All values that should be omitted will be removed from it inside this method.
47
- * @param entityPriorChanges The current Entity.
48
- * It Is used to get changed values and only update them instead of sending the whole entity data
61
+ * @param entityPriorChanges - The current Entity.
62
+ * It Is used to get changed values and only update them instead of sending the whole entity data.
49
63
  */
50
64
  update(entity: EntityType, entityPriorChanges: EntityType): Promise<void>;
51
65
  /**
52
- * Method to delete a specific Entity
53
- * @param id The id of the element to delete
66
+ * Deletes a specific Entity.
67
+ *
68
+ * @param entity - The entity to delete.
54
69
  */
55
- delete(id: string): Promise<void>;
70
+ delete(entity: EntityType): Promise<void>;
56
71
  }
@@ -0,0 +1,153 @@
1
+ import { DecoratorType, DecoratorTypes } from '../decorators/base/decorator-types.enum';
2
+ /**
3
+ * Contains HelperMethods around handling Entities and their property-metadata.
4
+ */
5
+ export declare abstract class EntityUtilities {
6
+ /**
7
+ * Gets the properties to omit when updating the entity.
8
+ *
9
+ * @param entity - The entity to get the properties which should be left out for updating from.
10
+ * @returns The properties which should be left out for updating an Entity.
11
+ */
12
+ static getOmitForUpdate<EntityType extends object>(entity: EntityType): (keyof EntityType)[];
13
+ /**
14
+ * Gets the properties to omit when creating new entities.
15
+ *
16
+ * @param entity - The entity to get the properties which should be left out for creating from.
17
+ * @returns The properties which should be left out for creating a new Entity.
18
+ */
19
+ static getOmitForCreate<EntityType extends object>(entity: EntityType): (keyof EntityType)[];
20
+ /**
21
+ * Gets the metadata included in an property.
22
+ *
23
+ * @param entity - The entity with the property to get the metadata from.
24
+ * @param propertyKey - The property on the given Entity to get the metadata from.
25
+ * @param type - For secure Typing, defines the returned PropertyConfig.
26
+ * @returns The metadata of the property.
27
+ * @throws When no metadata can be found for the given property.
28
+ */
29
+ static getPropertyMetadata<EntityType extends object, T extends DecoratorTypes>(entity: EntityType, propertyKey: keyof EntityType, type?: T): DecoratorType<T>;
30
+ /**
31
+ * Gets the type of the property-metadata.
32
+ *
33
+ * @param entity - The entity with the property to get the type from.
34
+ * @param propertyKey - The property on the given Entity to get the type from.
35
+ * @returns The type of the metadata.
36
+ * @throws Will throw an error if no metadata can be found for the given property.
37
+ */
38
+ static getPropertyType<EntityType extends object>(entity: EntityType, propertyKey: keyof EntityType): DecoratorTypes;
39
+ /**
40
+ * Sets all property values based on a given entity data-object.
41
+ *
42
+ * @param target - The target object that needs to be constructed (if called inside an Entity constructor its usually this).
43
+ * @param entity - The data object to get the property values from.
44
+ * @alias new
45
+ * @alias build
46
+ * @alias construct
47
+ */
48
+ static new<EntityType extends object>(target: EntityType, entity?: EntityType): void;
49
+ static construct: typeof EntityUtilities.new;
50
+ static build: typeof EntityUtilities.new;
51
+ /**
52
+ * Checks if the values on an entity are valid.
53
+ * Also checks all the validators given by the metadata ("required", "maxLength" etc.).
54
+ *
55
+ * @param entity - The entity to validate.
56
+ * @param omit - Whether to check for creating or editing validity.
57
+ * @returns Whether or not the entity is valid.
58
+ */
59
+ static isEntityValid<EntityType extends object>(entity: EntityType, omit: 'create' | 'update'): boolean;
60
+ /**
61
+ * Checks if a single property value is valid.
62
+ *
63
+ * @param entity - The entity where the property is from.
64
+ * @param key - The name of the property.
65
+ * @param omit - Whether to check if the given entity is valid for creation or updating.
66
+ * @returns Whether or not the property value is valid.
67
+ * @throws Throws when it extracts an unknown metadata type.
68
+ */
69
+ private static isPropertyValid;
70
+ private static isStringValid;
71
+ private static isTextboxValid;
72
+ private static isNumberValid;
73
+ private static isDateValid;
74
+ private static isDateRangeValid;
75
+ private static isDateTimeValid;
76
+ /**
77
+ * Checks if an entity is "dirty" (if its values have changed).
78
+ *
79
+ * @param entity - The entity after all changes.
80
+ * @param entityPriorChanges - The entity before the changes.
81
+ * @returns Whether or not the entity is dirty.
82
+ */
83
+ static dirty<EntityType extends object>(entity: EntityType, entityPriorChanges: EntityType): boolean;
84
+ private static differencesForDirty;
85
+ /**
86
+ * Compares two Entities and returns their difference in an object.
87
+ *
88
+ * @param entity - The first entity to compare.
89
+ * @param entityPriorChanges - The second entity to compare.
90
+ * @returns The difference between the two Entities in form of a Partial.
91
+ */
92
+ static difference<EntityType extends object>(entity: EntityType, entityPriorChanges: EntityType): Partial<EntityType>;
93
+ private static isEqual;
94
+ private static isDateRange;
95
+ /**
96
+ * Compare function for sorting entity keys by their order value.
97
+ *
98
+ * @param a - First key of entity.
99
+ * @param b - Second key of entity.
100
+ * @param entity - Current entity (used to get metadata of entity keys).
101
+ * @returns 0 if both values have the same order, a negative value if 'a' comes before 'b', a positive value if 'a' comes behind 'b'.
102
+ */
103
+ static compareOrder<EntityType extends object>(a: keyof EntityType, b: keyof EntityType, entity: EntityType): number;
104
+ /**
105
+ * Gets the bootstrap column values for "lg", "md", "sm".
106
+ *
107
+ * @param entity - Entity to get the bootstrap column values of the key.
108
+ * @param key - Key of the property to get bootstrap column values from.
109
+ * @param type - Defines for which screen size the column values should be returned.
110
+ * @returns Bootstrap column value.
111
+ */
112
+ static getWidth<EntityType extends object>(entity: EntityType, key: keyof EntityType, type: 'lg' | 'md' | 'sm'): number;
113
+ /**
114
+ * Resets all changes on an entity.
115
+ *
116
+ * @param entity - The entity to reset.
117
+ * @param entityPriorChanges - The entity before any changes.
118
+ */
119
+ static resetChangesOnEntity<EntityType extends object>(entity: EntityType, entityPriorChanges: EntityType): void;
120
+ /**
121
+ * Gets the rows that are used to display the given entity.
122
+ *
123
+ * @param entity - The entity to get the rows from.
124
+ * @param hideOmitForCreate - Whether or not keys with the metadata omitForCreate should be filtered out.
125
+ * @param hideOmitForEdit - Whether or not keys with the metadata omitForUpdate should be filtered out.
126
+ * @returns The sorted Rows containing the row number and the keys to display in that row.
127
+ */
128
+ static getEntityRows<EntityType extends object>(entity: EntityType, hideOmitForCreate?: boolean, hideOmitForEdit?: boolean): EntityRow<EntityType>[];
129
+ private static getKeysForRow;
130
+ private static getNumberOfRows;
131
+ /**
132
+ * Gets the keys of the provided entity correctly typed.
133
+ *
134
+ * @param entity - The entity to get the keys of.
135
+ * @param hideOmitForCreate - Whether or not keys with the metadata omitForCreate should be filtered out.
136
+ * @param hideOmitForEdit - Whether or not keys with the metadata omitForUpdate should be filtered out.
137
+ * @returns An array of keys of the entity.
138
+ */
139
+ static keysOf<EntityType extends object>(entity: EntityType, hideOmitForCreate?: boolean, hideOmitForEdit?: boolean): (keyof EntityType)[];
140
+ }
141
+ /**
142
+ * A row that contains all the information about how to display an entity.
143
+ */
144
+ export interface EntityRow<EntityType extends object> {
145
+ /**
146
+ * The row in which this should be displayed.
147
+ */
148
+ row: number;
149
+ /**
150
+ * The keys of the values that should be displayed in that row.
151
+ */
152
+ keys: (keyof EntityType)[];
153
+ }
@@ -0,0 +1,23 @@
1
+ import { BaseBuilder } from '../../classes/base.builder';
2
+ import { ConfirmDialogData, ConfirmDialogTypes } from './confirm-dialog-data';
3
+ /**
4
+ * The internal ConfirmDialogData. Requires all default values the user can leave out.
5
+ */
6
+ export declare class ConfirmDialogDataInternal implements ConfirmDialogData {
7
+ text: string[];
8
+ type: ConfirmDialogTypes;
9
+ confirmButtonLabel: string;
10
+ cancelButtonLabel: string;
11
+ title: string;
12
+ requireConfirmation: boolean;
13
+ confirmationText?: string;
14
+ constructor(text: string[], type: ConfirmDialogTypes, confirmButtonLabel: string, cancelButtonLabel: string, title: string, requireConfirmation: boolean, confirmationText?: string);
15
+ }
16
+ /**
17
+ * The Builder for the ConfirmDialogData. Sets default values.
18
+ */
19
+ export declare class ConfirmDialogDataBuilder extends BaseBuilder<ConfirmDialogDataInternal, ConfirmDialogData> {
20
+ constructor(data?: ConfirmDialogData);
21
+ protected generateBaseData(data?: ConfirmDialogData): ConfirmDialogDataInternal;
22
+ protected validateInput(data?: ConfirmDialogData): void;
23
+ }
@@ -1,28 +1,37 @@
1
+ /**
2
+ * The different types of a confirm dialog.
3
+ * Is used for displaying different buttons accordingly.
4
+ */
1
5
  export declare type ConfirmDialogTypes = 'default' | 'delete' | 'info-only';
2
6
  /**
3
- * The Definition of the Confirm Dialog Data
7
+ * The Definition of the Confirm Dialog Data.
4
8
  */
5
9
  export interface ConfirmDialogData {
6
10
  /**
7
- * An array of paragraphs to display inside the dialog body
11
+ * An array of paragraphs to display inside the dialog body.
8
12
  */
9
13
  text?: string[];
10
14
  /**
11
15
  * The type of the Confirm Dialog. Changes the button layout. Can be either:
12
- * @value 'default': A confirm- and a cancel-button
13
- * @value 'delete': Like default but the confirm-button is red
14
- * @value 'info-only': Only a cancel-button
16
+ *
17
+ * 'default': A confirm- and a cancel-button.
18
+ *
19
+ * 'delete': Like default but the confirm-button is red.
20
+ *
21
+ * 'info-only': Only a cancel-button.
15
22
  */
16
23
  type?: ConfirmDialogTypes;
17
24
  /**
18
25
  * The label of the button that confirms the dialog.
19
26
  * In case of the 'delete' Dialog this is the string that is shown on the delete-button.
20
- * Defaults to "Confirm" or "Delete", depending on the type
27
+ *
28
+ * @default 'Confirm' or 'Delete', depending on the type
21
29
  */
22
30
  confirmButtonLabel?: string;
23
31
  /**
24
32
  * The label of the button that closes the dialog without doing anything.
25
- * Defaults to "Cancel"
33
+ *
34
+ * @default 'Cancel'
26
35
  */
27
36
  cancelButtonLabel?: string;
28
37
  /**
@@ -31,7 +40,8 @@ export interface ConfirmDialogData {
31
40
  title?: string;
32
41
  /**
33
42
  * Whether or not a checkbox needs to be selected before the user can confirm the dialog.
34
- * Defaults to false.
43
+ *
44
+ * @default false
35
45
  */
36
46
  requireConfirmation?: boolean;
37
47
  /**
@@ -1,17 +1,27 @@
1
1
  import { OnInit } from '@angular/core';
2
2
  import { MatDialogRef } from '@angular/material/dialog';
3
3
  import { ConfirmDialogData } from './confirm-dialog-data';
4
+ import { ConfirmDialogDataInternal } from './confirm-dialog-data.builder';
4
5
  import * as i0 from "@angular/core";
6
+ /**
7
+ * The Dialog used whenever confirmation by the user is required (e.g. When the user tries to delete an entity).
8
+ *
9
+ * Can be customized with the MAT_DIALOG_DATA "inputData". Customization options are defined in "ConfirmDialogData".
10
+ */
5
11
  export declare class NgxMatEntityConfirmDialogComponent implements OnInit {
6
12
  private readonly dialogRef;
7
- readonly data: ConfirmDialogData;
8
- /**
9
- * Used for the checkbox to confirm the action
10
- */
13
+ private readonly inputData;
11
14
  confirm: boolean;
12
- constructor(dialogRef: MatDialogRef<NgxMatEntityConfirmDialogComponent>, data: ConfirmDialogData);
15
+ data: ConfirmDialogDataInternal;
16
+ constructor(dialogRef: MatDialogRef<NgxMatEntityConfirmDialogComponent>, inputData: ConfirmDialogData);
13
17
  ngOnInit(): void;
18
+ /**
19
+ * Closes the dialog with value 1 to signal that the action should be run.
20
+ */
14
21
  confirmAction(): void;
22
+ /**
23
+ * Closes the dialog.
24
+ */
15
25
  cancel(): void;
16
26
  static ɵfac: i0.ɵɵFactoryDeclaration<NgxMatEntityConfirmDialogComponent, never>;
17
27
  static ɵcmp: i0.ɵɵComponentDeclaration<NgxMatEntityConfirmDialogComponent, "ngx-mat-entity-confirm-dialog", never, {}, {}, never, never>;
@@ -1,7 +1,8 @@
1
1
  import { NgModel } from '@angular/forms';
2
2
  /**
3
3
  * Generates a default error message for most validation errors.
4
- * @param model The ngModel to get the error from
5
- * @returns The Validation Error Message to display
4
+ *
5
+ * @param model - The ngModel to get the error from.
6
+ * @returns The Validation Error Message to display.
6
7
  */
7
8
  export declare function getValidationErrorMessage(model: NgModel): string;
@@ -0,0 +1,20 @@
1
+ import { NgModel } from '@angular/forms';
2
+ import { BaseBuilder } from '../../classes/base.builder';
3
+ import { CreateDialogDataInternal } from '../table/create-dialog/create-dialog-data.builder';
4
+ import { AddArrayItemDialogData } from './add-array-item-dialog-data';
5
+ /**
6
+ * The internal AddArrayItemDialogData. Requires all default values the user can leave out.
7
+ */
8
+ export declare class AddArrayItemDialogDataInternal<EntityType extends object> implements AddArrayItemDialogData<EntityType> {
9
+ entity: EntityType;
10
+ createDialogData: CreateDialogDataInternal;
11
+ getValidationErrorMessage: (model: NgModel) => string;
12
+ constructor(entity: EntityType, createDialogData: CreateDialogDataInternal, getValidationErrorMessage: (model: NgModel) => string);
13
+ }
14
+ /**
15
+ * The Builder for the AddArrayItemDialogData. Sets default values.
16
+ */
17
+ export declare class AddArrayItemDialogDataBuilder<EntityType extends object> extends BaseBuilder<AddArrayItemDialogDataInternal<EntityType>, AddArrayItemDialogData<EntityType>> {
18
+ constructor(data: AddArrayItemDialogData<EntityType>);
19
+ protected generateBaseData(data: AddArrayItemDialogData<EntityType>): AddArrayItemDialogDataInternal<EntityType>;
20
+ }
@@ -0,0 +1,19 @@
1
+ import { NgModel } from '@angular/forms';
2
+ import { CreateDialogData } from '../table/table-data';
3
+ /**
4
+ * The configuration options for the dialog that adds items to an array.
5
+ */
6
+ export interface AddArrayItemDialogData<EntityType extends object> {
7
+ /**
8
+ * An empty entity that is used as the data model.
9
+ */
10
+ entity: EntityType;
11
+ /**
12
+ * The info of the generic create-dialog.
13
+ */
14
+ createDialogData?: CreateDialogData;
15
+ /**
16
+ * A custom function to generate the error-message for invalid inputs.
17
+ */
18
+ getValidationErrorMessage?: (model: NgModel) => string;
19
+ }