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
|
@@ -6,75 +6,44 @@ import * as i0 from '@angular/core';
|
|
|
6
6
|
import { Component, Inject, NgModule, Input, ViewChild } from '@angular/core';
|
|
7
7
|
import * as i1 from '@angular/material/dialog';
|
|
8
8
|
import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
|
|
9
|
-
import * as
|
|
9
|
+
import * as i6 from '@angular/material/checkbox';
|
|
10
10
|
import { MatCheckboxModule } from '@angular/material/checkbox';
|
|
11
11
|
import * as i3 from '@angular/material/button';
|
|
12
12
|
import { MatButtonModule } from '@angular/material/button';
|
|
13
|
-
import * as
|
|
13
|
+
import * as i11 from '@angular/common';
|
|
14
14
|
import { CommonModule } from '@angular/common';
|
|
15
|
-
import * as
|
|
15
|
+
import * as i13 from '@angular/forms';
|
|
16
16
|
import { FormsModule } from '@angular/forms';
|
|
17
|
-
import * as
|
|
18
|
-
import { MatPaginator, MatPaginatorModule } from '@angular/material/paginator';
|
|
19
|
-
import { MatSort } from '@angular/material/sort';
|
|
20
|
-
import * as i4$1 from '@angular/material/table';
|
|
17
|
+
import * as i9 from '@angular/material/table';
|
|
21
18
|
import { MatTableDataSource, MatTableModule } from '@angular/material/table';
|
|
22
19
|
import { SelectionModel } from '@angular/cdk/collections';
|
|
23
|
-
import * as
|
|
20
|
+
import * as i2 from '@angular/material/form-field';
|
|
24
21
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
25
|
-
import * as
|
|
22
|
+
import * as i3$1 from '@angular/material/autocomplete';
|
|
26
23
|
import { MatAutocompleteModule } from '@angular/material/autocomplete';
|
|
27
|
-
import * as
|
|
28
|
-
import * as
|
|
24
|
+
import * as i4 from '@angular/material/core';
|
|
25
|
+
import * as i5 from '@angular/material/select';
|
|
29
26
|
import { MatSelectModule } from '@angular/material/select';
|
|
30
|
-
import * as
|
|
27
|
+
import * as i7 from '@angular/material/slide-toggle';
|
|
31
28
|
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
|
|
32
|
-
import * as
|
|
33
|
-
import { MatInputModule } from '@angular/material/input';
|
|
34
|
-
import * as i10 from '@angular/cdk/text-field';
|
|
35
|
-
import * as i8$1 from '@angular/material/chips';
|
|
29
|
+
import * as i10 from '@angular/material/chips';
|
|
36
30
|
import { MatChipsModule } from '@angular/material/chips';
|
|
37
|
-
import * as
|
|
31
|
+
import * as i12 from '@angular/material/input';
|
|
32
|
+
import { MatInputModule } from '@angular/material/input';
|
|
33
|
+
import * as i14 from '@angular/cdk/text-field';
|
|
38
34
|
import { MatIconModule } from '@angular/material/icon';
|
|
39
|
-
import * as
|
|
35
|
+
import * as i7$1 from '@angular/material/paginator';
|
|
36
|
+
import { MatPaginator, MatPaginatorModule } from '@angular/material/paginator';
|
|
37
|
+
import { MatSort } from '@angular/material/sort';
|
|
38
|
+
import * as i4$1 from '@angular/material/menu';
|
|
40
39
|
import { MatMenuModule } from '@angular/material/menu';
|
|
41
40
|
|
|
42
41
|
/**
|
|
43
|
-
* The base
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
* Is used inside the default create and edit dialogs.
|
|
49
|
-
*/
|
|
50
|
-
// lineBreakAfter?: boolean;
|
|
51
|
-
constructor(displayName, display = true, required = true, omitForCreate = false, omitForUpdate = false, defaultWidths = [6, 6, 12], order
|
|
52
|
-
// lineBreakAfter: boolean = false
|
|
53
|
-
) {
|
|
54
|
-
this.displayName = displayName;
|
|
55
|
-
this.display = display;
|
|
56
|
-
this.required = required;
|
|
57
|
-
this.omitForCreate = omitForCreate;
|
|
58
|
-
this.omitForUpdate = omitForUpdate;
|
|
59
|
-
this.defaultWidths = defaultWidths;
|
|
60
|
-
if (order) {
|
|
61
|
-
if (order < 0) {
|
|
62
|
-
throw new Error('order must be at least 0');
|
|
63
|
-
}
|
|
64
|
-
this.order = order;
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
this.order = -1;
|
|
68
|
-
}
|
|
69
|
-
// this.lineBreakAfter = lineBreakAfter;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* The base decorator for setting metadata on properties
|
|
75
|
-
* @param metadata The metadata to define
|
|
76
|
-
* @param type The type of metadata
|
|
77
|
-
* @returns The function that sets the metadata
|
|
42
|
+
* The base decorator for setting metadata on properties.
|
|
43
|
+
*
|
|
44
|
+
* @param metadata - The metadata to define.
|
|
45
|
+
* @param type - The type of metadata.
|
|
46
|
+
* @returns The method that sets the metadata.
|
|
78
47
|
*/
|
|
79
48
|
function baseProperty(metadata, type) {
|
|
80
49
|
return function (target, propertyKey) {
|
|
@@ -104,60 +73,108 @@ var DecoratorTypes;
|
|
|
104
73
|
})(DecoratorTypes || (DecoratorTypes = {}));
|
|
105
74
|
|
|
106
75
|
/**
|
|
107
|
-
*
|
|
108
|
-
* @param metadata The metadata of the string property
|
|
76
|
+
* The internal Position. Sets default values and validates user input.
|
|
109
77
|
*/
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
78
|
+
class PositionInternal {
|
|
79
|
+
constructor(data) {
|
|
80
|
+
this.validateInput(data);
|
|
81
|
+
this.row = (data === null || data === void 0 ? void 0 : data.row) ? data.row : -1;
|
|
82
|
+
this.order = (data === null || data === void 0 ? void 0 : data.order) ? data.order : -1;
|
|
83
|
+
}
|
|
84
|
+
validateInput(data) {
|
|
85
|
+
if (data === null || data === void 0 ? void 0 : data.order) {
|
|
86
|
+
if (data.order < 1) {
|
|
87
|
+
throw new Error('order must be at least 1');
|
|
88
|
+
}
|
|
89
|
+
if (data.order > 12) {
|
|
90
|
+
throw new Error('order cannot be bigger than 12 (the minimum value for a bootstrap column)');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if ((data === null || data === void 0 ? void 0 : data.row) && (data.row < 1)) {
|
|
94
|
+
throw new Error('row must be at least 1');
|
|
95
|
+
}
|
|
119
96
|
}
|
|
120
|
-
|
|
121
|
-
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The internal PropertyDecoratorConfig. Sets default values.
|
|
100
|
+
*/
|
|
101
|
+
class PropertyDecoratorConfigInternal {
|
|
102
|
+
constructor(data) {
|
|
103
|
+
this.display = data.display != undefined ? data.display : true;
|
|
104
|
+
this.displayName = data.displayName;
|
|
105
|
+
this.required = data.required != undefined ? data.required : true;
|
|
106
|
+
this.omitForCreate = data.omitForCreate != undefined ? data.omitForCreate : false;
|
|
107
|
+
this.omitForUpdate = data.omitForUpdate != undefined ? data.omitForUpdate : false;
|
|
108
|
+
this.defaultWidths = data.defaultWidths ? data.defaultWidths : [6, 6, 12];
|
|
109
|
+
this.position = new PositionInternal(data.position);
|
|
122
110
|
}
|
|
123
111
|
}
|
|
112
|
+
|
|
124
113
|
/**
|
|
125
|
-
*
|
|
114
|
+
* The internal DropdownStringDecoratorConfig. Sets default values.
|
|
126
115
|
*/
|
|
127
|
-
class
|
|
116
|
+
class DropdownStringDecoratorConfigInternal extends PropertyDecoratorConfigInternal {
|
|
117
|
+
constructor(data) {
|
|
118
|
+
super(data);
|
|
119
|
+
this.displayStyle = data.displayStyle;
|
|
120
|
+
this.dropdownValues = data.dropdownValues;
|
|
121
|
+
}
|
|
128
122
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
123
|
+
/**
|
|
124
|
+
* The internal DefaultStringDecoratorConfig. Sets default values.
|
|
125
|
+
*/
|
|
126
|
+
class DefaultStringDecoratorConfigInternal extends PropertyDecoratorConfigInternal {
|
|
127
|
+
constructor(data) {
|
|
128
|
+
super(data);
|
|
129
|
+
this.displayStyle = data.displayStyle;
|
|
130
|
+
this.minLength = data.minLength;
|
|
131
|
+
this.maxLength = data.maxLength;
|
|
132
|
+
this.regex = data.regex;
|
|
134
133
|
}
|
|
135
134
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
this.
|
|
135
|
+
/**
|
|
136
|
+
* The internal TextboxStringDecoratorConfig. Sets default values.
|
|
137
|
+
*/
|
|
138
|
+
class TextboxStringDecoratorConfigInternal extends PropertyDecoratorConfigInternal {
|
|
139
|
+
constructor(data) {
|
|
140
|
+
super(data);
|
|
141
|
+
this.displayStyle = data.displayStyle;
|
|
142
|
+
this.minLength = data.minLength;
|
|
143
|
+
this.maxLength = data.maxLength;
|
|
143
144
|
}
|
|
144
145
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
146
|
+
/**
|
|
147
|
+
* The internal AutocompleteStringDecoratorConfig. Sets default values.
|
|
148
|
+
*/
|
|
149
|
+
class AutocompleteStringDecoratorConfigInternal extends PropertyDecoratorConfigInternal {
|
|
150
|
+
constructor(data) {
|
|
151
|
+
super(data);
|
|
152
|
+
this.displayStyle = data.displayStyle;
|
|
153
|
+
this.autocompleteValues = data.autocompleteValues;
|
|
154
|
+
this.minLength = data.minLength;
|
|
155
|
+
this.maxLength = data.maxLength;
|
|
156
|
+
this.regex = data.regex;
|
|
151
157
|
}
|
|
152
158
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Decorator for setting and getting string Property metadata.
|
|
162
|
+
*
|
|
163
|
+
* @param metadata - The metadata of the string property.
|
|
164
|
+
* @returns The method that defines the metadata.
|
|
165
|
+
*/
|
|
166
|
+
function string(metadata) {
|
|
167
|
+
if (metadata.displayStyle === 'dropdown') {
|
|
168
|
+
return baseProperty(new DropdownStringDecoratorConfigInternal(metadata), DecoratorTypes.STRING_DROPDOWN);
|
|
169
|
+
}
|
|
170
|
+
else if (metadata.displayStyle === 'autocomplete') {
|
|
171
|
+
return baseProperty(new AutocompleteStringDecoratorConfigInternal(metadata), DecoratorTypes.STRING_AUTOCOMPLETE);
|
|
172
|
+
}
|
|
173
|
+
else if (metadata.displayStyle === 'textbox') {
|
|
174
|
+
return baseProperty(new TextboxStringDecoratorConfigInternal(metadata), DecoratorTypes.STRING_TEXTBOX);
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
return baseProperty(new DefaultStringDecoratorConfigInternal(metadata), DecoratorTypes.STRING);
|
|
161
178
|
}
|
|
162
179
|
}
|
|
163
180
|
|
|
@@ -180,17 +197,19 @@ __decorate([
|
|
|
180
197
|
|
|
181
198
|
var _a;
|
|
182
199
|
/**
|
|
183
|
-
* Contains HelperMethods around handling Entities and their property-metadata
|
|
200
|
+
* Contains HelperMethods around handling Entities and their property-metadata.
|
|
184
201
|
*/
|
|
185
202
|
class EntityUtilities {
|
|
186
203
|
/**
|
|
187
|
-
* Gets the properties to omit when updating the entity
|
|
188
|
-
*
|
|
204
|
+
* Gets the properties to omit when updating the entity.
|
|
205
|
+
*
|
|
206
|
+
* @param entity - The entity to get the properties which should be left out for updating from.
|
|
207
|
+
* @returns The properties which should be left out for updating an Entity.
|
|
189
208
|
*/
|
|
190
209
|
static getOmitForUpdate(entity) {
|
|
191
210
|
const res = [];
|
|
192
|
-
for (const key of
|
|
193
|
-
const metadata =
|
|
211
|
+
for (const key of EntityUtilities.keysOf(entity)) {
|
|
212
|
+
const metadata = EntityUtilities.getPropertyMetadata(entity, key);
|
|
194
213
|
if (metadata.omitForUpdate) {
|
|
195
214
|
res.push(key);
|
|
196
215
|
}
|
|
@@ -198,13 +217,15 @@ class EntityUtilities {
|
|
|
198
217
|
return res;
|
|
199
218
|
}
|
|
200
219
|
/**
|
|
201
|
-
* Gets the properties to omit when creating new entities
|
|
202
|
-
*
|
|
220
|
+
* Gets the properties to omit when creating new entities.
|
|
221
|
+
*
|
|
222
|
+
* @param entity - The entity to get the properties which should be left out for creating from.
|
|
223
|
+
* @returns The properties which should be left out for creating a new Entity.
|
|
203
224
|
*/
|
|
204
225
|
static getOmitForCreate(entity) {
|
|
205
226
|
const res = [];
|
|
206
|
-
for (const key of
|
|
207
|
-
const metadata =
|
|
227
|
+
for (const key of EntityUtilities.keysOf(entity)) {
|
|
228
|
+
const metadata = EntityUtilities.getPropertyMetadata(entity, key);
|
|
208
229
|
if (metadata.omitForCreate) {
|
|
209
230
|
res.push(key);
|
|
210
231
|
}
|
|
@@ -212,11 +233,13 @@ class EntityUtilities {
|
|
|
212
233
|
return res;
|
|
213
234
|
}
|
|
214
235
|
/**
|
|
215
|
-
* Gets the metadata included in an property
|
|
216
|
-
*
|
|
217
|
-
* @param
|
|
218
|
-
* @param
|
|
219
|
-
* @
|
|
236
|
+
* Gets the metadata included in an property.
|
|
237
|
+
*
|
|
238
|
+
* @param entity - The entity with the property to get the metadata from.
|
|
239
|
+
* @param propertyKey - The property on the given Entity to get the metadata from.
|
|
240
|
+
* @param type - For secure Typing, defines the returned PropertyConfig.
|
|
241
|
+
* @returns The metadata of the property.
|
|
242
|
+
* @throws When no metadata can be found for the given property.
|
|
220
243
|
*/
|
|
221
244
|
static getPropertyMetadata(entity, propertyKey,
|
|
222
245
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -224,58 +247,78 @@ class EntityUtilities {
|
|
|
224
247
|
try {
|
|
225
248
|
const metadata = Reflect.getMetadata('metadata', entity, propertyKey);
|
|
226
249
|
if (!metadata) {
|
|
227
|
-
throw new Error(`Could not find metadata for property ${String(propertyKey)}
|
|
228
|
-
on the entity ${JSON.stringify(entity)}`);
|
|
250
|
+
throw new Error(`Could not find metadata for property ${String(propertyKey)} on the entity ${JSON.stringify(entity)}`);
|
|
229
251
|
}
|
|
230
252
|
return metadata;
|
|
231
253
|
}
|
|
232
254
|
catch (error) {
|
|
233
|
-
throw new Error(`Could not find metadata for property ${String(propertyKey)}
|
|
234
|
-
on the entity ${JSON.stringify(entity)}`);
|
|
255
|
+
throw new Error(`Could not find metadata for property ${String(propertyKey)} on the entity ${JSON.stringify(entity)}`);
|
|
235
256
|
}
|
|
236
257
|
}
|
|
237
258
|
/**
|
|
238
259
|
* Gets the type of the property-metadata.
|
|
239
|
-
*
|
|
240
|
-
* @param
|
|
241
|
-
* @
|
|
260
|
+
*
|
|
261
|
+
* @param entity - The entity with the property to get the type from.
|
|
262
|
+
* @param propertyKey - The property on the given Entity to get the type from.
|
|
263
|
+
* @returns The type of the metadata.
|
|
264
|
+
* @throws Will throw an error if no metadata can be found for the given property.
|
|
242
265
|
*/
|
|
243
266
|
static getPropertyType(entity, propertyKey) {
|
|
244
267
|
try {
|
|
245
268
|
const propertyType = Reflect.getMetadata('type', entity, propertyKey);
|
|
246
269
|
if (!propertyType) {
|
|
247
|
-
throw new Error(`Could not find type metadata for property ${String(propertyKey)}
|
|
248
|
-
on the entity ${JSON.stringify(entity)}`);
|
|
270
|
+
throw new Error(`Could not find type metadata for property ${String(propertyKey)} on the entity ${JSON.stringify(entity)}`);
|
|
249
271
|
}
|
|
250
272
|
return propertyType;
|
|
251
273
|
}
|
|
252
274
|
catch (error) {
|
|
253
|
-
throw new Error(`Could not find type metadata for property ${String(propertyKey)}
|
|
254
|
-
on the entity ${JSON.stringify(entity)}`);
|
|
275
|
+
throw new Error(`Could not find type metadata for property ${String(propertyKey)} on the entity ${JSON.stringify(entity)}`);
|
|
255
276
|
}
|
|
256
277
|
}
|
|
257
278
|
/**
|
|
258
279
|
* Sets all property values based on a given entity data-object.
|
|
259
|
-
*
|
|
260
|
-
* @param target
|
|
261
|
-
*
|
|
262
|
-
* (if called inside a Entity constructor its usually this)
|
|
280
|
+
*
|
|
281
|
+
* @param target - The target object that needs to be constructed (if called inside an Entity constructor its usually this).
|
|
282
|
+
* @param entity - The data object to get the property values from.
|
|
263
283
|
* @alias new
|
|
264
284
|
* @alias build
|
|
265
285
|
* @alias construct
|
|
266
286
|
*/
|
|
267
287
|
static new(target, entity) {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
288
|
+
for (const key in target) {
|
|
289
|
+
const type = EntityUtilities.getPropertyType(target, key);
|
|
290
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
291
|
+
let value = entity ? Reflect.get(entity, key) : undefined;
|
|
292
|
+
switch (type) {
|
|
293
|
+
case DecoratorTypes.OBJECT:
|
|
294
|
+
const objectMetadata = EntityUtilities.getPropertyMetadata(target, key, DecoratorTypes.OBJECT);
|
|
295
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
296
|
+
value = new objectMetadata.type(value);
|
|
297
|
+
break;
|
|
298
|
+
case DecoratorTypes.ARRAY:
|
|
299
|
+
const inputArray = value;
|
|
300
|
+
const resArray = [];
|
|
301
|
+
if (inputArray) {
|
|
302
|
+
const arrayMetadata = EntityUtilities.getPropertyMetadata(target, key, DecoratorTypes.ARRAY);
|
|
303
|
+
for (const item of inputArray) {
|
|
304
|
+
const itemWithMetadata = new arrayMetadata.EntityClass(item);
|
|
305
|
+
resArray.push(itemWithMetadata);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
value = resArray;
|
|
309
|
+
break;
|
|
310
|
+
default:
|
|
311
|
+
break;
|
|
271
312
|
}
|
|
313
|
+
Reflect.set(target, key, value);
|
|
272
314
|
}
|
|
273
315
|
}
|
|
274
316
|
/**
|
|
275
317
|
* Checks if the values on an entity are valid.
|
|
276
|
-
* Also checks all the validators given by the metadata ("required", "maxLength" etc.)
|
|
277
|
-
*
|
|
278
|
-
* @param
|
|
318
|
+
* Also checks all the validators given by the metadata ("required", "maxLength" etc.).
|
|
319
|
+
*
|
|
320
|
+
* @param entity - The entity to validate.
|
|
321
|
+
* @param omit - Whether to check for creating or editing validity.
|
|
279
322
|
* @returns Whether or not the entity is valid.
|
|
280
323
|
*/
|
|
281
324
|
static isEntityValid(entity, omit) {
|
|
@@ -287,17 +330,19 @@ class EntityUtilities {
|
|
|
287
330
|
return true;
|
|
288
331
|
}
|
|
289
332
|
/**
|
|
290
|
-
* Checks if a single property value is valid
|
|
291
|
-
*
|
|
292
|
-
* @param
|
|
293
|
-
* @
|
|
333
|
+
* Checks if a single property value is valid.
|
|
334
|
+
*
|
|
335
|
+
* @param entity - The entity where the property is from.
|
|
336
|
+
* @param key - The name of the property.
|
|
337
|
+
* @param omit - Whether to check if the given entity is valid for creation or updating.
|
|
338
|
+
* @returns Whether or not the property value is valid.
|
|
339
|
+
* @throws Throws when it extracts an unknown metadata type.
|
|
294
340
|
*/
|
|
295
341
|
static isPropertyValid(entity, key, omit) {
|
|
296
342
|
const type = this.getPropertyType(entity, key);
|
|
297
343
|
const metadata = this.getPropertyMetadata(entity, key, type);
|
|
298
344
|
const metadataDefaultString = metadata;
|
|
299
345
|
const metadataTextboxString = metadata;
|
|
300
|
-
const metadataAutocompleteString = metadata;
|
|
301
346
|
const metadataDefaultNumber = metadata;
|
|
302
347
|
const objectProperty = entity[key];
|
|
303
348
|
const metadataEntityArray = metadata;
|
|
@@ -305,14 +350,21 @@ class EntityUtilities {
|
|
|
305
350
|
if (metadata.omitForCreate && omit === 'create') {
|
|
306
351
|
return true;
|
|
307
352
|
}
|
|
308
|
-
if (metadata.omitForUpdate && omit === '
|
|
353
|
+
if (metadata.omitForUpdate && omit === 'update') {
|
|
309
354
|
return true;
|
|
310
355
|
}
|
|
311
356
|
if (metadata.required && !entity[key]) {
|
|
312
357
|
return false;
|
|
313
358
|
}
|
|
314
359
|
switch (type) {
|
|
360
|
+
case DecoratorTypes.BOOLEAN_DROPDOWN:
|
|
361
|
+
case DecoratorTypes.BOOLEAN_CHECKBOX:
|
|
362
|
+
case DecoratorTypes.BOOLEAN_TOGGLE:
|
|
363
|
+
return true;
|
|
364
|
+
case DecoratorTypes.STRING_DROPDOWN:
|
|
365
|
+
return true;
|
|
315
366
|
case DecoratorTypes.STRING:
|
|
367
|
+
case DecoratorTypes.STRING_AUTOCOMPLETE:
|
|
316
368
|
if (metadataDefaultString.maxLength
|
|
317
369
|
&& entity[key].length > metadataDefaultString.maxLength) {
|
|
318
370
|
return false;
|
|
@@ -326,20 +378,6 @@ class EntityUtilities {
|
|
|
326
378
|
return false;
|
|
327
379
|
}
|
|
328
380
|
break;
|
|
329
|
-
case DecoratorTypes.STRING_AUTOCOMPLETE:
|
|
330
|
-
if (metadataAutocompleteString.maxLength
|
|
331
|
-
&& entity[key].length > metadataAutocompleteString.maxLength) {
|
|
332
|
-
return false;
|
|
333
|
-
}
|
|
334
|
-
if (metadataAutocompleteString.minLength
|
|
335
|
-
&& entity[key].length < metadataAutocompleteString.minLength) {
|
|
336
|
-
return false;
|
|
337
|
-
}
|
|
338
|
-
if (metadataAutocompleteString.regex
|
|
339
|
-
&& entity[key].match(metadataAutocompleteString.regex)) {
|
|
340
|
-
return false;
|
|
341
|
-
}
|
|
342
|
-
break;
|
|
343
381
|
case DecoratorTypes.STRING_TEXTBOX:
|
|
344
382
|
if (metadataTextboxString.maxLength
|
|
345
383
|
&& entity[key].length > metadataTextboxString.maxLength) {
|
|
@@ -350,11 +388,13 @@ class EntityUtilities {
|
|
|
350
388
|
return false;
|
|
351
389
|
}
|
|
352
390
|
break;
|
|
391
|
+
case DecoratorTypes.NUMBER_DROPDOWN:
|
|
392
|
+
return true;
|
|
353
393
|
case DecoratorTypes.NUMBER:
|
|
354
394
|
if (metadataDefaultNumber.max && entity[key] > metadataDefaultNumber.max) {
|
|
355
395
|
return false;
|
|
356
396
|
}
|
|
357
|
-
if (metadataDefaultNumber.min && entity[key]
|
|
397
|
+
if (metadataDefaultNumber.min && entity[key] < metadataDefaultNumber.min) {
|
|
358
398
|
return false;
|
|
359
399
|
}
|
|
360
400
|
break;
|
|
@@ -378,10 +418,11 @@ class EntityUtilities {
|
|
|
378
418
|
return true;
|
|
379
419
|
}
|
|
380
420
|
/**
|
|
381
|
-
* Checks if an entity is "dirty" (if its values have changed)
|
|
382
|
-
*
|
|
383
|
-
* @param
|
|
384
|
-
* @
|
|
421
|
+
* Checks if an entity is "dirty" (if its values have changed).
|
|
422
|
+
*
|
|
423
|
+
* @param entity - The entity after all changes.
|
|
424
|
+
* @param entityPriorChanges - The entity before the changes.
|
|
425
|
+
* @returns Whether or not the entity is dirty.
|
|
385
426
|
*/
|
|
386
427
|
static dirty(entity, entityPriorChanges) {
|
|
387
428
|
if (!entityPriorChanges) {
|
|
@@ -398,10 +439,11 @@ class EntityUtilities {
|
|
|
398
439
|
}
|
|
399
440
|
}
|
|
400
441
|
/**
|
|
401
|
-
* Compares two Entities and returns their difference in an object
|
|
402
|
-
*
|
|
403
|
-
* @param
|
|
404
|
-
* @
|
|
442
|
+
* Compares two Entities and returns their difference in an object.
|
|
443
|
+
*
|
|
444
|
+
* @param entity - The first entity to compare.
|
|
445
|
+
* @param entityPriorChanges - The second entity to compare.
|
|
446
|
+
* @returns The difference between the two Entities in form of a Partial.
|
|
405
447
|
*/
|
|
406
448
|
static difference(entity, entityPriorChanges) {
|
|
407
449
|
const res = {};
|
|
@@ -412,64 +454,120 @@ class EntityUtilities {
|
|
|
412
454
|
}
|
|
413
455
|
return res;
|
|
414
456
|
}
|
|
457
|
+
//TODO X Y
|
|
415
458
|
/**
|
|
416
|
-
*
|
|
417
|
-
*
|
|
418
|
-
* @param
|
|
419
|
-
* @param
|
|
459
|
+
* Compare function for sorting entity keys by their order value.
|
|
460
|
+
*
|
|
461
|
+
* @param a - First key of entity.
|
|
462
|
+
* @param b - Second key of entity.
|
|
463
|
+
* @param entity - Current entity (used to get metadata of entity keys).
|
|
464
|
+
* @returns 0 if both values have the same order, a negative value if X, a positive value if Y.
|
|
420
465
|
*/
|
|
421
466
|
static compareOrder(a, b, entity) {
|
|
422
|
-
const metadataA = EntityUtilities.getPropertyMetadata(entity, a
|
|
423
|
-
const metadataB = EntityUtilities.getPropertyMetadata(entity, b
|
|
424
|
-
if (metadataA.order === -1) {
|
|
467
|
+
const metadataA = EntityUtilities.getPropertyMetadata(entity, a);
|
|
468
|
+
const metadataB = EntityUtilities.getPropertyMetadata(entity, b);
|
|
469
|
+
if (metadataA.position.order === -1) {
|
|
470
|
+
if (metadataB.position.order === -1) {
|
|
471
|
+
return 0;
|
|
472
|
+
}
|
|
425
473
|
return 1;
|
|
426
474
|
}
|
|
427
|
-
else if (metadataB.order === -1) {
|
|
428
|
-
return
|
|
475
|
+
else if (metadataB.position.order === -1) {
|
|
476
|
+
return -1;
|
|
429
477
|
}
|
|
430
|
-
return (metadataA.order - metadataB.order);
|
|
478
|
+
return ((metadataA.position.order) - (metadataB.position.order));
|
|
431
479
|
}
|
|
432
480
|
/**
|
|
433
|
-
*
|
|
434
|
-
*
|
|
435
|
-
* @param
|
|
436
|
-
* @param
|
|
437
|
-
* @
|
|
481
|
+
* Gets the bootstrap column values for "lg", "md", "sm".
|
|
482
|
+
*
|
|
483
|
+
* @param entity - Entity to get the bootstrap column values of the key.
|
|
484
|
+
* @param key - Key of the property to get bootstrap column values from.
|
|
485
|
+
* @param type - Defines for which screen size the column values should be returned.
|
|
486
|
+
* @returns Bootstrap column value.
|
|
438
487
|
*/
|
|
439
488
|
static getWidth(entity, key, type) {
|
|
440
|
-
const
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
case 'sm':
|
|
449
|
-
return metadata.defaultWidths[2];
|
|
450
|
-
default:
|
|
451
|
-
throw new Error('Something went wrong getting the width');
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
else {
|
|
455
|
-
throw new Error('Something went wrong getting the width');
|
|
489
|
+
const metadata = EntityUtilities.getPropertyMetadata(entity, key);
|
|
490
|
+
switch (type) {
|
|
491
|
+
case 'lg':
|
|
492
|
+
return metadata.defaultWidths[0];
|
|
493
|
+
case 'md':
|
|
494
|
+
return metadata.defaultWidths[1];
|
|
495
|
+
case 'sm':
|
|
496
|
+
return metadata.defaultWidths[2];
|
|
456
497
|
}
|
|
457
498
|
}
|
|
458
499
|
/**
|
|
459
|
-
* Resets all changes on an entity
|
|
460
|
-
*
|
|
461
|
-
* @param
|
|
500
|
+
* Resets all changes on an entity.
|
|
501
|
+
*
|
|
502
|
+
* @param entity - The entity to reset.
|
|
503
|
+
* @param entityPriorChanges - The entity before any changes.
|
|
462
504
|
*/
|
|
463
505
|
static resetChangesOnEntity(entity, entityPriorChanges) {
|
|
464
506
|
for (const key in entityPriorChanges) {
|
|
465
507
|
Reflect.set(entity, key, Reflect.get(entityPriorChanges, key));
|
|
466
508
|
}
|
|
467
509
|
}
|
|
510
|
+
/**
|
|
511
|
+
* Gets the rows that are used to display the given entity.
|
|
512
|
+
*
|
|
513
|
+
* @param entity - The entity to get the rows from.
|
|
514
|
+
* @param hideOmitForCreate - Whether or not keys with the metadata omitForCreate should be filtered out.
|
|
515
|
+
* @param hideOmitForEdit - Whether or not keys with the metadata omitForUpdate should be filtered out.
|
|
516
|
+
* @returns The sorted Rows containing the row number and the keys to display in that row.
|
|
517
|
+
*/
|
|
518
|
+
static getEntityRows(entity, hideOmitForCreate = false, hideOmitForEdit = false) {
|
|
519
|
+
const res = [];
|
|
520
|
+
const keys = EntityUtilities.keysOf(entity, hideOmitForCreate, hideOmitForEdit);
|
|
521
|
+
const numberOfRows = EntityUtilities.getNumberOfRows(keys, entity);
|
|
522
|
+
for (let i = 1; i <= numberOfRows; i++) {
|
|
523
|
+
const row = {
|
|
524
|
+
row: i,
|
|
525
|
+
keys: EntityUtilities.getKeysForRow(keys, entity, i)
|
|
526
|
+
};
|
|
527
|
+
res.push(row);
|
|
528
|
+
}
|
|
529
|
+
const lastRow = {
|
|
530
|
+
row: numberOfRows + 1,
|
|
531
|
+
keys: EntityUtilities.getKeysForRow(keys, entity, -1)
|
|
532
|
+
};
|
|
533
|
+
res.push(lastRow);
|
|
534
|
+
return res;
|
|
535
|
+
}
|
|
536
|
+
static getKeysForRow(keys, entity, i) {
|
|
537
|
+
return keys
|
|
538
|
+
.filter(k => EntityUtilities.getPropertyMetadata(entity, k).position.row === i)
|
|
539
|
+
.sort((a, b) => EntityUtilities.compareOrder(a, b, entity));
|
|
540
|
+
}
|
|
541
|
+
static getNumberOfRows(keys, entity) {
|
|
542
|
+
return keys
|
|
543
|
+
.map(k => EntityUtilities.getPropertyMetadata(entity, k).position.row)
|
|
544
|
+
.sort((a, b) => (a > b ? -1 : 1))[0];
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Gets the keys of the provided entity correctly typed.
|
|
548
|
+
*
|
|
549
|
+
* @param entity - The entity to get the keys of.
|
|
550
|
+
* @param hideOmitForCreate - Whether or not keys with the metadata omitForCreate should be filtered out.
|
|
551
|
+
* @param hideOmitForEdit - Whether or not keys with the metadata omitForUpdate should be filtered out.
|
|
552
|
+
* @returns An array of keys of the entity.
|
|
553
|
+
*/
|
|
554
|
+
static keysOf(entity, hideOmitForCreate = false, hideOmitForEdit = false) {
|
|
555
|
+
let keys = Reflect.ownKeys(entity);
|
|
556
|
+
if (hideOmitForCreate) {
|
|
557
|
+
const omitForCreateKeys = EntityUtilities.getOmitForCreate(entity);
|
|
558
|
+
keys = keys.filter(k => !omitForCreateKeys.includes(k));
|
|
559
|
+
}
|
|
560
|
+
if (hideOmitForEdit) {
|
|
561
|
+
const omitForUpdateKeys = EntityUtilities.getOmitForUpdate(entity);
|
|
562
|
+
keys = keys.filter(k => !omitForUpdateKeys.includes(k));
|
|
563
|
+
}
|
|
564
|
+
return keys;
|
|
565
|
+
}
|
|
468
566
|
}
|
|
469
567
|
_a = EntityUtilities;
|
|
470
|
-
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
568
|
+
// eslint-disable-next-line @typescript-eslint/member-ordering, jsdoc/require-jsdoc
|
|
471
569
|
EntityUtilities.construct = _a.new;
|
|
472
|
-
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
570
|
+
// eslint-disable-next-line @typescript-eslint/member-ordering, jsdoc/require-jsdoc
|
|
473
571
|
EntityUtilities.build = _a.new;
|
|
474
572
|
|
|
475
573
|
/**
|
|
@@ -482,22 +580,25 @@ class EntityService {
|
|
|
482
580
|
constructor(http) {
|
|
483
581
|
this.http = http;
|
|
484
582
|
/**
|
|
485
|
-
*
|
|
583
|
+
* A subject of all the entity values.
|
|
486
584
|
* Can be subscribed to when you want to do a specific thing whenever the entities change.
|
|
487
585
|
*/
|
|
488
586
|
this.entitiesSubject = new BehaviorSubject([]);
|
|
489
587
|
}
|
|
490
588
|
/**
|
|
491
|
-
*
|
|
589
|
+
* Gets the entities in an array from the internal entitiesSubject.
|
|
590
|
+
*
|
|
591
|
+
* @returns The current entities in form of an array.
|
|
492
592
|
*/
|
|
493
593
|
get entities() {
|
|
494
594
|
return this.entitiesSubject.value;
|
|
495
595
|
}
|
|
496
596
|
/**
|
|
497
|
-
* Creates a new Entity and pushes it to the entities array
|
|
498
|
-
*
|
|
597
|
+
* Creates a new Entity and pushes it to the entities array.
|
|
598
|
+
*
|
|
599
|
+
* @param entity - The data of the entity to create.
|
|
499
600
|
* All values that should be omitted will be removed from it inside this method.
|
|
500
|
-
* @returns A Promise of the created entity
|
|
601
|
+
* @returns A Promise of the created entity.
|
|
501
602
|
*/
|
|
502
603
|
create(entity) {
|
|
503
604
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -509,8 +610,9 @@ class EntityService {
|
|
|
509
610
|
});
|
|
510
611
|
}
|
|
511
612
|
/**
|
|
512
|
-
* Gets all existing entities and pushes them to the
|
|
513
|
-
*
|
|
613
|
+
* Gets all existing entities and pushes them to the entities array.
|
|
614
|
+
*
|
|
615
|
+
* @returns A Promise of all received Entities.
|
|
514
616
|
*/
|
|
515
617
|
read() {
|
|
516
618
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -520,11 +622,12 @@ class EntityService {
|
|
|
520
622
|
});
|
|
521
623
|
}
|
|
522
624
|
/**
|
|
523
|
-
* Updates a specific Entity
|
|
524
|
-
*
|
|
625
|
+
* Updates a specific Entity.
|
|
626
|
+
*
|
|
627
|
+
* @param entity - The updated Entity
|
|
525
628
|
* All values that should be omitted will be removed from it inside this method.
|
|
526
|
-
* @param entityPriorChanges The current Entity.
|
|
527
|
-
* It Is used to get changed values and only update them instead of sending the whole entity data
|
|
629
|
+
* @param entityPriorChanges - The current Entity.
|
|
630
|
+
* It Is used to get changed values and only update them instead of sending the whole entity data.
|
|
528
631
|
*/
|
|
529
632
|
update(entity, entityPriorChanges) {
|
|
530
633
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -535,8 +638,9 @@ class EntityService {
|
|
|
535
638
|
});
|
|
536
639
|
}
|
|
537
640
|
/**
|
|
538
|
-
*
|
|
539
|
-
*
|
|
641
|
+
* Deletes a specific Entity.
|
|
642
|
+
*
|
|
643
|
+
* @param id - The id of the element to delete.
|
|
540
644
|
*/
|
|
541
645
|
delete(id) {
|
|
542
646
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -547,44 +651,125 @@ class EntityService {
|
|
|
547
651
|
}
|
|
548
652
|
}
|
|
549
653
|
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
this.
|
|
654
|
+
/**
|
|
655
|
+
* The abstract BaseBuilder class.
|
|
656
|
+
*/
|
|
657
|
+
class BaseBuilder {
|
|
658
|
+
constructor(data) {
|
|
659
|
+
this.validateInput(data);
|
|
660
|
+
this.inputData = data;
|
|
661
|
+
this.data = this.generateBaseData(data);
|
|
662
|
+
return this;
|
|
558
663
|
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
664
|
+
/**
|
|
665
|
+
* Used to validate the user input in the constructor.
|
|
666
|
+
*
|
|
667
|
+
* @param data - The user input.
|
|
668
|
+
*/
|
|
669
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
670
|
+
validateInput(data) {
|
|
671
|
+
// By default, no validation is done
|
|
672
|
+
}
|
|
673
|
+
;
|
|
674
|
+
/**
|
|
675
|
+
* Sets the value for the given key if no user value was provided.
|
|
676
|
+
*
|
|
677
|
+
* @param key - The key to set the default value for.
|
|
678
|
+
* @param value - The value to set when nothing was provided.
|
|
679
|
+
* @returns The Builder.
|
|
680
|
+
*/
|
|
681
|
+
withDefault(key, value) {
|
|
682
|
+
if (!this.inputData || !this.inputData[key]) {
|
|
683
|
+
this.data[key] = value;
|
|
564
684
|
}
|
|
565
|
-
|
|
566
|
-
|
|
685
|
+
return this;
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* Method used to get the final build value after applying all chaining.
|
|
689
|
+
*
|
|
690
|
+
* @returns The build value.
|
|
691
|
+
*/
|
|
692
|
+
getResult() {
|
|
693
|
+
return this.data;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* The internal ConfirmDialogData. Requires all default values the user can leave out.
|
|
699
|
+
*/
|
|
700
|
+
class ConfirmDialogDataInternal {
|
|
701
|
+
constructor(text, type, confirmButtonLabel, cancelButtonLabel, title, requireConfirmation, confirmationText) {
|
|
702
|
+
this.text = text;
|
|
703
|
+
this.type = type;
|
|
704
|
+
this.confirmButtonLabel = confirmButtonLabel;
|
|
705
|
+
this.cancelButtonLabel = cancelButtonLabel;
|
|
706
|
+
this.title = title;
|
|
707
|
+
this.requireConfirmation = requireConfirmation;
|
|
708
|
+
this.confirmationText = confirmationText;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* The Builder for the ConfirmDialogData. Sets default values.
|
|
713
|
+
*/
|
|
714
|
+
class ConfirmDialogDataBuilder extends BaseBuilder {
|
|
715
|
+
constructor(data) {
|
|
716
|
+
super(data);
|
|
717
|
+
}
|
|
718
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
719
|
+
generateBaseData(data) {
|
|
720
|
+
return new ConfirmDialogDataInternal((data === null || data === void 0 ? void 0 : data.text) ? data.text : ['Do you really want to do this?'], (data === null || data === void 0 ? void 0 : data.type) ? data.type : 'default', (data === null || data === void 0 ? void 0 : data.confirmButtonLabel) ? data.confirmButtonLabel : 'Confirm', (data === null || data === void 0 ? void 0 : data.cancelButtonLabel) ? data.cancelButtonLabel : 'Cancel', (data === null || data === void 0 ? void 0 : data.title) ? data.title : 'Confirmation', (data === null || data === void 0 ? void 0 : data.requireConfirmation) ? data.requireConfirmation : false, data === null || data === void 0 ? void 0 : data.confirmationText);
|
|
721
|
+
}
|
|
722
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
723
|
+
validateInput(data) {
|
|
724
|
+
if (!data) {
|
|
725
|
+
return;
|
|
567
726
|
}
|
|
568
|
-
if (
|
|
569
|
-
|
|
727
|
+
if (data.requireConfirmation && !data.confirmationText) {
|
|
728
|
+
throw new Error(`Missing required Input data "confirmationText".
|
|
729
|
+
You can only omit this value when "requireConfirmation" is false.`);
|
|
730
|
+
}
|
|
731
|
+
if (!data.requireConfirmation && data.confirmationText) {
|
|
732
|
+
throw new Error('The "confirmationText" will never be shown because "requireConfirmation" is not set to true');
|
|
570
733
|
}
|
|
571
|
-
if (
|
|
734
|
+
if (data.type === 'info-only' && data.cancelButtonLabel) {
|
|
572
735
|
throw new Error('The "cancelButtonLabel" will never be shown because "type" is set to "info-only"');
|
|
573
736
|
}
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* The Dialog used whenever confirmation by the user is required (e.g. When the user tries to delete an entity).
|
|
742
|
+
*
|
|
743
|
+
* Can be customized with the MAT_DIALOG_DATA "inputData". Customization options are defined in "ConfirmDialogData".
|
|
744
|
+
*/
|
|
745
|
+
class NgxMatEntityConfirmDialogComponent {
|
|
746
|
+
constructor(dialogRef, inputData) {
|
|
747
|
+
this.dialogRef = dialogRef;
|
|
748
|
+
this.inputData = inputData;
|
|
749
|
+
this.confirm = false;
|
|
750
|
+
}
|
|
751
|
+
ngOnInit() {
|
|
752
|
+
this.data = new ConfirmDialogDataBuilder(this.inputData).getResult();
|
|
574
753
|
this.dialogRef.disableClose = true;
|
|
575
754
|
}
|
|
755
|
+
/**
|
|
756
|
+
* Closes the dialog with value 1 to signal that the action should be run.
|
|
757
|
+
*/
|
|
576
758
|
confirmAction() {
|
|
577
759
|
this.dialogRef.close(1);
|
|
578
760
|
}
|
|
761
|
+
/**
|
|
762
|
+
* Closes the dialog.
|
|
763
|
+
*/
|
|
579
764
|
cancel() {
|
|
580
765
|
this.dialogRef.close();
|
|
581
766
|
}
|
|
582
767
|
}
|
|
583
768
|
NgxMatEntityConfirmDialogComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityConfirmDialogComponent, deps: [{ token: i1.MatDialogRef }, { token: MAT_DIALOG_DATA }], target: i0.ɵɵFactoryTarget.Component });
|
|
584
|
-
NgxMatEntityConfirmDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: NgxMatEntityConfirmDialogComponent, selector: "ngx-mat-entity-confirm-dialog", ngImport: i0, template: "<h2 mat-dialog-title *ngIf=\"data.title\">{{data.title}}</h2>\n\n<mat-dialog-content>\n <p *ngFor=\"let paragraph of data.text\">{{paragraph}}</p>\n <div *ngIf=\"data.requireConfirmation\" class=\"checkbox-wrapper\">\n <mat-checkbox [(ngModel)]=\"confirm\" name=\"confirm\">\n {{data.confirmationText}}\n </mat-checkbox>\n </div>\n</mat-dialog-content>\n\n<mat-dialog-actions>\n <button *ngIf=\"data.type === 'delete'\" mat-raised-button color=\"warn\" (click)=\"confirmAction()\" [disabled]=\"data.requireConfirmation && !confirm\" class=\"confirm-button\">\n {{data.confirmButtonLabel
|
|
769
|
+
NgxMatEntityConfirmDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: NgxMatEntityConfirmDialogComponent, selector: "ngx-mat-entity-confirm-dialog", ngImport: i0, template: "<h2 mat-dialog-title *ngIf=\"data.title\">{{data.title}}</h2>\n\n<mat-dialog-content>\n <p *ngFor=\"let paragraph of data.text\">{{paragraph}}</p>\n <div *ngIf=\"data.requireConfirmation\" class=\"checkbox-wrapper\">\n <mat-checkbox [(ngModel)]=\"confirm\" name=\"confirm\">\n {{data.confirmationText}}\n </mat-checkbox>\n </div>\n</mat-dialog-content>\n\n<mat-dialog-actions>\n <button *ngIf=\"data.type === 'delete'\" mat-raised-button color=\"warn\" (click)=\"confirmAction()\" [disabled]=\"data.requireConfirmation && !confirm\" class=\"confirm-button\">\n {{data.confirmButtonLabel}}\n </button>\n <button *ngIf=\"data.type !== 'delete'\" mat-raised-button (click)=\"confirmAction()\" [disabled]=\"data.requireConfirmation && !confirm\" class=\"confirm-button\">\n {{data.confirmButtonLabel}}\n </button>\n <button mat-raised-button (click)=\"cancel()\" class=\"cancel-button\">\n {{data.cancelButtonLabel}}\n </button>\n</mat-dialog-actions>\n", styles: [".checkbox-wrapper{min-height:50px;display:flex}.checkbox-wrapper>mat-checkbox{align-self:center}mat-dialog-actions{display:flex;justify-content:space-between}\n"], components: [{ type: i6.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex", "aria-label", "aria-labelledby", "aria-describedby", "id", "required", "labelPosition", "name", "value", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { type: i3.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i11.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { type: i1.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { type: i11.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i13.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i13.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i1.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]" }] });
|
|
585
770
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityConfirmDialogComponent, decorators: [{
|
|
586
771
|
type: Component,
|
|
587
|
-
args: [{ selector: 'ngx-mat-entity-confirm-dialog', template: "<h2 mat-dialog-title *ngIf=\"data.title\">{{data.title}}</h2>\n\n<mat-dialog-content>\n <p *ngFor=\"let paragraph of data.text\">{{paragraph}}</p>\n <div *ngIf=\"data.requireConfirmation\" class=\"checkbox-wrapper\">\n <mat-checkbox [(ngModel)]=\"confirm\" name=\"confirm\">\n {{data.confirmationText}}\n </mat-checkbox>\n </div>\n</mat-dialog-content>\n\n<mat-dialog-actions>\n <button *ngIf=\"data.type === 'delete'\" mat-raised-button color=\"warn\" (click)=\"confirmAction()\" [disabled]=\"data.requireConfirmation && !confirm\" class=\"confirm-button\">\n {{data.confirmButtonLabel
|
|
772
|
+
args: [{ selector: 'ngx-mat-entity-confirm-dialog', template: "<h2 mat-dialog-title *ngIf=\"data.title\">{{data.title}}</h2>\n\n<mat-dialog-content>\n <p *ngFor=\"let paragraph of data.text\">{{paragraph}}</p>\n <div *ngIf=\"data.requireConfirmation\" class=\"checkbox-wrapper\">\n <mat-checkbox [(ngModel)]=\"confirm\" name=\"confirm\">\n {{data.confirmationText}}\n </mat-checkbox>\n </div>\n</mat-dialog-content>\n\n<mat-dialog-actions>\n <button *ngIf=\"data.type === 'delete'\" mat-raised-button color=\"warn\" (click)=\"confirmAction()\" [disabled]=\"data.requireConfirmation && !confirm\" class=\"confirm-button\">\n {{data.confirmButtonLabel}}\n </button>\n <button *ngIf=\"data.type !== 'delete'\" mat-raised-button (click)=\"confirmAction()\" [disabled]=\"data.requireConfirmation && !confirm\" class=\"confirm-button\">\n {{data.confirmButtonLabel}}\n </button>\n <button mat-raised-button (click)=\"cancel()\" class=\"cancel-button\">\n {{data.cancelButtonLabel}}\n </button>\n</mat-dialog-actions>\n", styles: [".checkbox-wrapper{min-height:50px;display:flex}.checkbox-wrapper>mat-checkbox{align-self:center}mat-dialog-actions{display:flex;justify-content:space-between}\n"] }]
|
|
588
773
|
}], ctorParameters: function () {
|
|
589
774
|
return [{ type: i1.MatDialogRef }, { type: undefined, decorators: [{
|
|
590
775
|
type: Inject,
|
|
@@ -608,8 +793,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
|
|
|
608
793
|
|
|
609
794
|
/**
|
|
610
795
|
* Generates a default error message for most validation errors.
|
|
611
|
-
*
|
|
612
|
-
* @
|
|
796
|
+
*
|
|
797
|
+
* @param model - The ngModel to get the error from.
|
|
798
|
+
* @returns The Validation Error Message to display.
|
|
613
799
|
*/
|
|
614
800
|
function getValidationErrorMessage(model) {
|
|
615
801
|
if (model.hasError('matDatepickerParse')) {
|
|
@@ -633,23 +819,100 @@ function getValidationErrorMessage(model) {
|
|
|
633
819
|
else if (model.hasError('required')) {
|
|
634
820
|
return 'required';
|
|
635
821
|
}
|
|
822
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
823
|
+
else if (model.hasError('pattern') && model.getError('pattern').requiredPattern === '^true$') {
|
|
824
|
+
return 'needs to be selected';
|
|
825
|
+
}
|
|
636
826
|
else {
|
|
637
827
|
return 'invalid input';
|
|
638
828
|
}
|
|
639
829
|
}
|
|
640
830
|
|
|
641
|
-
|
|
642
|
-
|
|
831
|
+
/**
|
|
832
|
+
* The internal CreateDialogData. Requires all default values the user can leave out.
|
|
833
|
+
*/
|
|
834
|
+
class CreateDialogDataInternal {
|
|
835
|
+
constructor(title, createButtonLabel, cancelButtonLabel, createRequiresConfirmDialog, confirmCreateDialogData) {
|
|
836
|
+
this.title = title;
|
|
837
|
+
this.createButtonLabel = createButtonLabel;
|
|
838
|
+
this.cancelButtonLabel = cancelButtonLabel;
|
|
839
|
+
this.createRequiresConfirmDialog = createRequiresConfirmDialog;
|
|
840
|
+
this.confirmCreateDialogData = confirmCreateDialogData;
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* The Builder for the CreateDialogData. Sets default values.
|
|
845
|
+
*/
|
|
846
|
+
class CreateDialogDataBuilder extends BaseBuilder {
|
|
847
|
+
constructor(data) {
|
|
848
|
+
super(data);
|
|
849
|
+
}
|
|
850
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
851
|
+
generateBaseData(data) {
|
|
852
|
+
const confirmCreateDialogData = new ConfirmDialogDataBuilder(data === null || data === void 0 ? void 0 : data.confirmCreateDialogData)
|
|
853
|
+
.withDefault('confirmButtonLabel', 'create')
|
|
854
|
+
.withDefault('text', ['Do you really want to create this entity?'])
|
|
855
|
+
.withDefault('title', 'Create')
|
|
856
|
+
.getResult();
|
|
857
|
+
return new CreateDialogDataInternal((data === null || data === void 0 ? void 0 : data.title) ? data.title : 'Create', (data === null || data === void 0 ? void 0 : data.createButtonLabel) ? data.createButtonLabel : 'Create', (data === null || data === void 0 ? void 0 : data.cancelButtonLabel) ? data.cancelButtonLabel : 'Cancel', (data === null || data === void 0 ? void 0 : data.createRequiresConfirmDialog) ? data.createRequiresConfirmDialog : false, confirmCreateDialogData);
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
/**
|
|
862
|
+
* The internal AddArrayItemDialogData. Requires all default values the user can leave out.
|
|
863
|
+
*/
|
|
864
|
+
class AddArrayItemDialogDataInternal {
|
|
865
|
+
constructor(entity, createDialogData, getValidationErrorMessage) {
|
|
866
|
+
this.entity = entity;
|
|
867
|
+
this.createDialogData = createDialogData;
|
|
868
|
+
this.getValidationErrorMessage = getValidationErrorMessage;
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* The Builder for the AddArrayItemDialogData. Sets default values.
|
|
873
|
+
*/
|
|
874
|
+
class AddArrayItemDialogDataBuilder extends BaseBuilder {
|
|
875
|
+
constructor(data) {
|
|
876
|
+
super(data);
|
|
877
|
+
}
|
|
878
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
879
|
+
generateBaseData(data) {
|
|
880
|
+
const createDialogData = new CreateDialogDataBuilder(data.createDialogData)
|
|
881
|
+
.withDefault('createButtonLabel', 'Add')
|
|
882
|
+
.withDefault('title', 'Add to array')
|
|
883
|
+
.getResult();
|
|
884
|
+
return new AddArrayItemDialogDataInternal(data.entity, createDialogData, data.getValidationErrorMessage ? data.getValidationErrorMessage : getValidationErrorMessage);
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
/**
|
|
889
|
+
* The default input component. It gets the metadata of the property from the given @Input "entity" and @Input "propertyKey"
|
|
890
|
+
* and displays the input field accordingly.
|
|
891
|
+
*
|
|
892
|
+
* You can also define a method that generates error-messages and if the input should be hidden when its metadata says
|
|
893
|
+
* that it should be omitted for creating or updating.
|
|
894
|
+
* The last part being mostly relevant if you want to use this component inside an ngFor.
|
|
895
|
+
*/
|
|
896
|
+
class NgxMatEntityInputComponent {
|
|
897
|
+
constructor(dialog) {
|
|
898
|
+
this.dialog = dialog;
|
|
899
|
+
this.chipsInput = '';
|
|
900
|
+
this.selection = new SelectionModel(true, []);
|
|
643
901
|
this.DecoratorTypes = DecoratorTypes;
|
|
902
|
+
this.EntityUtilities = EntityUtilities;
|
|
644
903
|
this.getWidth = EntityUtilities.getWidth;
|
|
645
904
|
}
|
|
646
905
|
/**
|
|
647
|
-
*
|
|
906
|
+
* This is needed for the inputs to work inside an ngFor.
|
|
907
|
+
*
|
|
908
|
+
* @param index - The index of the element in the ngFor.
|
|
909
|
+
* @returns The index.
|
|
648
910
|
*/
|
|
649
911
|
trackByFn(index) {
|
|
650
912
|
return index;
|
|
651
913
|
}
|
|
652
914
|
ngOnInit() {
|
|
915
|
+
var _a;
|
|
653
916
|
if (!this.entity) {
|
|
654
917
|
throw new Error('Missing required Input data "entity"');
|
|
655
918
|
}
|
|
@@ -661,149 +924,113 @@ class NgxMatEntityInternalInputComponent {
|
|
|
661
924
|
this.metadataDefaultString = this.metadata;
|
|
662
925
|
this.metadataTextboxString = this.metadata;
|
|
663
926
|
this.metadataAutocompleteString = this.metadata;
|
|
927
|
+
this.autocompleteStrings = this.metadataAutocompleteString.autocompleteValues;
|
|
928
|
+
this.filteredAutocompleteStrings = cloneDeep(this.autocompleteStrings);
|
|
664
929
|
this.metadataDropdownString = this.metadata;
|
|
665
930
|
this.metadataDropdownBoolean = this.metadata;
|
|
931
|
+
if ((this.type === DecoratorTypes.BOOLEAN_CHECKBOX || this.type === DecoratorTypes.BOOLEAN_TOGGLE)
|
|
932
|
+
&& this.entity[this.propertyKey] === undefined) {
|
|
933
|
+
this.entity[this.propertyKey] = false;
|
|
934
|
+
}
|
|
666
935
|
this.metadataDefaultNumber = this.metadata;
|
|
667
936
|
this.metadataDropdownNumber = this.metadata;
|
|
668
937
|
this.metadataDefaultObject = this.metadata;
|
|
669
938
|
this.objectProperty = this.entity[this.propertyKey];
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
if (!
|
|
676
|
-
|
|
677
|
-
|
|
939
|
+
if (this.type === DecoratorTypes.OBJECT) {
|
|
940
|
+
this.objectPropertyRows = EntityUtilities.getEntityRows(this.objectProperty, this.hideOmitForCreate, this.hideOmitForEdit);
|
|
941
|
+
}
|
|
942
|
+
this.metadataEntityArray = this.metadata;
|
|
943
|
+
if (this.type === DecoratorTypes.ARRAY) {
|
|
944
|
+
if (!this.entity[this.propertyKey]) {
|
|
945
|
+
this.entity[this.propertyKey] = [];
|
|
946
|
+
}
|
|
947
|
+
this.entityArrayValues = this.entity[this.propertyKey];
|
|
948
|
+
if (this.metadataEntityArray.createInline === undefined) {
|
|
949
|
+
this.metadataEntityArray.createInline = true;
|
|
950
|
+
}
|
|
951
|
+
if (!this.metadataEntityArray.createInline && !this.metadataEntityArray.createDialogData) {
|
|
952
|
+
this.metadataEntityArray.createDialogData = {
|
|
953
|
+
title: 'Add'
|
|
954
|
+
};
|
|
678
955
|
}
|
|
956
|
+
// TODO
|
|
957
|
+
const givenDisplayColumns = this.metadataEntityArray.displayColumns.map((v) => v.displayName);
|
|
958
|
+
if (givenDisplayColumns.find((s) => s === 'select')) {
|
|
959
|
+
throw new Error(`The name "select" for a display column is reserved.
|
|
960
|
+
Please choose a different name.`);
|
|
961
|
+
}
|
|
962
|
+
this.displayedColumns = ['select'].concat(givenDisplayColumns);
|
|
963
|
+
this.dataSource = new MatTableDataSource();
|
|
964
|
+
this.dataSource.data = this.entityArrayValues;
|
|
965
|
+
this.arrayItem = new this.metadataEntityArray.EntityClass();
|
|
966
|
+
this.arrayItemInlineRows = EntityUtilities.getEntityRows(this.arrayItem, this.hideOmitForCreate === false ? false : true, this.hideOmitForEdit ? true : false);
|
|
967
|
+
this.arrayItemPriorChanges = cloneDeep(this.arrayItem);
|
|
968
|
+
this.dialogInputData = {
|
|
969
|
+
entity: this.arrayItem,
|
|
970
|
+
createDialogData: this.metadataEntityArray.createDialogData,
|
|
971
|
+
getValidationErrorMessage: this.getValidationErrorMessage
|
|
972
|
+
};
|
|
973
|
+
this.dialogData = new AddArrayItemDialogDataBuilder(this.dialogInputData).getResult();
|
|
974
|
+
this.arrayItemDialogRows = EntityUtilities.getEntityRows(this.dialogData.entity, true);
|
|
679
975
|
}
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
NgxMatEntityInternalInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: NgxMatEntityInternalInputComponent, selector: "ngx-mat-entity-internal-input", inputs: { entity: "entity", propertyKey: "propertyKey", hideOmitForCreate: "hideOmitForCreate", hideOmitForEdit: "hideOmitForEdit", getValidationErrorMessage: "getValidationErrorMessage" }, ngImport: i0, template: "<div [ngSwitch]=\"type\" *ngIf=\"!(hideOmitForCreate && metadata.omitForCreate) && !(hideOmitForEdit && metadata.omitForUpdate)\">\n <!-------------------------------------------->\n <!-----------------Strings-------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.STRING\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString()\"\n #model=\"ngModel\"\n [pattern]=\"metadataDefaultString.regex ? metadataDefaultString.regex : '[\\\\s\\\\S]*'\"\n [minlength]=\"metadataDefaultString.minLength ? metadataDefaultString.minLength : null\"\n [maxlength]=\"metadataDefaultString.maxLength ? metadataDefaultString.maxLength : null\"\n />\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.STRING_TEXTBOX\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <textarea\n matInput\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString()\"\n #model=\"ngModel\"\n cdkTextareaAutosize\n cdkAutosizeMinRows=\"10\"\n [minlength]=\"metadataTextboxString.minLength ? metadataTextboxString.minLength : null\"\n [maxlength]=\"metadataTextboxString.maxLength ? metadataTextboxString.maxLength : null\"\n >\n </textarea>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.STRING_AUTOCOMPLETE\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString()\"\n #model=\"ngModel\"\n [matAutocomplete]=\"auto\"\n [minlength]=\"metadataAutocompleteString.minLength ? metadataAutocompleteString.minLength : null\"\n [maxlength]=\"metadataAutocompleteString.maxLength ? metadataAutocompleteString.maxLength : null\"\n [pattern]=\"metadataAutocompleteString.regex ? metadataAutocompleteString.regex : '[\\\\s\\\\S]*'\"\n />\n <mat-autocomplete #auto=\"matAutocomplete\">\n <mat-option *ngFor=\"let value of metadataAutocompleteString.autocompleteValues\" [value]=\"value\">\n {{value}}\n </mat-option>\n </mat-autocomplete>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.STRING_DROPDOWN\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-select [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\">\n <mat-option *ngFor=\"let value of metadataDropdownString.dropdownValues\" [value]=\"value.value\">{{value.displayName}}</mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <!-------------------------------------------->\n <!-----------------Booleans------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.BOOLEAN_CHECKBOX\">\n <mat-form-field>\n <mat-checkbox [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\">\n {{metadata.displayName}}\n </mat-checkbox>\n <!-- hidden input is needed so that the checkbox can be used inside a mat-form-field -->\n <textarea matInput hidden></textarea>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.BOOLEAN_TOGGLE\">\n <mat-form-field>\n <mat-slide-toggle [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\">\n {{metadata.displayName}}\n </mat-slide-toggle>\n <!-- hidden input is needed so that the toggle can be used inside a mat-form-field -->\n <textarea matInput hidden></textarea>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.BOOLEAN_DROPDOWN\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-select [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\">\n <mat-option [value]=\"undefined\">-</mat-option>\n <mat-option [value]=\"true\">{{metadataDropdownBoolean.dropdownTrue}}</mat-option>\n <mat-option [value]=\"false\">{{metadataDropdownBoolean.dropdownFalse}}</mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <!-------------------------------------------->\n <!------------------Numbers------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.NUMBER\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n type=\"number\"\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString()\"\n #model=\"ngModel\"\n [min]=\"metadataDefaultNumber.min ? metadataDefaultNumber.min : null\"\n [max]=\"metadataDefaultNumber.max ? metadataDefaultNumber.max : null\"\n />\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.NUMBER_DROPDOWN\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-select [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\">\n <mat-option *ngFor=\"let value of metadataDropdownNumber.dropdownValues\" [value]=\"value.value\">{{value.displayName}}</mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <!-------------------------------------------->\n <!-------------------Object------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.OBJECT\">\n <b>{{metadataDefaultObject.displayName}}</b>\n <!-- iterates over the object properties -->\n <div class=\"row\">\n <!--\n displays another ngx-material-entity with the:\n object as the entity,\n the current key in the loop received by the keyvalue direction as the propertyKey\n and the getValidationErrorMessage of the current component\n -->\n <ngx-mat-entity-internal-input\n *ngFor=\"let key of getObjectProperties(); let i = index; trackBy: trackByFn\"\n [entity]=\"objectProperty\"\n [propertyKey]=\"key\"\n [getValidationErrorMessage]=\"getValidationErrorMessage\"\n [hideOmitForCreate]=\"hideOmitForCreate\"\n [hideOmitForEdit]=\"hideOmitForEdit\"\n class=\"col-lg-{{getWidth(objectProperty, key, 'lg')}} col-md-{{getWidth(objectProperty, key, 'md')}} col-sm-{{getWidth(objectProperty, key, 'sm')}}\"\n >\n </ngx-mat-entity-internal-input>\n </div>\n </div>\n\n <div *ngSwitchDefault>ERROR: The type {{type}}is not known.</div>\n</div>", styles: ["mat-form-field{width:100%}\n"], components: [{ type: i1$1.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i2.MatAutocomplete, selector: "mat-autocomplete", inputs: ["disableRipple"], exportAs: ["matAutocomplete"] }, { type: i3$1.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { type: i4.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { type: i5.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex", "aria-label", "aria-labelledby", "aria-describedby", "id", "required", "labelPosition", "name", "value", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { type: i6.MatSlideToggle, selector: "mat-slide-toggle", inputs: ["disabled", "disableRipple", "color", "tabIndex", "name", "id", "labelPosition", "aria-label", "aria-labelledby", "aria-describedby", "required", "checked"], outputs: ["change", "toggleChange"], exportAs: ["matSlideToggle"] }, { type: NgxMatEntityInternalInputComponent, selector: "ngx-mat-entity-internal-input", inputs: ["entity", "propertyKey", "hideOmitForCreate", "hideOmitForEdit", "getValidationErrorMessage"] }], directives: [{ type: i7.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i7.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i7.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i1$1.MatLabel, selector: "mat-label" }, { type: i8.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { type: i12.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i12.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i12.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i12.PatternValidator, selector: "[pattern][formControlName],[pattern][formControl],[pattern][ngModel]", inputs: ["pattern"] }, { type: i12.MinLengthValidator, selector: "[minlength][formControlName],[minlength][formControl],[minlength][ngModel]", inputs: ["minlength"] }, { type: i12.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { type: i1$1.MatError, selector: "mat-error", inputs: ["id"] }, { type: i10.CdkTextareaAutosize, selector: "textarea[cdkTextareaAutosize]", inputs: ["cdkAutosizeMinRows", "cdkAutosizeMaxRows", "cdkTextareaAutosize", "placeholder"], exportAs: ["cdkTextareaAutosize"] }, { type: i2.MatAutocompleteTrigger, selector: "input[matAutocomplete], textarea[matAutocomplete]", exportAs: ["matAutocompleteTrigger"] }, { type: i7.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i12.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { type: i12.MinValidator, selector: "input[type=number][min][formControlName],input[type=number][min][formControl],input[type=number][min][ngModel]", inputs: ["min"] }, { type: i12.MaxValidator, selector: "input[type=number][max][formControlName],input[type=number][max][formControl],input[type=number][max][ngModel]", inputs: ["max"] }, { type: i7.NgSwitchDefault, selector: "[ngSwitchDefault]" }] });
|
|
685
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityInternalInputComponent, decorators: [{
|
|
686
|
-
type: Component,
|
|
687
|
-
args: [{ selector: 'ngx-mat-entity-internal-input', template: "<div [ngSwitch]=\"type\" *ngIf=\"!(hideOmitForCreate && metadata.omitForCreate) && !(hideOmitForEdit && metadata.omitForUpdate)\">\n <!-------------------------------------------->\n <!-----------------Strings-------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.STRING\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString()\"\n #model=\"ngModel\"\n [pattern]=\"metadataDefaultString.regex ? metadataDefaultString.regex : '[\\\\s\\\\S]*'\"\n [minlength]=\"metadataDefaultString.minLength ? metadataDefaultString.minLength : null\"\n [maxlength]=\"metadataDefaultString.maxLength ? metadataDefaultString.maxLength : null\"\n />\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.STRING_TEXTBOX\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <textarea\n matInput\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString()\"\n #model=\"ngModel\"\n cdkTextareaAutosize\n cdkAutosizeMinRows=\"10\"\n [minlength]=\"metadataTextboxString.minLength ? metadataTextboxString.minLength : null\"\n [maxlength]=\"metadataTextboxString.maxLength ? metadataTextboxString.maxLength : null\"\n >\n </textarea>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.STRING_AUTOCOMPLETE\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString()\"\n #model=\"ngModel\"\n [matAutocomplete]=\"auto\"\n [minlength]=\"metadataAutocompleteString.minLength ? metadataAutocompleteString.minLength : null\"\n [maxlength]=\"metadataAutocompleteString.maxLength ? metadataAutocompleteString.maxLength : null\"\n [pattern]=\"metadataAutocompleteString.regex ? metadataAutocompleteString.regex : '[\\\\s\\\\S]*'\"\n />\n <mat-autocomplete #auto=\"matAutocomplete\">\n <mat-option *ngFor=\"let value of metadataAutocompleteString.autocompleteValues\" [value]=\"value\">\n {{value}}\n </mat-option>\n </mat-autocomplete>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.STRING_DROPDOWN\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-select [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\">\n <mat-option *ngFor=\"let value of metadataDropdownString.dropdownValues\" [value]=\"value.value\">{{value.displayName}}</mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <!-------------------------------------------->\n <!-----------------Booleans------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.BOOLEAN_CHECKBOX\">\n <mat-form-field>\n <mat-checkbox [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\">\n {{metadata.displayName}}\n </mat-checkbox>\n <!-- hidden input is needed so that the checkbox can be used inside a mat-form-field -->\n <textarea matInput hidden></textarea>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.BOOLEAN_TOGGLE\">\n <mat-form-field>\n <mat-slide-toggle [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\">\n {{metadata.displayName}}\n </mat-slide-toggle>\n <!-- hidden input is needed so that the toggle can be used inside a mat-form-field -->\n <textarea matInput hidden></textarea>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.BOOLEAN_DROPDOWN\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-select [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\">\n <mat-option [value]=\"undefined\">-</mat-option>\n <mat-option [value]=\"true\">{{metadataDropdownBoolean.dropdownTrue}}</mat-option>\n <mat-option [value]=\"false\">{{metadataDropdownBoolean.dropdownFalse}}</mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <!-------------------------------------------->\n <!------------------Numbers------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.NUMBER\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n type=\"number\"\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString()\"\n #model=\"ngModel\"\n [min]=\"metadataDefaultNumber.min ? metadataDefaultNumber.min : null\"\n [max]=\"metadataDefaultNumber.max ? metadataDefaultNumber.max : null\"\n />\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.NUMBER_DROPDOWN\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-select [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\">\n <mat-option *ngFor=\"let value of metadataDropdownNumber.dropdownValues\" [value]=\"value.value\">{{value.displayName}}</mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <!-------------------------------------------->\n <!-------------------Object------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.OBJECT\">\n <b>{{metadataDefaultObject.displayName}}</b>\n <!-- iterates over the object properties -->\n <div class=\"row\">\n <!--\n displays another ngx-material-entity with the:\n object as the entity,\n the current key in the loop received by the keyvalue direction as the propertyKey\n and the getValidationErrorMessage of the current component\n -->\n <ngx-mat-entity-internal-input\n *ngFor=\"let key of getObjectProperties(); let i = index; trackBy: trackByFn\"\n [entity]=\"objectProperty\"\n [propertyKey]=\"key\"\n [getValidationErrorMessage]=\"getValidationErrorMessage\"\n [hideOmitForCreate]=\"hideOmitForCreate\"\n [hideOmitForEdit]=\"hideOmitForEdit\"\n class=\"col-lg-{{getWidth(objectProperty, key, 'lg')}} col-md-{{getWidth(objectProperty, key, 'md')}} col-sm-{{getWidth(objectProperty, key, 'sm')}}\"\n >\n </ngx-mat-entity-internal-input>\n </div>\n </div>\n\n <div *ngSwitchDefault>ERROR: The type {{type}}is not known.</div>\n</div>", styles: ["mat-form-field{width:100%}\n"] }]
|
|
688
|
-
}], propDecorators: { entity: [{
|
|
689
|
-
type: Input
|
|
690
|
-
}], propertyKey: [{
|
|
691
|
-
type: Input
|
|
692
|
-
}], hideOmitForCreate: [{
|
|
693
|
-
type: Input
|
|
694
|
-
}], hideOmitForEdit: [{
|
|
695
|
-
type: Input
|
|
696
|
-
}], getValidationErrorMessage: [{
|
|
697
|
-
type: Input
|
|
698
|
-
}] } });
|
|
699
|
-
|
|
700
|
-
class NgxMatEntityAddArrayItemDialogComponent {
|
|
701
|
-
constructor(data, dialogRef) {
|
|
702
|
-
this.data = data;
|
|
703
|
-
this.dialogRef = dialogRef;
|
|
704
|
-
this.EntityUtilities = EntityUtilities;
|
|
705
|
-
this.getWidth = EntityUtilities.getWidth;
|
|
706
|
-
}
|
|
707
|
-
ngOnInit() {
|
|
708
|
-
this.dialogRef.disableClose = true;
|
|
709
|
-
this.setEntityKeys();
|
|
710
|
-
}
|
|
711
|
-
setEntityKeys() {
|
|
712
|
-
this.entityKeys = Reflect.ownKeys(this.data.entity);
|
|
713
|
-
const omitCreateKeys = EntityUtilities.getOmitForCreate(this.data.entity);
|
|
714
|
-
this.entityKeys = this.entityKeys.filter((k) => !omitCreateKeys.includes(k))
|
|
715
|
-
.sort((a, b) => EntityUtilities.compareOrder(a, b, this.data.entity));
|
|
716
|
-
}
|
|
717
|
-
create() {
|
|
718
|
-
this.dialogRef.close(1);
|
|
719
|
-
}
|
|
720
|
-
cancel() {
|
|
721
|
-
this.dialogRef.close();
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
NgxMatEntityAddArrayItemDialogComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityAddArrayItemDialogComponent, deps: [{ token: MAT_DIALOG_DATA }, { token: i1.MatDialogRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
725
|
-
NgxMatEntityAddArrayItemDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: NgxMatEntityAddArrayItemDialogComponent, selector: "ngx-mat-entity-add-array-item-dialog", ngImport: i0, template: "<h2 mat-dialog-title>{{data.createDialogData.title}}</h2>\n\n<mat-dialog-content>\n <form #form=\"ngForm\" class=\"row\">\n <ngx-mat-entity-internal-input\n *ngFor=\"let key of entityKeys\"\n [entity]=\"data.entity\"\n [propertyKey]=\"key\"\n [hideOmitForCreate]=\"true\"\n [getValidationErrorMessage]=\"data.getValidationErrorMessage\"\n class=\"col-lg-{{getWidth(data.entity, key, 'lg')}} col-md-{{getWidth(data.entity, key, 'md')}} col-sm-{{getWidth(data.entity, key, 'sm')}}\"\n >\n </ngx-mat-entity-internal-input>\n </form>\n</mat-dialog-content>\n\n<mat-dialog-actions>\n <button mat-raised-button (click)=\"create()\" [disabled]=\"!EntityUtilities.isEntityValid(data.entity, 'create')\">\n {{data.createDialogData.createButtonLabel ? data.createDialogData.createButtonLabel : 'Add'}}\n </button>\n <button mat-raised-button (click)=\"cancel()\" class=\"cancel-button\">\n {{data.createDialogData.cancelButtonLabel ? data.createDialogData.cancelButtonLabel : 'Cancel'}}\n </button>\n</mat-dialog-actions>\n", styles: ["mat-dialog-actions{display:flex;justify-content:space-between}\n"], components: [{ type: NgxMatEntityInternalInputComponent, selector: "ngx-mat-entity-internal-input", inputs: ["entity", "propertyKey", "hideOmitForCreate", "hideOmitForEdit", "getValidationErrorMessage"] }, { type: i3.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i1.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { type: i1.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { type: i12.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i12.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i12.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i7.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i1.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]" }] });
|
|
726
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityAddArrayItemDialogComponent, decorators: [{
|
|
727
|
-
type: Component,
|
|
728
|
-
args: [{ selector: 'ngx-mat-entity-add-array-item-dialog', template: "<h2 mat-dialog-title>{{data.createDialogData.title}}</h2>\n\n<mat-dialog-content>\n <form #form=\"ngForm\" class=\"row\">\n <ngx-mat-entity-internal-input\n *ngFor=\"let key of entityKeys\"\n [entity]=\"data.entity\"\n [propertyKey]=\"key\"\n [hideOmitForCreate]=\"true\"\n [getValidationErrorMessage]=\"data.getValidationErrorMessage\"\n class=\"col-lg-{{getWidth(data.entity, key, 'lg')}} col-md-{{getWidth(data.entity, key, 'md')}} col-sm-{{getWidth(data.entity, key, 'sm')}}\"\n >\n </ngx-mat-entity-internal-input>\n </form>\n</mat-dialog-content>\n\n<mat-dialog-actions>\n <button mat-raised-button (click)=\"create()\" [disabled]=\"!EntityUtilities.isEntityValid(data.entity, 'create')\">\n {{data.createDialogData.createButtonLabel ? data.createDialogData.createButtonLabel : 'Add'}}\n </button>\n <button mat-raised-button (click)=\"cancel()\" class=\"cancel-button\">\n {{data.createDialogData.cancelButtonLabel ? data.createDialogData.cancelButtonLabel : 'Cancel'}}\n </button>\n</mat-dialog-actions>\n", styles: ["mat-dialog-actions{display:flex;justify-content:space-between}\n"] }]
|
|
729
|
-
}], ctorParameters: function () {
|
|
730
|
-
return [{ type: undefined, decorators: [{
|
|
731
|
-
type: Inject,
|
|
732
|
-
args: [MAT_DIALOG_DATA]
|
|
733
|
-
}] }, { type: i1.MatDialogRef }];
|
|
734
|
-
} });
|
|
735
|
-
|
|
736
|
-
class NgxMatEntityArrayTableComponent {
|
|
737
|
-
constructor(dialog) {
|
|
738
|
-
this.dialog = dialog;
|
|
739
|
-
this.selection = new SelectionModel(true, []);
|
|
740
|
-
this.getWidth = EntityUtilities.getWidth;
|
|
741
|
-
this.EntityUtilities = EntityUtilities;
|
|
742
|
-
}
|
|
743
|
-
trackByFn(index) {
|
|
744
|
-
return index;
|
|
745
|
-
}
|
|
746
|
-
ngOnInit() {
|
|
747
|
-
this.validateInput();
|
|
748
|
-
const givenDisplayColumns = this.metadata.displayColumns.map((v) => v.displayName);
|
|
749
|
-
if (givenDisplayColumns.find((s) => s === 'select')) {
|
|
750
|
-
throw new Error(`The name "select" for a display column is reserved.
|
|
751
|
-
Please choose a different name.`);
|
|
976
|
+
this.metadataStringChipsArray = this.metadata;
|
|
977
|
+
if ((this.type === DecoratorTypes.ARRAY_STRING_CHIPS || this.type === DecoratorTypes.ARRAY_STRING_AUTOCOMPLETE_CHIPS)
|
|
978
|
+
&& ((_a = this.entity[this.propertyKey]) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
979
|
+
this.stringChipsArrayValues = this.entity[this.propertyKey];
|
|
752
980
|
}
|
|
753
|
-
this.
|
|
754
|
-
this.
|
|
755
|
-
|
|
756
|
-
this.arrayItem = new this.metadata.EntityClass();
|
|
757
|
-
this.arrayItemPriorChanges = cloneDeep(this.arrayItem);
|
|
758
|
-
}
|
|
759
|
-
validateInput() {
|
|
760
|
-
if (!this.metadata.createInline && !this.metadata.createDialogData) {
|
|
761
|
-
throw new Error(`Missing required Input data "createDialogData".
|
|
762
|
-
You can only omit this value when the creation is inline.`);
|
|
981
|
+
this.metadataAutocompleteStringChipsArray = this.metadata;
|
|
982
|
+
if (!this.getValidationErrorMessage) {
|
|
983
|
+
this.getValidationErrorMessage = getValidationErrorMessage;
|
|
763
984
|
}
|
|
764
985
|
}
|
|
986
|
+
/**
|
|
987
|
+
* Tries to add an item to the array.
|
|
988
|
+
* Does this either inline if the "createInline"-metadata is set to true
|
|
989
|
+
* or in a separate dialog if it is set to false.
|
|
990
|
+
*/
|
|
765
991
|
add() {
|
|
766
|
-
if (this.
|
|
767
|
-
this.
|
|
768
|
-
this.dataSource.data = this.
|
|
992
|
+
if (this.metadataEntityArray.createInline) {
|
|
993
|
+
this.entityArrayValues.push(cloneDeep(this.arrayItem));
|
|
994
|
+
this.dataSource.data = this.entityArrayValues;
|
|
769
995
|
EntityUtilities.resetChangesOnEntity(this.arrayItem, this.arrayItemPriorChanges);
|
|
770
996
|
}
|
|
771
997
|
else {
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
createDialogData: this.metadata.createDialogData,
|
|
775
|
-
getValidationErrorMessage: this.getValidationErrorMessage
|
|
776
|
-
};
|
|
777
|
-
firstValueFrom(this.dialog.open(NgxMatEntityAddArrayItemDialogComponent, {
|
|
778
|
-
data: dialogData,
|
|
998
|
+
this.addArrayItemDialogRef = this.dialog.open(this.addArrayItemDialog, {
|
|
999
|
+
data: this.dialogData,
|
|
779
1000
|
autoFocus: false,
|
|
780
1001
|
restoreFocus: false
|
|
781
|
-
}).afterClosed()).then((res) => {
|
|
782
|
-
if (res === 1) {
|
|
783
|
-
this.arrayItems.push(cloneDeep(this.arrayItem));
|
|
784
|
-
this.dataSource.data = this.arrayItems;
|
|
785
|
-
}
|
|
786
|
-
EntityUtilities.resetChangesOnEntity(this.arrayItem, this.arrayItemPriorChanges);
|
|
787
1002
|
});
|
|
788
1003
|
}
|
|
789
1004
|
}
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
this.
|
|
795
|
-
this.
|
|
1005
|
+
/**
|
|
1006
|
+
* Adds the array item defined in the dialog.
|
|
1007
|
+
*/
|
|
1008
|
+
addArrayItem() {
|
|
1009
|
+
this.addArrayItemDialogRef.close();
|
|
1010
|
+
this.entityArrayValues.push(cloneDeep(this.arrayItem));
|
|
1011
|
+
this.dataSource.data = this.entityArrayValues;
|
|
1012
|
+
EntityUtilities.resetChangesOnEntity(this.arrayItem, this.arrayItemPriorChanges);
|
|
796
1013
|
}
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
return res.sort((a, b) => EntityUtilities.compareOrder(a, b, this.arrayItem));
|
|
1014
|
+
/**
|
|
1015
|
+
* Cancels adding the array item defined in the dialog.
|
|
1016
|
+
*/
|
|
1017
|
+
cancelAddArrayItem() {
|
|
1018
|
+
this.addArrayItemDialogRef.close();
|
|
1019
|
+
EntityUtilities.resetChangesOnEntity(this.arrayItem, this.arrayItemPriorChanges);
|
|
806
1020
|
}
|
|
1021
|
+
/**
|
|
1022
|
+
* Removes all selected entries from the array.
|
|
1023
|
+
*/
|
|
1024
|
+
remove() {
|
|
1025
|
+
this.selection.selected.forEach(s => {
|
|
1026
|
+
this.entityArrayValues.splice(this.entityArrayValues.indexOf(s), 1);
|
|
1027
|
+
});
|
|
1028
|
+
this.dataSource.data = this.entityArrayValues;
|
|
1029
|
+
this.selection.clear();
|
|
1030
|
+
}
|
|
1031
|
+
/**
|
|
1032
|
+
* Toggles all array-items in the table.
|
|
1033
|
+
*/
|
|
807
1034
|
masterToggle() {
|
|
808
1035
|
if (this.isAllSelected()) {
|
|
809
1036
|
this.selection.clear();
|
|
@@ -812,96 +1039,28 @@ class NgxMatEntityArrayTableComponent {
|
|
|
812
1039
|
this.dataSource.data.forEach((row) => this.selection.select(row));
|
|
813
1040
|
}
|
|
814
1041
|
}
|
|
1042
|
+
/**
|
|
1043
|
+
* Checks if all array-items in the table have been selected.
|
|
1044
|
+
* This is needed to display the "masterToggle"-checkbox correctly.
|
|
1045
|
+
*
|
|
1046
|
+
* @returns Whether or not all array-items in the table have been selected.
|
|
1047
|
+
*/
|
|
815
1048
|
isAllSelected() {
|
|
816
1049
|
const numSelected = this.selection.selected.length;
|
|
817
1050
|
const numRows = this.dataSource.data.length;
|
|
818
1051
|
return numSelected === numRows;
|
|
819
1052
|
}
|
|
820
|
-
}
|
|
821
|
-
NgxMatEntityArrayTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityArrayTableComponent, deps: [{ token: i1.MatDialog }], target: i0.ɵɵFactoryTarget.Component });
|
|
822
|
-
NgxMatEntityArrayTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: NgxMatEntityArrayTableComponent, selector: "ngx-mat-entity-array-table", inputs: { arrayItems: "arrayItems", metadata: "metadata", getValidationErrorMessage: "getValidationErrorMessage", omit: "omit" }, ngImport: i0, template: "<div class=\"mat-elevation-z8\" style=\"border-radius: 5px;padding: 15px;margin-bottom: 15px;margin-top: 15px;\">\n\n <div style=\"padding-bottom: 10px\">\n <b>{{metadata.displayName}}</b>\n </div>\n <div class=\"row\" *ngIf=\"metadata.createInline\">\n <ngx-mat-entity-internal-input\n *ngFor=\"let key of getObjectProperties(); let i = index; trackBy: trackByFn\"\n [entity]=\"arrayItem\"\n [propertyKey]=\"key\"\n [hideOmitForCreate]=\"true\"\n [getValidationErrorMessage]=\"getValidationErrorMessage\"\n class=\"col-lg-{{getWidth(arrayItem, key, 'lg')}} col-md-{{getWidth(arrayItem, key, 'md')}} col-sm-{{getWidth(arrayItem, key, 'sm')}}\"\n >\n </ngx-mat-entity-internal-input>\n </div>\n <div class=\"buttons\">\n <button mat-raised-button\n [disabled]=\"metadata.createInline && !EntityUtilities.isEntityValid(arrayItem, 'create')\"\n (click)=\"add()\">\n Add\n </button>\n <button mat-raised-button\n [disabled]=\"!selection.selected.length\"\n (click)=\"remove()\">\n Remove\n </button>\n </div>\n\n <mat-table [dataSource]=\"dataSource\">\n <!-- select Column -->\n <ng-container matColumnDef=\"select\">\n <mat-header-cell *matHeaderCellDef>\n <mat-checkbox (change)=\"$event ? masterToggle() : null\" [checked]=\"selection.hasValue() && isAllSelected()\" [indeterminate]=\"selection.hasValue() && !isAllSelected()\"></mat-checkbox>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let module\" class=\"module\">\n <mat-checkbox (click)=\"$event.stopPropagation()\" (change)=\"$event ? selection.toggle(module) : null\" [checked]=\"selection.isSelected(module)\"></mat-checkbox>\n </mat-cell>\n </ng-container>\n \n <ng-container *ngFor=\"let dCol of metadata.displayColumns\" [matColumnDef]=\"dCol.displayName\">\n <mat-header-cell *matHeaderCellDef>\n {{dCol.displayName}}\n </mat-header-cell>\n <mat-cell class=\"entity\" *matCellDef=\"let entity\">\n {{dCol.value(entity)}}\n </mat-cell>\n </ng-container>\n \n <mat-header-row *matHeaderRowDef=\"displayedColumns\"></mat-header-row>\n <mat-row *matRowDef=\"let row; columns: displayedColumns\"></mat-row>\n </mat-table>\n\n <div class=\"array-error\" *ngIf=\"metadata.required && !dataSource.data.length\">\n {{metadata.missingErrorMessage ? metadata.missingErrorMessage : 'Needs to have at least one value'}}\n </div>\n</div>", styles: [".buttons{display:flex;justify-content:space-between;margin-bottom:10px;margin-top:5px}mat-table{border:1px solid #E0E0E0;border-radius:5px;padding-top:5px;padding-bottom:25px}.mat-column-select{flex:0 0 75px}.array-error{display:flex;align-items:center;justify-content:center;margin-top:-25.5px;border:1px solid #E0E0E0;background-color:#f8d3d7;color:#721c24;height:25px;border-bottom-left-radius:5px;border-bottom-right-radius:5px}\n"], components: [{ type: NgxMatEntityInternalInputComponent, selector: "ngx-mat-entity-internal-input", inputs: ["entity", "propertyKey", "hideOmitForCreate", "hideOmitForEdit", "getValidationErrorMessage"] }, { type: i3.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i4$1.MatTable, selector: "mat-table, table[mat-table]", exportAs: ["matTable"] }, { type: i5.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex", "aria-label", "aria-labelledby", "aria-describedby", "id", "required", "labelPosition", "name", "value", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { type: i4$1.MatHeaderRow, selector: "mat-header-row, tr[mat-header-row]", exportAs: ["matHeaderRow"] }, { type: i4$1.MatRow, selector: "mat-row, tr[mat-row]", exportAs: ["matRow"] }], directives: [{ type: i7.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i7.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i4$1.MatColumnDef, selector: "[matColumnDef]", inputs: ["sticky", "matColumnDef"] }, { type: i4$1.MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { type: i4$1.MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { type: i4$1.MatCellDef, selector: "[matCellDef]" }, { type: i4$1.MatCell, selector: "mat-cell, td[mat-cell]" }, { type: i4$1.MatHeaderRowDef, selector: "[matHeaderRowDef]", inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"] }, { type: i4$1.MatRowDef, selector: "[matRowDef]", inputs: ["matRowDefColumns", "matRowDefWhen"] }] });
|
|
823
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityArrayTableComponent, decorators: [{
|
|
824
|
-
type: Component,
|
|
825
|
-
args: [{ selector: 'ngx-mat-entity-array-table', template: "<div class=\"mat-elevation-z8\" style=\"border-radius: 5px;padding: 15px;margin-bottom: 15px;margin-top: 15px;\">\n\n <div style=\"padding-bottom: 10px\">\n <b>{{metadata.displayName}}</b>\n </div>\n <div class=\"row\" *ngIf=\"metadata.createInline\">\n <ngx-mat-entity-internal-input\n *ngFor=\"let key of getObjectProperties(); let i = index; trackBy: trackByFn\"\n [entity]=\"arrayItem\"\n [propertyKey]=\"key\"\n [hideOmitForCreate]=\"true\"\n [getValidationErrorMessage]=\"getValidationErrorMessage\"\n class=\"col-lg-{{getWidth(arrayItem, key, 'lg')}} col-md-{{getWidth(arrayItem, key, 'md')}} col-sm-{{getWidth(arrayItem, key, 'sm')}}\"\n >\n </ngx-mat-entity-internal-input>\n </div>\n <div class=\"buttons\">\n <button mat-raised-button\n [disabled]=\"metadata.createInline && !EntityUtilities.isEntityValid(arrayItem, 'create')\"\n (click)=\"add()\">\n Add\n </button>\n <button mat-raised-button\n [disabled]=\"!selection.selected.length\"\n (click)=\"remove()\">\n Remove\n </button>\n </div>\n\n <mat-table [dataSource]=\"dataSource\">\n <!-- select Column -->\n <ng-container matColumnDef=\"select\">\n <mat-header-cell *matHeaderCellDef>\n <mat-checkbox (change)=\"$event ? masterToggle() : null\" [checked]=\"selection.hasValue() && isAllSelected()\" [indeterminate]=\"selection.hasValue() && !isAllSelected()\"></mat-checkbox>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let module\" class=\"module\">\n <mat-checkbox (click)=\"$event.stopPropagation()\" (change)=\"$event ? selection.toggle(module) : null\" [checked]=\"selection.isSelected(module)\"></mat-checkbox>\n </mat-cell>\n </ng-container>\n \n <ng-container *ngFor=\"let dCol of metadata.displayColumns\" [matColumnDef]=\"dCol.displayName\">\n <mat-header-cell *matHeaderCellDef>\n {{dCol.displayName}}\n </mat-header-cell>\n <mat-cell class=\"entity\" *matCellDef=\"let entity\">\n {{dCol.value(entity)}}\n </mat-cell>\n </ng-container>\n \n <mat-header-row *matHeaderRowDef=\"displayedColumns\"></mat-header-row>\n <mat-row *matRowDef=\"let row; columns: displayedColumns\"></mat-row>\n </mat-table>\n\n <div class=\"array-error\" *ngIf=\"metadata.required && !dataSource.data.length\">\n {{metadata.missingErrorMessage ? metadata.missingErrorMessage : 'Needs to have at least one value'}}\n </div>\n</div>", styles: [".buttons{display:flex;justify-content:space-between;margin-bottom:10px;margin-top:5px}mat-table{border:1px solid #E0E0E0;border-radius:5px;padding-top:5px;padding-bottom:25px}.mat-column-select{flex:0 0 75px}.array-error{display:flex;align-items:center;justify-content:center;margin-top:-25.5px;border:1px solid #E0E0E0;background-color:#f8d3d7;color:#721c24;height:25px;border-bottom-left-radius:5px;border-bottom-right-radius:5px}\n"] }]
|
|
826
|
-
}], ctorParameters: function () { return [{ type: i1.MatDialog }]; }, propDecorators: { arrayItems: [{
|
|
827
|
-
type: Input
|
|
828
|
-
}], metadata: [{
|
|
829
|
-
type: Input
|
|
830
|
-
}], getValidationErrorMessage: [{
|
|
831
|
-
type: Input
|
|
832
|
-
}], omit: [{
|
|
833
|
-
type: Input
|
|
834
|
-
}] } });
|
|
835
|
-
|
|
836
|
-
class NgxMatEntityInputComponent {
|
|
837
|
-
constructor() {
|
|
838
|
-
this.chipsInput = '';
|
|
839
|
-
this.DecoratorTypes = DecoratorTypes;
|
|
840
|
-
this.getWidth = EntityUtilities.getWidth;
|
|
841
|
-
}
|
|
842
1053
|
/**
|
|
843
|
-
*
|
|
1054
|
+
* Handles adding strings to the chipsArray.
|
|
1055
|
+
* Checks validation and also creates a new array if it is undefined.
|
|
1056
|
+
* This is needed because two things are validated: The array itself
|
|
1057
|
+
* and the contents of the array. And we need a way to display an
|
|
1058
|
+
* mat-error. As the only validation for the array is whether or not
|
|
1059
|
+
* it contains values, we can set it to undefined when the last element is removed
|
|
1060
|
+
* (removeStringChipArrayValue). That way we can use the "required" validator.
|
|
1061
|
+
*
|
|
1062
|
+
* @param event - The event that fires when a new chip is completed.
|
|
844
1063
|
*/
|
|
845
|
-
trackByFn(index) {
|
|
846
|
-
return index;
|
|
847
|
-
}
|
|
848
|
-
ngOnInit() {
|
|
849
|
-
var _a;
|
|
850
|
-
if (!this.entity) {
|
|
851
|
-
throw new Error('Missing required Input data "entity"');
|
|
852
|
-
}
|
|
853
|
-
if (!this.propertyKey) {
|
|
854
|
-
throw new Error('Missing required Input data "propertyKey"');
|
|
855
|
-
}
|
|
856
|
-
this.type = EntityUtilities.getPropertyType(this.entity, this.propertyKey);
|
|
857
|
-
this.metadata = EntityUtilities.getPropertyMetadata(this.entity, this.propertyKey, this.type);
|
|
858
|
-
this.metadataDefaultString = this.metadata;
|
|
859
|
-
this.metadataTextboxString = this.metadata;
|
|
860
|
-
this.metadataAutocompleteString = this.metadata;
|
|
861
|
-
this.autocompleteStrings = this.metadataAutocompleteString.autocompleteValues;
|
|
862
|
-
this.filteredAutocompleteStrings = cloneDeep(this.autocompleteStrings);
|
|
863
|
-
this.metadataDropdownString = this.metadata;
|
|
864
|
-
this.metadataDropdownBoolean = this.metadata;
|
|
865
|
-
this.metadataDefaultNumber = this.metadata;
|
|
866
|
-
this.metadataDropdownNumber = this.metadata;
|
|
867
|
-
this.metadataDefaultObject = this.metadata;
|
|
868
|
-
this.objectProperty = this.entity[this.propertyKey];
|
|
869
|
-
this.metadataEntityArray = this.metadata;
|
|
870
|
-
if (this.metadataEntityArray.EntityClass) {
|
|
871
|
-
if (!this.entity[this.propertyKey]) {
|
|
872
|
-
this.entity[this.propertyKey] = [];
|
|
873
|
-
}
|
|
874
|
-
this.entityArrayValues = this.entity[this.propertyKey];
|
|
875
|
-
if (this.metadataEntityArray.createInline === undefined) {
|
|
876
|
-
this.metadataEntityArray.createInline = true;
|
|
877
|
-
}
|
|
878
|
-
if (!this.metadataEntityArray.createInline && !this.metadataEntityArray.createDialogData) {
|
|
879
|
-
this.metadataEntityArray.createDialogData = {
|
|
880
|
-
title: 'Add'
|
|
881
|
-
};
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
this.metadataStringChipsArray = this.metadata;
|
|
885
|
-
if (this.metadataStringChipsArray.itemType
|
|
886
|
-
&& ((_a = this.entity[this.propertyKey]) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
887
|
-
this.stringChipsArrayValues = this.entity[this.propertyKey];
|
|
888
|
-
}
|
|
889
|
-
this.metadataAutocompleteStringChipsArray = this.metadata;
|
|
890
|
-
if (!this.getValidationErrorMessage) {
|
|
891
|
-
this.getValidationErrorMessage = getValidationErrorMessage;
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
getObjectProperties() {
|
|
895
|
-
const res = [];
|
|
896
|
-
for (const property in this.objectProperty) {
|
|
897
|
-
const metadata = EntityUtilities.getPropertyMetadata(this.objectProperty, property, EntityUtilities.getPropertyType(this.objectProperty, property));
|
|
898
|
-
if (!(this.hideOmitForCreate && metadata.omitForCreate)
|
|
899
|
-
&& !(this.hideOmitForEdit && metadata.omitForUpdate)) {
|
|
900
|
-
res.push(property);
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
return res.sort((a, b) => EntityUtilities.compareOrder(a, b, this.objectProperty));
|
|
904
|
-
}
|
|
905
1064
|
addStringChipArrayValue(event) {
|
|
906
1065
|
const value = (event.value || '').trim();
|
|
907
1066
|
if (value) {
|
|
@@ -924,6 +1083,16 @@ class NgxMatEntityInputComponent {
|
|
|
924
1083
|
}
|
|
925
1084
|
event.chipInput.clear();
|
|
926
1085
|
}
|
|
1086
|
+
/**
|
|
1087
|
+
* Removes the given value from the array.
|
|
1088
|
+
* Sets the array to undefined if it is now empty.
|
|
1089
|
+
* This is needed because two things are validated: The array itself
|
|
1090
|
+
* and the contents of the array. And we need a way to display an
|
|
1091
|
+
* mat-error. As the only validation for the array is whether or not
|
|
1092
|
+
* it is empty, setting it to undefined here enables us to use the "required" validator.
|
|
1093
|
+
*
|
|
1094
|
+
* @param value - The string to remove from the array.
|
|
1095
|
+
*/
|
|
927
1096
|
removeStringChipArrayValue(value) {
|
|
928
1097
|
this.stringChipsArrayValues.splice(this.stringChipsArrayValues.indexOf(value), 1);
|
|
929
1098
|
if (!this.stringChipsArrayValues.length) {
|
|
@@ -931,6 +1100,12 @@ class NgxMatEntityInputComponent {
|
|
|
931
1100
|
this.stringChipsArrayValues = this.entity[this.propertyKey];
|
|
932
1101
|
}
|
|
933
1102
|
}
|
|
1103
|
+
/**
|
|
1104
|
+
* Handles adding a string to the array when an autocomplete value has been selected.
|
|
1105
|
+
*
|
|
1106
|
+
* @param event - The autocomplete selected event.
|
|
1107
|
+
* @param chipsInput - The element where the user typed the value.
|
|
1108
|
+
*/
|
|
934
1109
|
selected(event, chipsInput) {
|
|
935
1110
|
const value = (event.option.viewValue || '').trim();
|
|
936
1111
|
if (this.metadataStringChipsArray.minLength && value.length < this.metadataStringChipsArray.minLength) {
|
|
@@ -951,17 +1126,22 @@ class NgxMatEntityInputComponent {
|
|
|
951
1126
|
this.stringChipsArrayValues.push(value);
|
|
952
1127
|
chipsInput.value = '';
|
|
953
1128
|
}
|
|
1129
|
+
/**
|
|
1130
|
+
* Dynamically filters the Autocomplete options when the user inputs something.
|
|
1131
|
+
*
|
|
1132
|
+
* @param input - The input of the user.
|
|
1133
|
+
*/
|
|
954
1134
|
filterAutocompleteStrings(input) {
|
|
955
1135
|
const filterValue = input.toLowerCase();
|
|
956
1136
|
this.filteredAutocompleteStrings = this.autocompleteStrings.filter(s => s.toLowerCase().includes(filterValue));
|
|
957
1137
|
}
|
|
958
1138
|
}
|
|
959
|
-
NgxMatEntityInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
960
|
-
NgxMatEntityInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: NgxMatEntityInputComponent, selector: "ngx-mat-entity-input", inputs: { entity: "entity", propertyKey: "propertyKey", getValidationErrorMessage: "getValidationErrorMessage", hideOmitForCreate: "hideOmitForCreate", hideOmitForEdit: "hideOmitForEdit" }, ngImport: i0, template: "<div [ngSwitch]=\"type\" *ngIf=\"!(hideOmitForCreate && metadata.omitForCreate) && !(hideOmitForEdit && metadata.omitForUpdate)\">\n <!-------------------------------------------->\n <!-----------------Strings-------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.STRING\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString()\"\n #model=\"ngModel\"\n [required]=\"metadata.required ? metadata.required : false\"\n [pattern]=\"metadataDefaultString.regex ? metadataDefaultString.regex : '[\\\\s\\\\S]*'\"\n [minlength]=\"metadataDefaultString.minLength ? metadataDefaultString.minLength : null\"\n [maxlength]=\"metadataDefaultString.maxLength ? metadataDefaultString.maxLength : null\"\n />\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.STRING_TEXTBOX\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <textarea\n matInput\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString()\"\n #model=\"ngModel\"\n cdkTextareaAutosize\n cdkAutosizeMinRows=\"10\"\n [required]=\"metadata.required ? metadata.required : false\"\n [minlength]=\"metadataTextboxString.minLength ? metadataTextboxString.minLength : null\"\n [maxlength]=\"metadataTextboxString.maxLength ? metadataTextboxString.maxLength : null\"\n >\n </textarea>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.STRING_AUTOCOMPLETE\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString()\"\n #model=\"ngModel\"\n [matAutocomplete]=\"auto\"\n (keyup)=\"filterAutocompleteStrings(entity[propertyKey])\"\n [required]=\"metadata.required ? metadata.required : false\"\n [minlength]=\"metadataAutocompleteString.minLength ? metadataAutocompleteString.minLength : null\"\n [maxlength]=\"metadataAutocompleteString.maxLength ? metadataAutocompleteString.maxLength : null\"\n [pattern]=\"metadataAutocompleteString.regex ? metadataAutocompleteString.regex : '[\\\\s\\\\S]*'\"\n />\n <mat-autocomplete #auto=\"matAutocomplete\">\n <mat-option *ngFor=\"let value of filteredAutocompleteStrings\" [value]=\"value\">\n {{value}}\n </mat-option>\n </mat-autocomplete>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.STRING_DROPDOWN\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-select [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\" [required]=\"metadata.required ? metadata.required : false\">\n <mat-option *ngFor=\"let value of metadataDropdownString.dropdownValues\" [value]=\"value.value\">{{value.displayName}}</mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <!-------------------------------------------->\n <!-----------------Booleans------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.BOOLEAN_CHECKBOX\">\n <mat-form-field>\n <mat-checkbox [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\" [required]=\"metadata.required ? metadata.required : false\">\n {{metadata.displayName}}\n </mat-checkbox>\n <!-- hidden input is needed so that the checkbox can be used inside a mat-form-field -->\n <textarea matInput hidden></textarea>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.BOOLEAN_TOGGLE\">\n <mat-form-field>\n <mat-slide-toggle [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\" [required]=\"metadata.required ? metadata.required : false\">\n {{metadata.displayName}}\n </mat-slide-toggle>\n <!-- hidden input is needed so that the toggle can be used inside a mat-form-field -->\n <textarea matInput hidden></textarea>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.BOOLEAN_DROPDOWN\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-select [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\" [required]=\"metadata.required ? metadata.required : false\">\n <mat-option [value]=\"undefined\">-</mat-option>\n <mat-option [value]=\"true\">{{metadataDropdownBoolean.dropdownTrue}}</mat-option>\n <mat-option [value]=\"false\">{{metadataDropdownBoolean.dropdownFalse}}</mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <!-------------------------------------------->\n <!------------------Numbers------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.NUMBER\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n type=\"number\"\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString()\"\n #model=\"ngModel\"\n [required]=\"metadata.required ? metadata.required : false\"\n [min]=\"metadataDefaultNumber.min ? metadataDefaultNumber.min : null\"\n [max]=\"metadataDefaultNumber.max ? metadataDefaultNumber.max : null\"\n />\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.NUMBER_DROPDOWN\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-select [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\" [required]=\"metadata.required ? metadata.required : false\">\n <mat-option *ngFor=\"let value of metadataDropdownNumber.dropdownValues\" [value]=\"value.value\">{{value.displayName}}</mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <!-------------------------------------------->\n <!-------------------Object------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.OBJECT\">\n <b>{{metadataDefaultObject.displayName}}</b>\n <!-- iterates over the object properties -->\n <div class=\"row\">\n <!--\n displays another ngx-material-entity with the:\n object as the entity,\n the current key in the loop received by the keyvalue direction as the propertyKey\n and the getValidationErrorMessage of the current component\n -->\n <ngx-mat-entity-input\n *ngFor=\"let key of getObjectProperties(); let i = index; trackBy: trackByFn\"\n [entity]=\"objectProperty\"\n [propertyKey]=\"key\"\n [getValidationErrorMessage]=\"getValidationErrorMessage\"\n [hideOmitForCreate]=\"hideOmitForCreate\"\n [hideOmitForEdit]=\"hideOmitForEdit\"\n class=\"col-lg-{{getWidth(objectProperty, key, 'lg')}} col-md-{{getWidth(objectProperty, key, 'md')}} col-sm-{{getWidth(objectProperty, key, 'sm')}}\"\n >\n </ngx-mat-entity-input>\n </div>\n </div>\n\n <!-------------------------------------------->\n <!-------------------Array-------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.ARRAY\">\n <ngx-mat-entity-array-table\n [arrayItems]=\"entityArrayValues\"\n [metadata]=\"metadataEntityArray\"\n [getValidationErrorMessage]=\"getValidationErrorMessage\"\n [omit]=\"hideOmitForCreate ? 'create' : 'edit'\"\n >\n </ngx-mat-entity-array-table>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.ARRAY_STRING_CHIPS\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-chip-list #chipList\n [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\"\n [required]=\"metadata.required ? metadata.required : false\"\n >\n <mat-chip *ngFor=\"let value of stringChipsArrayValues\" (removed)=\"removeStringChipArrayValue(value)\">\n {{value}}\n <button matChipRemove *ngIf=\"metadataStringChipsArray.deleteHtml\" [innerHtml]=\"metadataStringChipsArray.deleteHtml\">\n </button>\n <button matChipRemove *ngIf=\"!metadataStringChipsArray.deleteHtml\">\n <mat-icon>cancel</mat-icon>\n </button>\n </mat-chip>\n <input matInput\n [matChipInputFor]=\"chipList\"\n [matChipInputAddOnBlur]=\"true\"\n (matChipInputTokenEnd)=\"addStringChipArrayValue($event)\"\n [(ngModel)]=\"chipsInput\" [name]=\"propertyKey.toString()\" #chipsModel=\"ngModel\"\n [minlength]='metadataStringChipsArray.minLength ? metadataStringChipsArray.minLength : null'\n [maxlength]='metadataStringChipsArray.maxLength ? metadataStringChipsArray.maxLength : null'\n [pattern]=\"metadataStringChipsArray.regex ? metadataStringChipsArray.regex : '[\\\\s\\\\S]*'\"\n >\n <mat-error *ngIf=\"chipsModel.errors\">{{getValidationErrorMessage(chipsModel)}}</mat-error>\n </mat-chip-list>\n <mat-error *ngIf=\"!chipsModel.errors\">{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.ARRAY_STRING_AUTOCOMPLETE_CHIPS\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-chip-list #chipList\n [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\"\n [required]=\"metadata.required ? metadata.required : false\"\n >\n <mat-chip *ngFor=\"let value of stringChipsArrayValues\" (removed)=\"removeStringChipArrayValue(value)\">\n {{value}}\n <button matChipRemove *ngIf=\"metadataStringChipsArray.deleteHtml\" [innerHtml]=\"metadataStringChipsArray.deleteHtml\">\n </button>\n <button matChipRemove *ngIf=\"!metadataStringChipsArray.deleteHtml\">\n <mat-icon>cancel</mat-icon>\n </button>\n </mat-chip>\n <input matInput\n [matChipInputFor]=\"chipList\"\n [matAutocomplete]=\"auto\"\n [matChipInputAddOnBlur]=\"true\"\n (matChipInputTokenEnd)=\"addStringChipArrayValue($event)\"\n (keyup)=\"filterAutocompleteStrings(chipsInput)\"\n [(ngModel)]=\"chipsInput\" [name]=\"propertyKey.toString()\" #chipsModel=\"ngModel\"\n #chipsElement\n [minlength]='metadataStringChipsArray.minLength ? metadataStringChipsArray.minLength : null'\n [maxlength]='metadataStringChipsArray.maxLength ? metadataStringChipsArray.maxLength : null'\n [pattern]=\"metadataStringChipsArray.regex ? metadataStringChipsArray.regex : '[\\\\s\\\\S]*'\"\n >\n <mat-error *ngIf=\"chipsModel.errors\">{{getValidationErrorMessage(chipsModel)}}</mat-error>\n </mat-chip-list>\n <mat-autocomplete #auto=\"matAutocomplete\" (optionSelected)=\"selected($event, chipsElement)\">\n <mat-option *ngFor=\"let value of filteredAutocompleteStrings\" [value]=\"value\">\n {{value}}\n </mat-option>\n </mat-autocomplete>\n <mat-error *ngIf=\"!chipsModel.errors\">{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchDefault>ERROR: The type {{type}}is not known.</div>\n</div>", styles: ["mat-form-field{width:100%}\n"], components: [{ type: i1$1.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i2.MatAutocomplete, selector: "mat-autocomplete", inputs: ["disableRipple"], exportAs: ["matAutocomplete"] }, { type: i3$1.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { type: i4.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { type: i5.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex", "aria-label", "aria-labelledby", "aria-describedby", "id", "required", "labelPosition", "name", "value", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { type: i6.MatSlideToggle, selector: "mat-slide-toggle", inputs: ["disabled", "disableRipple", "color", "tabIndex", "name", "id", "labelPosition", "aria-label", "aria-labelledby", "aria-describedby", "required", "checked"], outputs: ["change", "toggleChange"], exportAs: ["matSlideToggle"] }, { type: NgxMatEntityInputComponent, selector: "ngx-mat-entity-input", inputs: ["entity", "propertyKey", "getValidationErrorMessage", "hideOmitForCreate", "hideOmitForEdit"] }, { type: NgxMatEntityArrayTableComponent, selector: "ngx-mat-entity-array-table", inputs: ["arrayItems", "metadata", "getValidationErrorMessage", "omit"] }, { type: i8$1.MatChipList, selector: "mat-chip-list", inputs: ["errorStateMatcher", "multiple", "compareWith", "value", "required", "placeholder", "disabled", "aria-orientation", "selectable", "tabIndex"], outputs: ["change", "valueChange"], exportAs: ["matChipList"] }, { type: i9.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], directives: [{ type: i7.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i7.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i7.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i1$1.MatLabel, selector: "mat-label" }, { type: i8.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { type: i12.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i12.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i12.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i12.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i12.PatternValidator, selector: "[pattern][formControlName],[pattern][formControl],[pattern][ngModel]", inputs: ["pattern"] }, { type: i12.MinLengthValidator, selector: "[minlength][formControlName],[minlength][formControl],[minlength][ngModel]", inputs: ["minlength"] }, { type: i12.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { type: i1$1.MatError, selector: "mat-error", inputs: ["id"] }, { type: i10.CdkTextareaAutosize, selector: "textarea[cdkTextareaAutosize]", inputs: ["cdkAutosizeMinRows", "cdkAutosizeMaxRows", "cdkTextareaAutosize", "placeholder"], exportAs: ["cdkTextareaAutosize"] }, { type: i2.MatAutocompleteTrigger, selector: "input[matAutocomplete], textarea[matAutocomplete]", exportAs: ["matAutocompleteTrigger"] }, { type: i7.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5.MatCheckboxRequiredValidator, selector: "mat-checkbox[required][formControlName], mat-checkbox[required][formControl], mat-checkbox[required][ngModel]" }, { type: i6.MatSlideToggleRequiredValidator, selector: "mat-slide-toggle[required][formControlName], mat-slide-toggle[required][formControl], mat-slide-toggle[required][ngModel]" }, { type: i12.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { type: i12.MinValidator, selector: "input[type=number][min][formControlName],input[type=number][min][formControl],input[type=number][min][ngModel]", inputs: ["min"] }, { type: i12.MaxValidator, selector: "input[type=number][max][formControlName],input[type=number][max][formControl],input[type=number][max][ngModel]", inputs: ["max"] }, { type: i8$1.MatChip, selector: "mat-basic-chip, [mat-basic-chip], mat-chip, [mat-chip]", inputs: ["color", "disableRipple", "tabIndex", "selected", "value", "selectable", "disabled", "removable"], outputs: ["selectionChange", "destroyed", "removed"], exportAs: ["matChip"] }, { type: i8$1.MatChipRemove, selector: "[matChipRemove]" }, { type: i8$1.MatChipInput, selector: "input[matChipInputFor]", inputs: ["matChipInputFor", "matChipInputAddOnBlur", "matChipInputSeparatorKeyCodes", "placeholder", "id", "disabled"], outputs: ["matChipInputTokenEnd"], exportAs: ["matChipInput", "matChipInputFor"] }, { type: i7.NgSwitchDefault, selector: "[ngSwitchDefault]" }] });
|
|
1139
|
+
NgxMatEntityInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityInputComponent, deps: [{ token: i1.MatDialog }], target: i0.ɵɵFactoryTarget.Component });
|
|
1140
|
+
NgxMatEntityInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: NgxMatEntityInputComponent, selector: "ngx-mat-entity-input", inputs: { entity: "entity", propertyKey: "propertyKey", getValidationErrorMessage: "getValidationErrorMessage", hideOmitForCreate: "hideOmitForCreate", hideOmitForEdit: "hideOmitForEdit" }, viewQueries: [{ propertyName: "addArrayItemDialog", first: true, predicate: ["addArrayItemDialog"], descendants: true }], ngImport: i0, template: "<div [ngSwitch]=\"type\" *ngIf=\"!(hideOmitForCreate && metadata.omitForCreate) && !(hideOmitForEdit && metadata.omitForUpdate)\">\n <!-------------------------------------------->\n <!-----------------Strings-------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.STRING\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString()\"\n #model=\"ngModel\"\n [required]=\"metadata.required\"\n [pattern]=\"metadataDefaultString.regex ? metadataDefaultString.regex : '[\\\\s\\\\S]*'\"\n [minlength]=\"metadataDefaultString.minLength ? metadataDefaultString.minLength : null\"\n [maxlength]=\"metadataDefaultString.maxLength ? metadataDefaultString.maxLength : null\"\n />\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.STRING_TEXTBOX\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <textarea\n matInput\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString()\"\n #model=\"ngModel\"\n cdkTextareaAutosize\n cdkAutosizeMinRows=\"10\"\n [required]=\"metadata.required\"\n [minlength]=\"metadataTextboxString.minLength ? metadataTextboxString.minLength : null\"\n [maxlength]=\"metadataTextboxString.maxLength ? metadataTextboxString.maxLength : null\"\n >\n </textarea>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.STRING_AUTOCOMPLETE\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString()\"\n #model=\"ngModel\"\n [matAutocomplete]=\"auto\"\n (keyup)=\"filterAutocompleteStrings(entity[propertyKey])\"\n [required]=\"metadata.required\"\n [minlength]=\"metadataAutocompleteString.minLength ? metadataAutocompleteString.minLength : null\"\n [maxlength]=\"metadataAutocompleteString.maxLength ? metadataAutocompleteString.maxLength : null\"\n [pattern]=\"metadataAutocompleteString.regex ? metadataAutocompleteString.regex : '[\\\\s\\\\S]*'\"\n />\n <mat-autocomplete #auto=\"matAutocomplete\">\n <mat-option *ngFor=\"let value of filteredAutocompleteStrings\" [value]=\"value\">\n {{value}}\n </mat-option>\n </mat-autocomplete>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.STRING_DROPDOWN\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-select [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\" [required]=\"metadata.required\">\n <mat-option *ngFor=\"let value of metadataDropdownString.dropdownValues\" [value]=\"value.value\">{{value.displayName}}</mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <!-------------------------------------------->\n <!-----------------Booleans------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.BOOLEAN_CHECKBOX\">\n <mat-form-field class=\"hideUnderline\">\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-checkbox (click)=\"model.control.markAsTouched()\" [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\"></mat-checkbox>\n <!-- hidden input is needed so that the checkbox can be used inside a mat-form-field -->\n <input matInput hidden\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString() + 'Helper'\"\n #model=\"ngModel\"\n [pattern]=\"metadata.required ? 'true' : '[\\\\s\\\\S]*'\"\n [required]=\"metadata.required\">\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.BOOLEAN_TOGGLE\">\n <mat-form-field class=\"hideUnderline\">\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-slide-toggle (click)=\"model.control.markAsTouched()\" [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\"></mat-slide-toggle>\n <!-- hidden input is needed so that the toggle can be used inside a mat-form-field -->\n <input matInput hidden\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString() + 'Helper'\"\n #model=\"ngModel\"\n [pattern]=\"metadata.required ? 'true' : '[\\\\s\\\\S]*'\"\n [required]=\"metadata.required\">\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.BOOLEAN_DROPDOWN\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-select [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\" [required]=\"metadata.required\">\n <mat-option [value]=\"undefined\">-</mat-option>\n <mat-option [value]=\"true\">{{metadataDropdownBoolean.dropdownTrue}}</mat-option>\n <mat-option [value]=\"false\">{{metadataDropdownBoolean.dropdownFalse}}</mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <!-------------------------------------------->\n <!------------------Numbers------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.NUMBER\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n type=\"number\"\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString()\"\n #model=\"ngModel\"\n [required]=\"metadata.required\"\n [min]=\"metadataDefaultNumber.min ? metadataDefaultNumber.min : null\"\n [max]=\"metadataDefaultNumber.max ? metadataDefaultNumber.max : null\"\n />\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.NUMBER_DROPDOWN\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-select [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\" [required]=\"metadata.required\">\n <mat-option *ngFor=\"let value of metadataDropdownNumber.dropdownValues\" [value]=\"value.value\">{{value.displayName}}</mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <!-------------------------------------------->\n <!-------------------Object------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.OBJECT\">\n <b>{{metadataDefaultObject.displayName}}</b>\n <!-- iterates over the object properties -->\n\n <div class=\"row\" *ngFor=\"let row of objectPropertyRows\">\n <!--\n displays another ngx-material-entity with the:\n object as the entity,\n the current key in the loop received by the keyvalue direction as the propertyKey\n and the getValidationErrorMessage of the current component\n -->\n <ngx-mat-entity-input\n *ngFor=\"let key of row.keys; let i = index; trackBy: trackByFn\"\n [entity]=\"objectProperty\"\n [propertyKey]=\"key\"\n [getValidationErrorMessage]=\"getValidationErrorMessage\"\n [hideOmitForCreate]=\"hideOmitForCreate\"\n [hideOmitForEdit]=\"hideOmitForEdit\"\n class=\"col-lg-{{getWidth(objectProperty, key, 'lg')}} col-md-{{getWidth(objectProperty, key, 'md')}} col-sm-{{getWidth(objectProperty, key, 'sm')}}\"\n >\n </ngx-mat-entity-input>\n </div>\n </div>\n\n <!-------------------------------------------->\n <!-------------------Array-------------------->\n <!-------------------------------------------->\n <div class=\"entityArray\" *ngSwitchCase=\"DecoratorTypes.ARRAY\">\n <div class=\"mat-elevation-z8\" style=\"border-radius: 5px;padding: 15px;margin-bottom: 15px;margin-top: 15px;\">\n\n <div style=\"padding-bottom: 10px\">\n <b>{{metadataEntityArray.displayName}}</b>\n </div>\n <div *ngIf=\"metadataEntityArray.createInline\">\n <div class=\"row\" *ngFor=\"let row of arrayItemInlineRows\">\n <ngx-mat-entity-input\n *ngFor=\"let key of row.keys; let i = index; trackBy: trackByFn\"\n [entity]=\"arrayItem\"\n [propertyKey]=\"key\"\n [hideOmitForCreate]=\"true\"\n [getValidationErrorMessage]=\"getValidationErrorMessage\"\n class=\"col-lg-{{getWidth(arrayItem, key, 'lg')}} col-md-{{getWidth(arrayItem, key, 'md')}} col-sm-{{getWidth(arrayItem, key, 'sm')}}\"\n >\n </ngx-mat-entity-input>\n </div>\n </div>\n \n <div class=\"buttons\">\n <button mat-raised-button\n [disabled]=\"metadataEntityArray.createInline && !EntityUtilities.isEntityValid(arrayItem, 'create')\"\n (click)=\"add()\">\n {{metadataEntityArray.addButtonLabel}}\n </button>\n <button mat-raised-button\n [disabled]=\"!selection.selected.length\"\n (click)=\"remove()\">\n {{metadataEntityArray.removeButtonLabel}}\n </button>\n </div>\n \n <mat-table [dataSource]=\"dataSource\">\n <!-- select Column -->\n <ng-container matColumnDef=\"select\">\n <mat-header-cell *matHeaderCellDef>\n <mat-checkbox [disabled]=\"!dataSource.data.length\" (change)=\"$event ? masterToggle() : null\" [checked]=\"selection.hasValue() && isAllSelected()\" [indeterminate]=\"selection.hasValue() && !isAllSelected()\"></mat-checkbox>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let module\" class=\"module\">\n <mat-checkbox (click)=\"$event.stopPropagation()\" (change)=\"$event ? selection.toggle(module) : null\" [checked]=\"selection.isSelected(module)\"></mat-checkbox>\n </mat-cell>\n </ng-container>\n \n <ng-container *ngFor=\"let dCol of metadataEntityArray.displayColumns\" [matColumnDef]=\"dCol.displayName\">\n <mat-header-cell *matHeaderCellDef>\n {{dCol.displayName}}\n </mat-header-cell>\n <mat-cell class=\"entity\" *matCellDef=\"let entity\">\n {{dCol.value(entity)}}\n </mat-cell>\n </ng-container>\n \n <mat-header-row *matHeaderRowDef=\"displayedColumns\"></mat-header-row>\n <mat-row *matRowDef=\"let row; columns: displayedColumns\"></mat-row>\n </mat-table>\n \n <div class=\"array-error\" *ngIf=\"metadataEntityArray.required && !dataSource.data.length\">\n {{metadataEntityArray.missingErrorMessage}}\n </div>\n </div>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.ARRAY_STRING_CHIPS\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-chip-list #chipList\n [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\"\n [required]=\"metadata.required\"\n >\n <mat-chip *ngFor=\"let value of stringChipsArrayValues\" (removed)=\"removeStringChipArrayValue(value)\">\n {{value}}\n <button matChipRemove>\n <i class=\"{{metadataStringChipsArray.deleteIcon}}\"></i>\n </button>\n </mat-chip>\n <input matInput\n [matChipInputFor]=\"chipList\"\n [matChipInputAddOnBlur]=\"true\"\n (matChipInputTokenEnd)=\"addStringChipArrayValue($event)\"\n [(ngModel)]=\"chipsInput\" [name]=\"propertyKey.toString()\" #chipsModel=\"ngModel\"\n [minlength]='metadataStringChipsArray.minLength ? metadataStringChipsArray.minLength : null'\n [maxlength]='metadataStringChipsArray.maxLength ? metadataStringChipsArray.maxLength : null'\n [pattern]=\"metadataStringChipsArray.regex ? metadataStringChipsArray.regex : '[\\\\s\\\\S]*'\"\n >\n <mat-error *ngIf=\"chipsModel.errors\">{{getValidationErrorMessage(chipsModel)}}</mat-error>\n </mat-chip-list>\n <mat-error *ngIf=\"!chipsModel.errors\">{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.ARRAY_STRING_AUTOCOMPLETE_CHIPS\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-chip-list #chipList\n [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\"\n [required]=\"metadata.required\"\n >\n <mat-chip *ngFor=\"let value of stringChipsArrayValues\" (removed)=\"removeStringChipArrayValue(value)\">\n {{value}}\n <button matChipRemove>\n <i class=\"{{metadataStringChipsArray.deleteIcon}}\"></i>\n </button>\n </mat-chip>\n <input matInput\n [matChipInputFor]=\"chipList\"\n [matAutocomplete]=\"auto\"\n [matChipInputAddOnBlur]=\"true\"\n (matChipInputTokenEnd)=\"addStringChipArrayValue($event)\"\n (keyup)=\"filterAutocompleteStrings(chipsInput)\"\n [(ngModel)]=\"chipsInput\" [name]=\"propertyKey.toString()\" #chipsModel=\"ngModel\"\n #chipsElement\n [minlength]='metadataStringChipsArray.minLength ? metadataStringChipsArray.minLength : null'\n [maxlength]='metadataStringChipsArray.maxLength ? metadataStringChipsArray.maxLength : null'\n [pattern]=\"metadataStringChipsArray.regex ? metadataStringChipsArray.regex : '[\\\\s\\\\S]*'\"\n >\n <mat-error *ngIf=\"chipsModel.errors\">{{getValidationErrorMessage(chipsModel)}}</mat-error>\n </mat-chip-list>\n <mat-autocomplete #auto=\"matAutocomplete\" (optionSelected)=\"selected($event, chipsElement)\">\n <mat-option *ngFor=\"let value of filteredAutocompleteStrings\" [value]=\"value\">\n {{value}}\n </mat-option>\n </mat-autocomplete>\n <mat-error *ngIf=\"!chipsModel.errors\">{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchDefault>ERROR: The type {{type}} is not known.</div>\n</div>\n\n<!--------------------------------------------------------->\n<!--------------------Add Array Item Dialog---------------->\n<!--------------------------------------------------------->\n<ng-template #addArrayItemDialog>\n <h2 mat-dialog-title>{{dialogData.createDialogData.title}}</h2>\n\n <mat-dialog-content>\n <form #form=\"ngForm\" class=\"row\">\n <div class=\"row\" *ngFor=\"let row of arrayItemDialogRows\">\n <ngx-mat-entity-input\n *ngFor=\"let key of row.keys\"\n [entity]=\"dialogData.entity\"\n [propertyKey]=\"key\"\n [hideOmitForCreate]=\"true\"\n [getValidationErrorMessage]=\"dialogData.getValidationErrorMessage\"\n class=\"col-lg-{{getWidth(dialogData.entity, key, 'lg')}} col-md-{{getWidth(dialogData.entity, key, 'md')}} col-sm-{{getWidth(dialogData.entity, key, 'sm')}}\"\n >\n </ngx-mat-entity-input>\n </div>\n </form>\n </mat-dialog-content>\n\n <mat-dialog-actions>\n <button mat-raised-button (click)=\"addArrayItem()\" [disabled]=\"!EntityUtilities.isEntityValid(dialogData.entity, 'create')\">\n {{dialogData.createDialogData.createButtonLabel}}\n </button>\n <button mat-raised-button (click)=\"cancelAddArrayItem()\" class=\"cancel-button\">\n {{dialogData.createDialogData.cancelButtonLabel}}\n </button>\n </mat-dialog-actions>\n\n</ng-template>", styles: ["mat-form-field{width:100%}::ng-deep .hideUnderline .mat-form-field-underline{opacity:0%}.entityArray .buttons{display:flex;justify-content:space-between;margin-bottom:10px;margin-top:5px}.entityArray mat-table{border:1px solid #E0E0E0;border-radius:5px;padding-top:5px;padding-bottom:25px}.entityArray .mat-column-select{flex:0 0 75px}.entityArray .array-error{display:flex;align-items:center;justify-content:center;margin-top:-25.8px;border:1px solid #E0E0E0;background-color:#f8d3d7;color:#721c24;height:25.8px;border-bottom-left-radius:5px;border-bottom-right-radius:5px}\n"], components: [{ type: i2.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i3$1.MatAutocomplete, selector: "mat-autocomplete", inputs: ["disableRipple"], exportAs: ["matAutocomplete"] }, { type: i4.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { type: i5.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { type: i6.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex", "aria-label", "aria-labelledby", "aria-describedby", "id", "required", "labelPosition", "name", "value", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { type: i7.MatSlideToggle, selector: "mat-slide-toggle", inputs: ["disabled", "disableRipple", "color", "tabIndex", "name", "id", "labelPosition", "aria-label", "aria-labelledby", "aria-describedby", "required", "checked"], outputs: ["change", "toggleChange"], exportAs: ["matSlideToggle"] }, { type: NgxMatEntityInputComponent, selector: "ngx-mat-entity-input", inputs: ["entity", "propertyKey", "getValidationErrorMessage", "hideOmitForCreate", "hideOmitForEdit"] }, { type: i3.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i9.MatTable, selector: "mat-table, table[mat-table]", exportAs: ["matTable"] }, { type: i9.MatHeaderRow, selector: "mat-header-row, tr[mat-header-row]", exportAs: ["matHeaderRow"] }, { type: i9.MatRow, selector: "mat-row, tr[mat-row]", exportAs: ["matRow"] }, { type: i10.MatChipList, selector: "mat-chip-list", inputs: ["errorStateMatcher", "multiple", "compareWith", "value", "required", "placeholder", "disabled", "aria-orientation", "selectable", "tabIndex"], outputs: ["change", "valueChange"], exportAs: ["matChipList"] }], directives: [{ type: i11.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i11.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i11.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i2.MatLabel, selector: "mat-label" }, { type: i12.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { type: i13.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i13.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i13.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i13.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i13.PatternValidator, selector: "[pattern][formControlName],[pattern][formControl],[pattern][ngModel]", inputs: ["pattern"] }, { type: i13.MinLengthValidator, selector: "[minlength][formControlName],[minlength][formControl],[minlength][ngModel]", inputs: ["minlength"] }, { type: i13.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { type: i2.MatError, selector: "mat-error", inputs: ["id"] }, { type: i14.CdkTextareaAutosize, selector: "textarea[cdkTextareaAutosize]", inputs: ["cdkAutosizeMinRows", "cdkAutosizeMaxRows", "cdkTextareaAutosize", "placeholder"], exportAs: ["cdkTextareaAutosize"] }, { type: i3$1.MatAutocompleteTrigger, selector: "input[matAutocomplete], textarea[matAutocomplete]", exportAs: ["matAutocompleteTrigger"] }, { type: i11.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i13.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { type: i13.MinValidator, selector: "input[type=number][min][formControlName],input[type=number][min][formControl],input[type=number][min][ngModel]", inputs: ["min"] }, { type: i13.MaxValidator, selector: "input[type=number][max][formControlName],input[type=number][max][formControl],input[type=number][max][ngModel]", inputs: ["max"] }, { type: i9.MatColumnDef, selector: "[matColumnDef]", inputs: ["sticky", "matColumnDef"] }, { type: i9.MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { type: i9.MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { type: i9.MatCellDef, selector: "[matCellDef]" }, { type: i9.MatCell, selector: "mat-cell, td[mat-cell]" }, { type: i9.MatHeaderRowDef, selector: "[matHeaderRowDef]", inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"] }, { type: i9.MatRowDef, selector: "[matRowDef]", inputs: ["matRowDefColumns", "matRowDefWhen"] }, { type: i10.MatChip, selector: "mat-basic-chip, [mat-basic-chip], mat-chip, [mat-chip]", inputs: ["color", "disableRipple", "tabIndex", "selected", "value", "selectable", "disabled", "removable"], outputs: ["selectionChange", "destroyed", "removed"], exportAs: ["matChip"] }, { type: i10.MatChipRemove, selector: "[matChipRemove]" }, { type: i10.MatChipInput, selector: "input[matChipInputFor]", inputs: ["matChipInputFor", "matChipInputAddOnBlur", "matChipInputSeparatorKeyCodes", "placeholder", "id", "disabled"], outputs: ["matChipInputTokenEnd"], exportAs: ["matChipInput", "matChipInputFor"] }, { type: i11.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { type: i1.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { type: i1.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { type: i13.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i13.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i13.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i1.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]" }] });
|
|
961
1141
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityInputComponent, decorators: [{
|
|
962
1142
|
type: Component,
|
|
963
|
-
args: [{ selector: 'ngx-mat-entity-input', template: "<div [ngSwitch]=\"type\" *ngIf=\"!(hideOmitForCreate && metadata.omitForCreate) && !(hideOmitForEdit && metadata.omitForUpdate)\">\n <!-------------------------------------------->\n <!-----------------Strings-------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.STRING\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString()\"\n #model=\"ngModel\"\n [required]=\"metadata.required ? metadata.required : false\"\n [pattern]=\"metadataDefaultString.regex ? metadataDefaultString.regex : '[\\\\s\\\\S]*'\"\n [minlength]=\"metadataDefaultString.minLength ? metadataDefaultString.minLength : null\"\n [maxlength]=\"metadataDefaultString.maxLength ? metadataDefaultString.maxLength : null\"\n />\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.STRING_TEXTBOX\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <textarea\n matInput\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString()\"\n #model=\"ngModel\"\n cdkTextareaAutosize\n cdkAutosizeMinRows=\"10\"\n [required]=\"metadata.required ? metadata.required : false\"\n [minlength]=\"metadataTextboxString.minLength ? metadataTextboxString.minLength : null\"\n [maxlength]=\"metadataTextboxString.maxLength ? metadataTextboxString.maxLength : null\"\n >\n </textarea>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.STRING_AUTOCOMPLETE\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString()\"\n #model=\"ngModel\"\n [matAutocomplete]=\"auto\"\n (keyup)=\"filterAutocompleteStrings(entity[propertyKey])\"\n [required]=\"metadata.required ? metadata.required : false\"\n [minlength]=\"metadataAutocompleteString.minLength ? metadataAutocompleteString.minLength : null\"\n [maxlength]=\"metadataAutocompleteString.maxLength ? metadataAutocompleteString.maxLength : null\"\n [pattern]=\"metadataAutocompleteString.regex ? metadataAutocompleteString.regex : '[\\\\s\\\\S]*'\"\n />\n <mat-autocomplete #auto=\"matAutocomplete\">\n <mat-option *ngFor=\"let value of filteredAutocompleteStrings\" [value]=\"value\">\n {{value}}\n </mat-option>\n </mat-autocomplete>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.STRING_DROPDOWN\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-select [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\" [required]=\"metadata.required ? metadata.required : false\">\n <mat-option *ngFor=\"let value of metadataDropdownString.dropdownValues\" [value]=\"value.value\">{{value.displayName}}</mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <!-------------------------------------------->\n <!-----------------Booleans------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.BOOLEAN_CHECKBOX\">\n <mat-form-field>\n <mat-checkbox [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\" [required]=\"metadata.required ? metadata.required : false\">\n {{metadata.displayName}}\n </mat-checkbox>\n <!-- hidden input is needed so that the checkbox can be used inside a mat-form-field -->\n <textarea matInput hidden></textarea>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.BOOLEAN_TOGGLE\">\n <mat-form-field>\n <mat-slide-toggle [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\" [required]=\"metadata.required ? metadata.required : false\">\n {{metadata.displayName}}\n </mat-slide-toggle>\n <!-- hidden input is needed so that the toggle can be used inside a mat-form-field -->\n <textarea matInput hidden></textarea>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.BOOLEAN_DROPDOWN\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-select [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\" [required]=\"metadata.required ? metadata.required : false\">\n <mat-option [value]=\"undefined\">-</mat-option>\n <mat-option [value]=\"true\">{{metadataDropdownBoolean.dropdownTrue}}</mat-option>\n <mat-option [value]=\"false\">{{metadataDropdownBoolean.dropdownFalse}}</mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <!-------------------------------------------->\n <!------------------Numbers------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.NUMBER\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n type=\"number\"\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString()\"\n #model=\"ngModel\"\n [required]=\"metadata.required ? metadata.required : false\"\n [min]=\"metadataDefaultNumber.min ? metadataDefaultNumber.min : null\"\n [max]=\"metadataDefaultNumber.max ? metadataDefaultNumber.max : null\"\n />\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.NUMBER_DROPDOWN\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-select [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\" [required]=\"metadata.required ? metadata.required : false\">\n <mat-option *ngFor=\"let value of metadataDropdownNumber.dropdownValues\" [value]=\"value.value\">{{value.displayName}}</mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <!-------------------------------------------->\n <!-------------------Object------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.OBJECT\">\n <b>{{metadataDefaultObject.displayName}}</b>\n <!-- iterates over the object properties -->\n <div class=\"row\">\n <!--\n displays another ngx-material-entity with the:\n object as the entity,\n the current key in the loop received by the keyvalue direction as the propertyKey\n and the getValidationErrorMessage of the current component\n -->\n <ngx-mat-entity-input\n *ngFor=\"let key of getObjectProperties(); let i = index; trackBy: trackByFn\"\n [entity]=\"objectProperty\"\n [propertyKey]=\"key\"\n [getValidationErrorMessage]=\"getValidationErrorMessage\"\n [hideOmitForCreate]=\"hideOmitForCreate\"\n [hideOmitForEdit]=\"hideOmitForEdit\"\n class=\"col-lg-{{getWidth(objectProperty, key, 'lg')}} col-md-{{getWidth(objectProperty, key, 'md')}} col-sm-{{getWidth(objectProperty, key, 'sm')}}\"\n >\n </ngx-mat-entity-input>\n </div>\n </div>\n\n <!-------------------------------------------->\n <!-------------------Array-------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.ARRAY\">\n <ngx-mat-entity-array-table\n [arrayItems]=\"entityArrayValues\"\n [metadata]=\"metadataEntityArray\"\n [getValidationErrorMessage]=\"getValidationErrorMessage\"\n [omit]=\"hideOmitForCreate ? 'create' : 'edit'\"\n >\n </ngx-mat-entity-array-table>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.ARRAY_STRING_CHIPS\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-chip-list #chipList\n [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\"\n [required]=\"metadata.required ? metadata.required : false\"\n >\n <mat-chip *ngFor=\"let value of stringChipsArrayValues\" (removed)=\"removeStringChipArrayValue(value)\">\n {{value}}\n <button matChipRemove *ngIf=\"metadataStringChipsArray.deleteHtml\" [innerHtml]=\"metadataStringChipsArray.deleteHtml\">\n </button>\n <button matChipRemove *ngIf=\"!metadataStringChipsArray.deleteHtml\">\n <mat-icon>cancel</mat-icon>\n </button>\n </mat-chip>\n <input matInput\n [matChipInputFor]=\"chipList\"\n [matChipInputAddOnBlur]=\"true\"\n (matChipInputTokenEnd)=\"addStringChipArrayValue($event)\"\n [(ngModel)]=\"chipsInput\" [name]=\"propertyKey.toString()\" #chipsModel=\"ngModel\"\n [minlength]='metadataStringChipsArray.minLength ? metadataStringChipsArray.minLength : null'\n [maxlength]='metadataStringChipsArray.maxLength ? metadataStringChipsArray.maxLength : null'\n [pattern]=\"metadataStringChipsArray.regex ? metadataStringChipsArray.regex : '[\\\\s\\\\S]*'\"\n >\n <mat-error *ngIf=\"chipsModel.errors\">{{getValidationErrorMessage(chipsModel)}}</mat-error>\n </mat-chip-list>\n <mat-error *ngIf=\"!chipsModel.errors\">{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.ARRAY_STRING_AUTOCOMPLETE_CHIPS\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-chip-list #chipList\n [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\"\n [required]=\"metadata.required ? metadata.required : false\"\n >\n <mat-chip *ngFor=\"let value of stringChipsArrayValues\" (removed)=\"removeStringChipArrayValue(value)\">\n {{value}}\n <button matChipRemove *ngIf=\"metadataStringChipsArray.deleteHtml\" [innerHtml]=\"metadataStringChipsArray.deleteHtml\">\n </button>\n <button matChipRemove *ngIf=\"!metadataStringChipsArray.deleteHtml\">\n <mat-icon>cancel</mat-icon>\n </button>\n </mat-chip>\n <input matInput\n [matChipInputFor]=\"chipList\"\n [matAutocomplete]=\"auto\"\n [matChipInputAddOnBlur]=\"true\"\n (matChipInputTokenEnd)=\"addStringChipArrayValue($event)\"\n (keyup)=\"filterAutocompleteStrings(chipsInput)\"\n [(ngModel)]=\"chipsInput\" [name]=\"propertyKey.toString()\" #chipsModel=\"ngModel\"\n #chipsElement\n [minlength]='metadataStringChipsArray.minLength ? metadataStringChipsArray.minLength : null'\n [maxlength]='metadataStringChipsArray.maxLength ? metadataStringChipsArray.maxLength : null'\n [pattern]=\"metadataStringChipsArray.regex ? metadataStringChipsArray.regex : '[\\\\s\\\\S]*'\"\n >\n <mat-error *ngIf=\"chipsModel.errors\">{{getValidationErrorMessage(chipsModel)}}</mat-error>\n </mat-chip-list>\n <mat-autocomplete #auto=\"matAutocomplete\" (optionSelected)=\"selected($event, chipsElement)\">\n <mat-option *ngFor=\"let value of filteredAutocompleteStrings\" [value]=\"value\">\n {{value}}\n </mat-option>\n </mat-autocomplete>\n <mat-error *ngIf=\"!chipsModel.errors\">{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchDefault>ERROR: The type {{type}}is not known.</div>\n</div>", styles: ["mat-form-field{width:100%}\n"] }]
|
|
964
|
-
}], ctorParameters: function () { return []; }, propDecorators: { entity: [{
|
|
1143
|
+
args: [{ selector: 'ngx-mat-entity-input', template: "<div [ngSwitch]=\"type\" *ngIf=\"!(hideOmitForCreate && metadata.omitForCreate) && !(hideOmitForEdit && metadata.omitForUpdate)\">\n <!-------------------------------------------->\n <!-----------------Strings-------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.STRING\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString()\"\n #model=\"ngModel\"\n [required]=\"metadata.required\"\n [pattern]=\"metadataDefaultString.regex ? metadataDefaultString.regex : '[\\\\s\\\\S]*'\"\n [minlength]=\"metadataDefaultString.minLength ? metadataDefaultString.minLength : null\"\n [maxlength]=\"metadataDefaultString.maxLength ? metadataDefaultString.maxLength : null\"\n />\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.STRING_TEXTBOX\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <textarea\n matInput\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString()\"\n #model=\"ngModel\"\n cdkTextareaAutosize\n cdkAutosizeMinRows=\"10\"\n [required]=\"metadata.required\"\n [minlength]=\"metadataTextboxString.minLength ? metadataTextboxString.minLength : null\"\n [maxlength]=\"metadataTextboxString.maxLength ? metadataTextboxString.maxLength : null\"\n >\n </textarea>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.STRING_AUTOCOMPLETE\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString()\"\n #model=\"ngModel\"\n [matAutocomplete]=\"auto\"\n (keyup)=\"filterAutocompleteStrings(entity[propertyKey])\"\n [required]=\"metadata.required\"\n [minlength]=\"metadataAutocompleteString.minLength ? metadataAutocompleteString.minLength : null\"\n [maxlength]=\"metadataAutocompleteString.maxLength ? metadataAutocompleteString.maxLength : null\"\n [pattern]=\"metadataAutocompleteString.regex ? metadataAutocompleteString.regex : '[\\\\s\\\\S]*'\"\n />\n <mat-autocomplete #auto=\"matAutocomplete\">\n <mat-option *ngFor=\"let value of filteredAutocompleteStrings\" [value]=\"value\">\n {{value}}\n </mat-option>\n </mat-autocomplete>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.STRING_DROPDOWN\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-select [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\" [required]=\"metadata.required\">\n <mat-option *ngFor=\"let value of metadataDropdownString.dropdownValues\" [value]=\"value.value\">{{value.displayName}}</mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <!-------------------------------------------->\n <!-----------------Booleans------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.BOOLEAN_CHECKBOX\">\n <mat-form-field class=\"hideUnderline\">\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-checkbox (click)=\"model.control.markAsTouched()\" [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\"></mat-checkbox>\n <!-- hidden input is needed so that the checkbox can be used inside a mat-form-field -->\n <input matInput hidden\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString() + 'Helper'\"\n #model=\"ngModel\"\n [pattern]=\"metadata.required ? 'true' : '[\\\\s\\\\S]*'\"\n [required]=\"metadata.required\">\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.BOOLEAN_TOGGLE\">\n <mat-form-field class=\"hideUnderline\">\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-slide-toggle (click)=\"model.control.markAsTouched()\" [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\"></mat-slide-toggle>\n <!-- hidden input is needed so that the toggle can be used inside a mat-form-field -->\n <input matInput hidden\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString() + 'Helper'\"\n #model=\"ngModel\"\n [pattern]=\"metadata.required ? 'true' : '[\\\\s\\\\S]*'\"\n [required]=\"metadata.required\">\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.BOOLEAN_DROPDOWN\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-select [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\" [required]=\"metadata.required\">\n <mat-option [value]=\"undefined\">-</mat-option>\n <mat-option [value]=\"true\">{{metadataDropdownBoolean.dropdownTrue}}</mat-option>\n <mat-option [value]=\"false\">{{metadataDropdownBoolean.dropdownFalse}}</mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <!-------------------------------------------->\n <!------------------Numbers------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.NUMBER\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n type=\"number\"\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString()\"\n #model=\"ngModel\"\n [required]=\"metadata.required\"\n [min]=\"metadataDefaultNumber.min ? metadataDefaultNumber.min : null\"\n [max]=\"metadataDefaultNumber.max ? metadataDefaultNumber.max : null\"\n />\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.NUMBER_DROPDOWN\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-select [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\" [required]=\"metadata.required\">\n <mat-option *ngFor=\"let value of metadataDropdownNumber.dropdownValues\" [value]=\"value.value\">{{value.displayName}}</mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <!-------------------------------------------->\n <!-------------------Object------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.OBJECT\">\n <b>{{metadataDefaultObject.displayName}}</b>\n <!-- iterates over the object properties -->\n\n <div class=\"row\" *ngFor=\"let row of objectPropertyRows\">\n <!--\n displays another ngx-material-entity with the:\n object as the entity,\n the current key in the loop received by the keyvalue direction as the propertyKey\n and the getValidationErrorMessage of the current component\n -->\n <ngx-mat-entity-input\n *ngFor=\"let key of row.keys; let i = index; trackBy: trackByFn\"\n [entity]=\"objectProperty\"\n [propertyKey]=\"key\"\n [getValidationErrorMessage]=\"getValidationErrorMessage\"\n [hideOmitForCreate]=\"hideOmitForCreate\"\n [hideOmitForEdit]=\"hideOmitForEdit\"\n class=\"col-lg-{{getWidth(objectProperty, key, 'lg')}} col-md-{{getWidth(objectProperty, key, 'md')}} col-sm-{{getWidth(objectProperty, key, 'sm')}}\"\n >\n </ngx-mat-entity-input>\n </div>\n </div>\n\n <!-------------------------------------------->\n <!-------------------Array-------------------->\n <!-------------------------------------------->\n <div class=\"entityArray\" *ngSwitchCase=\"DecoratorTypes.ARRAY\">\n <div class=\"mat-elevation-z8\" style=\"border-radius: 5px;padding: 15px;margin-bottom: 15px;margin-top: 15px;\">\n\n <div style=\"padding-bottom: 10px\">\n <b>{{metadataEntityArray.displayName}}</b>\n </div>\n <div *ngIf=\"metadataEntityArray.createInline\">\n <div class=\"row\" *ngFor=\"let row of arrayItemInlineRows\">\n <ngx-mat-entity-input\n *ngFor=\"let key of row.keys; let i = index; trackBy: trackByFn\"\n [entity]=\"arrayItem\"\n [propertyKey]=\"key\"\n [hideOmitForCreate]=\"true\"\n [getValidationErrorMessage]=\"getValidationErrorMessage\"\n class=\"col-lg-{{getWidth(arrayItem, key, 'lg')}} col-md-{{getWidth(arrayItem, key, 'md')}} col-sm-{{getWidth(arrayItem, key, 'sm')}}\"\n >\n </ngx-mat-entity-input>\n </div>\n </div>\n \n <div class=\"buttons\">\n <button mat-raised-button\n [disabled]=\"metadataEntityArray.createInline && !EntityUtilities.isEntityValid(arrayItem, 'create')\"\n (click)=\"add()\">\n {{metadataEntityArray.addButtonLabel}}\n </button>\n <button mat-raised-button\n [disabled]=\"!selection.selected.length\"\n (click)=\"remove()\">\n {{metadataEntityArray.removeButtonLabel}}\n </button>\n </div>\n \n <mat-table [dataSource]=\"dataSource\">\n <!-- select Column -->\n <ng-container matColumnDef=\"select\">\n <mat-header-cell *matHeaderCellDef>\n <mat-checkbox [disabled]=\"!dataSource.data.length\" (change)=\"$event ? masterToggle() : null\" [checked]=\"selection.hasValue() && isAllSelected()\" [indeterminate]=\"selection.hasValue() && !isAllSelected()\"></mat-checkbox>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let module\" class=\"module\">\n <mat-checkbox (click)=\"$event.stopPropagation()\" (change)=\"$event ? selection.toggle(module) : null\" [checked]=\"selection.isSelected(module)\"></mat-checkbox>\n </mat-cell>\n </ng-container>\n \n <ng-container *ngFor=\"let dCol of metadataEntityArray.displayColumns\" [matColumnDef]=\"dCol.displayName\">\n <mat-header-cell *matHeaderCellDef>\n {{dCol.displayName}}\n </mat-header-cell>\n <mat-cell class=\"entity\" *matCellDef=\"let entity\">\n {{dCol.value(entity)}}\n </mat-cell>\n </ng-container>\n \n <mat-header-row *matHeaderRowDef=\"displayedColumns\"></mat-header-row>\n <mat-row *matRowDef=\"let row; columns: displayedColumns\"></mat-row>\n </mat-table>\n \n <div class=\"array-error\" *ngIf=\"metadataEntityArray.required && !dataSource.data.length\">\n {{metadataEntityArray.missingErrorMessage}}\n </div>\n </div>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.ARRAY_STRING_CHIPS\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-chip-list #chipList\n [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\"\n [required]=\"metadata.required\"\n >\n <mat-chip *ngFor=\"let value of stringChipsArrayValues\" (removed)=\"removeStringChipArrayValue(value)\">\n {{value}}\n <button matChipRemove>\n <i class=\"{{metadataStringChipsArray.deleteIcon}}\"></i>\n </button>\n </mat-chip>\n <input matInput\n [matChipInputFor]=\"chipList\"\n [matChipInputAddOnBlur]=\"true\"\n (matChipInputTokenEnd)=\"addStringChipArrayValue($event)\"\n [(ngModel)]=\"chipsInput\" [name]=\"propertyKey.toString()\" #chipsModel=\"ngModel\"\n [minlength]='metadataStringChipsArray.minLength ? metadataStringChipsArray.minLength : null'\n [maxlength]='metadataStringChipsArray.maxLength ? metadataStringChipsArray.maxLength : null'\n [pattern]=\"metadataStringChipsArray.regex ? metadataStringChipsArray.regex : '[\\\\s\\\\S]*'\"\n >\n <mat-error *ngIf=\"chipsModel.errors\">{{getValidationErrorMessage(chipsModel)}}</mat-error>\n </mat-chip-list>\n <mat-error *ngIf=\"!chipsModel.errors\">{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.ARRAY_STRING_AUTOCOMPLETE_CHIPS\">\n <mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-chip-list #chipList\n [(ngModel)]=\"entity[propertyKey]\" [name]=\"propertyKey.toString()\" #model=\"ngModel\"\n [required]=\"metadata.required\"\n >\n <mat-chip *ngFor=\"let value of stringChipsArrayValues\" (removed)=\"removeStringChipArrayValue(value)\">\n {{value}}\n <button matChipRemove>\n <i class=\"{{metadataStringChipsArray.deleteIcon}}\"></i>\n </button>\n </mat-chip>\n <input matInput\n [matChipInputFor]=\"chipList\"\n [matAutocomplete]=\"auto\"\n [matChipInputAddOnBlur]=\"true\"\n (matChipInputTokenEnd)=\"addStringChipArrayValue($event)\"\n (keyup)=\"filterAutocompleteStrings(chipsInput)\"\n [(ngModel)]=\"chipsInput\" [name]=\"propertyKey.toString()\" #chipsModel=\"ngModel\"\n #chipsElement\n [minlength]='metadataStringChipsArray.minLength ? metadataStringChipsArray.minLength : null'\n [maxlength]='metadataStringChipsArray.maxLength ? metadataStringChipsArray.maxLength : null'\n [pattern]=\"metadataStringChipsArray.regex ? metadataStringChipsArray.regex : '[\\\\s\\\\S]*'\"\n >\n <mat-error *ngIf=\"chipsModel.errors\">{{getValidationErrorMessage(chipsModel)}}</mat-error>\n </mat-chip-list>\n <mat-autocomplete #auto=\"matAutocomplete\" (optionSelected)=\"selected($event, chipsElement)\">\n <mat-option *ngFor=\"let value of filteredAutocompleteStrings\" [value]=\"value\">\n {{value}}\n </mat-option>\n </mat-autocomplete>\n <mat-error *ngIf=\"!chipsModel.errors\">{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchDefault>ERROR: The type {{type}} is not known.</div>\n</div>\n\n<!--------------------------------------------------------->\n<!--------------------Add Array Item Dialog---------------->\n<!--------------------------------------------------------->\n<ng-template #addArrayItemDialog>\n <h2 mat-dialog-title>{{dialogData.createDialogData.title}}</h2>\n\n <mat-dialog-content>\n <form #form=\"ngForm\" class=\"row\">\n <div class=\"row\" *ngFor=\"let row of arrayItemDialogRows\">\n <ngx-mat-entity-input\n *ngFor=\"let key of row.keys\"\n [entity]=\"dialogData.entity\"\n [propertyKey]=\"key\"\n [hideOmitForCreate]=\"true\"\n [getValidationErrorMessage]=\"dialogData.getValidationErrorMessage\"\n class=\"col-lg-{{getWidth(dialogData.entity, key, 'lg')}} col-md-{{getWidth(dialogData.entity, key, 'md')}} col-sm-{{getWidth(dialogData.entity, key, 'sm')}}\"\n >\n </ngx-mat-entity-input>\n </div>\n </form>\n </mat-dialog-content>\n\n <mat-dialog-actions>\n <button mat-raised-button (click)=\"addArrayItem()\" [disabled]=\"!EntityUtilities.isEntityValid(dialogData.entity, 'create')\">\n {{dialogData.createDialogData.createButtonLabel}}\n </button>\n <button mat-raised-button (click)=\"cancelAddArrayItem()\" class=\"cancel-button\">\n {{dialogData.createDialogData.cancelButtonLabel}}\n </button>\n </mat-dialog-actions>\n\n</ng-template>", styles: ["mat-form-field{width:100%}::ng-deep .hideUnderline .mat-form-field-underline{opacity:0%}.entityArray .buttons{display:flex;justify-content:space-between;margin-bottom:10px;margin-top:5px}.entityArray mat-table{border:1px solid #E0E0E0;border-radius:5px;padding-top:5px;padding-bottom:25px}.entityArray .mat-column-select{flex:0 0 75px}.entityArray .array-error{display:flex;align-items:center;justify-content:center;margin-top:-25.8px;border:1px solid #E0E0E0;background-color:#f8d3d7;color:#721c24;height:25.8px;border-bottom-left-radius:5px;border-bottom-right-radius:5px}\n"] }]
|
|
1144
|
+
}], ctorParameters: function () { return [{ type: i1.MatDialog }]; }, propDecorators: { entity: [{
|
|
965
1145
|
type: Input
|
|
966
1146
|
}], propertyKey: [{
|
|
967
1147
|
type: Input
|
|
@@ -971,11 +1151,100 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
|
|
|
971
1151
|
type: Input
|
|
972
1152
|
}], hideOmitForEdit: [{
|
|
973
1153
|
type: Input
|
|
1154
|
+
}], addArrayItemDialog: [{
|
|
1155
|
+
type: ViewChild,
|
|
1156
|
+
args: ['addArrayItemDialog']
|
|
974
1157
|
}] } });
|
|
975
1158
|
|
|
1159
|
+
class NgxMatEntityInputModule {
|
|
1160
|
+
}
|
|
1161
|
+
NgxMatEntityInputModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityInputModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1162
|
+
NgxMatEntityInputModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityInputModule, declarations: [NgxMatEntityInputComponent], imports: [CommonModule,
|
|
1163
|
+
MatInputModule,
|
|
1164
|
+
FormsModule,
|
|
1165
|
+
MatFormFieldModule,
|
|
1166
|
+
MatSelectModule,
|
|
1167
|
+
MatAutocompleteModule,
|
|
1168
|
+
MatCheckboxModule,
|
|
1169
|
+
MatSlideToggleModule,
|
|
1170
|
+
MatChipsModule,
|
|
1171
|
+
MatIconModule,
|
|
1172
|
+
MatTableModule,
|
|
1173
|
+
MatDialogModule,
|
|
1174
|
+
MatButtonModule], exports: [NgxMatEntityInputComponent] });
|
|
1175
|
+
NgxMatEntityInputModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityInputModule, imports: [[
|
|
1176
|
+
CommonModule,
|
|
1177
|
+
MatInputModule,
|
|
1178
|
+
FormsModule,
|
|
1179
|
+
MatFormFieldModule,
|
|
1180
|
+
MatSelectModule,
|
|
1181
|
+
MatAutocompleteModule,
|
|
1182
|
+
MatCheckboxModule,
|
|
1183
|
+
MatSlideToggleModule,
|
|
1184
|
+
MatChipsModule,
|
|
1185
|
+
MatIconModule,
|
|
1186
|
+
MatTableModule,
|
|
1187
|
+
MatDialogModule,
|
|
1188
|
+
MatButtonModule
|
|
1189
|
+
]] });
|
|
1190
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityInputModule, decorators: [{
|
|
1191
|
+
type: NgModule,
|
|
1192
|
+
args: [{
|
|
1193
|
+
declarations: [
|
|
1194
|
+
NgxMatEntityInputComponent,
|
|
1195
|
+
],
|
|
1196
|
+
imports: [
|
|
1197
|
+
CommonModule,
|
|
1198
|
+
MatInputModule,
|
|
1199
|
+
FormsModule,
|
|
1200
|
+
MatFormFieldModule,
|
|
1201
|
+
MatSelectModule,
|
|
1202
|
+
MatAutocompleteModule,
|
|
1203
|
+
MatCheckboxModule,
|
|
1204
|
+
MatSlideToggleModule,
|
|
1205
|
+
MatChipsModule,
|
|
1206
|
+
MatIconModule,
|
|
1207
|
+
MatTableModule,
|
|
1208
|
+
MatDialogModule,
|
|
1209
|
+
MatButtonModule
|
|
1210
|
+
],
|
|
1211
|
+
exports: [NgxMatEntityInputComponent]
|
|
1212
|
+
}]
|
|
1213
|
+
}] });
|
|
1214
|
+
|
|
1215
|
+
/**
|
|
1216
|
+
* The internal CreateEntityDialogData. Requires all default values the user can leave out.
|
|
1217
|
+
*/
|
|
1218
|
+
class CreateEntityDialogDataInternal {
|
|
1219
|
+
constructor(entity, EntityServiceClass, createDialogData) {
|
|
1220
|
+
this.entity = entity;
|
|
1221
|
+
this.EntityServiceClass = EntityServiceClass;
|
|
1222
|
+
this.createDialogData = createDialogData;
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
/**
|
|
1226
|
+
* The Builder for the CreateEntityDialogData. Sets default values.
|
|
1227
|
+
*/
|
|
1228
|
+
class CreateEntityDialogDataBuilder extends BaseBuilder {
|
|
1229
|
+
constructor(data) {
|
|
1230
|
+
super(data);
|
|
1231
|
+
}
|
|
1232
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
1233
|
+
generateBaseData(data) {
|
|
1234
|
+
const createDialogData = new CreateDialogDataBuilder(data.createDialogData).getResult();
|
|
1235
|
+
return new CreateEntityDialogDataInternal(data.entity, data.EntityServiceClass, createDialogData);
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
/**
|
|
1240
|
+
* The default dialog used to create new entities based on the configuration passed in the MAT_DIALOG_DATA "inputData".
|
|
1241
|
+
* Used by the ngx-mat-entity-table.
|
|
1242
|
+
*
|
|
1243
|
+
* It offers a lot of customization options which can be found in "CreateEntityDialogData".
|
|
1244
|
+
*/
|
|
976
1245
|
class NgxMatEntityCreateDialogComponent {
|
|
977
|
-
constructor(
|
|
978
|
-
this.
|
|
1246
|
+
constructor(inputData, dialogRef, injector, dialog) {
|
|
1247
|
+
this.inputData = inputData;
|
|
979
1248
|
this.dialogRef = dialogRef;
|
|
980
1249
|
this.injector = injector;
|
|
981
1250
|
this.dialog = dialog;
|
|
@@ -983,42 +1252,31 @@ class NgxMatEntityCreateDialogComponent {
|
|
|
983
1252
|
this.getWidth = EntityUtilities.getWidth;
|
|
984
1253
|
}
|
|
985
1254
|
ngOnInit() {
|
|
1255
|
+
this.data = new CreateEntityDialogDataBuilder(this.inputData).getResult();
|
|
986
1256
|
this.dialogRef.disableClose = true;
|
|
987
|
-
this.
|
|
1257
|
+
this.entityRows = EntityUtilities.getEntityRows(this.data.entity, true);
|
|
988
1258
|
this.entityService = this.injector.get(this.data.EntityServiceClass);
|
|
989
1259
|
}
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
.sort((a, b) => EntityUtilities.compareOrder(a, b, this.data.entity));
|
|
995
|
-
}
|
|
1260
|
+
/**
|
|
1261
|
+
* Tries add the new entity and close the dialog afterwards.
|
|
1262
|
+
* Also handles the confirmation if required.
|
|
1263
|
+
*/
|
|
996
1264
|
create() {
|
|
997
|
-
var _a, _b
|
|
998
|
-
if (this.data.createDialogData
|
|
1265
|
+
var _a, _b;
|
|
1266
|
+
if (!((_a = this.data.createDialogData) === null || _a === void 0 ? void 0 : _a.createRequiresConfirmDialog)) {
|
|
999
1267
|
return this.confirmCreate();
|
|
1000
1268
|
}
|
|
1001
|
-
const dialogData =
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
// eslint-disable-next-line max-len
|
|
1008
|
-
cancelButtonLabel: ((_e = this.data.createDialogData.confirmCreateDialogData) === null || _e === void 0 ? void 0 : _e.cancelButtonLabel) ? (_f = this.data.createDialogData.confirmCreateDialogData) === null || _f === void 0 ? void 0 : _f.cancelButtonLabel : 'Cancel',
|
|
1009
|
-
// eslint-disable-next-line max-len
|
|
1010
|
-
title: ((_g = this.data.createDialogData.confirmCreateDialogData) === null || _g === void 0 ? void 0 : _g.title) ? (_h = this.data.createDialogData.confirmCreateDialogData) === null || _h === void 0 ? void 0 : _h.title : 'Create',
|
|
1011
|
-
// eslint-disable-next-line max-len
|
|
1012
|
-
requireConfirmation: ((_j = this.data.createDialogData.confirmCreateDialogData) === null || _j === void 0 ? void 0 : _j.requireConfirmation) ? (_k = this.data.createDialogData.confirmCreateDialogData) === null || _k === void 0 ? void 0 : _k.requireConfirmation : false,
|
|
1013
|
-
// eslint-disable-next-line max-len
|
|
1014
|
-
confirmationText: ((_l = this.data.createDialogData.confirmCreateDialogData) === null || _l === void 0 ? void 0 : _l.confirmationText) ? (_m = this.data.createDialogData.confirmCreateDialogData) === null || _m === void 0 ? void 0 : _m.confirmationText : undefined,
|
|
1015
|
-
};
|
|
1016
|
-
const dialogref = this.dialog.open(NgxMatEntityConfirmDialogComponent, {
|
|
1269
|
+
const dialogData = new ConfirmDialogDataBuilder((_b = this.data.createDialogData) === null || _b === void 0 ? void 0 : _b.confirmCreateDialogData)
|
|
1270
|
+
.withDefault('text', ['Do you really want to create this entity?'])
|
|
1271
|
+
.withDefault('confirmButtonLabel', 'Create')
|
|
1272
|
+
.withDefault('title', 'Create')
|
|
1273
|
+
.getResult();
|
|
1274
|
+
const dialogRef = this.dialog.open(NgxMatEntityConfirmDialogComponent, {
|
|
1017
1275
|
data: dialogData,
|
|
1018
1276
|
autoFocus: false,
|
|
1019
1277
|
restoreFocus: false
|
|
1020
1278
|
});
|
|
1021
|
-
|
|
1279
|
+
dialogRef.afterClosed().subscribe((res) => {
|
|
1022
1280
|
if (res === 1) {
|
|
1023
1281
|
this.confirmCreate();
|
|
1024
1282
|
}
|
|
@@ -1027,15 +1285,18 @@ class NgxMatEntityCreateDialogComponent {
|
|
|
1027
1285
|
confirmCreate() {
|
|
1028
1286
|
this.entityService.create(this.data.entity).then(() => this.dialogRef.close());
|
|
1029
1287
|
}
|
|
1288
|
+
/**
|
|
1289
|
+
* Closes the dialog.
|
|
1290
|
+
*/
|
|
1030
1291
|
cancel() {
|
|
1031
1292
|
this.dialogRef.close();
|
|
1032
1293
|
}
|
|
1033
1294
|
}
|
|
1034
1295
|
NgxMatEntityCreateDialogComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityCreateDialogComponent, deps: [{ token: MAT_DIALOG_DATA }, { token: i1.MatDialogRef }, { token: i0.Injector }, { token: i1.MatDialog }], target: i0.ɵɵFactoryTarget.Component });
|
|
1035
|
-
NgxMatEntityCreateDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: NgxMatEntityCreateDialogComponent, selector: "ngx-mat-entity-create-dialog", ngImport: i0, template: "<h2 mat-dialog-title>{{data.createDialogData.title}}</h2>\n\n<mat-dialog-content>\n <form #form=\"ngForm\" class=\"row\">\n
|
|
1296
|
+
NgxMatEntityCreateDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: NgxMatEntityCreateDialogComponent, selector: "ngx-mat-entity-create-dialog", ngImport: i0, template: "<h2 mat-dialog-title>{{data.createDialogData.title}}</h2>\n\n<mat-dialog-content>\n <form #form=\"ngForm\">\n <div class=\"row\" *ngFor=\"let row of entityRows\">\n <ngx-mat-entity-input\n *ngFor=\"let key of row.keys\"\n [entity]=\"data.entity\"\n [propertyKey]=\"key\"\n [hideOmitForCreate]=\"true\"\n class=\"col-lg-{{getWidth(data.entity, key, 'lg')}} col-md-{{getWidth(data.entity, key, 'md')}} col-sm-{{getWidth(data.entity, key, 'sm')}}\"\n >\n </ngx-mat-entity-input>\n </div>\n </form>\n</mat-dialog-content>\n\n<mat-dialog-actions>\n <button mat-raised-button (click)=\"create()\" [disabled]=\"!EntityUtilities.isEntityValid(data.entity, 'create')\">\n {{data.createDialogData.createButtonLabel}}\n </button>\n <button mat-raised-button (click)=\"cancel()\" class=\"cancel-button\">\n {{data.createDialogData.cancelButtonLabel}}\n </button>\n</mat-dialog-actions>\n", styles: ["mat-dialog-actions{display:flex;justify-content:space-between}\n"], components: [{ type: NgxMatEntityInputComponent, selector: "ngx-mat-entity-input", inputs: ["entity", "propertyKey", "getValidationErrorMessage", "hideOmitForCreate", "hideOmitForEdit"] }, { type: i3.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i1.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { type: i1.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { type: i13.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i13.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i13.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i11.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i1.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]" }] });
|
|
1036
1297
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityCreateDialogComponent, decorators: [{
|
|
1037
1298
|
type: Component,
|
|
1038
|
-
args: [{ selector: 'ngx-mat-entity-create-dialog', template: "<h2 mat-dialog-title>{{data.createDialogData.title}}</h2>\n\n<mat-dialog-content>\n <form #form=\"ngForm\" class=\"row\">\n
|
|
1299
|
+
args: [{ selector: 'ngx-mat-entity-create-dialog', template: "<h2 mat-dialog-title>{{data.createDialogData.title}}</h2>\n\n<mat-dialog-content>\n <form #form=\"ngForm\">\n <div class=\"row\" *ngFor=\"let row of entityRows\">\n <ngx-mat-entity-input\n *ngFor=\"let key of row.keys\"\n [entity]=\"data.entity\"\n [propertyKey]=\"key\"\n [hideOmitForCreate]=\"true\"\n class=\"col-lg-{{getWidth(data.entity, key, 'lg')}} col-md-{{getWidth(data.entity, key, 'md')}} col-sm-{{getWidth(data.entity, key, 'sm')}}\"\n >\n </ngx-mat-entity-input>\n </div>\n </form>\n</mat-dialog-content>\n\n<mat-dialog-actions>\n <button mat-raised-button (click)=\"create()\" [disabled]=\"!EntityUtilities.isEntityValid(data.entity, 'create')\">\n {{data.createDialogData.createButtonLabel}}\n </button>\n <button mat-raised-button (click)=\"cancel()\" class=\"cancel-button\">\n {{data.createDialogData.cancelButtonLabel}}\n </button>\n</mat-dialog-actions>\n", styles: ["mat-dialog-actions{display:flex;justify-content:space-between}\n"] }]
|
|
1039
1300
|
}], ctorParameters: function () {
|
|
1040
1301
|
return [{ type: undefined, decorators: [{
|
|
1041
1302
|
type: Inject,
|
|
@@ -1043,9 +1304,79 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
|
|
|
1043
1304
|
}] }, { type: i1.MatDialogRef }, { type: i0.Injector }, { type: i1.MatDialog }];
|
|
1044
1305
|
} });
|
|
1045
1306
|
|
|
1307
|
+
/**
|
|
1308
|
+
* The internal EditDialogData. Requires all default values the user can leave out.
|
|
1309
|
+
*/
|
|
1310
|
+
class EditDialogDataInternal {
|
|
1311
|
+
constructor(title, confirmButtonLabel, deleteButtonLabel, cancelButtonLabel, deleteRequiresConfirmDialog, editRequiresConfirmDialog, confirmDeleteDialogData, confirmEditDialogData) {
|
|
1312
|
+
this.title = title;
|
|
1313
|
+
this.confirmButtonLabel = confirmButtonLabel;
|
|
1314
|
+
this.deleteButtonLabel = deleteButtonLabel;
|
|
1315
|
+
this.cancelButtonLabel = cancelButtonLabel;
|
|
1316
|
+
this.deleteRequiresConfirmDialog = deleteRequiresConfirmDialog;
|
|
1317
|
+
this.editRequiresConfirmDialog = editRequiresConfirmDialog;
|
|
1318
|
+
this.confirmDeleteDialogData = confirmDeleteDialogData;
|
|
1319
|
+
this.confirmEditDialogData = confirmEditDialogData;
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
/**
|
|
1323
|
+
* The Builder for the EditDialogData. Sets default values.
|
|
1324
|
+
*/
|
|
1325
|
+
class EditDialogDataBuilder extends BaseBuilder {
|
|
1326
|
+
constructor(data) {
|
|
1327
|
+
super(data);
|
|
1328
|
+
}
|
|
1329
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
1330
|
+
generateBaseData(data) {
|
|
1331
|
+
const confirmEditDialogData = new ConfirmDialogDataBuilder(data === null || data === void 0 ? void 0 : data.confirmEditDialogData)
|
|
1332
|
+
.withDefault('confirmButtonLabel', 'Save')
|
|
1333
|
+
.withDefault('text', ['Do you really want to save all changes?'])
|
|
1334
|
+
.withDefault('title', 'Edit')
|
|
1335
|
+
.getResult();
|
|
1336
|
+
const confirmDeleteDialogData = new ConfirmDialogDataBuilder(data === null || data === void 0 ? void 0 : data.confirmDeleteDialogData)
|
|
1337
|
+
.withDefault('confirmButtonLabel', 'Delete')
|
|
1338
|
+
.withDefault('type', 'delete')
|
|
1339
|
+
.withDefault('text', ['Do you really want to delete this entity?'])
|
|
1340
|
+
.withDefault('title', 'Delete')
|
|
1341
|
+
.getResult();
|
|
1342
|
+
return new EditDialogDataInternal((data === null || data === void 0 ? void 0 : data.title) ? data.title : () => 'Edit', (data === null || data === void 0 ? void 0 : data.confirmButtonLabel) ? data.confirmButtonLabel : 'Save', (data === null || data === void 0 ? void 0 : data.deleteButtonLabel) ? data.deleteButtonLabel : 'Delete', (data === null || data === void 0 ? void 0 : data.cancelButtonLabel) ? data.cancelButtonLabel : 'Cancel', (data === null || data === void 0 ? void 0 : data.deleteRequiresConfirmDialog) ? data.deleteRequiresConfirmDialog : true, (data === null || data === void 0 ? void 0 : data.editRequiresConfirmDialog) ? data.editRequiresConfirmDialog : false, confirmDeleteDialogData, confirmEditDialogData);
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
/**
|
|
1347
|
+
* The internal EditEntityDialogData. Requires all default values the user can leave out.
|
|
1348
|
+
*/
|
|
1349
|
+
class EditEntityDialogDataInternal {
|
|
1350
|
+
constructor(entity, EntityServiceClass, editDialogData, allowDelete) {
|
|
1351
|
+
this.entity = entity;
|
|
1352
|
+
this.EntityServiceClass = EntityServiceClass;
|
|
1353
|
+
this.editDialogData = editDialogData;
|
|
1354
|
+
this.allowDelete = allowDelete;
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
/**
|
|
1358
|
+
* The Builder for the EditEntityDialogData. Sets default values.
|
|
1359
|
+
*/
|
|
1360
|
+
class EditEntityDialogDataBuilder extends BaseBuilder {
|
|
1361
|
+
constructor(data) {
|
|
1362
|
+
super(data);
|
|
1363
|
+
}
|
|
1364
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
1365
|
+
generateBaseData(data) {
|
|
1366
|
+
const editDialogData = new EditDialogDataBuilder(data.editDialogData).getResult();
|
|
1367
|
+
return new EditEntityDialogDataInternal(data.entity, data.EntityServiceClass, editDialogData, data.allowDelete ? data.allowDelete : () => true);
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
/**
|
|
1372
|
+
* The default dialog used to edit an existing entity based on the configuration passed in the MAT_DIALOG_DATA "inputData".
|
|
1373
|
+
* Used by the ngx-mat-entity-table.
|
|
1374
|
+
*
|
|
1375
|
+
* It offers a lot of customization options which can be found in "EditEntityDialogData".
|
|
1376
|
+
*/
|
|
1046
1377
|
class NgxMatEntityEditDialogComponent {
|
|
1047
|
-
constructor(
|
|
1048
|
-
this.
|
|
1378
|
+
constructor(inputData, dialogRef, injector, dialog) {
|
|
1379
|
+
this.inputData = inputData;
|
|
1049
1380
|
this.dialogRef = dialogRef;
|
|
1050
1381
|
this.injector = injector;
|
|
1051
1382
|
this.dialog = dialog;
|
|
@@ -1053,42 +1384,31 @@ class NgxMatEntityEditDialogComponent {
|
|
|
1053
1384
|
this.getWidth = EntityUtilities.getWidth;
|
|
1054
1385
|
}
|
|
1055
1386
|
ngOnInit() {
|
|
1387
|
+
this.data = new EditEntityDialogDataBuilder(this.inputData).getResult();
|
|
1056
1388
|
this.dialogRef.disableClose = true;
|
|
1057
|
-
this.
|
|
1389
|
+
this.entityRows = EntityUtilities.getEntityRows(this.data.entity, false, true);
|
|
1058
1390
|
this.entityService = this.injector.get(this.data.EntityServiceClass);
|
|
1059
1391
|
this.entityPriorChanges = cloneDeep(this.data.entity);
|
|
1060
1392
|
}
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
.sort((a, b) => EntityUtilities.compareOrder(a, b, this.data.entity));
|
|
1066
|
-
}
|
|
1393
|
+
/**
|
|
1394
|
+
* Tries to save the changes and close the dialog afterwards.
|
|
1395
|
+
* Also handles the confirmation if required.
|
|
1396
|
+
*/
|
|
1067
1397
|
edit() {
|
|
1068
|
-
|
|
1069
|
-
if (this.data.editDialogData.editRequiresConfirmDialog === false) {
|
|
1398
|
+
if (!this.data.editDialogData.editRequiresConfirmDialog) {
|
|
1070
1399
|
return this.confirmEdit();
|
|
1071
1400
|
}
|
|
1072
|
-
const dialogData =
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
// eslint-disable-next-line max-len
|
|
1079
|
-
cancelButtonLabel: ((_e = this.data.editDialogData.confirmEditDialogData) === null || _e === void 0 ? void 0 : _e.cancelButtonLabel) ? (_f = this.data.editDialogData.confirmEditDialogData) === null || _f === void 0 ? void 0 : _f.cancelButtonLabel : 'Cancel',
|
|
1080
|
-
title: ((_g = this.data.editDialogData.confirmEditDialogData) === null || _g === void 0 ? void 0 : _g.title) ? (_h = this.data.editDialogData.confirmEditDialogData) === null || _h === void 0 ? void 0 : _h.title : 'Edit',
|
|
1081
|
-
// eslint-disable-next-line max-len
|
|
1082
|
-
requireConfirmation: ((_j = this.data.editDialogData.confirmEditDialogData) === null || _j === void 0 ? void 0 : _j.requireConfirmation) ? (_k = this.data.editDialogData.confirmEditDialogData) === null || _k === void 0 ? void 0 : _k.requireConfirmation : false,
|
|
1083
|
-
// eslint-disable-next-line max-len
|
|
1084
|
-
confirmationText: ((_l = this.data.editDialogData.confirmEditDialogData) === null || _l === void 0 ? void 0 : _l.confirmationText) ? (_m = this.data.editDialogData.confirmEditDialogData) === null || _m === void 0 ? void 0 : _m.confirmationText : undefined,
|
|
1085
|
-
};
|
|
1086
|
-
const dialogref = this.dialog.open(NgxMatEntityConfirmDialogComponent, {
|
|
1401
|
+
const dialogData = new ConfirmDialogDataBuilder(this.data.editDialogData.confirmEditDialogData)
|
|
1402
|
+
.withDefault('text', ['Do you really want to save all changes?'])
|
|
1403
|
+
.withDefault('confirmButtonLabel', 'Save')
|
|
1404
|
+
.withDefault('title', 'Edit')
|
|
1405
|
+
.getResult();
|
|
1406
|
+
const dialogRef = this.dialog.open(NgxMatEntityConfirmDialogComponent, {
|
|
1087
1407
|
data: dialogData,
|
|
1088
1408
|
autoFocus: false,
|
|
1089
1409
|
restoreFocus: false
|
|
1090
1410
|
});
|
|
1091
|
-
|
|
1411
|
+
dialogRef.afterClosed().subscribe((res) => {
|
|
1092
1412
|
if (res === 1) {
|
|
1093
1413
|
this.confirmEdit();
|
|
1094
1414
|
}
|
|
@@ -1097,32 +1417,26 @@ class NgxMatEntityEditDialogComponent {
|
|
|
1097
1417
|
confirmEdit() {
|
|
1098
1418
|
this.entityService.update(this.data.entity, this.entityPriorChanges).then(() => this.dialogRef.close(1));
|
|
1099
1419
|
}
|
|
1420
|
+
/**
|
|
1421
|
+
* Tries to delete the entity and close the dialog afterwards.
|
|
1422
|
+
* Also handles the confirmation if required.
|
|
1423
|
+
*/
|
|
1100
1424
|
delete() {
|
|
1101
|
-
|
|
1102
|
-
if (this.data.editDialogData.deleteRequiresConfirmDialog === false) {
|
|
1425
|
+
if (!this.data.editDialogData.deleteRequiresConfirmDialog) {
|
|
1103
1426
|
return this.confirmDelete();
|
|
1104
1427
|
}
|
|
1105
|
-
const dialogData =
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
cancelButtonLabel: ((_e = this.data.editDialogData.confirmDeleteDialogData) === null || _e === void 0 ? void 0 : _e.cancelButtonLabel) ? (_f = this.data.editDialogData.confirmDeleteDialogData) === null || _f === void 0 ? void 0 : _f.cancelButtonLabel : 'Cancel',
|
|
1113
|
-
// eslint-disable-next-line max-len
|
|
1114
|
-
title: ((_g = this.data.editDialogData.confirmDeleteDialogData) === null || _g === void 0 ? void 0 : _g.title) ? (_h = this.data.editDialogData.confirmDeleteDialogData) === null || _h === void 0 ? void 0 : _h.title : 'Delete',
|
|
1115
|
-
// eslint-disable-next-line max-len
|
|
1116
|
-
requireConfirmation: ((_j = this.data.editDialogData.confirmDeleteDialogData) === null || _j === void 0 ? void 0 : _j.requireConfirmation) ? (_k = this.data.editDialogData.confirmDeleteDialogData) === null || _k === void 0 ? void 0 : _k.requireConfirmation : false,
|
|
1117
|
-
// eslint-disable-next-line max-len
|
|
1118
|
-
confirmationText: ((_l = this.data.editDialogData.confirmDeleteDialogData) === null || _l === void 0 ? void 0 : _l.confirmationText) ? (_m = this.data.editDialogData.confirmDeleteDialogData) === null || _m === void 0 ? void 0 : _m.confirmationText : undefined,
|
|
1119
|
-
};
|
|
1120
|
-
const dialogref = this.dialog.open(NgxMatEntityConfirmDialogComponent, {
|
|
1428
|
+
const dialogData = new ConfirmDialogDataBuilder(this.data.editDialogData.confirmDeleteDialogData)
|
|
1429
|
+
.withDefault('text', ['Do you really want to delete this entity?'])
|
|
1430
|
+
.withDefault('type', 'delete')
|
|
1431
|
+
.withDefault('confirmButtonLabel', 'Delete')
|
|
1432
|
+
.withDefault('title', 'Delete')
|
|
1433
|
+
.getResult();
|
|
1434
|
+
const dialogRef = this.dialog.open(NgxMatEntityConfirmDialogComponent, {
|
|
1121
1435
|
data: dialogData,
|
|
1122
1436
|
autoFocus: false,
|
|
1123
1437
|
restoreFocus: false
|
|
1124
1438
|
});
|
|
1125
|
-
|
|
1439
|
+
dialogRef.afterClosed().subscribe((res) => {
|
|
1126
1440
|
if (res === 1) {
|
|
1127
1441
|
this.confirmDelete();
|
|
1128
1442
|
}
|
|
@@ -1131,16 +1445,19 @@ class NgxMatEntityEditDialogComponent {
|
|
|
1131
1445
|
confirmDelete() {
|
|
1132
1446
|
this.entityService.delete(this.entityPriorChanges.id).then(() => this.dialogRef.close(2));
|
|
1133
1447
|
}
|
|
1448
|
+
/**
|
|
1449
|
+
* Reverts all changes made and closes the dialog.
|
|
1450
|
+
*/
|
|
1134
1451
|
cancel() {
|
|
1135
1452
|
EntityUtilities.resetChangesOnEntity(this.data.entity, this.entityPriorChanges);
|
|
1136
1453
|
this.dialogRef.close(0);
|
|
1137
1454
|
}
|
|
1138
1455
|
}
|
|
1139
1456
|
NgxMatEntityEditDialogComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityEditDialogComponent, deps: [{ token: MAT_DIALOG_DATA }, { token: i1.MatDialogRef }, { token: i0.Injector }, { token: i1.MatDialog }], target: i0.ɵɵFactoryTarget.Component });
|
|
1140
|
-
NgxMatEntityEditDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: NgxMatEntityEditDialogComponent, selector: "ngx-mat-entity-edit-dialog", ngImport: i0, template: "<h2 mat-dialog-title>\n {{data.editDialogData.title(data.entity)}}\n <button *ngIf=\"data.allowDelete(data.entity)\" mat-raised-button (click)=\"delete()\" color=\"warn\" class=\"delete-button\" tabindex=\"-1\">\n {{data.editDialogData.deleteButtonLabel
|
|
1457
|
+
NgxMatEntityEditDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: NgxMatEntityEditDialogComponent, selector: "ngx-mat-entity-edit-dialog", ngImport: i0, template: "<h2 mat-dialog-title>\n {{data.editDialogData.title(data.entity)}}\n <button *ngIf=\"data.allowDelete(data.entity)\" mat-raised-button (click)=\"delete()\" color=\"warn\" class=\"delete-button\" tabindex=\"-1\">\n {{data.editDialogData.deleteButtonLabel}}\n </button>\n</h2>\n\n<mat-dialog-content>\n <form #form=\"ngForm\" class=\"row\">\n <div class=\"row\" *ngFor=\"let row of entityRows\">\n <ngx-mat-entity-input\n *ngFor=\"let key of row.keys\"\n [entity]=\"data.entity\"\n [propertyKey]=\"key\"\n [hideOmitForEdit]=\"true\"\n class=\"col-lg-{{getWidth(data.entity, key, 'lg')}} col-md-{{getWidth(data.entity, key, 'md')}} col-sm-{{getWidth(data.entity, key, 'sm')}}\"\n >\n </ngx-mat-entity-input>\n </div>\n </form>\n</mat-dialog-content>\n\n<mat-dialog-actions>\n <button mat-raised-button (click)=\"edit()\" [disabled]=\"!EntityUtilities.isEntityValid(data.entity, 'update') || !EntityUtilities.dirty(data.entity, entityPriorChanges)\">\n {{data.editDialogData.confirmButtonLabel}}\n </button>\n <button mat-raised-button (click)=\"cancel()\" class=\"cancel-button\">\n {{data.editDialogData.cancelButtonLabel}}\n </button>\n</mat-dialog-actions>\n", styles: ["mat-dialog-actions{display:flex;justify-content:space-between}.delete-button{float:right}\n"], components: [{ type: i3.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: NgxMatEntityInputComponent, selector: "ngx-mat-entity-input", inputs: ["entity", "propertyKey", "getValidationErrorMessage", "hideOmitForCreate", "hideOmitForEdit"] }], directives: [{ type: i1.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { type: i11.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { type: i13.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i13.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i13.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i11.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i1.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]" }] });
|
|
1141
1458
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityEditDialogComponent, decorators: [{
|
|
1142
1459
|
type: Component,
|
|
1143
|
-
args: [{ selector: 'ngx-mat-entity-edit-dialog', template: "<h2 mat-dialog-title>\n {{data.editDialogData.title(data.entity)}}\n <button *ngIf=\"data.allowDelete(data.entity)\" mat-raised-button (click)=\"delete()\" color=\"warn\" class=\"delete-button\" tabindex=\"-1\">\n {{data.editDialogData.deleteButtonLabel
|
|
1460
|
+
args: [{ selector: 'ngx-mat-entity-edit-dialog', template: "<h2 mat-dialog-title>\n {{data.editDialogData.title(data.entity)}}\n <button *ngIf=\"data.allowDelete(data.entity)\" mat-raised-button (click)=\"delete()\" color=\"warn\" class=\"delete-button\" tabindex=\"-1\">\n {{data.editDialogData.deleteButtonLabel}}\n </button>\n</h2>\n\n<mat-dialog-content>\n <form #form=\"ngForm\" class=\"row\">\n <div class=\"row\" *ngFor=\"let row of entityRows\">\n <ngx-mat-entity-input\n *ngFor=\"let key of row.keys\"\n [entity]=\"data.entity\"\n [propertyKey]=\"key\"\n [hideOmitForEdit]=\"true\"\n class=\"col-lg-{{getWidth(data.entity, key, 'lg')}} col-md-{{getWidth(data.entity, key, 'md')}} col-sm-{{getWidth(data.entity, key, 'sm')}}\"\n >\n </ngx-mat-entity-input>\n </div>\n </form>\n</mat-dialog-content>\n\n<mat-dialog-actions>\n <button mat-raised-button (click)=\"edit()\" [disabled]=\"!EntityUtilities.isEntityValid(data.entity, 'update') || !EntityUtilities.dirty(data.entity, entityPriorChanges)\">\n {{data.editDialogData.confirmButtonLabel}}\n </button>\n <button mat-raised-button (click)=\"cancel()\" class=\"cancel-button\">\n {{data.editDialogData.cancelButtonLabel}}\n </button>\n</mat-dialog-actions>\n", styles: ["mat-dialog-actions{display:flex;justify-content:space-between}.delete-button{float:right}\n"] }]
|
|
1144
1461
|
}], ctorParameters: function () {
|
|
1145
1462
|
return [{ type: undefined, decorators: [{
|
|
1146
1463
|
type: Inject,
|
|
@@ -1148,6 +1465,115 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
|
|
|
1148
1465
|
}] }, { type: i1.MatDialogRef }, { type: i0.Injector }, { type: i1.MatDialog }];
|
|
1149
1466
|
} });
|
|
1150
1467
|
|
|
1468
|
+
/**
|
|
1469
|
+
* The internal TableData. Requires all default values the user can leave out.
|
|
1470
|
+
*/
|
|
1471
|
+
class TableDataInternal {
|
|
1472
|
+
constructor(baseData, createDialogData, editDialogData) {
|
|
1473
|
+
this.baseData = baseData;
|
|
1474
|
+
this.createDialogData = createDialogData;
|
|
1475
|
+
this.editDialogData = editDialogData;
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
/**
|
|
1479
|
+
* The Builder for the table BaseData. Sets default values.
|
|
1480
|
+
*/
|
|
1481
|
+
class BaseDataBuilder extends BaseBuilder {
|
|
1482
|
+
constructor(data) {
|
|
1483
|
+
super(data);
|
|
1484
|
+
}
|
|
1485
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
1486
|
+
generateBaseData(data) {
|
|
1487
|
+
return new BaseDataInternal(data.title, data.displayColumns, data.EntityServiceClass, data.searchLabel ? data.searchLabel : 'Search', data.createButtonLabel ? data.createButtonLabel : 'Create', data.searchString ? data.searchString : defaultSearchFunction, data.allowCreate === false ? data.allowCreate : true, data.allowEdit ? data.allowEdit : () => true, data.allowDelete ? data.allowDelete : () => true, data.multiSelectActions ? data.multiSelectActions : [], data.multiSelectLabel ? data.multiSelectLabel : 'Actions', data.EntityClass, data.edit, data.create);
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
/**
|
|
1491
|
+
* The internal TableData. Requires all default values the user can leave out.
|
|
1492
|
+
*/
|
|
1493
|
+
class BaseDataInternal {
|
|
1494
|
+
constructor(title, displayColumns, EntityServiceClass, searchLabel, createButtonLabel, searchString, allowCreate, allowEdit, allowDelete, multiSelectActions, multiSelectLabel, EntityClass, edit, create) {
|
|
1495
|
+
this.title = title;
|
|
1496
|
+
this.displayColumns = displayColumns;
|
|
1497
|
+
this.EntityServiceClass = EntityServiceClass;
|
|
1498
|
+
this.EntityClass = EntityClass;
|
|
1499
|
+
this.searchLabel = searchLabel;
|
|
1500
|
+
this.createButtonLabel = createButtonLabel;
|
|
1501
|
+
this.searchString = searchString;
|
|
1502
|
+
this.allowCreate = allowCreate;
|
|
1503
|
+
this.allowEdit = allowEdit;
|
|
1504
|
+
this.allowDelete = allowDelete;
|
|
1505
|
+
this.multiSelectActions = multiSelectActions;
|
|
1506
|
+
this.multiSelectLabel = multiSelectLabel;
|
|
1507
|
+
this.edit = edit;
|
|
1508
|
+
this.create = create;
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
/**
|
|
1512
|
+
* The Builder for the complete TableData. Sets default values and validates user input.
|
|
1513
|
+
*/
|
|
1514
|
+
class TableDataBuilder extends BaseBuilder {
|
|
1515
|
+
constructor(data) {
|
|
1516
|
+
super(data);
|
|
1517
|
+
}
|
|
1518
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
1519
|
+
generateBaseData(data) {
|
|
1520
|
+
const createDialogData = new CreateDialogDataBuilder(data.createDialogData).getResult();
|
|
1521
|
+
const editDialogData = new EditDialogDataBuilder(data.editDialogData).getResult();
|
|
1522
|
+
const baseData = new BaseDataBuilder(data.baseData).getResult();
|
|
1523
|
+
return new TableDataInternal(baseData, createDialogData, editDialogData);
|
|
1524
|
+
}
|
|
1525
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
1526
|
+
validateInput(data) {
|
|
1527
|
+
var _a;
|
|
1528
|
+
if (((_a = data.baseData.multiSelectActions) === null || _a === void 0 ? void 0 : _a.length) && data.baseData.displayColumns.find(dp => dp.displayName === 'select')) {
|
|
1529
|
+
throw new Error(`The name "select" for a display column is reserved for the multi-select action functionality.
|
|
1530
|
+
Please choose a different name.`);
|
|
1531
|
+
}
|
|
1532
|
+
if ((data.baseData.allowEdit && data.baseData.allowEdit !== (() => false)
|
|
1533
|
+
|| data.baseData.allowDelete && data.baseData.allowDelete !== (() => false)
|
|
1534
|
+
|| data.baseData.allowCreate)
|
|
1535
|
+
&& !data.baseData.EntityClass) {
|
|
1536
|
+
throw new Error(`
|
|
1537
|
+
Missing required Input data "EntityClass".
|
|
1538
|
+
You can only omit this value if you can neither create or update entities.`);
|
|
1539
|
+
}
|
|
1540
|
+
if (data.baseData.allowCreate !== false && !data.baseData.create && !data.createDialogData) {
|
|
1541
|
+
throw new Error(`Missing required Input data "createDialogData".
|
|
1542
|
+
You can only omit this value when creation is disallowed or done with a custom create method.`);
|
|
1543
|
+
}
|
|
1544
|
+
if ((data.baseData.allowEdit !== (() => false)
|
|
1545
|
+
|| data.baseData.allowDelete !== (() => false))
|
|
1546
|
+
&& !data.baseData.edit
|
|
1547
|
+
&& !data.editDialogData) {
|
|
1548
|
+
throw new Error(`Missing required Input data "editDialogData".
|
|
1549
|
+
You can only omit this value when editing and deleting is disallowed or done with a custom edit method.`);
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
/**
|
|
1554
|
+
* The default search function taken from googles mat table.
|
|
1555
|
+
* This will be used if no custom search function is provided by the configuration.
|
|
1556
|
+
*
|
|
1557
|
+
* It generates a string from an entity which is then used to compare it to the search input.
|
|
1558
|
+
*
|
|
1559
|
+
* @param entity - An entity that is in the search.
|
|
1560
|
+
* @returns The generated string of the given entity used for comparison with the search input.
|
|
1561
|
+
*/
|
|
1562
|
+
function defaultSearchFunction(entity) {
|
|
1563
|
+
const searchString = Object.keys(entity)
|
|
1564
|
+
.reduce((currentTerm, key) => {
|
|
1565
|
+
return `${currentTerm}${entity[key]}◬`;
|
|
1566
|
+
}, '')
|
|
1567
|
+
.toLowerCase();
|
|
1568
|
+
return searchString;
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
/**
|
|
1572
|
+
* Generates a fully functional table for displaying, creating, updating and deleting entities
|
|
1573
|
+
* based on the configuration passed in the @Input "tableData".
|
|
1574
|
+
*
|
|
1575
|
+
* It offers a lot of customization options which can be found in "TableData".
|
|
1576
|
+
*/
|
|
1151
1577
|
class NgxMatEntityTableComponent {
|
|
1152
1578
|
constructor(dialog, injector) {
|
|
1153
1579
|
this.dialog = dialog;
|
|
@@ -1156,16 +1582,14 @@ class NgxMatEntityTableComponent {
|
|
|
1156
1582
|
this.dataSource = new MatTableDataSource();
|
|
1157
1583
|
this.selection = new SelectionModel(true, []);
|
|
1158
1584
|
}
|
|
1585
|
+
/**
|
|
1586
|
+
* Sets up all the configuration for the table and the EntityService.
|
|
1587
|
+
*/
|
|
1159
1588
|
ngOnInit() {
|
|
1160
|
-
|
|
1161
|
-
this.
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
if ((_a = this.entitiesData.baseData.multiSelectActions) === null || _a === void 0 ? void 0 : _a.length) {
|
|
1165
|
-
if (givenDisplayColumns.find((s) => s === 'select')) {
|
|
1166
|
-
throw new Error(`The name "select" for a display column is reserved for the multi-select action functionality.
|
|
1167
|
-
Please choose a different name.`);
|
|
1168
|
-
}
|
|
1589
|
+
this.data = new TableDataBuilder(this.tableData).getResult();
|
|
1590
|
+
this.entityService = this.injector.get(this.data.baseData.EntityServiceClass);
|
|
1591
|
+
const givenDisplayColumns = this.data.baseData.displayColumns.map((v) => v.displayName);
|
|
1592
|
+
if (this.data.baseData.multiSelectActions.length) {
|
|
1169
1593
|
this.displayedColumns = ['select'].concat(givenDisplayColumns);
|
|
1170
1594
|
}
|
|
1171
1595
|
else {
|
|
@@ -1173,13 +1597,12 @@ class NgxMatEntityTableComponent {
|
|
|
1173
1597
|
}
|
|
1174
1598
|
this.dataSource.sortingDataAccessor = (entity, header) => {
|
|
1175
1599
|
var _a;
|
|
1176
|
-
return (_a = this.
|
|
1600
|
+
return (_a = this.data.baseData.displayColumns.find((dp) => dp.displayName === header)) === null || _a === void 0 ? void 0 : _a.value(entity);
|
|
1177
1601
|
};
|
|
1178
1602
|
this.dataSource.sort = this.sort;
|
|
1179
|
-
if (this.
|
|
1603
|
+
if (this.data.baseData.searchString) {
|
|
1180
1604
|
this.dataSource.filterPredicate = (entity, filter) => {
|
|
1181
|
-
|
|
1182
|
-
const searchStr = (_b = (_a = this.entitiesData.baseData).searchString) === null || _b === void 0 ? void 0 : _b.call(_a, entity);
|
|
1605
|
+
const searchStr = this.data.baseData.searchString(entity);
|
|
1183
1606
|
const formattedSearchString = searchStr.toLowerCase();
|
|
1184
1607
|
const formattedFilterString = filter.toLowerCase();
|
|
1185
1608
|
return formattedSearchString.includes(formattedFilterString);
|
|
@@ -1193,63 +1616,33 @@ class NgxMatEntityTableComponent {
|
|
|
1193
1616
|
});
|
|
1194
1617
|
this.entityService.read();
|
|
1195
1618
|
}
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
}
|
|
1203
|
-
if (!this.entitiesData.baseData.EntityServiceClass) {
|
|
1204
|
-
throw new Error('Missing required Input data "EntityServiceClass"');
|
|
1205
|
-
}
|
|
1206
|
-
if (this.entitiesData.baseData.allowCreate === undefined) {
|
|
1207
|
-
this.entitiesData.baseData.allowCreate = true;
|
|
1208
|
-
}
|
|
1209
|
-
if (this.entitiesData.baseData.allowEdit === undefined) {
|
|
1210
|
-
this.entitiesData.baseData.allowEdit = () => true;
|
|
1211
|
-
}
|
|
1212
|
-
if (this.entitiesData.baseData.allowDelete === undefined) {
|
|
1213
|
-
this.entitiesData.baseData.allowDelete = () => true;
|
|
1214
|
-
}
|
|
1215
|
-
if ((this.entitiesData.baseData.allowEdit !== (() => false)
|
|
1216
|
-
|| this.entitiesData.baseData.allowDelete !== (() => false)
|
|
1217
|
-
|| this.entitiesData.baseData.allowCreate)
|
|
1218
|
-
&& !this.entitiesData.baseData.EntityClass) {
|
|
1219
|
-
throw new Error(`
|
|
1220
|
-
Missing required Input data "EntityClass".
|
|
1221
|
-
You can only omit this value if you can neither create or update entities.`);
|
|
1222
|
-
}
|
|
1223
|
-
if (this.entitiesData.baseData.allowCreate && !this.entitiesData.baseData.create && !this.entitiesData.createDialogData) {
|
|
1224
|
-
throw new Error(`Missing required Input data "createDialogData".
|
|
1225
|
-
You can only omit this value when creation is disallowed or done with a custom create method.`);
|
|
1226
|
-
}
|
|
1227
|
-
if ((this.entitiesData.baseData.allowEdit !== (() => false)
|
|
1228
|
-
|| this.entitiesData.baseData.allowDelete !== (() => false))
|
|
1229
|
-
&& !this.entitiesData.baseData.edit
|
|
1230
|
-
&& !this.entitiesData.editDialogData) {
|
|
1231
|
-
throw new Error(`Missing required Input data "editDialogData".
|
|
1232
|
-
You can only omit this value when editing and deleting is disallowed or done with a custom edit method.`);
|
|
1233
|
-
}
|
|
1234
|
-
}
|
|
1619
|
+
/**
|
|
1620
|
+
* Edits an entity. This either calls the edit-Method provided by the user or uses a default edit-dialog.
|
|
1621
|
+
*
|
|
1622
|
+
* @param entity - The entity that should be updated.
|
|
1623
|
+
* @throws When no EntityClass was provided, as a new call is needed to initialize metadata.
|
|
1624
|
+
*/
|
|
1235
1625
|
editEntity(entity) {
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1626
|
+
if (this.data.baseData.allowEdit(entity)) {
|
|
1627
|
+
if (!this.data.baseData.EntityClass) {
|
|
1628
|
+
throw new Error('No "EntityClass" specified for this table');
|
|
1629
|
+
}
|
|
1630
|
+
if (this.data.baseData.edit) {
|
|
1631
|
+
this.data.baseData.edit(new this.data.baseData.EntityClass(entity));
|
|
1240
1632
|
}
|
|
1241
1633
|
else {
|
|
1242
|
-
this.editDefault(new this.
|
|
1634
|
+
this.editDefault(new this.data.baseData.EntityClass(entity));
|
|
1243
1635
|
}
|
|
1244
1636
|
}
|
|
1245
1637
|
}
|
|
1246
1638
|
editDefault(entity) {
|
|
1247
|
-
const
|
|
1639
|
+
const inputDialogData = {
|
|
1248
1640
|
entity: entity,
|
|
1249
|
-
EntityServiceClass: this.
|
|
1250
|
-
allowDelete: this.
|
|
1251
|
-
editDialogData: this.
|
|
1641
|
+
EntityServiceClass: this.data.baseData.EntityServiceClass,
|
|
1642
|
+
allowDelete: this.data.baseData.allowDelete,
|
|
1643
|
+
editDialogData: this.data.editDialogData
|
|
1252
1644
|
};
|
|
1645
|
+
const dialogData = new EditEntityDialogDataBuilder(inputDialogData).getResult();
|
|
1253
1646
|
firstValueFrom(this.dialog.open(NgxMatEntityEditDialogComponent, {
|
|
1254
1647
|
data: dialogData,
|
|
1255
1648
|
minWidth: '60%',
|
|
@@ -1264,22 +1657,30 @@ class NgxMatEntityTableComponent {
|
|
|
1264
1657
|
}
|
|
1265
1658
|
});
|
|
1266
1659
|
}
|
|
1660
|
+
/**
|
|
1661
|
+
* Creates a new Entity. This either calls the create-Method provided by the user or uses a default create-dialog.
|
|
1662
|
+
*
|
|
1663
|
+
* @throws When no EntityClass was provided, as a new call is needed to initialize metadata.
|
|
1664
|
+
*/
|
|
1267
1665
|
createEntity() {
|
|
1268
|
-
if (this.
|
|
1269
|
-
if (this.
|
|
1270
|
-
|
|
1666
|
+
if (this.data.baseData.allowCreate) {
|
|
1667
|
+
if (!this.data.baseData.EntityClass) {
|
|
1668
|
+
throw new Error('No "EntityClass" specified for this table');
|
|
1669
|
+
}
|
|
1670
|
+
if (this.data.baseData.create) {
|
|
1671
|
+
this.data.baseData.create(new this.data.baseData.EntityClass());
|
|
1271
1672
|
}
|
|
1272
1673
|
else {
|
|
1273
|
-
this.createDefault(new this.
|
|
1674
|
+
this.createDefault(new this.data.baseData.EntityClass());
|
|
1274
1675
|
}
|
|
1275
1676
|
}
|
|
1276
1677
|
}
|
|
1277
1678
|
createDefault(entity) {
|
|
1278
|
-
const dialogData = {
|
|
1679
|
+
const dialogData = new CreateEntityDialogDataBuilder({
|
|
1279
1680
|
entity: entity,
|
|
1280
|
-
EntityServiceClass: this.
|
|
1281
|
-
createDialogData: this.
|
|
1282
|
-
};
|
|
1681
|
+
EntityServiceClass: this.data.baseData.EntityServiceClass,
|
|
1682
|
+
createDialogData: this.data.createDialogData
|
|
1683
|
+
}).getResult();
|
|
1283
1684
|
this.dialog.open(NgxMatEntityCreateDialogComponent, {
|
|
1284
1685
|
data: dialogData,
|
|
1285
1686
|
minWidth: '60%',
|
|
@@ -1287,27 +1688,26 @@ class NgxMatEntityTableComponent {
|
|
|
1287
1688
|
restoreFocus: false
|
|
1288
1689
|
});
|
|
1289
1690
|
}
|
|
1691
|
+
/**
|
|
1692
|
+
* Runs the MultiAction for all selected entries.
|
|
1693
|
+
* Also handles confirmation with an additional dialog if configured.
|
|
1694
|
+
*
|
|
1695
|
+
* @param action - The MultiAction to run.
|
|
1696
|
+
*/
|
|
1290
1697
|
runMultiAction(action) {
|
|
1291
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
1292
1698
|
if (!action.requireConfirmDialog || !action.requireConfirmDialog(this.selection.selected)) {
|
|
1293
1699
|
return this.confirmRunMultiAction(action);
|
|
1294
1700
|
}
|
|
1295
|
-
const dialogData =
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
cancelButtonLabel: ((_e = action.confirmDialogData) === null || _e === void 0 ? void 0 : _e.cancelButtonLabel) ? (_f = action.confirmDialogData) === null || _f === void 0 ? void 0 : _f.cancelButtonLabel : 'Cancel',
|
|
1301
|
-
title: ((_g = action.confirmDialogData) === null || _g === void 0 ? void 0 : _g.title) ? (_h = action.confirmDialogData) === null || _h === void 0 ? void 0 : _h.title : action.displayName,
|
|
1302
|
-
requireConfirmation: ((_j = action.confirmDialogData) === null || _j === void 0 ? void 0 : _j.requireConfirmation) ? (_k = action.confirmDialogData) === null || _k === void 0 ? void 0 : _k.requireConfirmation : false,
|
|
1303
|
-
confirmationText: ((_l = action.confirmDialogData) === null || _l === void 0 ? void 0 : _l.confirmationText) ? (_m = action.confirmDialogData) === null || _m === void 0 ? void 0 : _m.confirmationText : undefined
|
|
1304
|
-
};
|
|
1305
|
-
const dialogref = this.dialog.open(NgxMatEntityConfirmDialogComponent, {
|
|
1701
|
+
const dialogData = new ConfirmDialogDataBuilder(action.confirmDialogData)
|
|
1702
|
+
.withDefault('text', [`Do you really want to run this action on ${this.selection.selected.length} entries?`])
|
|
1703
|
+
.withDefault('title', action.displayName)
|
|
1704
|
+
.getResult();
|
|
1705
|
+
const dialogRef = this.dialog.open(NgxMatEntityConfirmDialogComponent, {
|
|
1306
1706
|
data: dialogData,
|
|
1307
1707
|
autoFocus: false,
|
|
1308
1708
|
restoreFocus: false
|
|
1309
1709
|
});
|
|
1310
|
-
|
|
1710
|
+
dialogRef.afterClosed().subscribe((res) => {
|
|
1311
1711
|
if (res === 1) {
|
|
1312
1712
|
this.confirmRunMultiAction(action);
|
|
1313
1713
|
}
|
|
@@ -1316,6 +1716,12 @@ class NgxMatEntityTableComponent {
|
|
|
1316
1716
|
confirmRunMultiAction(action) {
|
|
1317
1717
|
action.action(this.selection.selected);
|
|
1318
1718
|
}
|
|
1719
|
+
/**
|
|
1720
|
+
* Checks if an MultiAction is disabled (e.g. Because no entries have been selected).
|
|
1721
|
+
*
|
|
1722
|
+
* @param action - The MultiAction to check.
|
|
1723
|
+
* @returns Whether or not the Action can be used.
|
|
1724
|
+
*/
|
|
1319
1725
|
multiActionDisabled(action) {
|
|
1320
1726
|
var _a;
|
|
1321
1727
|
if (!this.selection.selected.length) {
|
|
@@ -1326,6 +1732,9 @@ class NgxMatEntityTableComponent {
|
|
|
1326
1732
|
}
|
|
1327
1733
|
return false;
|
|
1328
1734
|
}
|
|
1735
|
+
/**
|
|
1736
|
+
* Toggles all entries in the table.
|
|
1737
|
+
*/
|
|
1329
1738
|
masterToggle() {
|
|
1330
1739
|
if (this.isAllSelected()) {
|
|
1331
1740
|
this.selection.clear();
|
|
@@ -1334,6 +1743,12 @@ class NgxMatEntityTableComponent {
|
|
|
1334
1743
|
this.dataSource.data.forEach((row) => this.selection.select(row));
|
|
1335
1744
|
}
|
|
1336
1745
|
}
|
|
1746
|
+
/**
|
|
1747
|
+
* Checks if all entries in the table have been selected.
|
|
1748
|
+
* This is needed to display the "masterToggle"-checkbox correctly.
|
|
1749
|
+
*
|
|
1750
|
+
* @returns Whether or not all entries in the table have been selected.
|
|
1751
|
+
*/
|
|
1337
1752
|
isAllSelected() {
|
|
1338
1753
|
const numSelected = this.selection.selected.length;
|
|
1339
1754
|
const numRows = this.dataSource.data.length;
|
|
@@ -1343,17 +1758,22 @@ class NgxMatEntityTableComponent {
|
|
|
1343
1758
|
this.onDestroy.next(undefined);
|
|
1344
1759
|
this.onDestroy.complete();
|
|
1345
1760
|
}
|
|
1761
|
+
/**
|
|
1762
|
+
* Applies the search input to filter the table entries.
|
|
1763
|
+
*
|
|
1764
|
+
* @param event - The keyup-event which contains the search-string of the user.
|
|
1765
|
+
*/
|
|
1346
1766
|
applyFilter(event) {
|
|
1347
1767
|
const filterValue = event.target.value;
|
|
1348
1768
|
this.dataSource.filter = filterValue.trim().toLowerCase();
|
|
1349
1769
|
}
|
|
1350
1770
|
}
|
|
1351
1771
|
NgxMatEntityTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityTableComponent, deps: [{ token: i1.MatDialog }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Component });
|
|
1352
|
-
NgxMatEntityTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: NgxMatEntityTableComponent, selector: "ngx-mat-entity-table", inputs: {
|
|
1772
|
+
NgxMatEntityTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: NgxMatEntityTableComponent, selector: "ngx-mat-entity-table", inputs: { tableData: "tableData" }, viewQueries: [{ propertyName: "paginator", first: true, predicate: MatPaginator, descendants: true, static: true }, { propertyName: "sort", first: true, predicate: MatSort, descendants: true, static: true }, { propertyName: "filter", first: true, predicate: ["filter"], descendants: true, static: true }], ngImport: i0, template: "<h1 class=\"title\">{{data.baseData.title}}</h1>\n\n<div class=\"row\">\n <mat-form-field class=\"col-lg-8 col-md-6 col-sm-12\">\n <mat-label>{{data.baseData.searchLabel}}</mat-label>\n <input matInput (keyup)=\"applyFilter($event)\" />\n </mat-form-field>\n <div\n *ngIf=\"data.baseData.multiSelectActions.length\"\n [class.col-lg-2]=\"data.baseData.allowCreate\"\n [class.col-lg-4]=\"!data.baseData.allowCreate\"\n [class.col-md-3]=\"data.baseData.allowCreate\"\n [class.col-md-6]=\"!data.baseData.allowCreate\"\n [class.col-sm-6]=\"data.baseData.allowCreate\"\n [class.col-sm-12]=\"!data.baseData.allowCreate\"\n >\n <button class=\"actions-button\" [matMenuTriggerFor]=\"menu\" mat-raised-button>\n {{data.baseData.multiSelectLabel}}\n </button>\n </div>\n <mat-menu #menu=\"matMenu\">\n <button *ngFor=\"let action of data.baseData.multiSelectActions\" [disabled]=\"multiActionDisabled(action)\" (click)=\"runMultiAction(action)\" mat-menu-item>\n {{action.displayName}}\n </button>\n </mat-menu>\n\n <div\n *ngIf=\"data.baseData.allowCreate\"\n [class.col-lg-2]=\"data.baseData.multiSelectActions.length\"\n [class.col-lg-4]=\"!data.baseData.multiSelectActions.length\"\n [class.col-md-3]=\"data.baseData.multiSelectActions.length\"\n [class.col-md-6]=\"!data.baseData.multiSelectActions.length\"\n [class.col-sm-6]=\"data.baseData.multiSelectActions.length\"\n [class.col-sm-12]=\"!data.baseData.multiSelectActions.length\"\n >\n <button class=\"create-button\" (click)=\"createEntity()\" mat-raised-button>\n {{data.baseData.createButtonLabel}}\n </button>\n </div>\n</div>\n\n<div class=\"mat-elevation-z8\">\n <mat-table *ngIf=\"dataSource\" [dataSource]=\"dataSource\" matSort>\n <!-- select Column -->\n <ng-container matColumnDef=\"select\">\n <mat-header-cell *matHeaderCellDef>\n <mat-checkbox (change)=\"$event ? masterToggle() : null\" [checked]=\"selection.hasValue() && isAllSelected()\" [indeterminate]=\"selection.hasValue() && !isAllSelected()\"> </mat-checkbox>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let module\" class=\"module\">\n <mat-checkbox (click)=\"$event.stopPropagation()\" (change)=\"$event ? selection.toggle(module) : null\" [checked]=\"selection.isSelected(module)\"> </mat-checkbox>\n </mat-cell>\n </ng-container>\n\n <ng-container *ngFor=\"let dCol of data.baseData.displayColumns\" [matColumnDef]=\"dCol.displayName\">\n <mat-header-cell *matHeaderCellDef mat-sort-header>\n {{dCol.displayName}}\n </mat-header-cell>\n <mat-cell class=\"entity\" [class.enabled]=\"data.baseData.allowEdit(entity)\" (click)=\"editEntity(entity)\" *matCellDef=\"let entity\">\n {{dCol.value(entity)}}\n </mat-cell>\n </ng-container>\n\n <mat-header-row *matHeaderRowDef=\"displayedColumns\"></mat-header-row>\n <mat-row *matRowDef=\"let row; columns: displayedColumns\"></mat-row>\n </mat-table>\n\n <mat-paginator *ngIf=\"dataSource\" id=\"paginator\" [length]=\"dataSource.filteredData.length\" [pageIndex]=\"0\" [pageSize]=\"10\" [pageSizeOptions]=\"[5, 10, 25, 50]\"> </mat-paginator>\n</div>\n", styles: [".title{text-align:center}button{width:100%}.mat-column-select{flex:0 0 75px}.enabled:hover{cursor:pointer}@media (max-width: 767px){.actions-button,.create-button{margin-bottom:15px}}\n"], components: [{ type: i2.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i3.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i4$1.MatMenu, selector: "mat-menu", exportAs: ["matMenu"] }, { type: i4$1.MatMenuItem, selector: "[mat-menu-item]", inputs: ["disabled", "disableRipple", "role"], exportAs: ["matMenuItem"] }, { type: i9.MatTable, selector: "mat-table, table[mat-table]", exportAs: ["matTable"] }, { type: i6.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex", "aria-label", "aria-labelledby", "aria-describedby", "id", "required", "labelPosition", "name", "value", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { type: i9.MatHeaderRow, selector: "mat-header-row, tr[mat-header-row]", exportAs: ["matHeaderRow"] }, { type: i9.MatRow, selector: "mat-row, tr[mat-row]", exportAs: ["matRow"] }, { type: i7$1.MatPaginator, selector: "mat-paginator", inputs: ["disabled"], exportAs: ["matPaginator"] }], directives: [{ type: i2.MatLabel, selector: "mat-label" }, { type: i12.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { type: i11.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4$1.MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", exportAs: ["matMenuTrigger"] }, { type: i11.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i9.MatColumnDef, selector: "[matColumnDef]", inputs: ["sticky", "matColumnDef"] }, { type: i9.MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { type: i9.MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { type: i9.MatCellDef, selector: "[matCellDef]" }, { type: i9.MatCell, selector: "mat-cell, td[mat-cell]" }, { type: i9.MatHeaderRowDef, selector: "[matHeaderRowDef]", inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"] }, { type: i9.MatRowDef, selector: "[matRowDef]", inputs: ["matRowDefColumns", "matRowDefWhen"] }] });
|
|
1353
1773
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityTableComponent, decorators: [{
|
|
1354
1774
|
type: Component,
|
|
1355
|
-
args: [{ selector: 'ngx-mat-entity-table', template: "<h1 class=\"title\">{{
|
|
1356
|
-
}], ctorParameters: function () { return [{ type: i1.MatDialog }, { type: i0.Injector }]; }, propDecorators: {
|
|
1775
|
+
args: [{ selector: 'ngx-mat-entity-table', template: "<h1 class=\"title\">{{data.baseData.title}}</h1>\n\n<div class=\"row\">\n <mat-form-field class=\"col-lg-8 col-md-6 col-sm-12\">\n <mat-label>{{data.baseData.searchLabel}}</mat-label>\n <input matInput (keyup)=\"applyFilter($event)\" />\n </mat-form-field>\n <div\n *ngIf=\"data.baseData.multiSelectActions.length\"\n [class.col-lg-2]=\"data.baseData.allowCreate\"\n [class.col-lg-4]=\"!data.baseData.allowCreate\"\n [class.col-md-3]=\"data.baseData.allowCreate\"\n [class.col-md-6]=\"!data.baseData.allowCreate\"\n [class.col-sm-6]=\"data.baseData.allowCreate\"\n [class.col-sm-12]=\"!data.baseData.allowCreate\"\n >\n <button class=\"actions-button\" [matMenuTriggerFor]=\"menu\" mat-raised-button>\n {{data.baseData.multiSelectLabel}}\n </button>\n </div>\n <mat-menu #menu=\"matMenu\">\n <button *ngFor=\"let action of data.baseData.multiSelectActions\" [disabled]=\"multiActionDisabled(action)\" (click)=\"runMultiAction(action)\" mat-menu-item>\n {{action.displayName}}\n </button>\n </mat-menu>\n\n <div\n *ngIf=\"data.baseData.allowCreate\"\n [class.col-lg-2]=\"data.baseData.multiSelectActions.length\"\n [class.col-lg-4]=\"!data.baseData.multiSelectActions.length\"\n [class.col-md-3]=\"data.baseData.multiSelectActions.length\"\n [class.col-md-6]=\"!data.baseData.multiSelectActions.length\"\n [class.col-sm-6]=\"data.baseData.multiSelectActions.length\"\n [class.col-sm-12]=\"!data.baseData.multiSelectActions.length\"\n >\n <button class=\"create-button\" (click)=\"createEntity()\" mat-raised-button>\n {{data.baseData.createButtonLabel}}\n </button>\n </div>\n</div>\n\n<div class=\"mat-elevation-z8\">\n <mat-table *ngIf=\"dataSource\" [dataSource]=\"dataSource\" matSort>\n <!-- select Column -->\n <ng-container matColumnDef=\"select\">\n <mat-header-cell *matHeaderCellDef>\n <mat-checkbox (change)=\"$event ? masterToggle() : null\" [checked]=\"selection.hasValue() && isAllSelected()\" [indeterminate]=\"selection.hasValue() && !isAllSelected()\"> </mat-checkbox>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let module\" class=\"module\">\n <mat-checkbox (click)=\"$event.stopPropagation()\" (change)=\"$event ? selection.toggle(module) : null\" [checked]=\"selection.isSelected(module)\"> </mat-checkbox>\n </mat-cell>\n </ng-container>\n\n <ng-container *ngFor=\"let dCol of data.baseData.displayColumns\" [matColumnDef]=\"dCol.displayName\">\n <mat-header-cell *matHeaderCellDef mat-sort-header>\n {{dCol.displayName}}\n </mat-header-cell>\n <mat-cell class=\"entity\" [class.enabled]=\"data.baseData.allowEdit(entity)\" (click)=\"editEntity(entity)\" *matCellDef=\"let entity\">\n {{dCol.value(entity)}}\n </mat-cell>\n </ng-container>\n\n <mat-header-row *matHeaderRowDef=\"displayedColumns\"></mat-header-row>\n <mat-row *matRowDef=\"let row; columns: displayedColumns\"></mat-row>\n </mat-table>\n\n <mat-paginator *ngIf=\"dataSource\" id=\"paginator\" [length]=\"dataSource.filteredData.length\" [pageIndex]=\"0\" [pageSize]=\"10\" [pageSizeOptions]=\"[5, 10, 25, 50]\"> </mat-paginator>\n</div>\n", styles: [".title{text-align:center}button{width:100%}.mat-column-select{flex:0 0 75px}.enabled:hover{cursor:pointer}@media (max-width: 767px){.actions-button,.create-button{margin-bottom:15px}}\n"] }]
|
|
1776
|
+
}], ctorParameters: function () { return [{ type: i1.MatDialog }, { type: i0.Injector }]; }, propDecorators: { tableData: [{
|
|
1357
1777
|
type: Input
|
|
1358
1778
|
}], paginator: [{
|
|
1359
1779
|
type: ViewChild,
|
|
@@ -1366,421 +1786,342 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
|
|
|
1366
1786
|
args: ['filter', { static: true }]
|
|
1367
1787
|
}] } });
|
|
1368
1788
|
|
|
1369
|
-
class
|
|
1789
|
+
class NgxMatEntityCreateDialogModule {
|
|
1370
1790
|
}
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1791
|
+
NgxMatEntityCreateDialogModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityCreateDialogModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1792
|
+
NgxMatEntityCreateDialogModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityCreateDialogModule, declarations: [NgxMatEntityCreateDialogComponent], imports: [CommonModule,
|
|
1793
|
+
NgxMatEntityInputModule,
|
|
1794
|
+
MatDialogModule,
|
|
1374
1795
|
FormsModule,
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
MatTableModule,
|
|
1378
|
-
MatPaginatorModule,
|
|
1379
|
-
MatButtonModule,
|
|
1380
|
-
MatMenuModule,
|
|
1381
|
-
MatDialogModule], exports: [NgxMatEntityTableComponent] });
|
|
1382
|
-
NgxMatEntityTableModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityTableModule, imports: [[
|
|
1796
|
+
MatButtonModule], exports: [NgxMatEntityCreateDialogComponent] });
|
|
1797
|
+
NgxMatEntityCreateDialogModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityCreateDialogModule, imports: [[
|
|
1383
1798
|
CommonModule,
|
|
1384
|
-
|
|
1799
|
+
NgxMatEntityInputModule,
|
|
1800
|
+
MatDialogModule,
|
|
1385
1801
|
FormsModule,
|
|
1386
|
-
|
|
1387
|
-
MatCheckboxModule,
|
|
1388
|
-
MatTableModule,
|
|
1389
|
-
MatPaginatorModule,
|
|
1390
|
-
MatButtonModule,
|
|
1391
|
-
MatMenuModule,
|
|
1392
|
-
MatDialogModule
|
|
1802
|
+
MatButtonModule
|
|
1393
1803
|
]] });
|
|
1394
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type:
|
|
1804
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityCreateDialogModule, decorators: [{
|
|
1395
1805
|
type: NgModule,
|
|
1396
1806
|
args: [{
|
|
1397
|
-
declarations: [
|
|
1807
|
+
declarations: [NgxMatEntityCreateDialogComponent],
|
|
1398
1808
|
imports: [
|
|
1399
1809
|
CommonModule,
|
|
1400
|
-
|
|
1810
|
+
NgxMatEntityInputModule,
|
|
1811
|
+
MatDialogModule,
|
|
1401
1812
|
FormsModule,
|
|
1402
|
-
|
|
1403
|
-
MatCheckboxModule,
|
|
1404
|
-
MatTableModule,
|
|
1405
|
-
MatPaginatorModule,
|
|
1406
|
-
MatButtonModule,
|
|
1407
|
-
MatMenuModule,
|
|
1408
|
-
MatDialogModule
|
|
1813
|
+
MatButtonModule
|
|
1409
1814
|
],
|
|
1410
|
-
exports: [
|
|
1815
|
+
exports: [NgxMatEntityCreateDialogComponent]
|
|
1411
1816
|
}]
|
|
1412
1817
|
}] });
|
|
1413
1818
|
|
|
1414
|
-
class
|
|
1819
|
+
class NgxMatEntityEditDialogModule {
|
|
1415
1820
|
}
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1821
|
+
NgxMatEntityEditDialogModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityEditDialogModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1822
|
+
NgxMatEntityEditDialogModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityEditDialogModule, declarations: [NgxMatEntityEditDialogComponent], imports: [CommonModule,
|
|
1823
|
+
NgxMatEntityInputModule,
|
|
1824
|
+
MatDialogModule,
|
|
1419
1825
|
FormsModule,
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
MatCheckboxModule,
|
|
1424
|
-
MatSlideToggleModule,
|
|
1425
|
-
MatTableModule], exports: [NgxMatEntityInternalInputComponent] });
|
|
1426
|
-
NgxMatEntityInternalInputModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityInternalInputModule, imports: [[
|
|
1826
|
+
MatButtonModule,
|
|
1827
|
+
NgxMatEntityConfirmDialogModule], exports: [NgxMatEntityEditDialogComponent] });
|
|
1828
|
+
NgxMatEntityEditDialogModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityEditDialogModule, imports: [[
|
|
1427
1829
|
CommonModule,
|
|
1428
|
-
|
|
1830
|
+
NgxMatEntityInputModule,
|
|
1831
|
+
MatDialogModule,
|
|
1429
1832
|
FormsModule,
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
MatAutocompleteModule,
|
|
1433
|
-
MatCheckboxModule,
|
|
1434
|
-
MatSlideToggleModule,
|
|
1435
|
-
MatTableModule
|
|
1833
|
+
MatButtonModule,
|
|
1834
|
+
NgxMatEntityConfirmDialogModule
|
|
1436
1835
|
]] });
|
|
1437
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type:
|
|
1836
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityEditDialogModule, decorators: [{
|
|
1438
1837
|
type: NgModule,
|
|
1439
1838
|
args: [{
|
|
1440
|
-
declarations: [
|
|
1839
|
+
declarations: [NgxMatEntityEditDialogComponent],
|
|
1441
1840
|
imports: [
|
|
1442
1841
|
CommonModule,
|
|
1443
|
-
|
|
1842
|
+
NgxMatEntityInputModule,
|
|
1843
|
+
MatDialogModule,
|
|
1444
1844
|
FormsModule,
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
MatAutocompleteModule,
|
|
1448
|
-
MatCheckboxModule,
|
|
1449
|
-
MatSlideToggleModule,
|
|
1450
|
-
MatTableModule
|
|
1845
|
+
MatButtonModule,
|
|
1846
|
+
NgxMatEntityConfirmDialogModule
|
|
1451
1847
|
],
|
|
1452
|
-
exports: [
|
|
1453
|
-
}]
|
|
1454
|
-
}] });
|
|
1455
|
-
|
|
1456
|
-
class NgxMatEntityAddArrayItemDialogModule {
|
|
1457
|
-
}
|
|
1458
|
-
NgxMatEntityAddArrayItemDialogModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityAddArrayItemDialogModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1459
|
-
NgxMatEntityAddArrayItemDialogModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityAddArrayItemDialogModule, declarations: [NgxMatEntityAddArrayItemDialogComponent], imports: [CommonModule, NgxMatEntityInternalInputModule, MatDialogModule, FormsModule, MatButtonModule], exports: [NgxMatEntityAddArrayItemDialogComponent] });
|
|
1460
|
-
NgxMatEntityAddArrayItemDialogModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityAddArrayItemDialogModule, imports: [[CommonModule, NgxMatEntityInternalInputModule, MatDialogModule, FormsModule, MatButtonModule]] });
|
|
1461
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityAddArrayItemDialogModule, decorators: [{
|
|
1462
|
-
type: NgModule,
|
|
1463
|
-
args: [{
|
|
1464
|
-
declarations: [NgxMatEntityAddArrayItemDialogComponent],
|
|
1465
|
-
imports: [CommonModule, NgxMatEntityInternalInputModule, MatDialogModule, FormsModule, MatButtonModule],
|
|
1466
|
-
exports: [NgxMatEntityAddArrayItemDialogComponent]
|
|
1848
|
+
exports: [NgxMatEntityEditDialogComponent]
|
|
1467
1849
|
}]
|
|
1468
1850
|
}] });
|
|
1469
1851
|
|
|
1470
|
-
class
|
|
1852
|
+
class NgxMatEntityTableModule {
|
|
1471
1853
|
}
|
|
1472
|
-
|
|
1473
|
-
|
|
1854
|
+
NgxMatEntityTableModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityTableModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1855
|
+
NgxMatEntityTableModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityTableModule, declarations: [NgxMatEntityTableComponent], imports: [CommonModule,
|
|
1474
1856
|
MatInputModule,
|
|
1475
1857
|
FormsModule,
|
|
1476
1858
|
MatFormFieldModule,
|
|
1477
|
-
MatSelectModule,
|
|
1478
|
-
MatAutocompleteModule,
|
|
1479
1859
|
MatCheckboxModule,
|
|
1480
|
-
MatSlideToggleModule,
|
|
1481
1860
|
MatTableModule,
|
|
1482
|
-
|
|
1861
|
+
MatPaginatorModule,
|
|
1483
1862
|
MatButtonModule,
|
|
1484
|
-
|
|
1485
|
-
|
|
1863
|
+
MatMenuModule,
|
|
1864
|
+
MatDialogModule,
|
|
1865
|
+
NgxMatEntityCreateDialogModule,
|
|
1866
|
+
NgxMatEntityEditDialogModule], exports: [NgxMatEntityTableComponent] });
|
|
1867
|
+
NgxMatEntityTableModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityTableModule, imports: [[
|
|
1486
1868
|
CommonModule,
|
|
1487
1869
|
MatInputModule,
|
|
1488
1870
|
FormsModule,
|
|
1489
1871
|
MatFormFieldModule,
|
|
1490
|
-
MatSelectModule,
|
|
1491
|
-
MatAutocompleteModule,
|
|
1492
1872
|
MatCheckboxModule,
|
|
1493
|
-
MatSlideToggleModule,
|
|
1494
1873
|
MatTableModule,
|
|
1495
|
-
|
|
1874
|
+
MatPaginatorModule,
|
|
1496
1875
|
MatButtonModule,
|
|
1497
|
-
|
|
1876
|
+
MatMenuModule,
|
|
1877
|
+
MatDialogModule,
|
|
1878
|
+
NgxMatEntityCreateDialogModule,
|
|
1879
|
+
NgxMatEntityEditDialogModule,
|
|
1498
1880
|
]] });
|
|
1499
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type:
|
|
1881
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityTableModule, decorators: [{
|
|
1500
1882
|
type: NgModule,
|
|
1501
1883
|
args: [{
|
|
1502
|
-
declarations: [
|
|
1884
|
+
declarations: [NgxMatEntityTableComponent],
|
|
1503
1885
|
imports: [
|
|
1504
1886
|
CommonModule,
|
|
1505
1887
|
MatInputModule,
|
|
1506
1888
|
FormsModule,
|
|
1507
1889
|
MatFormFieldModule,
|
|
1508
|
-
MatSelectModule,
|
|
1509
|
-
MatAutocompleteModule,
|
|
1510
1890
|
MatCheckboxModule,
|
|
1511
|
-
MatSlideToggleModule,
|
|
1512
1891
|
MatTableModule,
|
|
1513
|
-
|
|
1892
|
+
MatPaginatorModule,
|
|
1514
1893
|
MatButtonModule,
|
|
1515
|
-
|
|
1894
|
+
MatMenuModule,
|
|
1895
|
+
MatDialogModule,
|
|
1896
|
+
NgxMatEntityCreateDialogModule,
|
|
1897
|
+
NgxMatEntityEditDialogModule,
|
|
1516
1898
|
],
|
|
1517
|
-
exports: [
|
|
1899
|
+
exports: [NgxMatEntityTableComponent]
|
|
1518
1900
|
}]
|
|
1519
1901
|
}] });
|
|
1520
1902
|
|
|
1521
|
-
|
|
1903
|
+
/**
|
|
1904
|
+
* The internal EntityArrayDecoratorConfig. Sets default values.
|
|
1905
|
+
*/
|
|
1906
|
+
class EntityArrayDecoratorConfigInternal extends PropertyDecoratorConfigInternal {
|
|
1907
|
+
constructor(data) {
|
|
1908
|
+
super(data);
|
|
1909
|
+
this.createInline = data.createInline != undefined ? data.createInline : true;
|
|
1910
|
+
this.displayStyle = data.displayStyle;
|
|
1911
|
+
this.itemType = data.itemType;
|
|
1912
|
+
this.EntityClass = data.EntityClass;
|
|
1913
|
+
this.displayColumns = data.displayColumns;
|
|
1914
|
+
this.createInline = data.createInline != undefined ? data.createInline : true;
|
|
1915
|
+
this.missingErrorMessage = data.missingErrorMessage ? data.missingErrorMessage : 'Needs to contain at least one value';
|
|
1916
|
+
this.defaultWidths = data.defaultWidths ? data.defaultWidths : [12, 12, 12];
|
|
1917
|
+
this.addButtonLabel = data.addButtonLabel ? data.addButtonLabel : 'Add';
|
|
1918
|
+
this.removeButtonLabel = data.removeButtonLabel ? data.removeButtonLabel : 'Remove';
|
|
1919
|
+
}
|
|
1522
1920
|
}
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
MatInputModule,
|
|
1538
|
-
FormsModule,
|
|
1539
|
-
MatFormFieldModule,
|
|
1540
|
-
MatSelectModule,
|
|
1541
|
-
MatAutocompleteModule,
|
|
1542
|
-
MatCheckboxModule,
|
|
1543
|
-
MatSlideToggleModule,
|
|
1544
|
-
NgxMatEntityArrayTableModule,
|
|
1545
|
-
MatChipsModule,
|
|
1546
|
-
MatIconModule
|
|
1547
|
-
]] });
|
|
1548
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityInputModule, decorators: [{
|
|
1549
|
-
type: NgModule,
|
|
1550
|
-
args: [{
|
|
1551
|
-
declarations: [NgxMatEntityInputComponent],
|
|
1552
|
-
imports: [
|
|
1553
|
-
CommonModule,
|
|
1554
|
-
MatInputModule,
|
|
1555
|
-
FormsModule,
|
|
1556
|
-
MatFormFieldModule,
|
|
1557
|
-
MatSelectModule,
|
|
1558
|
-
MatAutocompleteModule,
|
|
1559
|
-
MatCheckboxModule,
|
|
1560
|
-
MatSlideToggleModule,
|
|
1561
|
-
NgxMatEntityArrayTableModule,
|
|
1562
|
-
MatChipsModule,
|
|
1563
|
-
MatIconModule
|
|
1564
|
-
],
|
|
1565
|
-
exports: [NgxMatEntityInputComponent]
|
|
1566
|
-
}]
|
|
1567
|
-
}] });
|
|
1568
|
-
|
|
1569
|
-
class NgxMatEntityCreateDialogModule {
|
|
1921
|
+
/**
|
|
1922
|
+
* The internal StringChipsArrayDecoratorConfig. Sets default values.
|
|
1923
|
+
*/
|
|
1924
|
+
class StringChipsArrayDecoratorConfigInternal extends PropertyDecoratorConfigInternal {
|
|
1925
|
+
constructor(data) {
|
|
1926
|
+
super(data);
|
|
1927
|
+
this.deleteIcon = data.deleteIcon ? data.deleteIcon : 'fas fa-circle-minus';
|
|
1928
|
+
this.displayStyle = data.displayStyle;
|
|
1929
|
+
this.itemType = data.itemType;
|
|
1930
|
+
this.maxLength = data.maxLength;
|
|
1931
|
+
this.minLength = data.minLength;
|
|
1932
|
+
this.regex = data.regex;
|
|
1933
|
+
this.defaultWidths = data.defaultWidths ? data.defaultWidths : [6, 12, 12];
|
|
1934
|
+
}
|
|
1570
1935
|
}
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1936
|
+
/**
|
|
1937
|
+
* The internal AutocompleteStringChipsArrayDecoratorConfig. Sets default values.
|
|
1938
|
+
*/
|
|
1939
|
+
class AutocompleteStringChipsArrayDecoratorConfigInternal extends PropertyDecoratorConfigInternal {
|
|
1940
|
+
constructor(data) {
|
|
1941
|
+
super(data);
|
|
1942
|
+
this.autocompleteValues = data.autocompleteValues;
|
|
1943
|
+
this.deleteIcon = data.deleteIcon ? data.deleteIcon : 'fas fa-circle-minus';
|
|
1944
|
+
this.displayStyle = data.displayStyle;
|
|
1945
|
+
this.itemType = data.itemType;
|
|
1946
|
+
this.maxLength = data.maxLength;
|
|
1947
|
+
this.minLength = data.minLength;
|
|
1948
|
+
this.regex = data.regex;
|
|
1949
|
+
this.defaultWidths = data.defaultWidths ? data.defaultWidths : [6, 12, 12];
|
|
1950
|
+
}
|
|
1584
1951
|
}
|
|
1585
|
-
NgxMatEntityEditDialogModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityEditDialogModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1586
|
-
NgxMatEntityEditDialogModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityEditDialogModule, declarations: [NgxMatEntityEditDialogComponent], imports: [CommonModule,
|
|
1587
|
-
NgxMatEntityInputModule,
|
|
1588
|
-
MatDialogModule,
|
|
1589
|
-
FormsModule,
|
|
1590
|
-
MatButtonModule,
|
|
1591
|
-
NgxMatEntityConfirmDialogModule], exports: [NgxMatEntityEditDialogComponent] });
|
|
1592
|
-
NgxMatEntityEditDialogModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityEditDialogModule, imports: [[
|
|
1593
|
-
CommonModule,
|
|
1594
|
-
NgxMatEntityInputModule,
|
|
1595
|
-
MatDialogModule,
|
|
1596
|
-
FormsModule,
|
|
1597
|
-
MatButtonModule,
|
|
1598
|
-
NgxMatEntityConfirmDialogModule
|
|
1599
|
-
]] });
|
|
1600
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityEditDialogModule, decorators: [{
|
|
1601
|
-
type: NgModule,
|
|
1602
|
-
args: [{
|
|
1603
|
-
declarations: [NgxMatEntityEditDialogComponent],
|
|
1604
|
-
imports: [
|
|
1605
|
-
CommonModule,
|
|
1606
|
-
NgxMatEntityInputModule,
|
|
1607
|
-
MatDialogModule,
|
|
1608
|
-
FormsModule,
|
|
1609
|
-
MatButtonModule,
|
|
1610
|
-
NgxMatEntityConfirmDialogModule
|
|
1611
|
-
],
|
|
1612
|
-
exports: [NgxMatEntityEditDialogComponent]
|
|
1613
|
-
}]
|
|
1614
|
-
}] });
|
|
1615
1952
|
|
|
1616
1953
|
/**
|
|
1617
|
-
* Decorator for setting and getting array
|
|
1618
|
-
*
|
|
1954
|
+
* Decorator for setting and getting array property metadata.
|
|
1955
|
+
*
|
|
1956
|
+
* @param metadata - The metadata of the array property.
|
|
1957
|
+
* @returns The method that defines the metadata.
|
|
1958
|
+
* @throws When the given type of the array-items is unknown.
|
|
1619
1959
|
*/
|
|
1620
1960
|
function array(metadata) {
|
|
1621
1961
|
switch (metadata.itemType) {
|
|
1622
1962
|
case DecoratorTypes.OBJECT:
|
|
1623
|
-
return baseProperty(new
|
|
1963
|
+
return baseProperty(new EntityArrayDecoratorConfigInternal(metadata), DecoratorTypes.ARRAY);
|
|
1624
1964
|
case DecoratorTypes.STRING:
|
|
1625
|
-
return baseProperty(new
|
|
1965
|
+
return baseProperty(new StringChipsArrayDecoratorConfigInternal(metadata), DecoratorTypes.ARRAY_STRING_CHIPS);
|
|
1626
1966
|
case DecoratorTypes.STRING_AUTOCOMPLETE:
|
|
1627
|
-
return baseProperty(new
|
|
1967
|
+
return baseProperty(new AutocompleteStringChipsArrayDecoratorConfigInternal(metadata), DecoratorTypes.ARRAY_STRING_AUTOCOMPLETE_CHIPS);
|
|
1628
1968
|
default:
|
|
1629
1969
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
|
|
1630
1970
|
throw new Error(`Unknown itemType ${metadata.itemType}`);
|
|
1631
1971
|
}
|
|
1632
1972
|
}
|
|
1973
|
+
|
|
1974
|
+
/**
|
|
1975
|
+
* The base options for all propertyDecorators.
|
|
1976
|
+
*/
|
|
1977
|
+
class PropertyDecoratorConfig {
|
|
1978
|
+
}
|
|
1979
|
+
|
|
1633
1980
|
/**
|
|
1634
|
-
* Interface definition for the @array metadata
|
|
1981
|
+
* Interface definition for the @array metadata.
|
|
1635
1982
|
*/
|
|
1636
1983
|
class ArrayDecoratorConfig extends PropertyDecoratorConfig {
|
|
1637
1984
|
}
|
|
1985
|
+
|
|
1638
1986
|
/**
|
|
1639
|
-
*
|
|
1987
|
+
* The internal DropdownBooleanDecoratorConfig. Sets default values.
|
|
1640
1988
|
*/
|
|
1641
|
-
class
|
|
1642
|
-
constructor(
|
|
1643
|
-
super(
|
|
1644
|
-
this.
|
|
1645
|
-
this.
|
|
1646
|
-
this.
|
|
1647
|
-
this.createDialogData = metadata.createDialogData;
|
|
1648
|
-
this.missingErrorMessage = metadata.missingErrorMessage;
|
|
1649
|
-
this.createInline = metadata.createInline;
|
|
1650
|
-
this.displayColumns = metadata.displayColumns;
|
|
1989
|
+
class DropdownBooleanDecoratorConfigInternal extends PropertyDecoratorConfigInternal {
|
|
1990
|
+
constructor(data) {
|
|
1991
|
+
super(data);
|
|
1992
|
+
this.displayStyle = data.displayStyle;
|
|
1993
|
+
this.dropdownTrue = data.dropdownTrue;
|
|
1994
|
+
this.dropdownFalse = data.dropdownFalse;
|
|
1651
1995
|
}
|
|
1652
1996
|
}
|
|
1653
1997
|
/**
|
|
1654
|
-
*
|
|
1998
|
+
* The internal CheckboxBooleanDecoratorConfig. Sets default values.
|
|
1655
1999
|
*/
|
|
1656
|
-
class
|
|
1657
|
-
constructor(
|
|
1658
|
-
super(
|
|
1659
|
-
this.
|
|
1660
|
-
this.
|
|
1661
|
-
this.deleteHtml = metadata.deleteHtml;
|
|
1662
|
-
this.minLength = metadata.minLength;
|
|
1663
|
-
this.maxLength = metadata.maxLength;
|
|
1664
|
-
this.regex = metadata.regex;
|
|
2000
|
+
class CheckboxBooleanDecoratorConfigInternal extends PropertyDecoratorConfigInternal {
|
|
2001
|
+
constructor(data) {
|
|
2002
|
+
super(data);
|
|
2003
|
+
this.displayStyle = data.displayStyle;
|
|
2004
|
+
this.required = data.required === undefined ? false : data.required;
|
|
1665
2005
|
}
|
|
1666
2006
|
}
|
|
1667
2007
|
/**
|
|
1668
|
-
*
|
|
2008
|
+
* The internal ToggleBooleanDecoratorConfig. Sets default values.
|
|
1669
2009
|
*/
|
|
1670
|
-
class
|
|
1671
|
-
constructor(
|
|
1672
|
-
super(
|
|
1673
|
-
this.
|
|
1674
|
-
this.
|
|
1675
|
-
this.deleteHtml = metadata.deleteHtml;
|
|
1676
|
-
this.autocompleteValues = metadata.autocompleteValues;
|
|
1677
|
-
this.minLength = metadata.minLength;
|
|
1678
|
-
this.maxLength = metadata.maxLength;
|
|
1679
|
-
this.regex = metadata.regex;
|
|
2010
|
+
class ToggleBooleanDecoratorConfigInternal extends PropertyDecoratorConfigInternal {
|
|
2011
|
+
constructor(data) {
|
|
2012
|
+
super(data);
|
|
2013
|
+
this.displayStyle = data.displayStyle;
|
|
2014
|
+
this.required = data.required === undefined ? false : data.required;
|
|
1680
2015
|
}
|
|
1681
2016
|
}
|
|
1682
2017
|
|
|
1683
2018
|
/**
|
|
1684
|
-
* Decorator for setting and getting
|
|
1685
|
-
*
|
|
2019
|
+
* Decorator for setting and getting boolean property metadata.
|
|
2020
|
+
*
|
|
2021
|
+
* @param metadata - The metadata of the boolean property.
|
|
2022
|
+
* @returns The method that defines the metadata.
|
|
1686
2023
|
*/
|
|
1687
2024
|
function boolean(metadata) {
|
|
1688
2025
|
if (metadata.displayStyle === 'dropdown') {
|
|
1689
|
-
return baseProperty(new
|
|
2026
|
+
return baseProperty(new DropdownBooleanDecoratorConfigInternal(metadata), DecoratorTypes.BOOLEAN_DROPDOWN);
|
|
1690
2027
|
}
|
|
1691
2028
|
else if (metadata.displayStyle === 'checkbox') {
|
|
1692
|
-
return baseProperty(new
|
|
2029
|
+
return baseProperty(new CheckboxBooleanDecoratorConfigInternal(metadata), DecoratorTypes.BOOLEAN_CHECKBOX);
|
|
1693
2030
|
}
|
|
1694
2031
|
else {
|
|
1695
|
-
return baseProperty(new
|
|
2032
|
+
return baseProperty(new ToggleBooleanDecoratorConfigInternal(metadata), DecoratorTypes.BOOLEAN_TOGGLE);
|
|
1696
2033
|
}
|
|
1697
2034
|
}
|
|
2035
|
+
|
|
1698
2036
|
/**
|
|
1699
|
-
* The Definition for the @boolean metadata
|
|
2037
|
+
* The Definition for the @boolean metadata.
|
|
1700
2038
|
*/
|
|
1701
2039
|
class BooleanDecoratorConfig extends PropertyDecoratorConfig {
|
|
1702
2040
|
}
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
super(metadata.displayName, metadata.display, metadata.required, metadata.omitForCreate, metadata.omitForUpdate, metadata.defaultWidths, metadata.order);
|
|
1714
|
-
this.displayStyle = metadata.displayStyle;
|
|
2041
|
+
|
|
2042
|
+
/**
|
|
2043
|
+
* The internal DefaultNumberDecoratorConfig. Sets default values.
|
|
2044
|
+
*/
|
|
2045
|
+
class DefaultNumberDecoratorConfigInternal extends PropertyDecoratorConfigInternal {
|
|
2046
|
+
constructor(data) {
|
|
2047
|
+
super(data);
|
|
2048
|
+
this.displayStyle = data.displayStyle;
|
|
2049
|
+
this.max = data.max;
|
|
2050
|
+
this.min = data.min;
|
|
1715
2051
|
}
|
|
1716
2052
|
}
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
2053
|
+
/**
|
|
2054
|
+
* The internal DropdownNumberDecoratorConfig. Sets default values.
|
|
2055
|
+
*/
|
|
2056
|
+
class DropdownNumberDecoratorConfigInternal extends PropertyDecoratorConfigInternal {
|
|
2057
|
+
constructor(data) {
|
|
2058
|
+
super(data);
|
|
2059
|
+
this.displayStyle = data.displayStyle;
|
|
2060
|
+
this.dropdownValues = data.dropdownValues;
|
|
1721
2061
|
}
|
|
1722
2062
|
}
|
|
1723
2063
|
|
|
1724
2064
|
/**
|
|
1725
|
-
* Decorator for setting and getting string
|
|
1726
|
-
*
|
|
2065
|
+
* Decorator for setting and getting string property metadata.
|
|
2066
|
+
*
|
|
2067
|
+
* @param metadata - The metadata of the string property.
|
|
2068
|
+
* @returns The method that defines the metadata.
|
|
1727
2069
|
*/
|
|
1728
2070
|
function number(metadata) {
|
|
1729
2071
|
if (metadata.displayStyle === 'dropdown') {
|
|
1730
|
-
return baseProperty(new
|
|
2072
|
+
return baseProperty(new DropdownNumberDecoratorConfigInternal(metadata), DecoratorTypes.NUMBER_DROPDOWN);
|
|
1731
2073
|
}
|
|
1732
2074
|
else {
|
|
1733
|
-
return baseProperty(new
|
|
2075
|
+
return baseProperty(new DefaultNumberDecoratorConfigInternal(metadata), DecoratorTypes.NUMBER);
|
|
1734
2076
|
}
|
|
1735
2077
|
}
|
|
2078
|
+
|
|
1736
2079
|
/**
|
|
1737
|
-
*
|
|
2080
|
+
* Definition for the @number metadata.
|
|
1738
2081
|
*/
|
|
1739
2082
|
class NumberDecoratorConfig extends PropertyDecoratorConfig {
|
|
1740
2083
|
}
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
constructor(metadata) {
|
|
1751
|
-
super(metadata.displayName, metadata.display, metadata.required, metadata.omitForCreate, metadata.omitForUpdate, metadata.defaultWidths, metadata.order);
|
|
1752
|
-
this.displayStyle = metadata.displayStyle;
|
|
1753
|
-
this.dropdownValues = metadata.dropdownValues;
|
|
2084
|
+
|
|
2085
|
+
/**
|
|
2086
|
+
* The internal DefaultObjectDecoratorConfig. Sets default values.
|
|
2087
|
+
*/
|
|
2088
|
+
class DefaultObjectDecoratorConfigInternal extends PropertyDecoratorConfigInternal {
|
|
2089
|
+
constructor(data) {
|
|
2090
|
+
super(data);
|
|
2091
|
+
this.displayStyle = data.displayStyle;
|
|
2092
|
+
this.type = data.type;
|
|
1754
2093
|
}
|
|
1755
2094
|
}
|
|
1756
2095
|
|
|
1757
2096
|
/**
|
|
1758
|
-
* Decorator for setting and getting object
|
|
1759
|
-
*
|
|
2097
|
+
* Decorator for setting and getting object property metadata.
|
|
2098
|
+
*
|
|
2099
|
+
* @param metadata - The metadata of the object property.
|
|
2100
|
+
* @returns The method that defines the metadata.
|
|
1760
2101
|
*/
|
|
1761
2102
|
function object(metadata) {
|
|
1762
|
-
return baseProperty(new
|
|
2103
|
+
return baseProperty(new DefaultObjectDecoratorConfigInternal(metadata), DecoratorTypes.OBJECT);
|
|
1763
2104
|
}
|
|
2105
|
+
|
|
1764
2106
|
/**
|
|
1765
|
-
*
|
|
2107
|
+
* Definition for the @object metadata.
|
|
1766
2108
|
*/
|
|
1767
2109
|
class ObjectDecoratorConfig extends PropertyDecoratorConfig {
|
|
1768
2110
|
}
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
}
|
|
2111
|
+
|
|
2112
|
+
/**
|
|
2113
|
+
* Definition for the @string metadata.
|
|
2114
|
+
*/
|
|
2115
|
+
class StringDecoratorConfig extends PropertyDecoratorConfig {
|
|
1775
2116
|
}
|
|
1776
2117
|
|
|
1777
|
-
|
|
1778
|
-
* Public API Surface of ngx-material-entity
|
|
2118
|
+
/**
|
|
2119
|
+
* Public API Surface of ngx-material-entity.
|
|
1779
2120
|
*/
|
|
1780
2121
|
|
|
1781
2122
|
/**
|
|
1782
2123
|
* Generated bundle index. Do not edit.
|
|
1783
2124
|
*/
|
|
1784
2125
|
|
|
1785
|
-
export {
|
|
2126
|
+
export { DecoratorTypes, Entity, EntityService, EntityUtilities, NgxMatEntityConfirmDialogComponent, NgxMatEntityConfirmDialogModule, NgxMatEntityCreateDialogComponent, NgxMatEntityCreateDialogModule, NgxMatEntityEditDialogComponent, NgxMatEntityEditDialogModule, NgxMatEntityInputComponent, NgxMatEntityInputModule, NgxMatEntityTableComponent, NgxMatEntityTableModule, array, boolean, getValidationErrorMessage, number, object, string };
|
|
1786
2127
|
//# sourceMappingURL=ngx-material-entity.mjs.map
|