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.
- package/CONTRIBUTING.md +7 -1
- package/README.md +3 -2
- package/classes/entity-model.class.d.ts +1 -1
- package/classes/entity-service.class.d.ts +27 -17
- package/classes/entity-utilities.class.d.ts +62 -45
- package/components/confirm-dialog/confirm-dialog-data.builder.d.ts +24 -0
- package/components/confirm-dialog/confirm-dialog-data.d.ts +14 -8
- package/components/confirm-dialog/confirm-dialog.component.d.ts +4 -5
- package/components/get-validation-error-message.function.d.ts +3 -2
- package/components/input/array-table/add-array-item-dialog/add-array-item-dialog-data.builder.d.ts +17 -0
- package/components/input/array-table/add-array-item-dialog/add-array-item-dialog-data.d.ts +17 -0
- package/components/input/array-table/add-array-item-dialog/add-array-item-dialog.component.d.ts +5 -18
- package/components/input/array-table/array-table.component.d.ts +3 -3
- package/components/input/input.component.d.ts +18 -21
- package/components/input/internal-input/internal-input.component.d.ts +14 -17
- package/components/table/create-dialog/create-dialog-data.builder.d.ts +20 -0
- package/components/table/create-dialog/create-entity-dialog-data.builder.d.ts +16 -0
- package/components/table/create-dialog/create-entity-dialog-data.d.ts +2 -2
- package/components/table/create-dialog/create-entity-dialog.component.d.ts +4 -2
- package/components/table/edit-dialog/edit-dialog-data.builder.d.ts +27 -0
- package/components/table/edit-dialog/edit-entity-dialog-data.d.ts +5 -5
- package/components/table/edit-dialog/edit-entity-dialog.builder.d.ts +17 -0
- package/components/table/edit-dialog/edit-entity-dialog.component.d.ts +4 -2
- package/components/table/table-data.builder.d.ts +40 -0
- package/components/table/table-data.d.ts +26 -22
- package/components/table/table.component.d.ts +6 -5
- package/decorators/array/array-decorator-internal.data.d.ts +34 -0
- package/decorators/{array.decorator.d.ts → array/array-decorator.data.d.ts} +32 -37
- package/decorators/array/array.decorator.d.ts +10 -0
- package/decorators/base/base-property.decorator.d.ts +7 -6
- package/decorators/base/decorator-types.enum.d.ts +7 -7
- package/decorators/base/property-decorator-internal.data.d.ts +11 -0
- package/decorators/base/{property-decorator-config.interface.d.ts → property-decorator.data.d.ts} +11 -12
- package/decorators/boolean/boolean-decorator-internal.data.d.ts +16 -0
- package/decorators/boolean/boolean-decorator.data.d.ts +28 -0
- package/decorators/boolean/boolean.decorator.d.ts +8 -0
- package/decorators/number/number-decorator-internal.data.d.ts +16 -0
- package/decorators/number/number-decorator.data.d.ts +32 -0
- package/decorators/number/number.decorator.d.ts +8 -0
- package/decorators/object/object-decorator-internal.data.d.ts +8 -0
- package/decorators/object/object-decorator.data.d.ts +22 -0
- package/decorators/object/object.decorator.d.ts +9 -0
- package/decorators/string/string-decorator-internal.data.d.ts +31 -0
- package/decorators/string/string-decorator.data.d.ts +67 -0
- package/decorators/string/string.decorator.d.ts +8 -0
- package/esm2020/classes/entity-model.class.mjs +2 -2
- package/esm2020/classes/entity-service.class.mjs +20 -14
- package/esm2020/classes/entity-utilities.class.mjs +108 -75
- package/esm2020/components/confirm-dialog/confirm-dialog-data.builder.mjs +77 -0
- package/esm2020/components/confirm-dialog/confirm-dialog-data.mjs +1 -1
- package/esm2020/components/confirm-dialog/confirm-dialog.component.mjs +7 -22
- package/esm2020/components/get-validation-error-message.function.mjs +4 -3
- package/esm2020/components/input/array-table/add-array-item-dialog/add-array-item-dialog-data.builder.mjs +33 -0
- package/esm2020/components/input/array-table/add-array-item-dialog/add-array-item-dialog-data.mjs +2 -0
- package/esm2020/components/input/array-table/add-array-item-dialog/add-array-item-dialog.component.mjs +7 -5
- package/esm2020/components/input/array-table/array-table.component.mjs +14 -11
- package/esm2020/components/input/input.component.mjs +3 -6
- package/esm2020/components/input/internal-input/internal-input.component.mjs +1 -4
- package/esm2020/components/table/create-dialog/create-dialog-data.builder.mjs +54 -0
- package/esm2020/components/table/create-dialog/create-entity-dialog-data.builder.mjs +18 -0
- package/esm2020/components/table/create-dialog/create-entity-dialog-data.mjs +1 -1
- package/esm2020/components/table/create-dialog/create-entity-dialog.component.mjs +14 -21
- package/esm2020/components/table/edit-dialog/edit-dialog-data.builder.mjs +81 -0
- package/esm2020/components/table/edit-dialog/edit-entity-dialog-data.mjs +1 -1
- package/esm2020/components/table/edit-dialog/edit-entity-dialog.builder.mjs +19 -0
- package/esm2020/components/table/edit-dialog/edit-entity-dialog.component.mjs +21 -36
- package/esm2020/components/table/table-data.builder.mjs +89 -0
- package/esm2020/components/table/table-data.mjs +1 -1
- package/esm2020/components/table/table.component.mjs +41 -80
- package/esm2020/decorators/array/array-decorator-internal.data.mjs +40 -0
- package/esm2020/decorators/array/array-decorator.data.mjs +7 -0
- package/esm2020/decorators/array/array.decorator.mjs +24 -0
- package/esm2020/decorators/base/base-property.decorator.mjs +6 -5
- package/esm2020/decorators/base/decorator-types.enum.mjs +1 -1
- package/esm2020/decorators/base/property-decorator-internal.data.mjs +15 -0
- package/esm2020/decorators/base/property-decorator.data.mjs +6 -0
- package/esm2020/decorators/boolean/boolean-decorator-internal.data.mjs +22 -0
- package/esm2020/decorators/boolean/boolean-decorator.data.mjs +7 -0
- package/esm2020/decorators/boolean/boolean.decorator.mjs +21 -0
- package/esm2020/decorators/number/number-decorator-internal.data.mjs +17 -0
- package/esm2020/decorators/number/number-decorator.data.mjs +7 -0
- package/esm2020/decorators/number/number.decorator.mjs +18 -0
- package/esm2020/decorators/object/object-decorator-internal.data.mjs +9 -0
- package/esm2020/decorators/object/object-decorator.data.mjs +7 -0
- package/esm2020/decorators/object/object.decorator.mjs +13 -0
- package/esm2020/decorators/string/string-decorator-internal.data.mjs +36 -0
- package/esm2020/decorators/string/string-decorator.data.mjs +7 -0
- package/esm2020/decorators/string/string.decorator.mjs +24 -0
- package/esm2020/public-api.mjs +15 -10
- package/fesm2015/ngx-material-entity.mjs +1019 -683
- package/fesm2015/ngx-material-entity.mjs.map +1 -1
- package/fesm2020/ngx-material-entity.mjs +1005 -684
- package/fesm2020/ngx-material-entity.mjs.map +1 -1
- package/package.json +1 -1
- package/public-api.d.ts +16 -7
- package/decorators/boolean.decorator.d.ts +0 -42
- package/decorators/number.decorator.d.ts +0 -40
- package/decorators/object.decorator.d.ts +0 -27
- package/decorators/string.decorator.d.ts +0 -76
- package/esm2020/decorators/array.decorator.mjs +0 -70
- package/esm2020/decorators/base/property-decorator-config.interface.mjs +0 -31
- package/esm2020/decorators/boolean.decorator.mjs +0 -44
- package/esm2020/decorators/number.decorator.mjs +0 -36
- package/esm2020/decorators/object.decorator.mjs +0 -23
- package/esm2020/decorators/string.decorator.mjs +0 -61
package/CONTRIBUTING.md
CHANGED
|
@@ -13,6 +13,7 @@ All development is done using github.
|
|
|
13
13
|
- [Codestyle](#codestyle)
|
|
14
14
|
- [Decorator Configs / User Input](#decorator-configs--user-input)
|
|
15
15
|
- [Naming conventions](#naming-conventions)
|
|
16
|
+
- [Tests](#tests)
|
|
16
17
|
- [Workflow for submitting Code Changes](#workflow-for-submitting-code-changes)
|
|
17
18
|
- [License](#license)
|
|
18
19
|
|
|
@@ -75,13 +76,18 @@ Their selector should follow the same logic:
|
|
|
75
76
|
|
|
76
77
|
In the folder structure however, you are encouraged to leave the prefix out, because the user will never see this anyway.
|
|
77
78
|
|
|
79
|
+
# Tests
|
|
80
|
+
The testing consists of two test types:
|
|
81
|
+
1. Unit Tests with Jest, should be used for everything that isn't an angular component
|
|
82
|
+
2. E2E Tests using Cypress, should be used to test how angular components behave in the "real" world
|
|
83
|
+
|
|
78
84
|
# Workflow for submitting Code Changes
|
|
79
85
|
|
|
80
86
|
1. Create an issue if it not already exists.
|
|
81
87
|
2. Create a branch for that specific issue (The best way to this is directly inside the issue on the right side under "Development". That way the the issue and the branch are automatically linked)
|
|
82
88
|
3. Checkout the new branch
|
|
83
89
|
4. Add your code
|
|
84
|
-
5. Update / add tests.
|
|
90
|
+
5. Update / add [tests](#tests).
|
|
85
91
|
6. Update the documentation.
|
|
86
92
|
7. Check that tests and linting passes.
|
|
87
93
|
1. For tests: `npm run test`
|
package/README.md
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
# NgxMaterialEntity
|
|
2
2
|
Create Entities and define how to display them directly on their properties.
|
|
3
|
-
<br>
|
|
4
3
|
Can even generate complete and highly customizable CRUD-Tables for them.
|
|
5
4
|
|
|
6
5
|
[](https://github.com/tim-fabian/ngx-material-entity/actions/workflows/main.yml)
|
|
6
|
+
[](https://badge.fury.io/js/ngx-material-entity)
|
|
7
|
+
[](https://snyk.io/test/npm/ngx-material-entity)
|
|
8
|
+
[](https://codecov.io/gh/tim-fabian/ngx-material-entity)
|
|
7
9
|
|
|
8
10
|
# Table of Contents
|
|
9
11
|
- [NgxMaterialEntity](#ngxmaterialentity)
|
|
@@ -688,4 +690,3 @@ export interface MultiSelectAction<EntityType extends Entity> {
|
|
|
688
690
|
enabled?: (entity: EntityType[]) => boolean;
|
|
689
691
|
}
|
|
690
692
|
```
|
|
691
|
-
//TODO
|
|
@@ -12,45 +12,55 @@ export declare abstract class EntityService<EntityType extends Entity> {
|
|
|
12
12
|
/**
|
|
13
13
|
* The base url used for api requests. If u want to have more control over this,
|
|
14
14
|
* you can override the create, read, update and delete methods.
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
15
|
+
*
|
|
16
|
+
* Create Sends a POST-Request to baseUrl.
|
|
17
|
+
*
|
|
18
|
+
* Read Sends a GET-Request to baseUrl.
|
|
19
|
+
*
|
|
20
|
+
* Update Sends a PATCH-Request to baseUrl/{id}.
|
|
21
|
+
*
|
|
22
|
+
* Delete Sends a DEL-Request to baseUrl/{id}.
|
|
19
23
|
*/
|
|
20
24
|
abstract readonly baseUrl: string;
|
|
21
25
|
/**
|
|
22
|
-
*
|
|
26
|
+
* A subject of all the entity values.
|
|
23
27
|
* Can be subscribed to when you want to do a specific thing whenever the entities change.
|
|
24
28
|
*/
|
|
25
29
|
readonly entitiesSubject: BehaviorSubject<EntityType[]>;
|
|
26
30
|
/**
|
|
27
|
-
*
|
|
31
|
+
* Gets the entities in an array from the internal entitiesSubject.
|
|
32
|
+
*
|
|
33
|
+
* @returns The current entities in form of an array.
|
|
28
34
|
*/
|
|
29
35
|
get entities(): EntityType[];
|
|
30
36
|
constructor(http: HttpClient);
|
|
31
37
|
/**
|
|
32
|
-
* Creates a new Entity and pushes it to the entities array
|
|
33
|
-
*
|
|
38
|
+
* Creates a new Entity and pushes it to the entities array.
|
|
39
|
+
*
|
|
40
|
+
* @param entity - The data of the entity to create.
|
|
34
41
|
* All values that should be omitted will be removed from it inside this method.
|
|
35
|
-
* @returns A Promise of the created entity
|
|
42
|
+
* @returns A Promise of the created entity.
|
|
36
43
|
*/
|
|
37
44
|
create(entity: EntityType): Promise<EntityType>;
|
|
38
45
|
/**
|
|
39
|
-
* Gets all existing entities and pushes them to the entites array
|
|
40
|
-
*
|
|
46
|
+
* Gets all existing entities and pushes them to the entites array.
|
|
47
|
+
*
|
|
48
|
+
* @returns A Promise of all received Entities.
|
|
41
49
|
*/
|
|
42
50
|
read(): Promise<EntityType[]>;
|
|
43
51
|
/**
|
|
44
|
-
* Updates a specific Entity
|
|
45
|
-
*
|
|
52
|
+
* Updates a specific Entity.
|
|
53
|
+
*
|
|
54
|
+
* @param entity - The updated Entity
|
|
46
55
|
* 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
|
|
56
|
+
* @param entityPriorChanges - The current Entity.
|
|
57
|
+
* It Is used to get changed values and only update them instead of sending the whole entity data.
|
|
49
58
|
*/
|
|
50
59
|
update(entity: EntityType, entityPriorChanges: EntityType): Promise<void>;
|
|
51
60
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
61
|
+
* Deletes a specific Entity.
|
|
62
|
+
*
|
|
63
|
+
* @param id - The id of the element to delete.
|
|
54
64
|
*/
|
|
55
65
|
delete(id: string): Promise<void>;
|
|
56
66
|
}
|
|
@@ -1,40 +1,47 @@
|
|
|
1
1
|
import { DecoratorType, DecoratorTypes } from '../decorators/base/decorator-types.enum';
|
|
2
2
|
import { Entity } from './entity-model.class';
|
|
3
3
|
/**
|
|
4
|
-
* Contains HelperMethods around handling Entities and their property-metadata
|
|
4
|
+
* Contains HelperMethods around handling Entities and their property-metadata.
|
|
5
5
|
*/
|
|
6
6
|
export declare abstract class EntityUtilities {
|
|
7
7
|
/**
|
|
8
|
-
* Gets the properties to omit when updating the entity
|
|
9
|
-
*
|
|
8
|
+
* Gets the properties to omit when updating the entity.
|
|
9
|
+
*
|
|
10
|
+
* @param entity - The entity to get the properties which should be left out for updating from.
|
|
11
|
+
* @returns The properties which should be left out for updating an Entity.
|
|
10
12
|
*/
|
|
11
13
|
static getOmitForUpdate<EntityType extends Entity>(entity: EntityType): (keyof EntityType)[];
|
|
12
14
|
/**
|
|
13
|
-
* Gets the properties to omit when creating new entities
|
|
14
|
-
*
|
|
15
|
+
* Gets the properties to omit when creating new entities.
|
|
16
|
+
*
|
|
17
|
+
* @param entity - The entity to get the properties which should be left out for creating from.
|
|
18
|
+
* @returns The properties which should be left out for creating a new Entity.
|
|
15
19
|
*/
|
|
16
20
|
static getOmitForCreate<EntityType extends Entity>(entity: EntityType): (keyof EntityType)[];
|
|
17
21
|
/**
|
|
18
|
-
* Gets the metadata included in an property
|
|
19
|
-
*
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
22
|
-
* @
|
|
22
|
+
* Gets the metadata included in an property.
|
|
23
|
+
*
|
|
24
|
+
* @param entity - The entity with the property to get the metadata from.
|
|
25
|
+
* @param propertyKey - The property on the given Entity to get the metadata from.
|
|
26
|
+
* @param type - For secure Typing, defines the returned PropertyConfig.
|
|
27
|
+
* @returns The metadata of the property.
|
|
28
|
+
* @throws When no metadata can be found for the given property.
|
|
23
29
|
*/
|
|
24
30
|
static getPropertyMetadata<EntityType extends Entity, T extends DecoratorTypes>(entity: EntityType, propertyKey: keyof EntityType, type: T): DecoratorType<T>;
|
|
25
31
|
/**
|
|
26
32
|
* Gets the type of the property-metadata.
|
|
27
|
-
*
|
|
28
|
-
* @param
|
|
29
|
-
* @
|
|
33
|
+
*
|
|
34
|
+
* @param entity - The entity with the property to get the type from.
|
|
35
|
+
* @param propertyKey - The property on the given Entity to get the type from.
|
|
36
|
+
* @returns The type of the metadata.
|
|
37
|
+
* @throws Will throw an error if no metadata can be found for the given property.
|
|
30
38
|
*/
|
|
31
39
|
static getPropertyType<EntityType extends Entity>(entity: EntityType, propertyKey: keyof EntityType): DecoratorTypes;
|
|
32
40
|
/**
|
|
33
41
|
* Sets all property values based on a given entity data-object.
|
|
34
|
-
*
|
|
35
|
-
* @param target
|
|
36
|
-
*
|
|
37
|
-
* (if called inside a Entity constructor its usually this)
|
|
42
|
+
*
|
|
43
|
+
* @param target - The target object that needs to be constructed (if called inside an Entity constructor its usually this).
|
|
44
|
+
* @param entity - The data object to get the property values from.
|
|
38
45
|
* @alias new
|
|
39
46
|
* @alias build
|
|
40
47
|
* @alias construct
|
|
@@ -44,52 +51,62 @@ export declare abstract class EntityUtilities {
|
|
|
44
51
|
static build: typeof EntityUtilities.new;
|
|
45
52
|
/**
|
|
46
53
|
* Checks if the values on an entity are valid.
|
|
47
|
-
* Also checks all the validators given by the metadata ("required", "maxLength" etc.)
|
|
48
|
-
*
|
|
49
|
-
* @param
|
|
54
|
+
* Also checks all the validators given by the metadata ("required", "maxLength" etc.).
|
|
55
|
+
*
|
|
56
|
+
* @param entity - The entity to validate.
|
|
57
|
+
* @param omit - Whether to check for creatiung or editing validity.
|
|
50
58
|
* @returns Whether or not the entity is valid.
|
|
51
59
|
*/
|
|
52
|
-
static isEntityValid<EntityType extends Entity>(entity: EntityType, omit: 'create' | '
|
|
60
|
+
static isEntityValid<EntityType extends Entity>(entity: EntityType, omit: 'create' | 'update'): boolean;
|
|
53
61
|
/**
|
|
54
|
-
* Checks if a single property value is valid
|
|
55
|
-
*
|
|
56
|
-
* @param
|
|
57
|
-
* @
|
|
62
|
+
* Checks if a single property value is valid.
|
|
63
|
+
*
|
|
64
|
+
* @param entity - The entity where the property is from.
|
|
65
|
+
* @param key - The name of the property.
|
|
66
|
+
* @param omit - Whether to check if the given entity is valid for creation or updating.
|
|
67
|
+
* @returns Whether or not the property value is valid.
|
|
68
|
+
* @throws Throws when it extracts an unknown metadata type.
|
|
58
69
|
*/
|
|
59
70
|
private static isPropertyValid;
|
|
60
71
|
/**
|
|
61
|
-
* Checks if an entity is "dirty" (if its values have changed)
|
|
62
|
-
*
|
|
63
|
-
* @param
|
|
64
|
-
* @
|
|
72
|
+
* Checks if an entity is "dirty" (if its values have changed).
|
|
73
|
+
*
|
|
74
|
+
* @param entity - The entity after all changes.
|
|
75
|
+
* @param entityPriorChanges - The entity before the changes.
|
|
76
|
+
* @returns Whether or not the entity is dirty.
|
|
65
77
|
*/
|
|
66
78
|
static dirty(entity: Entity, entityPriorChanges: Entity): boolean;
|
|
67
79
|
/**
|
|
68
|
-
* Compares two Entities and returns their difference in an object
|
|
69
|
-
*
|
|
70
|
-
* @param
|
|
71
|
-
* @
|
|
80
|
+
* Compares two Entities and returns their difference in an object.
|
|
81
|
+
*
|
|
82
|
+
* @param entity - The first entity to compare.
|
|
83
|
+
* @param entityPriorChanges - The second entity to compare.
|
|
84
|
+
* @returns The difference between the two Entities in form of a Partial.
|
|
72
85
|
*/
|
|
73
86
|
static difference<EntityType extends Entity>(entity: EntityType, entityPriorChanges: EntityType): Partial<EntityType>;
|
|
74
87
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* @param
|
|
78
|
-
* @param
|
|
88
|
+
* Compare function for sorting entity keys by their order value.
|
|
89
|
+
*
|
|
90
|
+
* @param a - First key of entity.
|
|
91
|
+
* @param b - Second key of entity.
|
|
92
|
+
* @param entity - Current entity (used to get metadata of entity keys).
|
|
93
|
+
* @returns 0 if both values have the same order, a negative value if X, a positive value if Y.
|
|
79
94
|
*/
|
|
80
95
|
static compareOrder<EntityType extends Entity>(a: keyof EntityType, b: keyof EntityType, entity: EntityType): number;
|
|
81
96
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* @param
|
|
85
|
-
* @param
|
|
86
|
-
* @
|
|
97
|
+
* Gets the bootstrap column values for "lg", "md", "sm".
|
|
98
|
+
*
|
|
99
|
+
* @param entity - Entity to get the bootstrap column values of the key.
|
|
100
|
+
* @param key - Key of the property to get bootstrap column values from.
|
|
101
|
+
* @param type - Defines for which screensize the column values should be returned.
|
|
102
|
+
* @returns Bootstrap column value.
|
|
87
103
|
*/
|
|
88
104
|
static getWidth<EntityType extends Entity>(entity: EntityType, key: keyof EntityType, type: 'lg' | 'md' | 'sm'): number;
|
|
89
105
|
/**
|
|
90
|
-
* Resets all changes on an entity
|
|
91
|
-
*
|
|
92
|
-
* @param
|
|
106
|
+
* Resets all changes on an entity.
|
|
107
|
+
*
|
|
108
|
+
* @param entity - The entity to reset.
|
|
109
|
+
* @param entityPriorChanges - The entity before any changes.
|
|
93
110
|
*/
|
|
94
111
|
static resetChangesOnEntity<EntityType extends Entity>(entity: EntityType, entityPriorChanges: EntityType): void;
|
|
95
112
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ConfirmDialogData, ConfirmDialogTypes } from './confirm-dialog-data';
|
|
2
|
+
export declare class ConfirmDialogDataInternal implements ConfirmDialogData {
|
|
3
|
+
text: string[];
|
|
4
|
+
type: ConfirmDialogTypes;
|
|
5
|
+
confirmButtonLabel: string;
|
|
6
|
+
cancelButtonLabel: string;
|
|
7
|
+
title: string;
|
|
8
|
+
requireConfirmation: boolean;
|
|
9
|
+
confirmationText?: string;
|
|
10
|
+
constructor(text: string[], type: ConfirmDialogTypes, confirmButtonLabel: string, cancelButtonLabel: string, title: string, requireConfirmation: boolean, confirmationText?: string);
|
|
11
|
+
}
|
|
12
|
+
export declare class ConfirmDialogDataBuilder {
|
|
13
|
+
confirmDialogData: ConfirmDialogDataInternal;
|
|
14
|
+
private readonly dataInput?;
|
|
15
|
+
constructor(data?: ConfirmDialogData);
|
|
16
|
+
private validateInput;
|
|
17
|
+
withDefaultText(text: string[]): ConfirmDialogDataBuilder;
|
|
18
|
+
withDefaultType(type: ConfirmDialogTypes): ConfirmDialogDataBuilder;
|
|
19
|
+
withDefaultConfirmButtonLabel(label: string): ConfirmDialogDataBuilder;
|
|
20
|
+
withDefaultCancelButtonLabel(label: string): ConfirmDialogDataBuilder;
|
|
21
|
+
withDefaultTitle(title: string): ConfirmDialogDataBuilder;
|
|
22
|
+
withDefaultRequireConfirmation(requireConfirmation: boolean): ConfirmDialogDataBuilder;
|
|
23
|
+
withDefaultConfirmationText(confirmationText: string): ConfirmDialogDataBuilder;
|
|
24
|
+
}
|
|
@@ -1,28 +1,33 @@
|
|
|
1
1
|
export declare type ConfirmDialogTypes = 'default' | 'delete' | 'info-only';
|
|
2
2
|
/**
|
|
3
|
-
* The Definition of the Confirm Dialog Data
|
|
3
|
+
* The Definition of the Confirm Dialog Data.
|
|
4
4
|
*/
|
|
5
5
|
export interface ConfirmDialogData {
|
|
6
6
|
/**
|
|
7
|
-
* An array of paragraphs to display inside the dialog body
|
|
7
|
+
* An array of paragraphs to display inside the dialog body.
|
|
8
8
|
*/
|
|
9
9
|
text?: string[];
|
|
10
10
|
/**
|
|
11
11
|
* The type of the Confirm Dialog. Changes the button layout. Can be either:
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
*
|
|
13
|
+
* 'default': A confirm- and a cancel-button.
|
|
14
|
+
*
|
|
15
|
+
* 'delete': Like default but the confirm-button is red.
|
|
16
|
+
*
|
|
17
|
+
* 'info-only': Only a cancel-button.
|
|
15
18
|
*/
|
|
16
19
|
type?: ConfirmDialogTypes;
|
|
17
20
|
/**
|
|
18
21
|
* The label of the button that confirms the dialog.
|
|
19
22
|
* In case of the 'delete' Dialog this is the string that is shown on the delete-button.
|
|
20
|
-
*
|
|
23
|
+
*
|
|
24
|
+
* @default 'Confirm' or 'Delete', depending on the type
|
|
21
25
|
*/
|
|
22
26
|
confirmButtonLabel?: string;
|
|
23
27
|
/**
|
|
24
28
|
* The label of the button that closes the dialog without doing anything.
|
|
25
|
-
*
|
|
29
|
+
*
|
|
30
|
+
* @default 'Cancel'
|
|
26
31
|
*/
|
|
27
32
|
cancelButtonLabel?: string;
|
|
28
33
|
/**
|
|
@@ -31,7 +36,8 @@ export interface ConfirmDialogData {
|
|
|
31
36
|
title?: string;
|
|
32
37
|
/**
|
|
33
38
|
* Whether or not a checkbox needs to be selected before the user can confirm the dialog.
|
|
34
|
-
*
|
|
39
|
+
*
|
|
40
|
+
* @default false
|
|
35
41
|
*/
|
|
36
42
|
requireConfirmation?: boolean;
|
|
37
43
|
/**
|
|
@@ -1,15 +1,14 @@
|
|
|
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";
|
|
5
6
|
export declare class NgxMatEntityConfirmDialogComponent implements OnInit {
|
|
6
7
|
private readonly dialogRef;
|
|
7
|
-
readonly
|
|
8
|
-
/**
|
|
9
|
-
* Used for the checkbox to confirm the action
|
|
10
|
-
*/
|
|
8
|
+
private readonly inputData;
|
|
11
9
|
confirm: boolean;
|
|
12
|
-
|
|
10
|
+
data: ConfirmDialogDataInternal;
|
|
11
|
+
constructor(dialogRef: MatDialogRef<NgxMatEntityConfirmDialogComponent>, inputData: ConfirmDialogData);
|
|
13
12
|
ngOnInit(): void;
|
|
14
13
|
confirmAction(): void;
|
|
15
14
|
cancel(): void;
|
|
@@ -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
|
-
*
|
|
5
|
-
* @
|
|
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;
|
package/components/input/array-table/add-array-item-dialog/add-array-item-dialog-data.builder.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { NgModel } from '@angular/forms';
|
|
2
|
+
import { Entity } from '../../../../classes/entity-model.class';
|
|
3
|
+
import { CreateDialogDataInternal } from '../../../table/create-dialog/create-dialog-data.builder';
|
|
4
|
+
import { AddArrayItemDialogData } from './add-array-item-dialog-data';
|
|
5
|
+
export declare class AddArrayItemDialogDataInternal<EntityType extends Entity> implements AddArrayItemDialogData<EntityType> {
|
|
6
|
+
entity: EntityType;
|
|
7
|
+
createDialogData: CreateDialogDataInternal;
|
|
8
|
+
getValidationErrorMessage: (model: NgModel) => string;
|
|
9
|
+
constructor(entity: EntityType, createDialogData: CreateDialogDataInternal, getValidationErrorMessage: (model: NgModel) => string);
|
|
10
|
+
}
|
|
11
|
+
export declare class AddArrayItemDialogDataBuilder<EntityType extends Entity> {
|
|
12
|
+
addArrayItemDialogData: AddArrayItemDialogDataInternal<EntityType>;
|
|
13
|
+
private readonly dataInput;
|
|
14
|
+
constructor(data: AddArrayItemDialogData<EntityType>);
|
|
15
|
+
withDefaultCreateDialogData(createDialogData: CreateDialogDataInternal): AddArrayItemDialogDataBuilder<EntityType>;
|
|
16
|
+
withDefaultGetValidationErrorMessage(getValidationErrorMessage: (model: NgModel) => string): AddArrayItemDialogDataBuilder<EntityType>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { NgModel } from '@angular/forms';
|
|
2
|
+
import { Entity } from '../../../../classes/entity-model.class';
|
|
3
|
+
import { CreateDialogData } from '../../../table/table-data';
|
|
4
|
+
export interface AddArrayItemDialogData<EntityType extends Entity> {
|
|
5
|
+
/**
|
|
6
|
+
* An empty entity that is used as the data model.
|
|
7
|
+
*/
|
|
8
|
+
entity: EntityType;
|
|
9
|
+
/**
|
|
10
|
+
* The info of the generic create-dialog.
|
|
11
|
+
*/
|
|
12
|
+
createDialogData?: CreateDialogData;
|
|
13
|
+
/**
|
|
14
|
+
* A custom function to generate the error-message for invalid inputs.
|
|
15
|
+
*/
|
|
16
|
+
getValidationErrorMessage?: (model: NgModel) => string;
|
|
17
|
+
}
|
package/components/input/array-table/add-array-item-dialog/add-array-item-dialog.component.d.ts
CHANGED
|
@@ -1,31 +1,18 @@
|
|
|
1
1
|
import { OnInit } from '@angular/core';
|
|
2
|
-
import { NgModel } from '@angular/forms';
|
|
3
2
|
import { MatDialogRef } from '@angular/material/dialog';
|
|
4
3
|
import { Entity } from '../../../../classes/entity-model.class';
|
|
5
4
|
import { EntityUtilities } from '../../../../classes/entity-utilities.class';
|
|
6
|
-
import {
|
|
5
|
+
import { AddArrayItemDialogData } from './add-array-item-dialog-data';
|
|
6
|
+
import { AddArrayItemDialogDataInternal } from './add-array-item-dialog-data.builder';
|
|
7
7
|
import * as i0 from "@angular/core";
|
|
8
|
-
export interface AddArrayItemDialogData<EntityType extends Entity> {
|
|
9
|
-
/**
|
|
10
|
-
* An empty entity that is used as the data model.
|
|
11
|
-
*/
|
|
12
|
-
entity: EntityType;
|
|
13
|
-
/**
|
|
14
|
-
* The info of the generic create-dialog.
|
|
15
|
-
*/
|
|
16
|
-
createDialogData: CreateDialogData;
|
|
17
|
-
/**
|
|
18
|
-
* (optional) A custom function to generate the error-message for invalid inputs.
|
|
19
|
-
*/
|
|
20
|
-
getValidationErrorMessage: (model: NgModel) => string;
|
|
21
|
-
}
|
|
22
8
|
export declare class NgxMatEntityAddArrayItemDialogComponent<EntityType extends Entity> implements OnInit {
|
|
23
|
-
|
|
9
|
+
private readonly inputData;
|
|
24
10
|
dialogRef: MatDialogRef<NgxMatEntityAddArrayItemDialogComponent<EntityType>>;
|
|
25
11
|
EntityUtilities: typeof EntityUtilities;
|
|
26
12
|
entityKeys: (keyof EntityType)[];
|
|
27
13
|
getWidth: typeof EntityUtilities.getWidth;
|
|
28
|
-
|
|
14
|
+
data: AddArrayItemDialogDataInternal<EntityType>;
|
|
15
|
+
constructor(inputData: AddArrayItemDialogData<EntityType>, dialogRef: MatDialogRef<NgxMatEntityAddArrayItemDialogComponent<EntityType>>);
|
|
29
16
|
ngOnInit(): void;
|
|
30
17
|
private setEntityKeys;
|
|
31
18
|
create(): void;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { SelectionModel } from '@angular/cdk/collections';
|
|
2
2
|
import { OnInit } from '@angular/core';
|
|
3
|
-
import { EntityArrayDecoratorConfig } from '../../../decorators/array.decorator';
|
|
4
3
|
import { Entity } from '../../../classes/entity-model.class';
|
|
5
4
|
import { EntityUtilities } from '../../../classes/entity-utilities.class';
|
|
6
5
|
import { NgModel } from '@angular/forms';
|
|
7
6
|
import { MatTableDataSource } from '@angular/material/table';
|
|
8
7
|
import { MatDialog } from '@angular/material/dialog';
|
|
8
|
+
import { EntityArrayDecoratorConfigInternal } from '../../../decorators/array/array-decorator-internal.data';
|
|
9
9
|
import * as i0 from "@angular/core";
|
|
10
10
|
export declare class NgxMatEntityArrayTableComponent<EntityType extends Entity> implements OnInit {
|
|
11
11
|
private readonly dialog;
|
|
12
12
|
arrayItems: EntityType[];
|
|
13
|
-
metadata:
|
|
13
|
+
metadata: EntityArrayDecoratorConfigInternal<EntityType>;
|
|
14
14
|
getValidationErrorMessage: (model: NgModel) => string;
|
|
15
|
-
omit: 'create' | '
|
|
15
|
+
omit: 'create' | 'update';
|
|
16
16
|
dataSource: MatTableDataSource<EntityType>;
|
|
17
17
|
selection: SelectionModel<EntityType>;
|
|
18
18
|
displayedColumns: string[];
|
|
@@ -3,14 +3,14 @@ import { NgModel } from '@angular/forms';
|
|
|
3
3
|
import { 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
14
|
import * as i0 from "@angular/core";
|
|
15
15
|
export declare class NgxMatEntityInputComponent<EntityType extends Entity> implements OnInit {
|
|
16
16
|
/**
|
|
@@ -37,30 +37,27 @@ export declare class NgxMatEntityInputComponent<EntityType extends Entity> imple
|
|
|
37
37
|
*/
|
|
38
38
|
hideOmitForEdit?: boolean;
|
|
39
39
|
type: DecoratorTypes;
|
|
40
|
-
metadata:
|
|
41
|
-
metadataDefaultString:
|
|
42
|
-
metadataTextboxString:
|
|
43
|
-
metadataAutocompleteString:
|
|
40
|
+
metadata: PropertyDecoratorConfigInternal;
|
|
41
|
+
metadataDefaultString: DefaultStringDecoratorConfigInternal;
|
|
42
|
+
metadataTextboxString: TextboxStringDecoratorConfigInternal;
|
|
43
|
+
metadataAutocompleteString: AutocompleteStringDecoratorConfigInternal;
|
|
44
44
|
autocompleteStrings: string[];
|
|
45
45
|
filteredAutocompleteStrings: string[];
|
|
46
|
-
metadataDropdownString:
|
|
47
|
-
metadataDropdownBoolean:
|
|
48
|
-
metadataDefaultNumber:
|
|
49
|
-
metadataDropdownNumber:
|
|
50
|
-
metadataDefaultObject:
|
|
46
|
+
metadataDropdownString: DropdownStringDecoratorConfigInternal;
|
|
47
|
+
metadataDropdownBoolean: DropdownBooleanDecoratorConfigInternal;
|
|
48
|
+
metadataDefaultNumber: DefaultNumberDecoratorConfigInternal;
|
|
49
|
+
metadataDropdownNumber: DropdownNumberDecoratorConfigInternal;
|
|
50
|
+
metadataDefaultObject: DefaultObjectDecoratorConfigInternal<EntityType>;
|
|
51
51
|
objectProperty: Entity;
|
|
52
|
-
metadataEntityArray:
|
|
52
|
+
metadataEntityArray: EntityArrayDecoratorConfigInternal<Entity>;
|
|
53
53
|
entityArrayValues: Entity[];
|
|
54
|
-
metadataStringChipsArray:
|
|
54
|
+
metadataStringChipsArray: StringChipsArrayDecoratorConfigInternal;
|
|
55
55
|
stringChipsArrayValues: string[];
|
|
56
56
|
chipsInput: string;
|
|
57
|
-
metadataAutocompleteStringChipsArray:
|
|
57
|
+
metadataAutocompleteStringChipsArray: AutocompleteStringChipsArrayDecoratorConfigInternal;
|
|
58
58
|
readonly DecoratorTypes: typeof DecoratorTypes;
|
|
59
59
|
getWidth: typeof EntityUtilities.getWidth;
|
|
60
60
|
constructor();
|
|
61
|
-
/**
|
|
62
|
-
* Helper method needed to recursively generate property input components (used eg. with the object)
|
|
63
|
-
*/
|
|
64
61
|
trackByFn(index: unknown): unknown;
|
|
65
62
|
ngOnInit(): void;
|
|
66
63
|
getObjectProperties(): (keyof Entity)[];
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { OnInit } from '@angular/core';
|
|
2
2
|
import { DecoratorTypes } from '../../../decorators/base/decorator-types.enum';
|
|
3
|
-
import { PropertyDecoratorConfig } from '../../../decorators/base/property-decorator-config.interface';
|
|
4
|
-
import { DefaultNumberDecoratorConfig, DropdownNumberDecoratorConfig } from '../../../decorators/number.decorator';
|
|
5
|
-
import { AutocompleteStringDecoratorConfig, DefaultStringDecoratorConfig, DropdownStringDecoratorConfig, TextboxStringDecoratorConfig } from '../../../decorators/string.decorator';
|
|
6
|
-
import { DropdownBooleanDecoratorConfig } from '../../../decorators/boolean.decorator';
|
|
7
3
|
import { Entity } from '../../../classes/entity-model.class';
|
|
8
|
-
import { DefaultObjectDecoratorConfig } from '../../../decorators/object.decorator';
|
|
9
4
|
import { EntityUtilities } from '../../../classes/entity-utilities.class';
|
|
10
5
|
import { NgModel } from '@angular/forms';
|
|
6
|
+
import { DropdownBooleanDecoratorConfigInternal } from '../../../decorators/boolean/boolean-decorator-internal.data';
|
|
7
|
+
import { DefaultNumberDecoratorConfigInternal, DropdownNumberDecoratorConfigInternal } from '../../../decorators/number/number-decorator-internal.data';
|
|
8
|
+
import { DefaultObjectDecoratorConfigInternal } from '../../../decorators/object/object-decorator-internal.data';
|
|
9
|
+
import { AutocompleteStringDecoratorConfigInternal, DefaultStringDecoratorConfigInternal, DropdownStringDecoratorConfigInternal, TextboxStringDecoratorConfigInternal } from '../../../decorators/string/string-decorator-internal.data';
|
|
10
|
+
import { PropertyDecoratorConfigInternal } from '../../../decorators/base/property-decorator-internal.data';
|
|
11
11
|
import * as i0 from "@angular/core";
|
|
12
12
|
export declare class NgxMatEntityInternalInputComponent<EntityType extends Entity> implements OnInit {
|
|
13
13
|
/**
|
|
@@ -34,21 +34,18 @@ export declare class NgxMatEntityInternalInputComponent<EntityType extends Entit
|
|
|
34
34
|
*/
|
|
35
35
|
getValidationErrorMessage: (model: NgModel) => string;
|
|
36
36
|
type: DecoratorTypes;
|
|
37
|
-
metadata:
|
|
38
|
-
metadataDefaultString:
|
|
39
|
-
metadataTextboxString:
|
|
40
|
-
metadataAutocompleteString:
|
|
41
|
-
metadataDropdownString:
|
|
42
|
-
metadataDropdownBoolean:
|
|
43
|
-
metadataDefaultNumber:
|
|
44
|
-
metadataDropdownNumber:
|
|
45
|
-
metadataDefaultObject:
|
|
37
|
+
metadata: PropertyDecoratorConfigInternal;
|
|
38
|
+
metadataDefaultString: DefaultStringDecoratorConfigInternal;
|
|
39
|
+
metadataTextboxString: TextboxStringDecoratorConfigInternal;
|
|
40
|
+
metadataAutocompleteString: AutocompleteStringDecoratorConfigInternal;
|
|
41
|
+
metadataDropdownString: DropdownStringDecoratorConfigInternal;
|
|
42
|
+
metadataDropdownBoolean: DropdownBooleanDecoratorConfigInternal;
|
|
43
|
+
metadataDefaultNumber: DefaultNumberDecoratorConfigInternal;
|
|
44
|
+
metadataDropdownNumber: DropdownNumberDecoratorConfigInternal;
|
|
45
|
+
metadataDefaultObject: DefaultObjectDecoratorConfigInternal<EntityType>;
|
|
46
46
|
objectProperty: Entity;
|
|
47
47
|
readonly DecoratorTypes: typeof DecoratorTypes;
|
|
48
48
|
getWidth: typeof EntityUtilities.getWidth;
|
|
49
|
-
/**
|
|
50
|
-
* Helper method needed to recursively generate property input components (used eg. with the object)
|
|
51
|
-
*/
|
|
52
49
|
trackByFn(index: unknown): unknown;
|
|
53
50
|
ngOnInit(): void;
|
|
54
51
|
getObjectProperties(): (keyof Entity)[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ConfirmDialogDataInternal } from '../../confirm-dialog/confirm-dialog-data.builder';
|
|
2
|
+
import { CreateDialogData } from '../table-data';
|
|
3
|
+
export declare class CreateDialogDataInternal implements CreateDialogData {
|
|
4
|
+
title: string;
|
|
5
|
+
createButtonLabel: string;
|
|
6
|
+
cancelButtonLabel: string;
|
|
7
|
+
createRequiresConfirmDialog: boolean;
|
|
8
|
+
confirmCreateDialogData: ConfirmDialogDataInternal;
|
|
9
|
+
constructor(title: string, createButtonLabel: string, cancelButtonLabel: string, createRequiresConfirmDialog: boolean, confirmCreateDialogData: ConfirmDialogDataInternal);
|
|
10
|
+
}
|
|
11
|
+
export declare class CreateDialogDataBuilder {
|
|
12
|
+
createDialogData: CreateDialogDataInternal;
|
|
13
|
+
private readonly dataInput?;
|
|
14
|
+
constructor(data?: CreateDialogData);
|
|
15
|
+
withDefaultTitle(title: string): CreateDialogDataBuilder;
|
|
16
|
+
withDefaultCreateButtonLabel(label: string): CreateDialogDataBuilder;
|
|
17
|
+
withDefaultCancelButtonLabel(label: string): CreateDialogDataBuilder;
|
|
18
|
+
withDefaultCreateRequiresConfirmDialog(createRequiresConfirmDialog: boolean): CreateDialogDataBuilder;
|
|
19
|
+
withDefaultConfirmCreateDialogData(confirmCreateDialogData: ConfirmDialogDataInternal): CreateDialogDataBuilder;
|
|
20
|
+
}
|