ngx-material-entity 1.0.6 → 1.1.0

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 (28) hide show
  1. package/capsulation/jszip.utilities.d.ts +12 -0
  2. package/classes/entity.utilities.d.ts +0 -9
  3. package/classes/file.utilities.d.ts +13 -0
  4. package/components/input/array/array-table.class.d.ts +1 -1
  5. package/components/input/file/file-input/file-input.component.d.ts +7 -7
  6. package/components/table/edit-dialog/edit-entity-dialog.component.d.ts +5 -2
  7. package/decorators/file/file-decorator-internal.data.d.ts +2 -0
  8. package/decorators/file/file-decorator.data.d.ts +9 -1
  9. package/esm2020/capsulation/jszip.utilities.mjs +18 -0
  10. package/esm2020/classes/entity.utilities.mjs +23 -16
  11. package/esm2020/classes/file.utilities.mjs +40 -1
  12. package/esm2020/components/input/array/array-date-input/array-date-input.component.mjs +3 -3
  13. package/esm2020/components/input/array/array-date-range-input/array-date-range-input.component.mjs +3 -3
  14. package/esm2020/components/input/array/array-date-time-input/array-date-time-input.component.mjs +3 -3
  15. package/esm2020/components/input/array/array-table.class.mjs +2 -2
  16. package/esm2020/components/input/file/file-default-input/file-default-input.component.mjs +3 -3
  17. package/esm2020/components/input/file/file-image-input/file-image-input.component.mjs +3 -3
  18. package/esm2020/components/input/file/file-input/file-input.component.mjs +54 -29
  19. package/esm2020/components/input/input.component.mjs +3 -3
  20. package/esm2020/components/input/string/string-password-input/string-password-input.component.mjs +3 -3
  21. package/esm2020/components/table/edit-dialog/edit-entity-dialog.component.mjs +10 -8
  22. package/esm2020/decorators/file/file-decorator-internal.data.mjs +3 -1
  23. package/esm2020/decorators/file/file-decorator.data.mjs +1 -1
  24. package/fesm2015/ngx-material-entity.mjs +170 -70
  25. package/fesm2015/ngx-material-entity.mjs.map +1 -1
  26. package/fesm2020/ngx-material-entity.mjs +157 -63
  27. package/fesm2020/ngx-material-entity.mjs.map +1 -1
  28. package/package.json +2 -1
@@ -0,0 +1,12 @@
1
+ import * as JSZipType from 'jszip';
2
+ /**
3
+ * Encapsulates JSZip functionality.
4
+ */
5
+ export declare abstract class JSZipUtilities {
6
+ /**
7
+ * Generates a new JSZip object that is correctly typed.
8
+ *
9
+ * @returns A new JSZip object.
10
+ */
11
+ static new(): JSZipType;
12
+ }
@@ -146,15 +146,6 @@ export declare abstract class EntityUtilities {
146
146
  * @param entityPriorChanges - The entity before any changes.
147
147
  */
148
148
  static resetChangesOnEntity<EntityType extends BaseEntityType<EntityType>>(entity: EntityType, entityPriorChanges: EntityType): void;
149
- /**
150
- * Gets the rows that are used to display the given entity.
151
- *
152
- * @param entity - The entity to get the rows from.
153
- * @param tab - The tab number for which the rows should be returned.
154
- * @param hideOmitForCreate - Whether or not keys with the metadata omitForCreate should be filtered out.
155
- * @param hideOmitForEdit - Whether or not keys with the metadata omitForUpdate should be filtered out.
156
- * @returns The sorted Rows containing the row number and the keys to display in that row.
157
- */
158
149
  private static getEntityRows;
159
150
  /**
160
151
  * Gets the tabs that are used to display the given entity.
@@ -32,6 +32,19 @@ export declare abstract class FileUtilities {
32
32
  * @returns FileDataWithFile.
33
33
  */
34
34
  static getFileData(data: FileData): Promise<FileDataWithFile>;
35
+ /**
36
+ * Downloads a single file from the given File Data.
37
+ *
38
+ * @param fileData - The file data. Needs to contain a blob.
39
+ */
40
+ static downloadSingleFile(fileData: FileDataWithFile): void;
41
+ /**
42
+ * Downloads multiple files as a zip with the given name.
43
+ *
44
+ * @param name - The name of the zip file to generate.
45
+ * @param multiFileData - The file data array to put in the zip.
46
+ */
47
+ static downloadMultipleFiles(name: string, multiFileData: FileData[]): Promise<void>;
35
48
  /**
36
49
  * Checks if the given file has a valid mime type.
37
50
  *
@@ -8,7 +8,7 @@ import { OnInit } from '@angular/core';
8
8
  import * as i0 from "@angular/core";
9
9
  declare type ArrayTableType = DecoratorTypes.ARRAY | DecoratorTypes.ARRAY_DATE | DecoratorTypes.ARRAY_DATE_RANGE | DecoratorTypes.ARRAY_DATE_TIME;
10
10
  /**
11
- * The base data needed for all arrays that are displayed as a table.
11
+ * The base component needed for all arrays that are displayed as a table.
12
12
  */
13
13
  export declare abstract class ArrayTableComponent<ValueType, EntityType extends BaseEntityType<EntityType>, ArrayType extends ArrayTableType> extends NgxMatEntityBaseInputComponent<EntityType, ArrayType, ValueType[]> implements OnInit {
14
14
  private readonly matDialog;
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter, OnInit } from '@angular/core';
2
2
  import { NgModel } from '@angular/forms';
3
- import { DefaultFileDecoratorConfigInternal } from '../../../../decorators/file/file-decorator-internal.data';
3
+ import { DefaultFileDecoratorConfigInternal, ImageFileDecoratorConfigInternal } from '../../../../decorators/file/file-decorator-internal.data';
4
4
  import { FileUtilities } from '../../../../classes/file.utilities';
5
5
  import { FileData } from '../../../../decorators/file/file-decorator.data';
6
6
  import { MatDialog } from '@angular/material/dialog';
@@ -8,16 +8,13 @@ import { BaseEntityType } from '../../../../classes/entity.model';
8
8
  import * as i0 from "@angular/core";
9
9
  export declare class FileInputComponent<EntityType extends BaseEntityType<EntityType>> implements OnInit {
10
10
  private readonly dialog;
11
- singleFileData?: FileData;
12
- multiFileData?: FileData[];
13
11
  filenames?: string[];
14
12
  FileUtilities: typeof FileUtilities;
15
- entity: EntityType;
16
- key: keyof EntityType;
13
+ propertyValue: FileData | FileData[] | undefined;
14
+ metadata: DefaultFileDecoratorConfigInternal | ImageFileDecoratorConfigInternal;
17
15
  getValidationErrorMessage: (model: NgModel) => string;
18
16
  isReadOnly: boolean;
19
17
  fileDataChangeEvent: EventEmitter<FileData | FileData[]>;
20
- metadata: DefaultFileDecoratorConfigInternal;
21
18
  constructor(dialog: MatDialog);
22
19
  ngOnInit(): Promise<void>;
23
20
  private initMultiFile;
@@ -28,6 +25,9 @@ export declare class FileInputComponent<EntityType extends BaseEntityType<Entity
28
25
  private setMultiFile;
29
26
  private setSingleFile;
30
27
  removeFile(name: string): void;
28
+ downloadFile(name: string): Promise<void>;
29
+ downloadAllEnabled(): boolean;
30
+ downloadAll(): Promise<void>;
31
31
  static ɵfac: i0.ɵɵFactoryDeclaration<FileInputComponent<any>, never>;
32
- static ɵcmp: i0.ɵɵComponentDeclaration<FileInputComponent<any>, "file-input", never, { "entity": "entity"; "key": "key"; "getValidationErrorMessage": "getValidationErrorMessage"; "isReadOnly": "isReadOnly"; }, { "fileDataChangeEvent": "fileDataChangeEvent"; }, never, never>;
32
+ static ɵcmp: i0.ɵɵComponentDeclaration<FileInputComponent<any>, "file-input", never, { "propertyValue": "propertyValue"; "metadata": "metadata"; "getValidationErrorMessage": "getValidationErrorMessage"; "isReadOnly": "isReadOnly"; }, { "fileDataChangeEvent": "fileDataChangeEvent"; }, never, never>;
33
33
  }
@@ -23,11 +23,14 @@ export declare class NgxMatEntityEditDialogComponent<EntityType extends BaseEnti
23
23
  entityPriorChanges: EntityType;
24
24
  data: EditEntityDialogDataInternal<EntityType>;
25
25
  isEntityValid: boolean;
26
- isEntityDirty: Promise<boolean>;
26
+ isEntityDirty: boolean;
27
27
  isReadOnly: boolean;
28
28
  constructor(inputData: EditEntityDialogData<EntityType>, dialogRef: MatDialogRef<NgxMatEntityEditDialogComponent<EntityType>>, injector: Injector, dialog: MatDialog);
29
29
  ngOnInit(): void;
30
- checkEntity(): void;
30
+ /**
31
+ * Checks if the entity has become invalid or dirty.
32
+ */
33
+ checkEntity(): Promise<void>;
31
34
  /**
32
35
  * Tries to save the changes and close the dialog afterwards.
33
36
  * Also handles the confirmation if required.
@@ -70,6 +70,7 @@ export declare class DefaultFileDecoratorConfigInternal extends PropertyDecorato
70
70
  maxSizeErrorDialog: ConfirmDialogData;
71
71
  maxSizeTotalErrorDialog: ConfirmDialogData;
72
72
  dragAndDrop: boolean;
73
+ downloadAllButtonLabel: string;
73
74
  constructor(data: DefaultFileDecoratorConfig);
74
75
  }
75
76
  /**
@@ -88,5 +89,6 @@ export declare class ImageFileDecoratorConfigInternal extends PropertyDecoratorC
88
89
  maxSizeErrorDialog: ConfirmDialogData;
89
90
  maxSizeTotalErrorDialog: ConfirmDialogData;
90
91
  dragAndDrop: boolean;
92
+ downloadAllButtonLabel: string;
91
93
  constructor(data: ImageFileDecoratorConfig);
92
94
  }
@@ -61,10 +61,18 @@ declare abstract class FileDecoratorConfig extends PropertyDecoratorConfig {
61
61
  /**
62
62
  * Defines whether or not a dropdown box is displayed.
63
63
  *
64
- * @default true // when multiple is set to true.
64
+ * @default
65
+ * true // when multiple is set to true.
65
66
  * false // when multiple is set to false.
66
67
  */
67
68
  dragAndDrop?: boolean;
69
+ /**
70
+ * The label of the button to download all files.
71
+ * Is only shown when the property contains multiple files.
72
+ *
73
+ * @default 'Download All'
74
+ */
75
+ downloadAllButtonLabel?: string;
68
76
  }
69
77
  /**
70
78
  * Definition for a default file.
@@ -0,0 +1,18 @@
1
+ import JSZip from 'jszip';
2
+ // TODO: Find a way to use blobs with jest
3
+ /* istanbul ignore next */
4
+ /**
5
+ * Encapsulates JSZip functionality.
6
+ */
7
+ export class JSZipUtilities {
8
+ /**
9
+ * Generates a new JSZip object that is correctly typed.
10
+ *
11
+ * @returns A new JSZip object.
12
+ */
13
+ static new() {
14
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
15
+ return new JSZip();
16
+ }
17
+ }
18
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoianN6aXAudXRpbGl0aWVzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vcHJvamVjdHMvbmd4LW1hdGVyaWFsLWVudGl0eS9zcmMvY2Fwc3VsYXRpb24vanN6aXAudXRpbGl0aWVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxNQUFNLE9BQU8sQ0FBQztBQUkxQiwwQ0FBMEM7QUFDMUMsMEJBQTBCO0FBQzFCOztHQUVHO0FBQ0gsTUFBTSxPQUFnQixjQUFjO0lBQ2hDOzs7O09BSUc7SUFDSC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