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.
- package/CONTRIBUTING.md +7 -1
- package/README.md +3 -2
- package/classes/base-builder.class.d.ts +35 -0
- 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 +96 -46
- package/components/confirm-dialog/confirm-dialog-data.builder.d.ts +23 -0
- package/components/confirm-dialog/confirm-dialog-data.d.ts +18 -8
- package/components/confirm-dialog/confirm-dialog.component.d.ts +15 -5
- package/components/get-validation-error-message.function.d.ts +3 -2
- package/components/input/add-array-item-dialog-data.builder.d.ts +21 -0
- package/components/input/add-array-item-dialog-data.d.ts +20 -0
- package/components/input/input.component.d.ts +116 -26
- package/components/input/input.module.d.ts +6 -4
- package/components/table/create-dialog/create-dialog-data.builder.d.ts +21 -0
- package/components/table/create-dialog/create-entity-dialog-data.builder.d.ts +22 -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 +19 -5
- package/components/table/edit-dialog/edit-dialog-data.builder.d.ts +25 -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 +23 -0
- package/components/table/edit-dialog/edit-entity-dialog.component.d.ts +23 -5
- package/components/table/table-data.builder.d.ts +51 -0
- package/components/table/table-data.d.ts +40 -24
- package/components/table/table.component.d.ts +52 -5
- package/components/table/table.module.d.ts +3 -1
- package/decorators/array/array-decorator-internal.data.d.ts +45 -0
- package/decorators/array/array-decorator.data.d.ts +129 -0
- 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 +24 -0
- package/decorators/base/property-decorator.data.d.ts +70 -0
- package/decorators/boolean/boolean-decorator-internal.data.d.ts +25 -0
- package/decorators/boolean/boolean-decorator.data.d.ts +37 -0
- package/decorators/boolean/boolean.decorator.d.ts +8 -0
- package/decorators/number/number-decorator-internal.data.d.ts +22 -0
- package/decorators/number/number-decorator.data.d.ts +38 -0
- package/decorators/number/number.decorator.d.ts +8 -0
- package/decorators/object/object-decorator-internal.data.d.ts +11 -0
- package/decorators/object/object-decorator.data.d.ts +25 -0
- package/decorators/object/object.decorator.d.ts +9 -0
- package/decorators/string/string-decorator-internal.data.d.ts +43 -0
- package/decorators/string/string-decorator.data.d.ts +79 -0
- package/decorators/string/string.decorator.d.ts +8 -0
- package/esm2020/classes/base-builder.class.mjs +43 -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 +182 -101
- package/esm2020/components/confirm-dialog/confirm-dialog-data.builder.mjs +44 -0
- package/esm2020/components/confirm-dialog/confirm-dialog-data.mjs +1 -1
- package/esm2020/components/confirm-dialog/confirm-dialog.component.mjs +18 -22
- package/esm2020/components/get-validation-error-message.function.mjs +8 -3
- package/esm2020/components/input/add-array-item-dialog-data.builder.mjs +30 -0
- package/esm2020/components/input/add-array-item-dialog-data.mjs +2 -0
- package/esm2020/components/input/input.component.mjs +168 -32
- package/esm2020/components/input/input.module.mjs +19 -9
- package/esm2020/components/table/create-dialog/create-dialog-data.builder.mjs +32 -0
- package/esm2020/components/table/create-dialog/create-entity-dialog-data.builder.mjs +26 -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 +30 -30
- package/esm2020/components/table/create-dialog/create-entity-dialog.module.mjs +20 -4
- package/esm2020/components/table/edit-dialog/edit-dialog-data.builder.mjs +41 -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 +27 -0
- package/esm2020/components/table/edit-dialog/edit-entity-dialog.component.mjs +43 -47
- package/esm2020/components/table/table-data.builder.mjs +105 -0
- package/esm2020/components/table/table-data.mjs +1 -1
- package/esm2020/components/table/table.component.mjs +90 -82
- package/esm2020/components/table/table.module.mjs +12 -4
- package/esm2020/decorators/array/array-decorator-internal.data.mjs +51 -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 +38 -0
- package/esm2020/decorators/base/property-decorator.data.mjs +6 -0
- package/esm2020/decorators/boolean/boolean-decorator-internal.data.mjs +33 -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 +23 -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 +12 -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 +48 -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 +1221 -880
- package/fesm2015/ngx-material-entity.mjs.map +1 -1
- package/fesm2020/ngx-material-entity.mjs +1225 -877
- package/fesm2020/ngx-material-entity.mjs.map +1 -1
- package/package.json +2 -1
- package/public-api.d.ts +15 -7
- package/components/input/array-table/add-array-item-dialog/add-array-item-dialog.component.d.ts +0 -35
- package/components/input/array-table/add-array-item-dialog/add-array-item-dialog.module.d.ts +0 -12
- package/components/input/array-table/array-table.component.d.ts +0 -34
- package/components/input/array-table/array-table.module.d.ts +0 -19
- package/components/input/internal-input/internal-input.component.d.ts +0 -57
- package/components/input/internal-input/internal-input.module.d.ts +0 -16
- package/decorators/array.decorator.d.ts +0 -125
- package/decorators/base/property-decorator-config.interface.d.ts +0 -50
- 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/components/input/array-table/add-array-item-dialog/add-array-item-dialog.component.mjs +0 -43
- package/esm2020/components/input/array-table/add-array-item-dialog/add-array-item-dialog.module.mjs +0 -22
- package/esm2020/components/input/array-table/array-table.component.mjs +0 -116
- package/esm2020/components/input/array-table/array-table.module.mjs +0 -66
- package/esm2020/components/input/internal-input/internal-input.component.mjs +0 -73
- package/esm2020/components/input/internal-input/internal-input.module.mjs +0 -54
- 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
|
|
@@ -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
|
+
}
|
|
@@ -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
|
|
40
|
-
*
|
|
46
|
+
* Gets all existing entities and pushes them to the entities 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
|
-
static getPropertyMetadata<EntityType extends Entity, T extends DecoratorTypes>(entity: EntityType, propertyKey: keyof EntityType, type
|
|
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,95 @@ 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 creating 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 screen size 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;
|
|
112
|
+
/**
|
|
113
|
+
* Gets the rows that are used to display the given entity.
|
|
114
|
+
*
|
|
115
|
+
* @param entity - The entity to get the rows from.
|
|
116
|
+
* @param hideOmitForCreate - Whether or not keys with the metadata omitForCreate should be filtered out.
|
|
117
|
+
* @param hideOmitForEdit - Whether or not keys with the metadata omitForUpdate should be filtered out.
|
|
118
|
+
* @returns The sorted Rows containing the row number and the keys to display in that row.
|
|
119
|
+
*/
|
|
120
|
+
static getEntityRows<EntityType extends Entity>(entity: EntityType, hideOmitForCreate?: boolean, hideOmitForEdit?: boolean): EntityRow<EntityType>[];
|
|
121
|
+
private static getKeysForRow;
|
|
122
|
+
private static getNumberOfRows;
|
|
123
|
+
/**
|
|
124
|
+
* Gets the keys of the provided entity correctly typed.
|
|
125
|
+
*
|
|
126
|
+
* @param entity - The entity to get the keys of.
|
|
127
|
+
* @param hideOmitForCreate - Whether or not keys with the metadata omitForCreate should be filtered out.
|
|
128
|
+
* @param hideOmitForEdit - Whether or not keys with the metadata omitForUpdate should be filtered out.
|
|
129
|
+
* @returns An array of keys of the entity.
|
|
130
|
+
*/
|
|
131
|
+
static keysOf<EntityType extends Entity>(entity: EntityType, hideOmitForCreate?: boolean, hideOmitForEdit?: boolean): (keyof EntityType)[];
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* A row that contains all the information about how to display an entity.
|
|
135
|
+
*/
|
|
136
|
+
export interface EntityRow<EntityType extends Entity> {
|
|
137
|
+
/**
|
|
138
|
+
* The row in which this should be displayed.
|
|
139
|
+
*/
|
|
140
|
+
row: number;
|
|
141
|
+
/**
|
|
142
|
+
* The keys of the values that should be displayed in that row.
|
|
143
|
+
*/
|
|
144
|
+
keys: (keyof EntityType)[];
|
|
95
145
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BaseBuilder } from '../../classes/base-builder.class';
|
|
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
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
|
8
|
-
/**
|
|
9
|
-
* Used for the checkbox to confirm the action
|
|
10
|
-
*/
|
|
13
|
+
private readonly inputData;
|
|
11
14
|
confirm: boolean;
|
|
12
|
-
|
|
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
|
-
*
|
|
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;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { NgModel } from '@angular/forms';
|
|
2
|
+
import { BaseBuilder } from '../../classes/base-builder.class';
|
|
3
|
+
import { Entity } from '../../classes/entity-model.class';
|
|
4
|
+
import { CreateDialogDataInternal } from '../table/create-dialog/create-dialog-data.builder';
|
|
5
|
+
import { AddArrayItemDialogData } from './add-array-item-dialog-data';
|
|
6
|
+
/**
|
|
7
|
+
* The internal AddArrayItemDialogData. Requires all default values the user can leave out.
|
|
8
|
+
*/
|
|
9
|
+
export declare class AddArrayItemDialogDataInternal<EntityType extends Entity> implements AddArrayItemDialogData<EntityType> {
|
|
10
|
+
entity: EntityType;
|
|
11
|
+
createDialogData: CreateDialogDataInternal;
|
|
12
|
+
getValidationErrorMessage: (model: NgModel) => string;
|
|
13
|
+
constructor(entity: EntityType, createDialogData: CreateDialogDataInternal, getValidationErrorMessage: (model: NgModel) => string);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The Builder for the AddArrayItemDialogData. Sets default values.
|
|
17
|
+
*/
|
|
18
|
+
export declare class AddArrayItemDialogDataBuilder<EntityType extends Entity> extends BaseBuilder<AddArrayItemDialogDataInternal<EntityType>, AddArrayItemDialogData<EntityType>> {
|
|
19
|
+
constructor(data: AddArrayItemDialogData<EntityType>);
|
|
20
|
+
protected generateBaseData(data: AddArrayItemDialogData<EntityType>): AddArrayItemDialogDataInternal<EntityType>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { NgModel } from '@angular/forms';
|
|
2
|
+
import { Entity } from '../../classes/entity-model.class';
|
|
3
|
+
import { CreateDialogData } from '../table/table-data';
|
|
4
|
+
/**
|
|
5
|
+
* The configuration options for the dialog that adds items to an array.
|
|
6
|
+
*/
|
|
7
|
+
export interface AddArrayItemDialogData<EntityType extends Entity> {
|
|
8
|
+
/**
|
|
9
|
+
* An empty entity that is used as the data model.
|
|
10
|
+
*/
|
|
11
|
+
entity: EntityType;
|
|
12
|
+
/**
|
|
13
|
+
* The info of the generic create-dialog.
|
|
14
|
+
*/
|
|
15
|
+
createDialogData?: CreateDialogData;
|
|
16
|
+
/**
|
|
17
|
+
* A custom function to generate the error-message for invalid inputs.
|
|
18
|
+
*/
|
|
19
|
+
getValidationErrorMessage?: (model: NgModel) => string;
|
|
20
|
+
}
|