ngx-material-entity 15.1.9 → 15.2.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.
@@ -16,7 +16,7 @@ import { DateUtilities } from '../../utilities/date.utilities';
16
16
  import { EntityTab, EntityUtilities } from '../../utilities/entity.utilities';
17
17
  import { SelectionUtilities } from '../../utilities/selection.utilities';
18
18
  import { CreateDialogDataInternal } from '../table/create-dialog/create-dialog-data.builder';
19
- import { MultiSelectAction } from '../table/table-data';
19
+ import { BaseTableActionInternal, TableActionInternal } from '../table/table-data.builder';
20
20
  import * as i0 from "@angular/core";
21
21
  /**
22
22
  * The default input component. It gets the metadata of the property from the given @Input "entity" and @Input "propertyKey"
@@ -101,7 +101,7 @@ export declare class NgxMatEntityInputComponent<EntityType extends BaseEntityTyp
101
101
  displayedHasManyColumns: string[];
102
102
  hasManyDataSource: MatTableDataSource<EntityType>;
103
103
  hasManySelection: SelectionModel<EntityType>;
104
- hasManyImportAction: Omit<MultiSelectAction<EntityType>, 'confirmationDialog'>;
104
+ hasManyImportAction: BaseTableActionInternal;
105
105
  private hasManyEntityService;
106
106
  createHasManyDialog: TemplateRef<unknown>;
107
107
  createHasManyDialogRef: MatDialogRef<unknown>;
@@ -182,20 +182,20 @@ export declare class NgxMatEntityInputComponent<EntityType extends BaseEntityTyp
182
182
  */
183
183
  dialogCancelCreateHasMany(): void;
184
184
  /**
185
- * Runs the MultiAction for all selected entries.
185
+ * Runs the TableAction for all selected entries.
186
186
  * Also handles confirmation with an additional dialog if configured.
187
187
  *
188
- * @param action - The MultiAction to run.
188
+ * @param action - The TableAction to run.
189
189
  */
190
- runHasManyMultiAction(action: MultiSelectAction<EntityType>): void;
191
- private confirmRunHasManyMultiAction;
190
+ runHasManyTableAction(action: TableActionInternal<EntityType>): void;
191
+ private confirmRunHasManyTableAction;
192
192
  /**
193
- * Checks if an MultiAction is disabled (e.g. Because no entries have been selected).
193
+ * Checks if an TableAction is disabled (e.g. Because no entries have been selected).
194
194
  *
195
- * @param action - The MultiAction to check.
195
+ * @param action - The TableAction to check.
196
196
  * @returns Whether or not the Action can be used.
197
197
  */
198
- hasManyMultiActionDisabled(action: MultiSelectAction<EntityType>): boolean;
198
+ hasManyTableActionDisabled(action: TableActionInternal<EntityType>): boolean;
199
199
  /**
200
200
  * Applies the search input to filter the table entries.
201
201
  *
@@ -1,4 +1,4 @@
1
- import { BaseEntityType } from '../../public-api';
1
+ import { BaseEntityType } from '../../classes/entity.model';
2
2
  /**
3
3
  * A multi select action that exports the data as a json file.
4
4
  *
@@ -2,9 +2,38 @@ import { HttpClient } from '@angular/common/http';
2
2
  import { BaseBuilder } from '../../classes/base.builder';
3
3
  import { BaseEntityType, EntityClassNewable } from '../../classes/entity.model';
4
4
  import { EntityService } from '../../services/entity.service';
5
+ import { ConfirmDialogDataInternal } from '../confirm-dialog/confirm-dialog-data.builder';
5
6
  import { CreateDialogDataInternal } from './create-dialog/create-dialog-data.builder';
6
7
  import { EditDataInternal } from './edit-dialog/edit-data.builder';
7
- import { BaseData, DisplayColumn, MultiSelectAction, TableData } from './table-data';
8
+ import { BaseData, BaseTableAction, DisplayColumn, MultiSelectAction, TableData } from './table-data';
9
+ /**
10
+ * The internal BaseTableAction. Sets default values.
11
+ */
12
+ export declare class BaseTableActionInternal implements BaseTableAction {
13
+ type: 'default';
14
+ displayName: string;
15
+ action: () => unknown;
16
+ enabled: (() => boolean);
17
+ requireConfirmDialog: (() => boolean);
18
+ confirmDialogData: ConfirmDialogDataInternal;
19
+ constructor(data: BaseTableAction);
20
+ }
21
+ /**
22
+ * The internal BaseTableAction. Sets default values.
23
+ */
24
+ export declare class MultiSelectActionInternal<EntityType extends BaseEntityType<EntityType>> implements MultiSelectAction<EntityType> {
25
+ type: 'multi-select';
26
+ displayName: string;
27
+ action: (selectedEntities: EntityType[]) => unknown;
28
+ enabled: ((selectedEntities: EntityType[]) => boolean);
29
+ requireConfirmDialog: ((selectedEntities: EntityType[]) => boolean);
30
+ confirmDialogData: ConfirmDialogDataInternal;
31
+ constructor(data: MultiSelectAction<EntityType>);
32
+ }
33
+ /**
34
+ * The Internal Table Action. Sets default values.
35
+ */
36
+ export declare type TableActionInternal<EntityType extends BaseEntityType<EntityType>> = BaseTableActionInternal | MultiSelectActionInternal<EntityType>;
8
37
  /**
9
38
  * The internal TableData. Requires all default values the user can leave out.
10
39
  */
@@ -36,15 +65,16 @@ export declare class BaseDataInternal<EntityType extends BaseEntityType<EntityTy
36
65
  allowRead: (entity?: EntityType) => boolean;
37
66
  allowUpdate: (entity?: EntityType) => boolean;
38
67
  allowDelete: (entity?: EntityType) => boolean;
39
- multiSelectActions: MultiSelectAction<EntityType>[];
40
- multiSelectLabel: string;
68
+ tableActions: TableActionInternal<EntityType>[];
69
+ tableActionsLabel: string;
41
70
  displayLoadingSpinner: boolean;
42
71
  allowJsonImport: boolean;
43
- importActionData: Omit<MultiSelectAction<EntityType>, 'action' | 'requireConfirmDialog'>;
72
+ importActionData: Omit<BaseTableActionInternal, 'action'>;
44
73
  EntityClass?: EntityClassNewable<EntityType>;
45
74
  edit?: (entity: EntityType) => unknown;
46
75
  create?: (entity: EntityType) => unknown;
47
76
  constructor(data: BaseData<EntityType>);
77
+ private buildImportActionData;
48
78
  private allowDataToFunction;
49
79
  }
50
80
  /**
@@ -15,10 +15,47 @@ export interface DisplayColumn<EntityType extends BaseEntityType<EntityType>> {
15
15
  */
16
16
  value: (entity: EntityType) => string;
17
17
  }
18
+ /**
19
+ * A table action that will run regardless if something has been selected in the table.
20
+ */
21
+ export interface BaseTableAction {
22
+ /**
23
+ * The type of the table action to distinct between base and multi-select actions.
24
+ */
25
+ type: 'default';
26
+ /**
27
+ * The name of the action.
28
+ */
29
+ displayName: string;
30
+ /**
31
+ * The action itself.
32
+ */
33
+ action: () => unknown;
34
+ /**
35
+ * A method that defines whether or not the action can be used.
36
+ *
37
+ * @default () => true
38
+ */
39
+ enabled?: () => boolean;
40
+ /**
41
+ * A method that defines whether or not a confirm dialog is needed to run the action.
42
+ *
43
+ * @default false
44
+ */
45
+ requireConfirmDialog?: () => boolean;
46
+ /**
47
+ * The data used to generate a confirmation dialog for the table action.
48
+ */
49
+ confirmDialogData?: ConfirmDialogData;
50
+ }
18
51
  /**
19
52
  * The Definition of an Action that can be run on multiple selected entities.
20
53
  */
21
54
  export interface MultiSelectAction<EntityType extends BaseEntityType<EntityType>> {
55
+ /**
56
+ * The type of the table action to distinct between base and multi-select actions.
57
+ */
58
+ type: 'multi-select';
22
59
  /**
23
60
  * The name of the action.
24
61
  */
@@ -30,7 +67,7 @@ export interface MultiSelectAction<EntityType extends BaseEntityType<EntityType>
30
67
  /**
31
68
  * A method that defines whether or not the action can be used.
32
69
  *
33
- * @default true
70
+ * @default (selectedEntities: EntityType[]) => !!selectedEntities.length
34
71
  */
35
72
  enabled?: (selectedEntities: EntityType[]) => boolean;
36
73
  /**
@@ -40,10 +77,14 @@ export interface MultiSelectAction<EntityType extends BaseEntityType<EntityType>
40
77
  */
41
78
  requireConfirmDialog?: (selectedEntities: EntityType[]) => boolean;
42
79
  /**
43
- * The data used to generate a confirmation dialog for the multiSelect action.
80
+ * The data used to generate a confirmation dialog for the table action.
44
81
  */
45
82
  confirmDialogData?: ConfirmDialogData;
46
83
  }
84
+ /**
85
+ * An action for the table. Can either be independent or run on the selected entities in the table.
86
+ */
87
+ export declare type TableAction<EntityType extends BaseEntityType<EntityType>> = BaseTableAction | MultiSelectAction<EntityType>;
47
88
  /**
48
89
  * The base data of the ngx-mat-entity-table.
49
90
  */
@@ -119,14 +160,14 @@ export interface BaseData<EntityType extends BaseEntityType<EntityType>> {
119
160
  */
120
161
  allowDelete?: boolean | ((entity?: EntityType) => boolean);
121
162
  /**
122
- * All Actions that you want to run on multiple entities can be defined here.
123
- * (e.g. Download as zip-file or mass delete).
163
+ * All Actions that you want to run on the table can be defined here.
164
+ * (e.g. Download as zip-file, import or mass delete).
124
165
  */
125
- multiSelectActions?: MultiSelectAction<EntityType>[];
166
+ tableActions?: TableAction<EntityType>[];
126
167
  /**
127
- * The Label for the button that opens all multi-actions.
168
+ * The Label for the button that opens all table-actions.
128
169
  */
129
- multiSelectLabel?: string;
170
+ tableActionsLabel?: string;
130
171
  /**
131
172
  * Whether or not to display a loading spinner while the entities of the table are loaded.
132
173
  *
@@ -135,7 +176,7 @@ export interface BaseData<EntityType extends BaseEntityType<EntityType>> {
135
176
  displayLoadingSpinner?: boolean;
136
177
  /**
137
178
  * Whether or not JSON imports are allowed.
138
- * This adds an multi select action.
179
+ * This adds an table select action.
139
180
  *
140
181
  * @default false
141
182
  */
@@ -143,7 +184,7 @@ export interface BaseData<EntityType extends BaseEntityType<EntityType>> {
143
184
  /**
144
185
  * Data to customize the json import action.
145
186
  */
146
- importActionData?: Omit<MultiSelectAction<EntityType>, 'action' | 'requireConfirmDialog'>;
187
+ importActionData?: Omit<BaseTableAction, 'action' | 'requireConfirmDialog' | 'type'>;
147
188
  }
148
189
  /**
149
190
  * The data of the default create-dialog.
@@ -7,8 +7,8 @@ import { MatTableDataSource } from '@angular/material/table';
7
7
  import { Router } from '@angular/router';
8
8
  import { BaseEntityType, Entity } from '../../classes/entity.model';
9
9
  import { SelectionUtilities } from '../../utilities/selection.utilities';
10
- import { MultiSelectAction, TableData } from './table-data';
11
- import { TableDataInternal } from './table-data.builder';
10
+ import { TableData } from './table-data';
11
+ import { BaseTableActionInternal, TableActionInternal, TableDataInternal } from './table-data.builder';
12
12
  import * as i0 from "@angular/core";
13
13
  /**
14
14
  * Generates a fully functional table for displaying, creating, updating and deleting entities
@@ -35,7 +35,7 @@ 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
+ importAction: BaseTableActionInternal;
39
39
  constructor(dialog: MatDialog, injector: Injector, router: Router);
40
40
  /**
41
41
  * Sets up all the configuration for the table and the EntityService.
@@ -60,20 +60,20 @@ export declare class NgxMatEntityTableComponent<EntityType extends BaseEntityTyp
60
60
  createEntity(): void;
61
61
  private createDefault;
62
62
  /**
63
- * Runs the MultiAction for all selected entries.
63
+ * Runs the TableAction for all selected entries.
64
64
  * Also handles confirmation with an additional dialog if configured.
65
65
  *
66
- * @param action - The MultiAction to run.
66
+ * @param action - The TableAction to run.
67
67
  */
68
- runMultiAction(action: MultiSelectAction<EntityType>): void;
69
- private confirmRunMultiAction;
68
+ runTableAction(action: TableActionInternal<EntityType>): void;
69
+ private confirmRunTableAction;
70
70
  /**
71
- * Checks if an MultiAction is disabled (e.g. Because no entries have been selected).
71
+ * Checks if an TableAction is disabled (e.g. Because no entries have been selected).
72
72
  *
73
- * @param action - The MultiAction to check.
73
+ * @param action - The TableAction to check.
74
74
  * @returns Whether or not the Action can be used.
75
75
  */
76
- multiActionDisabled(action: MultiSelectAction<EntityType>): boolean;
76
+ tableActionDisabled(action: TableActionInternal<EntityType>): boolean;
77
77
  ngOnDestroy(): void;
78
78
  /**
79
79
  * Applies the search input to filter the table entries.