ngx-material-entity 15.1.4 → 15.1.6

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 (36) hide show
  1. package/components/input/input.component.d.ts +32 -12
  2. package/components/table/default.actions.d.ts +21 -0
  3. package/components/table/table-data.builder.d.ts +3 -1
  4. package/components/table/table-data.d.ts +11 -0
  5. package/components/table/table.component.d.ts +3 -0
  6. package/decorators/array/array-decorator-internal.data.d.ts +12 -1
  7. package/decorators/array/array-decorator.data.d.ts +27 -5
  8. package/encapsulation/js-2-xml.utilities.d.ts +15 -0
  9. package/encapsulation/jszip.utilities.d.ts +3 -2
  10. package/encapsulation/lodash.utilities.d.ts +7 -0
  11. package/esm2020/components/input/input.component.mjs +68 -28
  12. package/esm2020/components/table/create-dialog/create-entity-dialog.component.mjs +3 -3
  13. package/esm2020/components/table/default.actions.mjs +65 -0
  14. package/esm2020/components/table/table-data.builder.mjs +11 -3
  15. package/esm2020/components/table/table-data.mjs +1 -1
  16. package/esm2020/components/table/table.component.mjs +34 -3
  17. package/esm2020/decorators/array/array-decorator-internal.data.mjs +13 -1
  18. package/esm2020/decorators/array/array-decorator.data.mjs +1 -1
  19. package/esm2020/encapsulation/js-2-xml.utilities.mjs +18 -0
  20. package/esm2020/encapsulation/jszip.utilities.mjs +1 -1
  21. package/esm2020/encapsulation/lodash.utilities.mjs +13 -1
  22. package/esm2020/public-api.mjs +2 -1
  23. package/esm2020/services/entity.service.mjs +17 -1
  24. package/esm2020/utilities/file.utilities.mjs +17 -4
  25. package/fesm2015/ngx-material-entity.mjs +250 -70
  26. package/fesm2015/ngx-material-entity.mjs.map +1 -1
  27. package/fesm2020/ngx-material-entity.mjs +246 -68
  28. package/fesm2020/ngx-material-entity.mjs.map +1 -1
  29. package/package.json +3 -2
  30. package/public-api.d.ts +1 -0
  31. package/services/entity.service.d.ts +7 -0
  32. package/utilities/file.utilities.d.ts +7 -0
  33. package/components/input/add-array-item-dialog-data.builder.d.ts +0 -22
  34. package/components/input/add-array-item-dialog-data.d.ts +0 -20
  35. package/esm2020/components/input/add-array-item-dialog-data.builder.mjs +0 -38
  36. package/esm2020/components/input/add-array-item-dialog-data.mjs +0 -2
@@ -4,15 +4,14 @@ import { NgModel } from '@angular/forms';
4
4
  import { MatDialog, MatDialogRef } from '@angular/material/dialog';
5
5
  import { MatTableDataSource } from '@angular/material/table';
6
6
  import { BaseEntityType } from '../../classes/entity.model';
7
- import { EntityArrayDecoratorConfigInternal } from '../../decorators/array/array-decorator-internal.data';
7
+ import { EditArrayItemDialogDataInternal, EntityArrayDecoratorConfigInternal } from '../../decorators/array/array-decorator-internal.data';
8
8
  import { DecoratorTypes } from '../../decorators/base/decorator-types.enum';
9
9
  import { PropertyDecoratorConfigInternal } from '../../decorators/base/property-decorator-internal.data';
10
10
  import { DefaultObjectDecoratorConfigInternal } from '../../decorators/object/object-decorator-internal.data';
11
11
  import { DateUtilities } from '../../utilities/date.utilities';
12
12
  import { EntityTab, EntityUtilities } from '../../utilities/entity.utilities';
13
13
  import { SelectionUtilities } from '../../utilities/selection.utilities';
14
- import { AddArrayItemDialogData } from './add-array-item-dialog-data';
15
- import { AddArrayItemDialogDataInternal } from './add-array-item-dialog-data.builder';
14
+ import { CreateDialogDataInternal } from '../table/create-dialog/create-dialog-data.builder';
16
15
  import * as i0 from "@angular/core";
17
16
  /**
18
17
  * The default input component. It gets the metadata of the property from the given @Input "entity" and @Input "propertyKey"
@@ -66,6 +65,8 @@ export declare class NgxMatEntityInputComponent<EntityType extends BaseEntityTyp
66
65
  inputChangeEvent: EventEmitter<void>;
67
66
  addArrayItemDialog: TemplateRef<unknown>;
68
67
  addArrayItemDialogRef: MatDialogRef<unknown>;
68
+ editArrayItemDialog: TemplateRef<unknown>;
69
+ editArrayItemDialogRef: MatDialogRef<unknown>;
69
70
  type: DecoratorTypes;
70
71
  metadata: PropertyDecoratorConfigInternal;
71
72
  metadataDefaultObject: DefaultObjectDecoratorConfigInternal<EntityType>;
@@ -74,16 +75,17 @@ export declare class NgxMatEntityInputComponent<EntityType extends BaseEntityTyp
74
75
  metadataEntityArray: EntityArrayDecoratorConfigInternal<EntityType>;
75
76
  entityArrayValues: EntityType[];
76
77
  arrayItem: EntityType;
77
- private arrayItemPriorChanges;
78
+ arrayItemPriorChanges: EntityType;
78
79
  arrayItemInlineTabs: EntityTab<EntityType>[];
79
80
  dataSource: MatTableDataSource<EntityType>;
80
81
  selection: SelectionModel<EntityType>;
81
82
  displayedColumns: string[];
82
83
  isArrayItemValid: boolean;
83
- dialogInputData: AddArrayItemDialogData<EntityType>;
84
- dialogData: AddArrayItemDialogDataInternal<EntityType>;
84
+ isArrayItemDirty: boolean;
85
+ indexOfEditedArrayItem: number;
86
+ addArrayItemDialogData: CreateDialogDataInternal;
85
87
  arrayItemDialogTabs: EntityTab<EntityType>[];
86
- isDialogArrayItemValid: boolean;
88
+ editArrayItemDialogData: EditArrayItemDialogDataInternal<EntityType>;
87
89
  readonly DecoratorTypes: typeof DecoratorTypes;
88
90
  EntityUtilities: typeof EntityUtilities;
89
91
  DateUtilities: typeof DateUtilities;
@@ -100,13 +102,17 @@ export declare class NgxMatEntityInputComponent<EntityType extends BaseEntityTyp
100
102
  private initEntityArray;
101
103
  private initObjectInput;
102
104
  /**
103
- * Checks if the arrayItem is valid.
105
+ * Checks whether the array item is valid and if the array item is dirty.
104
106
  */
105
- checkIsArrayItemValid(): void;
107
+ checkArrayItem(): void;
106
108
  /**
107
- * Checks if the arrayItem inside the dialog is valid.
109
+ * Checks if the array item is dirty.
108
110
  */
109
- checkIsDialogArrayItemValid(): void;
111
+ checkIsArrayItemDirty(): Promise<void>;
112
+ /**
113
+ * Checks if the arrayItem is valid.
114
+ */
115
+ checkIsArrayItemValid(): void;
110
116
  /**
111
117
  * Emits that a the value has been changed.
112
118
  */
@@ -124,7 +130,21 @@ export declare class NgxMatEntityInputComponent<EntityType extends BaseEntityTyp
124
130
  /**
125
131
  * Cancels adding the array item defined in the dialog.
126
132
  */
127
- cancelAddArrayItem(): void;
133
+ closeAddArrayItemDialog(): void;
134
+ /**
135
+ * Edits an entity array item.
136
+ *
137
+ * @param entity - The entity that has been clicked.
138
+ */
139
+ editArrayItem(entity: EntityType): void;
140
+ /**
141
+ * Saves changes on the array item in the dialog.
142
+ */
143
+ saveArrayItem(): void;
144
+ /**
145
+ * Closes the edit array item dialog and resets changes.
146
+ */
147
+ closeEditArrayItemDialog(): void;
128
148
  /**
129
149
  * Removes all selected entries from the entity array.
130
150
  */
@@ -0,0 +1,21 @@
1
+ import { BaseEntityType } from '../../public-api';
2
+ /**
3
+ * A multi select action that exports the data as a json file.
4
+ *
5
+ * @param selectedEntities - The selected entities to export.
6
+ */
7
+ export declare function exportAsJsonMultiAction<EntityType extends BaseEntityType<EntityType>>(selectedEntities: EntityType[]): void;
8
+ /**
9
+ * A multi select action that exports the data as a csv file.
10
+ * Object values get stringified.
11
+ *
12
+ * @param selectedEntities - The selected entities to export.
13
+ */
14
+ export declare function exportAsCsvMultiAction<EntityType extends BaseEntityType<EntityType>>(selectedEntities: EntityType[]): void;
15
+ /**
16
+ * A multi select action that exports the data as a xml file.
17
+ * Object values get stringified.
18
+ *
19
+ * @param selectedEntities - The selected entities to export.
20
+ */
21
+ export declare function exportAsXmlMultiAction<EntityType extends BaseEntityType<EntityType>>(selectedEntities: EntityType[]): void;
@@ -39,10 +39,12 @@ export declare class BaseDataInternal<EntityType extends BaseEntityType<EntityTy
39
39
  multiSelectActions: MultiSelectAction<EntityType>[];
40
40
  multiSelectLabel: string;
41
41
  displayLoadingSpinner: boolean;
42
+ allowJsonImport: boolean;
43
+ importActionData: Omit<MultiSelectAction<EntityType>, 'action' | 'requireConfirmDialog'>;
42
44
  EntityClass?: EntityClassNewable<EntityType>;
43
45
  edit?: (entity: EntityType) => unknown;
44
46
  create?: (entity: EntityType) => unknown;
45
- constructor(title: string, displayColumns: DisplayColumn<EntityType>[], EntityServiceClass: new (httpClient: HttpClient) => EntityService<EntityType>, searchLabel: string, createButtonLabel: string, defaultEdit: 'dialog' | 'page', searchString: (entity: EntityType) => string, allowCreate: () => boolean, allowRead: (entity: EntityType) => boolean, allowUpdate: (entity: EntityType) => boolean, allowDelete: (entity: EntityType) => boolean, multiSelectActions: MultiSelectAction<EntityType>[], multiSelectLabel: string, displayLoadingSpinner: boolean, EntityClass?: EntityClassNewable<EntityType>, edit?: (entity: EntityType) => unknown, create?: (entity: EntityType) => unknown);
47
+ constructor(title: string, displayColumns: DisplayColumn<EntityType>[], EntityServiceClass: new (httpClient: HttpClient) => EntityService<EntityType>, searchLabel: string, createButtonLabel: string, defaultEdit: 'dialog' | 'page', searchString: (entity: EntityType) => string, allowCreate: () => boolean, allowRead: (entity: EntityType) => boolean, allowUpdate: (entity: EntityType) => boolean, allowDelete: (entity: EntityType) => boolean, multiSelectActions: MultiSelectAction<EntityType>[], multiSelectLabel: string, displayLoadingSpinner: boolean, allowJsonImport: boolean, importActionData: Omit<MultiSelectAction<EntityType>, 'action' | 'requireConfirmDialog'>, EntityClass?: EntityClassNewable<EntityType>, edit?: (entity: EntityType) => unknown, create?: (entity: EntityType) => unknown);
46
48
  }
47
49
  /**
48
50
  * The Builder for the complete TableData. Sets default values and validates user input.
@@ -133,6 +133,17 @@ export interface BaseData<EntityType extends BaseEntityType<EntityType>> {
133
133
  * @default true
134
134
  */
135
135
  displayLoadingSpinner?: boolean;
136
+ /**
137
+ * Whether or not JSON imports are allowed.
138
+ * This adds an multi select action.
139
+ *
140
+ * @default false
141
+ */
142
+ allowJsonImport?: boolean;
143
+ /**
144
+ * Data to customize the json import action.
145
+ */
146
+ importActionData?: Omit<MultiSelectAction<EntityType>, 'action' | 'requireConfirmDialog'>;
136
147
  }
137
148
  /**
138
149
  * The data of the default create-dialog.
@@ -35,11 +35,14 @@ export declare class NgxMatEntityTableComponent<EntityType extends BaseEntityTyp
35
35
  dataSource: MatTableDataSource<EntityType>;
36
36
  selection: SelectionModel<EntityType>;
37
37
  SelectionUtilities: typeof SelectionUtilities;
38
+ importAction: Omit<MultiSelectAction<EntityType>, 'confirmationDialog'>;
38
39
  constructor(dialog: MatDialog, injector: Injector, router: Router);
39
40
  /**
40
41
  * Sets up all the configuration for the table and the EntityService.
41
42
  */
42
43
  ngOnInit(): void;
44
+ private startImportJson;
45
+ private importJson;
43
46
  /**
44
47
  * Edits an entity. This either calls the edit-Method provided by the user or uses a default edit-dialog.
45
48
  *
@@ -7,7 +7,17 @@ import { DecoratorTypes } from '../base/decorator-types.enum';
7
7
  import { DropdownValue } from '../base/dropdown-value.interface';
8
8
  import { PropertyDecoratorConfigInternal } from '../base/property-decorator-internal.data';
9
9
  import { DateRange } from '../date/date-decorator.data';
10
- import { AutocompleteStringChipsArrayDecoratorConfig, DateArrayDecoratorConfig, DateRangeArrayDecoratorConfig, DateTimeArrayDecoratorConfig, EntityArrayDecoratorConfig, StringChipsArrayDecoratorConfig } from './array-decorator.data';
10
+ import { AutocompleteStringChipsArrayDecoratorConfig, DateArrayDecoratorConfig, DateRangeArrayDecoratorConfig, DateTimeArrayDecoratorConfig, EditArrayItemDialogData, EntityArrayDecoratorConfig, StringChipsArrayDecoratorConfig } from './array-decorator.data';
11
+ /**
12
+ * The internal dialog data for the entities array edit dialog.
13
+ * Sets default values.
14
+ */
15
+ export declare class EditArrayItemDialogDataInternal<EntityType extends BaseEntityType<EntityType>> implements EditArrayItemDialogData<EntityType> {
16
+ title: (entity: EntityType) => string;
17
+ confirmButtonLabel: string;
18
+ cancelButtonLabel: string;
19
+ constructor(data?: EditArrayItemDialogData<EntityType>);
20
+ }
11
21
  /**
12
22
  * The internal EntityArrayDecoratorConfig. Sets default values.
13
23
  */
@@ -18,6 +28,7 @@ export declare class EntityArrayDecoratorConfigInternal<EntityType extends BaseE
18
28
  EntityClass: EntityClassNewable<EntityType>;
19
29
  displayColumns: DisplayColumn<EntityType>[];
20
30
  createDialogData?: CreateDialogData;
31
+ editDialogData: EditArrayItemDialogDataInternal<EntityType>;
21
32
  createInline: boolean;
22
33
  missingErrorMessage: string;
23
34
  addButtonLabel: string;
@@ -1,12 +1,12 @@
1
- import { CreateDialogData, DisplayColumn } from '../../components/table/table-data';
1
+ import { Time } from '@angular/common';
2
+ import { DateFilterFn } from '@angular/material/datepicker';
2
3
  import { BaseEntityType, EntityClassNewable } from '../../classes/entity.model';
4
+ import { ConfirmDialogData } from '../../components/confirm-dialog/confirm-dialog-data';
5
+ import { CreateDialogData, DisplayColumn } from '../../components/table/table-data';
3
6
  import { DecoratorTypes } from '../base/decorator-types.enum';
4
- import { PropertyDecoratorConfig } from '../base/property-decorator.data';
5
- import { DateFilterFn } from '@angular/material/datepicker';
6
- import { Time } from '@angular/common';
7
7
  import { DropdownValue } from '../base/dropdown-value.interface';
8
+ import { PropertyDecoratorConfig } from '../base/property-decorator.data';
8
9
  import { DateRange } from '../date/date-decorator.data';
9
- import { ConfirmDialogData } from '../../components/confirm-dialog/confirm-dialog-data';
10
10
  /**
11
11
  * Interface definition for the @array metadata.
12
12
  */
@@ -26,6 +26,23 @@ export declare abstract class ArrayDecoratorConfig extends PropertyDecoratorConf
26
26
  */
27
27
  duplicatesErrorDialog?: ConfirmDialogData;
28
28
  }
29
+ /**
30
+ * The dialog data for the entities array edit dialog.
31
+ */
32
+ export interface EditArrayItemDialogData<EntityType extends BaseEntityType<EntityType>> {
33
+ /**
34
+ * The title of the default edit-dialog.
35
+ */
36
+ title?: (entity: EntityType) => string;
37
+ /**
38
+ * The label on the confirm-button of the default edit-dialog or page. Defaults to "Save".
39
+ */
40
+ confirmButtonLabel?: string;
41
+ /**
42
+ * The label on the cancel-button for the default edit-dialog or page. Defaults to "Cancel".
43
+ */
44
+ cancelButtonLabel?: string;
45
+ }
29
46
  /**
30
47
  * Definition for an array of Entities.
31
48
  */
@@ -45,6 +62,11 @@ export interface EntityArrayDecoratorConfig<EntityType extends BaseEntityType<En
45
62
  * Can be omitted when adding items inline.
46
63
  */
47
64
  createDialogData?: CreateDialogData;
65
+ /**
66
+ * The data for the edit-item-dialog.
67
+ * Can be omitted when adding items inline.
68
+ */
69
+ editDialogData?: EditArrayItemDialogData<EntityType>;
48
70
  /**
49
71
  * Whether or not the form for adding items to the array
50
72
  * should be displayed inline.
@@ -0,0 +1,15 @@
1
+ import * as js2xml from 'js2xmlparser';
2
+ /**
3
+ * Encapsulates functionality of the js2xml package.
4
+ */
5
+ export declare abstract class Js2XmlUtilities {
6
+ /**
7
+ * Returns a XML string representation of the specified object using the specified options.
8
+ *
9
+ * @param root - Name of the xml root element.
10
+ * @param value - The json value to convert. Will be a child of root.
11
+ * @param options - Additional options for the conversion.
12
+ * @returns The converted xml string.
13
+ */
14
+ static parse(root: string, value: unknown, options?: js2xml.IOptions): string;
15
+ }
@@ -1,4 +1,5 @@
1
- import * as JSZipType from 'jszip';
1
+ import JSZip from 'jszip';
2
+ export declare type Zip = JSZip;
2
3
  /**
3
4
  * Encapsulates JSZip functionality.
4
5
  */
@@ -8,5 +9,5 @@ export declare abstract class JSZipUtilities {
8
9
  *
9
10
  * @returns A new JSZip object.
10
11
  */
11
- static new(): JSZipType;
12
+ static new(): Zip;
12
13
  }
@@ -59,4 +59,11 @@ export declare abstract class LodashUtilities {
59
59
  * @returns Returns true if value is correctly classified, else false.
60
60
  */
61
61
  static isArray(value?: unknown): value is unknown[];
62
+ /**
63
+ * Checks if value is classified as an object that is not an array.
64
+ *
65
+ * @param value - The value to check.
66
+ * @returns Returns true if value is correctly classified, else false.
67
+ */
68
+ static isObject(value?: unknown): value is object;
62
69
  }