ngx-material-entity 0.1.4 → 0.1.5
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/capsulation/lodash.utilities.d.ts +62 -0
- package/capsulation/reflect.utilities.d.ts +56 -0
- package/classes/base.builder.d.ts +2 -1
- package/classes/date.utilities.d.ts +16 -4
- package/classes/entity.model.d.ts +7 -1
- package/classes/entity.service.d.ts +38 -1
- package/classes/entity.utilities.d.ts +43 -16
- package/classes/file.utilities.d.ts +52 -0
- package/components/input/add-array-item-dialog-data.builder.d.ts +3 -2
- package/components/input/add-array-item-dialog-data.d.ts +2 -1
- package/components/input/array/array-date-input/array-date-input.component.d.ts +22 -0
- package/components/input/array/array-date-range-input/array-date-range-input.component.d.ts +30 -0
- package/components/input/array/array-date-time-input/array-date-time-input.component.d.ts +32 -0
- package/components/input/array/array-string-autocomplete-chips/array-string-autocomplete-chips.component.d.ts +58 -0
- package/components/input/array/array-string-chips-input/array-string-chips-input.component.d.ts +51 -0
- package/components/input/array/array-table.class.d.ts +48 -0
- package/components/input/boolean/boolean-checkbox-input/boolean-checkbox-input.component.d.ts +17 -0
- package/components/input/boolean/boolean-dropdown-input/boolean-dropdown-input.component.d.ts +17 -0
- package/components/input/boolean/boolean-toggle-input/boolean-toggle-input.component.d.ts +17 -0
- package/components/input/date/date-input/date-input.component.d.ts +21 -0
- package/components/input/date/date-range-input/date-range-input.component.d.ts +27 -0
- package/components/input/date/date-time-input/date-time-input.component.d.ts +38 -0
- package/components/input/file/file-default-input/file-default-input.component.d.ts +21 -0
- package/components/input/file/file-image-input/file-image-input.component.d.ts +30 -0
- package/components/input/file/file-input/dragDrop.directive.d.ts +32 -0
- package/components/input/file/file-input/file-input.component.d.ts +32 -0
- package/components/input/input.component.d.ts +37 -92
- package/components/input/input.module.d.ts +37 -16
- package/components/input/number/number-dropdown-input/number-dropdown-input.component.d.ts +17 -0
- package/components/input/number/number-input/number-input.component.d.ts +17 -0
- package/components/input/string/string-autocomplete-input/string-autocomplete-input.component.d.ts +25 -0
- package/components/input/string/string-dropdown-input/string-dropdown-input.component.d.ts +17 -0
- package/components/input/string/string-input/string-input.component.d.ts +17 -0
- package/components/input/string/string-textbox-input/string-textbox-input.component.d.ts +17 -0
- package/components/table/create-dialog/create-entity-dialog-data.builder.d.ts +3 -2
- package/components/table/create-dialog/create-entity-dialog-data.d.ts +2 -1
- package/components/table/create-dialog/create-entity-dialog.component.d.ts +7 -2
- package/components/table/edit-dialog/edit-dialog-data.builder.d.ts +3 -2
- package/components/table/edit-dialog/edit-entity-dialog-data.d.ts +2 -1
- package/components/table/edit-dialog/edit-entity-dialog.builder.d.ts +3 -2
- package/components/table/edit-dialog/edit-entity-dialog.component.d.ts +5 -2
- package/components/table/table-data.builder.d.ts +5 -5
- package/components/table/table-data.d.ts +6 -6
- package/components/table/table.component.d.ts +2 -1
- package/decorators/array/array-decorator-internal.data.d.ts +71 -6
- package/decorators/array/array-decorator.data.d.ts +178 -12
- package/decorators/array/array.decorator.d.ts +3 -2
- package/decorators/base/base-property.decorator.d.ts +2 -3
- package/decorators/base/decorator-types.enum.d.ts +9 -3
- package/decorators/date/date-decorator-internal.data.d.ts +2 -2
- package/decorators/date/date.decorator.d.ts +8 -0
- package/decorators/file/file-decorator-internal.data.d.ts +92 -0
- package/decorators/file/file-decorator.data.d.ts +92 -0
- package/decorators/file/file.decorator.d.ts +9 -0
- package/decorators/object/object-decorator-internal.data.d.ts +2 -2
- package/decorators/object/object-decorator.data.d.ts +3 -3
- package/decorators/object/object.decorator.d.ts +2 -1
- package/esm2020/capsulation/lodash.utilities.mjs +75 -0
- package/esm2020/capsulation/reflect.utilities.mjs +69 -0
- package/esm2020/classes/base.builder.mjs +2 -3
- package/esm2020/classes/date.utilities.mjs +33 -13
- package/esm2020/classes/entity.model.mjs +1 -1
- package/esm2020/classes/entity.service.mjs +103 -6
- package/esm2020/classes/entity.utilities.mjs +202 -71
- package/esm2020/classes/file.utilities.mjs +123 -0
- package/esm2020/components/confirm-dialog/confirm-dialog-data.builder.mjs +4 -4
- package/esm2020/components/confirm-dialog/confirm-dialog.component.mjs +3 -3
- package/esm2020/components/input/add-array-item-dialog-data.builder.mjs +2 -2
- package/esm2020/components/input/add-array-item-dialog-data.mjs +1 -1
- package/esm2020/components/input/array/array-date-input/array-date-input.component.mjs +44 -0
- package/esm2020/components/input/array/array-date-range-input/array-date-range-input.component.mjs +68 -0
- package/esm2020/components/input/array/array-date-time-input/array-date-time-input.component.mjs +65 -0
- package/esm2020/components/input/array/array-string-autocomplete-chips/array-string-autocomplete-chips.component.mjs +131 -0
- package/esm2020/components/input/array/array-string-chips-input/array-string-chips-input.component.mjs +116 -0
- package/esm2020/components/input/array/array-table.class.mjs +92 -0
- package/esm2020/components/input/boolean/boolean-checkbox-input/boolean-checkbox-input.component.mjs +38 -0
- package/esm2020/components/input/boolean/boolean-dropdown-input/boolean-dropdown-input.component.mjs +35 -0
- package/esm2020/components/input/boolean/boolean-toggle-input/boolean-toggle-input.component.mjs +38 -0
- package/esm2020/components/input/date/date-input/date-input.component.mjs +38 -0
- package/esm2020/components/input/date/date-range-input/date-range-input.component.mjs +63 -0
- package/esm2020/components/input/date/date-time-input/date-time-input.component.mjs +74 -0
- package/esm2020/components/input/file/file-default-input/file-default-input.component.mjs +39 -0
- package/esm2020/components/input/file/file-image-input/file-image-input.component.mjs +95 -0
- package/esm2020/components/input/file/file-input/dragDrop.directive.mjs +64 -0
- package/esm2020/components/input/file/file-input/file-input.component.mjs +152 -0
- package/esm2020/components/input/input.component.mjs +124 -234
- package/esm2020/components/input/input.module.mjs +66 -3
- package/esm2020/components/input/number/number-dropdown-input/number-dropdown-input.component.mjs +36 -0
- package/esm2020/components/input/number/number-input/number-input.component.mjs +34 -0
- package/esm2020/components/input/string/string-autocomplete-input/string-autocomplete-input.component.mjs +52 -0
- package/esm2020/components/input/string/string-dropdown-input/string-dropdown-input.component.mjs +36 -0
- package/esm2020/components/input/string/string-input/string-input.component.mjs +34 -0
- package/esm2020/components/input/string/string-textbox-input/string-textbox-input.component.mjs +35 -0
- package/esm2020/components/table/create-dialog/create-dialog-data.builder.mjs +2 -2
- package/esm2020/components/table/create-dialog/create-entity-dialog-data.builder.mjs +1 -1
- package/esm2020/components/table/create-dialog/create-entity-dialog-data.mjs +1 -1
- package/esm2020/components/table/create-dialog/create-entity-dialog.component.mjs +15 -8
- package/esm2020/components/table/edit-dialog/edit-dialog-data.builder.mjs +2 -2
- package/esm2020/components/table/edit-dialog/edit-entity-dialog-data.mjs +1 -1
- package/esm2020/components/table/edit-dialog/edit-entity-dialog.builder.mjs +2 -2
- package/esm2020/components/table/edit-dialog/edit-entity-dialog.component.mjs +18 -10
- package/esm2020/components/table/table-data.builder.mjs +3 -3
- package/esm2020/components/table/table-data.mjs +1 -1
- package/esm2020/components/table/table.component.mjs +21 -23
- package/esm2020/decorators/array/array-decorator-internal.data.mjs +102 -14
- package/esm2020/decorators/array/array-decorator.data.mjs +2 -2
- package/esm2020/decorators/array/array.decorator.mjs +8 -2
- package/esm2020/decorators/base/base-property.decorator.mjs +4 -3
- package/esm2020/decorators/base/decorator-types.enum.mjs +6 -1
- package/esm2020/decorators/base/property-decorator-internal.data.mjs +10 -10
- package/esm2020/decorators/base/property-decorator.data.mjs +1 -1
- package/esm2020/decorators/boolean/boolean-decorator-internal.data.mjs +3 -3
- package/esm2020/decorators/date/date-decorator-internal.data.mjs +5 -5
- package/esm2020/decorators/date/date.decorator.mjs +21 -0
- package/esm2020/decorators/file/file-decorator-internal.data.mjs +98 -0
- package/esm2020/decorators/file/file-decorator.data.mjs +7 -0
- package/esm2020/decorators/file/file.decorator.mjs +22 -0
- package/esm2020/decorators/object/object-decorator-internal.data.mjs +1 -1
- package/esm2020/decorators/object/object-decorator.data.mjs +1 -1
- package/esm2020/decorators/object/object.decorator.mjs +1 -1
- package/esm2020/decorators/string/string.decorator.mjs +1 -1
- package/esm2020/mocks/placeholder-data.png.mjs +3 -0
- package/esm2020/public-api.mjs +6 -1
- package/fesm2015/ngx-material-entity.mjs +2452 -459
- package/fesm2015/ngx-material-entity.mjs.map +1 -1
- package/fesm2020/ngx-material-entity.mjs +2370 -464
- package/fesm2020/ngx-material-entity.mjs.map +1 -1
- package/mocks/placeholder-data.png.d.ts +1 -0
- package/package.json +1 -1
- package/public-api.d.ts +5 -0
|
@@ -1,45 +1,114 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { __decorate, __metadata, __awaiter } from 'tslib';
|
|
3
3
|
import { BehaviorSubject, firstValueFrom, Subject, takeUntil } from 'rxjs';
|
|
4
|
-
import {
|
|
4
|
+
import { isEqual, cloneDeep, omit, isNil, omitBy, isArray } from 'lodash';
|
|
5
5
|
import * as i0 from '@angular/core';
|
|
6
|
-
import { Component, Inject, NgModule, Input, ViewChild } from '@angular/core';
|
|
6
|
+
import { Component, Inject, NgModule, EventEmitter, Input, Output, Directive, HostListener, 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
9
|
import * as i6 from '@angular/material/checkbox';
|
|
10
10
|
import { MatCheckboxModule } from '@angular/material/checkbox';
|
|
11
|
-
import * as
|
|
11
|
+
import * as i4 from '@angular/material/button';
|
|
12
12
|
import { MatButtonModule } from '@angular/material/button';
|
|
13
|
-
import * as
|
|
13
|
+
import * as i4$1 from '@angular/common';
|
|
14
14
|
import { CommonModule } from '@angular/common';
|
|
15
|
-
import * as
|
|
15
|
+
import * as i3 from '@angular/forms';
|
|
16
16
|
import { FormsModule } from '@angular/forms';
|
|
17
|
-
import * as
|
|
17
|
+
import * as i5 from '@angular/material/table';
|
|
18
18
|
import { MatTableDataSource, MatTableModule } from '@angular/material/table';
|
|
19
19
|
import { SelectionModel } from '@angular/cdk/collections';
|
|
20
|
-
import * as
|
|
20
|
+
import * as i1$1 from '@angular/material/form-field';
|
|
21
21
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
22
|
-
import * as
|
|
22
|
+
import * as i4$2 from '@angular/material/input';
|
|
23
|
+
import { MatInputModule } from '@angular/material/input';
|
|
24
|
+
import * as i3$1 from '@angular/cdk/text-field';
|
|
25
|
+
import * as i2 from '@angular/material/autocomplete';
|
|
23
26
|
import { MatAutocompleteModule } from '@angular/material/autocomplete';
|
|
24
|
-
import * as
|
|
25
|
-
import * as
|
|
27
|
+
import * as i3$2 from '@angular/material/core';
|
|
28
|
+
import * as i2$1 from '@angular/material/select';
|
|
26
29
|
import { MatSelectModule } from '@angular/material/select';
|
|
27
|
-
import * as
|
|
30
|
+
import * as i2$2 from '@angular/material/slide-toggle';
|
|
28
31
|
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
|
|
29
|
-
import * as
|
|
30
|
-
import { MatChipsModule } from '@angular/material/chips';
|
|
31
|
-
import * as i11 from '@angular/material/datepicker';
|
|
32
|
+
import * as i3$3 from '@angular/material/datepicker';
|
|
32
33
|
import { MatDatepickerModule } from '@angular/material/datepicker';
|
|
33
|
-
import * as
|
|
34
|
-
import {
|
|
35
|
-
import * as i15 from '@angular/cdk/text-field';
|
|
34
|
+
import * as i2$3 from '@angular/material/chips';
|
|
35
|
+
import { MatChipsModule } from '@angular/material/chips';
|
|
36
36
|
import { MatIconModule } from '@angular/material/icon';
|
|
37
|
-
import * as i7
|
|
37
|
+
import * as i7 from '@angular/material/paginator';
|
|
38
38
|
import { MatPaginator, MatPaginatorModule } from '@angular/material/paginator';
|
|
39
39
|
import { MatSort } from '@angular/material/sort';
|
|
40
|
-
import * as i4$
|
|
40
|
+
import * as i4$3 from '@angular/material/menu';
|
|
41
41
|
import { MatMenuModule } from '@angular/material/menu';
|
|
42
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Encapsulates all functionality of Reflect.
|
|
45
|
+
*/
|
|
46
|
+
class ReflectUtilities {
|
|
47
|
+
/**
|
|
48
|
+
* Gets the metadata value for the provided metadata key on the target object or its prototype chain.
|
|
49
|
+
*
|
|
50
|
+
* @param metadataKey - A key used to store and retrieve metadata.
|
|
51
|
+
* @param target - The target object on which the metadata is defined.
|
|
52
|
+
* @param propertyKey - The property key for the target.
|
|
53
|
+
* @returns The metadata value for the metadata key if found; otherwise, undefined.
|
|
54
|
+
*/
|
|
55
|
+
static getMetadata(metadataKey, target, propertyKey) {
|
|
56
|
+
return Reflect.getMetadata(metadataKey, target, propertyKey);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Returns the string and symbol keys of the own properties of an object. The own properties of an object
|
|
60
|
+
* are those that are defined directly on that object, and are not inherited from the object's prototype.
|
|
61
|
+
*
|
|
62
|
+
* @param target - Object that contains the own properties.
|
|
63
|
+
* @returns The keys of the given object.
|
|
64
|
+
*/
|
|
65
|
+
static ownKeys(target) {
|
|
66
|
+
return Reflect.ownKeys(target);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Gets the property of target, equivalent to `target[propertyKey]`.
|
|
70
|
+
*
|
|
71
|
+
* @param target - Object that contains the property on itself or in its prototype chain.
|
|
72
|
+
* @param propertyKey - The property name.
|
|
73
|
+
* @returns The property of the target of the given key.
|
|
74
|
+
*/
|
|
75
|
+
static get(target, propertyKey) {
|
|
76
|
+
return Reflect.get(target, propertyKey);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Sets the property of target, equivalent to `target[propertyKey] = value`.
|
|
80
|
+
*
|
|
81
|
+
* @param target - Object that contains the property on itself or in its prototype chain.
|
|
82
|
+
* @param propertyKey - The property name.
|
|
83
|
+
* @param value - The value to set the property to.
|
|
84
|
+
* @returns If setting the value was successful.
|
|
85
|
+
*/
|
|
86
|
+
static set(target, propertyKey, value) {
|
|
87
|
+
return Reflect.set(target, propertyKey, value);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Equivalent to `propertyKey in target`.
|
|
91
|
+
*
|
|
92
|
+
* @param target - Object that contains the property on itself or in its prototype chain.
|
|
93
|
+
* @param propertyKey - Name of the property.
|
|
94
|
+
* @returns Whether or not the given target has the key.
|
|
95
|
+
*/
|
|
96
|
+
static has(target, propertyKey) {
|
|
97
|
+
return Reflect.has(target, propertyKey);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Define a unique metadata entry on the target.
|
|
101
|
+
*
|
|
102
|
+
* @param metadataKey - A key used to store and retrieve metadata.
|
|
103
|
+
* @param metadataValue - A value that contains attached metadata.
|
|
104
|
+
* @param target - The target object on which to define metadata.
|
|
105
|
+
* @param propertyKey - The property key for the target.
|
|
106
|
+
*/
|
|
107
|
+
static defineMetadata(metadataKey, metadataValue, target, propertyKey) {
|
|
108
|
+
Reflect.defineMetadata(metadataKey, metadataValue, target, propertyKey);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
43
112
|
/**
|
|
44
113
|
* The base decorator for setting metadata on properties.
|
|
45
114
|
*
|
|
@@ -49,8 +118,8 @@ import { MatMenuModule } from '@angular/material/menu';
|
|
|
49
118
|
*/
|
|
50
119
|
function baseProperty(metadata, type) {
|
|
51
120
|
return function (target, propertyKey) {
|
|
52
|
-
|
|
53
|
-
|
|
121
|
+
ReflectUtilities.defineMetadata('metadata', metadata, target, propertyKey);
|
|
122
|
+
ReflectUtilities.defineMetadata('type', type, target, propertyKey);
|
|
54
123
|
};
|
|
55
124
|
}
|
|
56
125
|
|
|
@@ -70,11 +139,16 @@ var DecoratorTypes;
|
|
|
70
139
|
DecoratorTypes["BOOLEAN_DROPDOWN"] = "booleanDropdown";
|
|
71
140
|
DecoratorTypes["OBJECT"] = "object";
|
|
72
141
|
DecoratorTypes["ARRAY"] = "array";
|
|
142
|
+
DecoratorTypes["ARRAY_DATE"] = "arrayDate";
|
|
143
|
+
DecoratorTypes["ARRAY_DATE_TIME"] = "arrayDateTime";
|
|
144
|
+
DecoratorTypes["ARRAY_DATE_RANGE"] = "arrayDateRange";
|
|
73
145
|
DecoratorTypes["ARRAY_STRING_CHIPS"] = "arrayStringChips";
|
|
74
146
|
DecoratorTypes["ARRAY_STRING_AUTOCOMPLETE_CHIPS"] = "arrayStringAutocompleteChips";
|
|
75
147
|
DecoratorTypes["DATE"] = "date";
|
|
76
148
|
DecoratorTypes["DATE_RANGE"] = "dateRange";
|
|
77
149
|
DecoratorTypes["DATE_TIME"] = "dateTime";
|
|
150
|
+
DecoratorTypes["FILE_DEFAULT"] = "fileDefault";
|
|
151
|
+
DecoratorTypes["FILE_IMAGE"] = "fileImage";
|
|
78
152
|
})(DecoratorTypes || (DecoratorTypes = {}));
|
|
79
153
|
|
|
80
154
|
/**
|
|
@@ -82,12 +156,13 @@ var DecoratorTypes;
|
|
|
82
156
|
*/
|
|
83
157
|
class PositionInternal {
|
|
84
158
|
constructor(data) {
|
|
159
|
+
var _a, _b;
|
|
85
160
|
this.validateInput(data);
|
|
86
|
-
this.row = (data === null || data === void 0 ? void 0 : data.row) ?
|
|
87
|
-
this.order = (data === null || data === void 0 ? void 0 : data.order) ?
|
|
161
|
+
this.row = (_a = data === null || data === void 0 ? void 0 : data.row) !== null && _a !== void 0 ? _a : -1;
|
|
162
|
+
this.order = (_b = data === null || data === void 0 ? void 0 : data.order) !== null && _b !== void 0 ? _b : -1;
|
|
88
163
|
}
|
|
89
164
|
validateInput(data) {
|
|
90
|
-
if (data === null || data === void 0 ? void 0 : data.order) {
|
|
165
|
+
if ((data === null || data === void 0 ? void 0 : data.order) != null) {
|
|
91
166
|
if (data.order < 1) {
|
|
92
167
|
throw new Error('order must be at least 1');
|
|
93
168
|
}
|
|
@@ -95,7 +170,7 @@ class PositionInternal {
|
|
|
95
170
|
throw new Error('order cannot be bigger than 12 (the minimum value for a bootstrap column)');
|
|
96
171
|
}
|
|
97
172
|
}
|
|
98
|
-
if ((data === null || data === void 0 ? void 0 : data.row) &&
|
|
173
|
+
if ((data === null || data === void 0 ? void 0 : data.row) != null && data.row < 1) {
|
|
99
174
|
throw new Error('row must be at least 1');
|
|
100
175
|
}
|
|
101
176
|
}
|
|
@@ -105,12 +180,13 @@ class PositionInternal {
|
|
|
105
180
|
*/
|
|
106
181
|
class PropertyDecoratorConfigInternal {
|
|
107
182
|
constructor(data) {
|
|
108
|
-
|
|
183
|
+
var _a, _b, _c, _d, _e;
|
|
184
|
+
this.display = (_a = data.display) !== null && _a !== void 0 ? _a : true;
|
|
109
185
|
this.displayName = data.displayName;
|
|
110
|
-
this.required = data.required
|
|
111
|
-
this.omitForCreate = data.omitForCreate
|
|
112
|
-
this.omitForUpdate = data.omitForUpdate
|
|
113
|
-
this.defaultWidths = data.defaultWidths ?
|
|
186
|
+
this.required = (_b = data.required) !== null && _b !== void 0 ? _b : true;
|
|
187
|
+
this.omitForCreate = (_c = data.omitForCreate) !== null && _c !== void 0 ? _c : false;
|
|
188
|
+
this.omitForUpdate = (_d = data.omitForUpdate) !== null && _d !== void 0 ? _d : false;
|
|
189
|
+
this.defaultWidths = (_e = data.defaultWidths) !== null && _e !== void 0 ? _e : [6, 6, 12];
|
|
114
190
|
this.position = new PositionInternal(data.position);
|
|
115
191
|
}
|
|
116
192
|
}
|
|
@@ -200,6 +276,80 @@ __decorate([
|
|
|
200
276
|
__metadata("design:type", String)
|
|
201
277
|
], Entity.prototype, "id", void 0);
|
|
202
278
|
|
|
279
|
+
/**
|
|
280
|
+
* Encapsulates all functionality of lodash.
|
|
281
|
+
*/
|
|
282
|
+
class LodashUtilities {
|
|
283
|
+
/**
|
|
284
|
+
* Performs a deep comparison between two values to determine if they are
|
|
285
|
+
* equivalent.
|
|
286
|
+
*
|
|
287
|
+
* **Note:** This method supports comparing arrays, array buffers, booleans,
|
|
288
|
+
* date objects, error objects, maps, numbers, `Object` objects, regexps,
|
|
289
|
+
* sets, strings, symbols, and typed arrays. `Object` objects are compared
|
|
290
|
+
* by their own, not inherited, enumerable properties. Functions and DOM
|
|
291
|
+
* nodes are **not** supported.
|
|
292
|
+
*
|
|
293
|
+
* @param value - The value to compare.
|
|
294
|
+
* @param other - The other value to compare.
|
|
295
|
+
* @returns Returns `true` if the values are equivalent, else `false`.
|
|
296
|
+
*/
|
|
297
|
+
static isEqual(value, other) {
|
|
298
|
+
return isEqual(value, other);
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* This method is like _.clone except that it recursively clones value.
|
|
302
|
+
*
|
|
303
|
+
* @param value - The value to recursively clone.
|
|
304
|
+
* @returns Returns the deep cloned value.
|
|
305
|
+
*/
|
|
306
|
+
static cloneDeep(value) {
|
|
307
|
+
return cloneDeep(value);
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* The opposite of `_.pick`; this method creates an object composed of the
|
|
311
|
+
* own and inherited enumerable properties of `object` that are not omitted.
|
|
312
|
+
*
|
|
313
|
+
* @param object - The source object.
|
|
314
|
+
* @param paths - The property names to omit, specified
|
|
315
|
+
* individually or in arrays.
|
|
316
|
+
* @returns Returns the new object.
|
|
317
|
+
*/
|
|
318
|
+
static omit(object, ...paths) {
|
|
319
|
+
return omit(object, ...paths);
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Checks if `value` is `null` or `undefined`.
|
|
323
|
+
*
|
|
324
|
+
* @param value - The value to check.
|
|
325
|
+
* @returns Returns `true` if `value` is nullish, else `false`.
|
|
326
|
+
*/
|
|
327
|
+
static isNil(value) {
|
|
328
|
+
return isNil(value);
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* The opposite of `_.pickBy`; this method creates an object composed of the
|
|
332
|
+
* own and inherited enumerable properties of `object` that `predicate`
|
|
333
|
+
* doesn't return truthy for.
|
|
334
|
+
*
|
|
335
|
+
* @param object - The source object.
|
|
336
|
+
* @param predicate - The function invoked per property.
|
|
337
|
+
* @returns Returns the new object.
|
|
338
|
+
*/
|
|
339
|
+
static omitBy(object, predicate) {
|
|
340
|
+
return omitBy(object, predicate);
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Checks if value is classified as an Array object.
|
|
344
|
+
*
|
|
345
|
+
* @param value - The value to check.
|
|
346
|
+
* @returns Returns true if value is correctly classified, else false.
|
|
347
|
+
*/
|
|
348
|
+
static isArray(value) {
|
|
349
|
+
return isArray(value);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
203
353
|
const DAY_IN_MS = 1000 * 60 * 60 * 24;
|
|
204
354
|
/**
|
|
205
355
|
* Contains Helper Functions for handling date properties.
|
|
@@ -225,14 +375,14 @@ class DateUtilities {
|
|
|
225
375
|
const res = [{ displayName: '-', value: undefined }];
|
|
226
376
|
for (let hour = 0; hour < 24; hour++) {
|
|
227
377
|
for (let minute = 0; minute < 60; minute += minuteSteps) {
|
|
228
|
-
res.push(
|
|
378
|
+
res.push(DateUtilities.getTimeDropdownValue(format, hour, minute));
|
|
229
379
|
}
|
|
230
380
|
}
|
|
231
381
|
return res;
|
|
232
382
|
}
|
|
233
383
|
static getTimeDropdownValue(format, hour, minute) {
|
|
234
|
-
const displayHour =
|
|
235
|
-
const displayMinute =
|
|
384
|
+
const displayHour = DateUtilities.getFormattedHour(format, LodashUtilities.cloneDeep(hour));
|
|
385
|
+
const displayMinute = DateUtilities.getFormattedMinute(format, hour, minute);
|
|
236
386
|
return {
|
|
237
387
|
displayName: `${displayHour}:${displayMinute}`,
|
|
238
388
|
value: {
|
|
@@ -270,10 +420,7 @@ class DateUtilities {
|
|
|
270
420
|
*/
|
|
271
421
|
static getTimeFromDate(value) {
|
|
272
422
|
if (!value) {
|
|
273
|
-
return
|
|
274
|
-
hours: undefined,
|
|
275
|
-
minutes: undefined
|
|
276
|
-
};
|
|
423
|
+
return undefined;
|
|
277
424
|
}
|
|
278
425
|
else {
|
|
279
426
|
return {
|
|
@@ -287,10 +434,10 @@ class DateUtilities {
|
|
|
287
434
|
*
|
|
288
435
|
* @param startDate - The start date.
|
|
289
436
|
* @param endDate - The end date.
|
|
290
|
-
* @param
|
|
437
|
+
* @param filter - The custom filter from the metadata.
|
|
291
438
|
* @returns All dates between the two provided dates. Includes start and end date.
|
|
292
439
|
*/
|
|
293
|
-
static getDatesBetween(startDate, endDate,
|
|
440
|
+
static getDatesBetween(startDate, endDate, filter) {
|
|
294
441
|
const res = [];
|
|
295
442
|
while (startDate.getFullYear() < endDate.getFullYear()
|
|
296
443
|
|| startDate.getMonth() < endDate.getMonth()
|
|
@@ -298,8 +445,8 @@ class DateUtilities {
|
|
|
298
445
|
res.push(new Date(startDate));
|
|
299
446
|
startDate.setTime(startDate.getTime() + DAY_IN_MS);
|
|
300
447
|
}
|
|
301
|
-
if (
|
|
302
|
-
return res.filter(d =>
|
|
448
|
+
if (filter) {
|
|
449
|
+
return res.filter(d => filter(d));
|
|
303
450
|
}
|
|
304
451
|
else {
|
|
305
452
|
return res;
|
|
@@ -335,6 +482,158 @@ class DateUtilities {
|
|
|
335
482
|
}
|
|
336
483
|
return times;
|
|
337
484
|
}
|
|
485
|
+
/**
|
|
486
|
+
* Checks if the time object has processable hours and minutes properties.
|
|
487
|
+
* Doesn't check custom validators like min/max from the metadata configuration.
|
|
488
|
+
*
|
|
489
|
+
* @param time - The time to check.
|
|
490
|
+
* @returns Whether or not the time object is unprocessable.
|
|
491
|
+
*/
|
|
492
|
+
static timeIsUnprocessable(time) {
|
|
493
|
+
if (!time
|
|
494
|
+
|| time.hours == null
|
|
495
|
+
|| typeof time.hours !== 'number'
|
|
496
|
+
|| Number.isNaN(time.hours)
|
|
497
|
+
|| time.minutes == null
|
|
498
|
+
|| typeof time.minutes !== 'number'
|
|
499
|
+
|| Number.isNaN(time.minutes)) {
|
|
500
|
+
return true;
|
|
501
|
+
}
|
|
502
|
+
return false;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* The default filter function to user when none was provided by the user.
|
|
507
|
+
*/
|
|
508
|
+
DateUtilities.defaultDateFilter = () => true;
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Provides functionality regarding files.
|
|
512
|
+
*/
|
|
513
|
+
class FileUtilities {
|
|
514
|
+
/**
|
|
515
|
+
* Gets the accept value for the html input.
|
|
516
|
+
*
|
|
517
|
+
* @param mimeTypes - The mimeTypes to get the accept string from.
|
|
518
|
+
* @returns A comma separated string of all the provided mime types.
|
|
519
|
+
*/
|
|
520
|
+
static getAcceptString(mimeTypes) {
|
|
521
|
+
if (!(mimeTypes === null || mimeTypes === void 0 ? void 0 : mimeTypes.length)) {
|
|
522
|
+
return '*';
|
|
523
|
+
}
|
|
524
|
+
return mimeTypes.join(', ');
|
|
525
|
+
}
|
|
526
|
+
// TODO: Find a way to use blobs with jest
|
|
527
|
+
/* istanbul ignore next */
|
|
528
|
+
/**
|
|
529
|
+
* Reads a url to display the given file.
|
|
530
|
+
*
|
|
531
|
+
* @param file - The file to get the url from.
|
|
532
|
+
* @returns A promise of the url. Undefined if no file was provided.
|
|
533
|
+
*/
|
|
534
|
+
static getDataURLFromFile(file) {
|
|
535
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
536
|
+
if (!file) {
|
|
537
|
+
return undefined;
|
|
538
|
+
}
|
|
539
|
+
return new Promise((resolve, reject) => {
|
|
540
|
+
const reader = new FileReader();
|
|
541
|
+
reader.onload = e => { var _a; return resolve((_a = e.target) === null || _a === void 0 ? void 0 : _a.result); };
|
|
542
|
+
reader.onerror = e => reject(e);
|
|
543
|
+
reader.readAsDataURL(file);
|
|
544
|
+
});
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
// TODO: Find a way to use blobs with jest
|
|
548
|
+
/* istanbul ignore next */
|
|
549
|
+
/**
|
|
550
|
+
* Gets a file from the given url.
|
|
551
|
+
*
|
|
552
|
+
* @param url - The url to get the file from.
|
|
553
|
+
* @returns A promise of the File.
|
|
554
|
+
*/
|
|
555
|
+
static getFileFromUrl(url) {
|
|
556
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
557
|
+
const res = yield fetch(url);
|
|
558
|
+
if (!res.ok) {
|
|
559
|
+
// TODO make error more robust
|
|
560
|
+
throw new Error(`Error fetching the file from the url ${url}`);
|
|
561
|
+
}
|
|
562
|
+
return yield res.blob();
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
// TODO: Find a way to use blobs with jest
|
|
566
|
+
/* istanbul ignore next */
|
|
567
|
+
/**
|
|
568
|
+
* Gets the file data with the blob from the given File Data.
|
|
569
|
+
*
|
|
570
|
+
* @param data - The File Data to get the file data with blob from.
|
|
571
|
+
* @returns FileDataWithFile.
|
|
572
|
+
*/
|
|
573
|
+
static getFileData(data) {
|
|
574
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
575
|
+
if (data.file) {
|
|
576
|
+
return {
|
|
577
|
+
file: data.file,
|
|
578
|
+
name: data.name,
|
|
579
|
+
url: data.url,
|
|
580
|
+
type: data.type,
|
|
581
|
+
size: data.size
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
else {
|
|
585
|
+
return {
|
|
586
|
+
file: yield FileUtilities.getFileFromUrl(data.url),
|
|
587
|
+
name: data.name,
|
|
588
|
+
url: data.url,
|
|
589
|
+
type: data.type,
|
|
590
|
+
size: data.size
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Checks if the given file has a valid mime type.
|
|
597
|
+
*
|
|
598
|
+
* @param type - The type of the file to check.
|
|
599
|
+
* @param allowedMimeTypes - The allowed mime types.
|
|
600
|
+
* @returns Whether or not the given file has a valid mime type.
|
|
601
|
+
*/
|
|
602
|
+
static isMimeTypeValid(type, allowedMimeTypes) {
|
|
603
|
+
if (allowedMimeTypes.includes('*')) {
|
|
604
|
+
return true;
|
|
605
|
+
}
|
|
606
|
+
for (const t of allowedMimeTypes) {
|
|
607
|
+
if (t === type) {
|
|
608
|
+
return true;
|
|
609
|
+
}
|
|
610
|
+
if (t.endsWith('*') && type.startsWith(t.split('*')[0])) {
|
|
611
|
+
return true;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
return false;
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* Transform the given value to Megabytes.
|
|
618
|
+
*
|
|
619
|
+
* @param value - The original value.
|
|
620
|
+
* @param unit - If the value is B, KB or GB.
|
|
621
|
+
* @returns The given value as bytes.
|
|
622
|
+
*/
|
|
623
|
+
static transformToMegaBytes(value, unit) {
|
|
624
|
+
const bytes = this.transformToBytes(value, unit);
|
|
625
|
+
return bytes / 1000000;
|
|
626
|
+
}
|
|
627
|
+
static transformToBytes(value, unit) {
|
|
628
|
+
switch (unit) {
|
|
629
|
+
case 'B':
|
|
630
|
+
return value;
|
|
631
|
+
case 'KB':
|
|
632
|
+
return value * 1000;
|
|
633
|
+
case 'GB':
|
|
634
|
+
return value * 1000000000;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
338
637
|
}
|
|
339
638
|
|
|
340
639
|
/**
|
|
@@ -373,6 +672,26 @@ class EntityUtilities {
|
|
|
373
672
|
}
|
|
374
673
|
return res;
|
|
375
674
|
}
|
|
675
|
+
/**
|
|
676
|
+
* Gets all properties on the given entity which are files.
|
|
677
|
+
*
|
|
678
|
+
* @param entity - The entity to check for file properties.
|
|
679
|
+
* @param omit - Whether to leave out values that are omitted for create or delete.
|
|
680
|
+
* @returns The keys of all file properties on the given entity.
|
|
681
|
+
*/
|
|
682
|
+
static getFileProperties(entity, omit) {
|
|
683
|
+
const res = [];
|
|
684
|
+
for (const key of EntityUtilities.keysOf(entity)) {
|
|
685
|
+
const type = EntityUtilities.getPropertyType(entity, key);
|
|
686
|
+
if (type === DecoratorTypes.FILE_DEFAULT || type === DecoratorTypes.FILE_IMAGE) {
|
|
687
|
+
const metadata = EntityUtilities.getPropertyMetadata(entity, key);
|
|
688
|
+
if (!(metadata.omitForCreate && omit === 'create') && !(metadata.omitForUpdate && omit === 'update')) {
|
|
689
|
+
res.push(key);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
return res;
|
|
694
|
+
}
|
|
376
695
|
/**
|
|
377
696
|
* Gets the metadata included in an property.
|
|
378
697
|
*
|
|
@@ -385,16 +704,11 @@ class EntityUtilities {
|
|
|
385
704
|
static getPropertyMetadata(entity, propertyKey,
|
|
386
705
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
387
706
|
type) {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
if (!metadata) {
|
|
391
|
-
throw new Error(`Could not find metadata for property ${String(propertyKey)} on the entity ${JSON.stringify(entity)}`);
|
|
392
|
-
}
|
|
393
|
-
return metadata;
|
|
394
|
-
}
|
|
395
|
-
catch (error) {
|
|
707
|
+
const metadata = ReflectUtilities.getMetadata('metadata', entity, propertyKey);
|
|
708
|
+
if (metadata == null) {
|
|
396
709
|
throw new Error(`Could not find metadata for property ${String(propertyKey)} on the entity ${JSON.stringify(entity)}`);
|
|
397
710
|
}
|
|
711
|
+
return metadata;
|
|
398
712
|
}
|
|
399
713
|
/**
|
|
400
714
|
* Gets the type of the property-metadata.
|
|
@@ -406,8 +720,8 @@ class EntityUtilities {
|
|
|
406
720
|
*/
|
|
407
721
|
static getPropertyType(entity, propertyKey) {
|
|
408
722
|
try {
|
|
409
|
-
const propertyType =
|
|
410
|
-
if (
|
|
723
|
+
const propertyType = ReflectUtilities.getMetadata('type', entity, propertyKey);
|
|
724
|
+
if (propertyType == null) {
|
|
411
725
|
throw new Error(`Could not find type metadata for property ${String(propertyKey)} on the entity ${JSON.stringify(entity)}`);
|
|
412
726
|
}
|
|
413
727
|
return propertyType;
|
|
@@ -428,12 +742,10 @@ class EntityUtilities {
|
|
|
428
742
|
static new(target, entity) {
|
|
429
743
|
for (const key in target) {
|
|
430
744
|
const type = EntityUtilities.getPropertyType(target, key);
|
|
431
|
-
|
|
432
|
-
let value = entity ? Reflect.get(entity, key) : undefined;
|
|
745
|
+
let value = entity ? ReflectUtilities.get(entity, key) : undefined;
|
|
433
746
|
switch (type) {
|
|
434
747
|
case DecoratorTypes.OBJECT:
|
|
435
748
|
const objectMetadata = EntityUtilities.getPropertyMetadata(target, key, DecoratorTypes.OBJECT);
|
|
436
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
437
749
|
value = new objectMetadata.EntityClass(value);
|
|
438
750
|
break;
|
|
439
751
|
case DecoratorTypes.ARRAY:
|
|
@@ -451,7 +763,7 @@ class EntityUtilities {
|
|
|
451
763
|
default:
|
|
452
764
|
break;
|
|
453
765
|
}
|
|
454
|
-
|
|
766
|
+
ReflectUtilities.set(target, key, value);
|
|
455
767
|
}
|
|
456
768
|
}
|
|
457
769
|
/**
|
|
@@ -488,28 +800,34 @@ class EntityUtilities {
|
|
|
488
800
|
if (metadata.omitForUpdate && omit === 'update') {
|
|
489
801
|
return true;
|
|
490
802
|
}
|
|
491
|
-
if (metadata.required &&
|
|
803
|
+
if (metadata.required && entity[key] == null) {
|
|
492
804
|
return false;
|
|
493
805
|
}
|
|
494
806
|
switch (type) {
|
|
495
807
|
case DecoratorTypes.BOOLEAN_DROPDOWN:
|
|
808
|
+
break;
|
|
496
809
|
case DecoratorTypes.BOOLEAN_CHECKBOX:
|
|
497
810
|
case DecoratorTypes.BOOLEAN_TOGGLE:
|
|
498
|
-
|
|
811
|
+
const entityBoolean = entity[key];
|
|
812
|
+
const booleanMetadata = metadata;
|
|
813
|
+
if (!EntityUtilities.isBooleanValid(entityBoolean, booleanMetadata)) {
|
|
814
|
+
return false;
|
|
815
|
+
}
|
|
816
|
+
break;
|
|
499
817
|
case DecoratorTypes.STRING_DROPDOWN:
|
|
500
|
-
|
|
818
|
+
break;
|
|
501
819
|
case DecoratorTypes.STRING:
|
|
502
820
|
case DecoratorTypes.STRING_AUTOCOMPLETE:
|
|
503
821
|
const entityString = entity[key];
|
|
504
822
|
const stringMetadata = metadata;
|
|
505
|
-
if (!
|
|
823
|
+
if (!EntityUtilities.isStringValid(entityString, stringMetadata)) {
|
|
506
824
|
return false;
|
|
507
825
|
}
|
|
508
826
|
break;
|
|
509
827
|
case DecoratorTypes.STRING_TEXTBOX:
|
|
510
828
|
const entityTextbox = entity[key];
|
|
511
829
|
const textboxMetadata = metadata;
|
|
512
|
-
if (!
|
|
830
|
+
if (!EntityUtilities.isTextboxValid(entityTextbox, textboxMetadata)) {
|
|
513
831
|
return false;
|
|
514
832
|
}
|
|
515
833
|
break;
|
|
@@ -518,7 +836,7 @@ class EntityUtilities {
|
|
|
518
836
|
case DecoratorTypes.NUMBER:
|
|
519
837
|
const entityNumber = entity[key];
|
|
520
838
|
const numberMetadata = metadata;
|
|
521
|
-
if (!
|
|
839
|
+
if (!EntityUtilities.isNumberValid(entityNumber, numberMetadata)) {
|
|
522
840
|
return false;
|
|
523
841
|
}
|
|
524
842
|
break;
|
|
@@ -532,6 +850,9 @@ class EntityUtilities {
|
|
|
532
850
|
break;
|
|
533
851
|
case DecoratorTypes.ARRAY_STRING_CHIPS:
|
|
534
852
|
case DecoratorTypes.ARRAY_STRING_AUTOCOMPLETE_CHIPS:
|
|
853
|
+
case DecoratorTypes.ARRAY_DATE:
|
|
854
|
+
case DecoratorTypes.ARRAY_DATE_TIME:
|
|
855
|
+
case DecoratorTypes.ARRAY_DATE_RANGE:
|
|
535
856
|
case DecoratorTypes.ARRAY:
|
|
536
857
|
const entityArray = entity[key];
|
|
537
858
|
const arrayMetadata = metadata;
|
|
@@ -542,21 +863,29 @@ class EntityUtilities {
|
|
|
542
863
|
case DecoratorTypes.DATE:
|
|
543
864
|
const entityDate = new Date(entity[key]);
|
|
544
865
|
const dateMetadata = metadata;
|
|
545
|
-
if (!
|
|
866
|
+
if (!EntityUtilities.isDateValid(entityDate, dateMetadata)) {
|
|
546
867
|
return false;
|
|
547
868
|
}
|
|
548
869
|
break;
|
|
549
870
|
case DecoratorTypes.DATE_RANGE:
|
|
550
|
-
const entityDateRange = cloneDeep(entity[key]);
|
|
871
|
+
const entityDateRange = LodashUtilities.cloneDeep(entity[key]);
|
|
551
872
|
const dateRangeMetadata = metadata;
|
|
552
|
-
if (!
|
|
873
|
+
if (!EntityUtilities.isDateRangeValid(entityDateRange, dateRangeMetadata)) {
|
|
553
874
|
return false;
|
|
554
875
|
}
|
|
555
876
|
break;
|
|
556
877
|
case DecoratorTypes.DATE_TIME:
|
|
557
878
|
const entityDateTime = new Date(entity[key]);
|
|
558
879
|
const dateTimeMetadata = metadata;
|
|
559
|
-
if (!
|
|
880
|
+
if (!EntityUtilities.isDateTimeValid(entityDateTime, dateTimeMetadata)) {
|
|
881
|
+
return false;
|
|
882
|
+
}
|
|
883
|
+
break;
|
|
884
|
+
case DecoratorTypes.FILE_DEFAULT:
|
|
885
|
+
case DecoratorTypes.FILE_IMAGE:
|
|
886
|
+
const entityFile = entity[key];
|
|
887
|
+
const entityFileMetadata = metadata;
|
|
888
|
+
if (!EntityUtilities.isFileDataValid(entityFile, entityFileMetadata)) {
|
|
560
889
|
return false;
|
|
561
890
|
}
|
|
562
891
|
break;
|
|
@@ -565,6 +894,12 @@ class EntityUtilities {
|
|
|
565
894
|
}
|
|
566
895
|
return true;
|
|
567
896
|
}
|
|
897
|
+
static isBooleanValid(value, metadata) {
|
|
898
|
+
if (metadata.required && !value) {
|
|
899
|
+
return false;
|
|
900
|
+
}
|
|
901
|
+
return true;
|
|
902
|
+
}
|
|
568
903
|
static isStringValid(value, metadata) {
|
|
569
904
|
if (metadata.maxLength && value.length > metadata.maxLength) {
|
|
570
905
|
return false;
|
|
@@ -608,8 +943,13 @@ class EntityUtilities {
|
|
|
608
943
|
return true;
|
|
609
944
|
}
|
|
610
945
|
static isDateRangeValid(value, metadata) {
|
|
611
|
-
if (metadata.required
|
|
612
|
-
|
|
946
|
+
if (metadata.required) {
|
|
947
|
+
if (!value.start) {
|
|
948
|
+
return false;
|
|
949
|
+
}
|
|
950
|
+
if (!value.end) {
|
|
951
|
+
return false;
|
|
952
|
+
}
|
|
613
953
|
}
|
|
614
954
|
value.start = new Date(value.start);
|
|
615
955
|
value.end = new Date(value.end);
|
|
@@ -679,6 +1019,29 @@ class EntityUtilities {
|
|
|
679
1019
|
}
|
|
680
1020
|
return true;
|
|
681
1021
|
}
|
|
1022
|
+
static isFileDataValid(value, metadata) {
|
|
1023
|
+
const files = metadata.multiple ? value : [value];
|
|
1024
|
+
const maxSize = metadata.maxSize * 1000000;
|
|
1025
|
+
const maxSizeTotal = metadata.maxSizeTotal * 1000000;
|
|
1026
|
+
let fileSizeTotal = 0;
|
|
1027
|
+
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
1028
|
+
for (let i = 0; i < files.length; i++) {
|
|
1029
|
+
if (!files[i].name || !files[i].file && !files[i].url) {
|
|
1030
|
+
return false;
|
|
1031
|
+
}
|
|
1032
|
+
if (!FileUtilities.isMimeTypeValid(files[i].type, metadata.allowedMimeTypes)) {
|
|
1033
|
+
return false;
|
|
1034
|
+
}
|
|
1035
|
+
if (files[i].size > maxSize) {
|
|
1036
|
+
return false;
|
|
1037
|
+
}
|
|
1038
|
+
fileSizeTotal += files[i].size;
|
|
1039
|
+
if (fileSizeTotal > maxSizeTotal) {
|
|
1040
|
+
return false;
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
return true;
|
|
1044
|
+
}
|
|
682
1045
|
/**
|
|
683
1046
|
* Checks if an entity is "dirty" (if its values have changed).
|
|
684
1047
|
*
|
|
@@ -687,26 +1050,32 @@ class EntityUtilities {
|
|
|
687
1050
|
* @returns Whether or not the entity is dirty.
|
|
688
1051
|
*/
|
|
689
1052
|
static dirty(entity, entityPriorChanges) {
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
1053
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1054
|
+
if (!entityPriorChanges) {
|
|
1055
|
+
return false;
|
|
1056
|
+
}
|
|
1057
|
+
else {
|
|
1058
|
+
const differences = yield EntityUtilities.differencesForDirty(entity, entityPriorChanges);
|
|
1059
|
+
return differences.length ? true : false;
|
|
1060
|
+
}
|
|
1061
|
+
});
|
|
697
1062
|
}
|
|
698
1063
|
static differencesForDirty(entity, entityPriorChanges) {
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
1064
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1065
|
+
const res = [];
|
|
1066
|
+
for (const key in entity) {
|
|
1067
|
+
const metadata = EntityUtilities.getPropertyMetadata(entity, key);
|
|
1068
|
+
const type = EntityUtilities.getPropertyType(entity, key);
|
|
1069
|
+
if (!(yield EntityUtilities.isEqual(entity[key], entityPriorChanges[key], metadata, type))) {
|
|
1070
|
+
res.push({
|
|
1071
|
+
key: key,
|
|
1072
|
+
before: entityPriorChanges[key],
|
|
1073
|
+
after: entity[key]
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
707
1076
|
}
|
|
708
|
-
|
|
709
|
-
|
|
1077
|
+
return res;
|
|
1078
|
+
});
|
|
710
1079
|
}
|
|
711
1080
|
/**
|
|
712
1081
|
* Compares two Entities and returns their difference in an object.
|
|
@@ -716,47 +1085,117 @@ class EntityUtilities {
|
|
|
716
1085
|
* @returns The difference between the two Entities in form of a Partial.
|
|
717
1086
|
*/
|
|
718
1087
|
static difference(entity, entityPriorChanges) {
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
1088
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1089
|
+
const res = {};
|
|
1090
|
+
for (const key in entity) {
|
|
1091
|
+
const metadata = EntityUtilities.getPropertyMetadata(entity, key);
|
|
1092
|
+
const type = EntityUtilities.getPropertyType(entity, key);
|
|
1093
|
+
if (!(yield EntityUtilities.isEqual(entity[key], entityPriorChanges[key], metadata, type))) {
|
|
1094
|
+
res[key] = entity[key];
|
|
1095
|
+
}
|
|
723
1096
|
}
|
|
724
|
-
|
|
725
|
-
|
|
1097
|
+
return res;
|
|
1098
|
+
});
|
|
726
1099
|
}
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
1100
|
+
/**
|
|
1101
|
+
* Checks if two given values are equal.
|
|
1102
|
+
* It uses the isEqual method from LodashUtilities and extends it with functionality regarding Dates.
|
|
1103
|
+
*
|
|
1104
|
+
* @param value - The updated value.
|
|
1105
|
+
* @param valuePriorChanges - The value before any changes.
|
|
1106
|
+
* @param metadata - The metadata of the property.
|
|
1107
|
+
* @param type - The type of the property.
|
|
1108
|
+
* @returns Whether or not the given values are equal.
|
|
1109
|
+
*/
|
|
1110
|
+
// eslint-disable-next-line max-len
|
|
1111
|
+
static isEqual(value, valuePriorChanges, metadata, type) {
|
|
1112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1113
|
+
switch (type) {
|
|
1114
|
+
case DecoratorTypes.DATE_RANGE:
|
|
1115
|
+
return EntityUtilities.isEqualDateRange(value, valuePriorChanges, metadata.filter);
|
|
1116
|
+
case DecoratorTypes.DATE:
|
|
1117
|
+
return EntityUtilities.isEqualDate(value, valuePriorChanges);
|
|
1118
|
+
case DecoratorTypes.DATE_TIME:
|
|
1119
|
+
return EntityUtilities.isEqualDateTime(value, valuePriorChanges);
|
|
1120
|
+
case DecoratorTypes.ARRAY_DATE:
|
|
1121
|
+
case DecoratorTypes.ARRAY_DATE_TIME:
|
|
1122
|
+
return EntityUtilities.isEqualArrayDate(value, valuePriorChanges);
|
|
1123
|
+
case DecoratorTypes.ARRAY_DATE_RANGE:
|
|
1124
|
+
return EntityUtilities.isEqualArrayDateRange(value, valuePriorChanges, metadata.filter);
|
|
1125
|
+
case DecoratorTypes.FILE_IMAGE:
|
|
1126
|
+
case DecoratorTypes.FILE_DEFAULT:
|
|
1127
|
+
return EntityUtilities.isEqualFile(value, valuePriorChanges, metadata.multiple);
|
|
1128
|
+
default:
|
|
1129
|
+
return LodashUtilities.isEqual(value, valuePriorChanges);
|
|
755
1130
|
}
|
|
756
|
-
|
|
757
|
-
|
|
1131
|
+
});
|
|
1132
|
+
}
|
|
1133
|
+
static isEqualArrayDate(value, valuePriorChanges) {
|
|
1134
|
+
const newValue = value.map(v => new Date(v)).sort();
|
|
1135
|
+
const newValuePriorChanges = valuePriorChanges.map(v => new Date(v)).sort();
|
|
1136
|
+
return LodashUtilities.isEqual(newValue, newValuePriorChanges);
|
|
1137
|
+
}
|
|
1138
|
+
static isEqualArrayDateRange(value, valuePriorChanges, filter) {
|
|
1139
|
+
const dateRanges = value.sort();
|
|
1140
|
+
const dateRangesPriorChanges = valuePriorChanges.sort();
|
|
1141
|
+
if (dateRanges.length !== dateRangesPriorChanges.length) {
|
|
1142
|
+
return false;
|
|
758
1143
|
}
|
|
759
|
-
|
|
1144
|
+
for (let i = 0; i < dateRanges.length; i++) {
|
|
1145
|
+
if (!EntityUtilities.isEqualDateRange(dateRanges[i], dateRangesPriorChanges[i], filter)) {
|
|
1146
|
+
return false;
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
return true;
|
|
1150
|
+
}
|
|
1151
|
+
static isEqualDateTime(value, valuePriorChanges) {
|
|
1152
|
+
const date = new Date(value);
|
|
1153
|
+
const datePriorChanges = new Date(valuePriorChanges);
|
|
1154
|
+
return LodashUtilities.isEqual(date, datePriorChanges);
|
|
1155
|
+
}
|
|
1156
|
+
static isEqualDate(value, valuePriorChanges) {
|
|
1157
|
+
const date = new Date(value);
|
|
1158
|
+
const datePriorChanges = new Date(valuePriorChanges);
|
|
1159
|
+
date.setHours(0, 0, 0, 0);
|
|
1160
|
+
datePriorChanges.setHours(0, 0, 0, 0);
|
|
1161
|
+
return LodashUtilities.isEqual(date, datePriorChanges);
|
|
1162
|
+
}
|
|
1163
|
+
static isEqualDateRange(value, valuePriorChanges, filter) {
|
|
1164
|
+
const dateRange = LodashUtilities.cloneDeep(value);
|
|
1165
|
+
dateRange.start = new Date(value.start);
|
|
1166
|
+
dateRange.end = new Date(value.end);
|
|
1167
|
+
dateRange.values = DateUtilities.getDatesBetween(dateRange.start, dateRange.end, filter);
|
|
1168
|
+
const dateRangePriorChanges = LodashUtilities.cloneDeep(valuePriorChanges);
|
|
1169
|
+
dateRangePriorChanges.start = new Date(valuePriorChanges.start);
|
|
1170
|
+
dateRangePriorChanges.end = new Date(valuePriorChanges.end);
|
|
1171
|
+
dateRangePriorChanges.values = DateUtilities.getDatesBetween(dateRangePriorChanges.start, dateRangePriorChanges.end, filter);
|
|
1172
|
+
return LodashUtilities.isEqual(dateRange, dateRangePriorChanges);
|
|
1173
|
+
}
|
|
1174
|
+
// TODO: Find a way to use blobs with jest
|
|
1175
|
+
/* istanbul ignore next */
|
|
1176
|
+
static isEqualFile(value, valuePriorChanges, multiple) {
|
|
1177
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1178
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1179
|
+
const files = multiple ? value.sort() : [value].sort();
|
|
1180
|
+
const filesPriorChanges = multiple ? valuePriorChanges.sort() : [valuePriorChanges].sort();
|
|
1181
|
+
if (files.length !== filesPriorChanges.length) {
|
|
1182
|
+
return false;
|
|
1183
|
+
}
|
|
1184
|
+
for (let i = 0; i < files.length; i++) {
|
|
1185
|
+
// checks this before actually getting any files due to performance reasons.
|
|
1186
|
+
if (!LodashUtilities.isEqual((_a = files[i]) === null || _a === void 0 ? void 0 : _a.name, (_b = filesPriorChanges[i]) === null || _b === void 0 ? void 0 : _b.name)
|
|
1187
|
+
|| !LodashUtilities.isEqual((_c = files[i]) === null || _c === void 0 ? void 0 : _c.url, (_d = filesPriorChanges[i]) === null || _d === void 0 ? void 0 : _d.url)) {
|
|
1188
|
+
return false;
|
|
1189
|
+
}
|
|
1190
|
+
files[i] = filesPriorChanges[i].file && !files[i].file ? yield FileUtilities.getFileData(files[i]) : files[i];
|
|
1191
|
+
// eslint-disable-next-line max-len
|
|
1192
|
+
filesPriorChanges[i] = files[i].file && !filesPriorChanges[i].file ? yield FileUtilities.getFileData(filesPriorChanges[i]) : filesPriorChanges[i];
|
|
1193
|
+
if (!LodashUtilities.isEqual(yield ((_e = files[i].file) === null || _e === void 0 ? void 0 : _e.text()), yield ((_f = filesPriorChanges[i].file) === null || _f === void 0 ? void 0 : _f.text()))) {
|
|
1194
|
+
return false;
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
return true;
|
|
1198
|
+
});
|
|
760
1199
|
}
|
|
761
1200
|
/**
|
|
762
1201
|
* Compare function for sorting entity keys by their order value.
|
|
@@ -778,7 +1217,7 @@ class EntityUtilities {
|
|
|
778
1217
|
else if (metadataB.position.order === -1) {
|
|
779
1218
|
return -1;
|
|
780
1219
|
}
|
|
781
|
-
return
|
|
1220
|
+
return metadataA.position.order - metadataB.position.order;
|
|
782
1221
|
}
|
|
783
1222
|
/**
|
|
784
1223
|
* Gets the bootstrap column values for "lg", "md", "sm".
|
|
@@ -807,7 +1246,7 @@ class EntityUtilities {
|
|
|
807
1246
|
*/
|
|
808
1247
|
static resetChangesOnEntity(entity, entityPriorChanges) {
|
|
809
1248
|
for (const key in entityPriorChanges) {
|
|
810
|
-
|
|
1249
|
+
ReflectUtilities.set(entity, key, ReflectUtilities.get(entityPriorChanges, key));
|
|
811
1250
|
}
|
|
812
1251
|
}
|
|
813
1252
|
/**
|
|
@@ -821,17 +1260,17 @@ class EntityUtilities {
|
|
|
821
1260
|
static getEntityRows(entity, hideOmitForCreate = false, hideOmitForEdit = false) {
|
|
822
1261
|
const res = [];
|
|
823
1262
|
const keys = EntityUtilities.keysOf(entity, hideOmitForCreate, hideOmitForEdit);
|
|
824
|
-
const numberOfRows =
|
|
1263
|
+
const numberOfRows = EntityUtilities.getNumberOfRows(keys, entity);
|
|
825
1264
|
for (let i = 1; i <= numberOfRows; i++) {
|
|
826
1265
|
const row = {
|
|
827
1266
|
row: i,
|
|
828
|
-
keys:
|
|
1267
|
+
keys: EntityUtilities.getKeysForRow(keys, entity, i)
|
|
829
1268
|
};
|
|
830
1269
|
res.push(row);
|
|
831
1270
|
}
|
|
832
1271
|
const lastRow = {
|
|
833
1272
|
row: numberOfRows + 1,
|
|
834
|
-
keys:
|
|
1273
|
+
keys: EntityUtilities.getKeysForRow(keys, entity, -1)
|
|
835
1274
|
};
|
|
836
1275
|
res.push(lastRow);
|
|
837
1276
|
return res;
|
|
@@ -855,7 +1294,7 @@ class EntityUtilities {
|
|
|
855
1294
|
* @returns An array of keys of the entity.
|
|
856
1295
|
*/
|
|
857
1296
|
static keysOf(entity, hideOmitForCreate = false, hideOmitForEdit = false) {
|
|
858
|
-
let keys =
|
|
1297
|
+
let keys = ReflectUtilities.ownKeys(entity);
|
|
859
1298
|
if (hideOmitForCreate) {
|
|
860
1299
|
const omitForCreateKeys = EntityUtilities.getOmitForCreate(entity);
|
|
861
1300
|
keys = keys.filter(k => !omitForCreateKeys.includes(k));
|
|
@@ -910,7 +1349,58 @@ class EntityService {
|
|
|
910
1349
|
*/
|
|
911
1350
|
create(entity) {
|
|
912
1351
|
return __awaiter(this, void 0, void 0, function* () {
|
|
913
|
-
const body = omit(entity, EntityUtilities.getOmitForCreate(entity));
|
|
1352
|
+
const body = LodashUtilities.omit(entity, EntityUtilities.getOmitForCreate(entity));
|
|
1353
|
+
const filePropertyKeys = EntityUtilities.getFileProperties(entity);
|
|
1354
|
+
if (!filePropertyKeys.length) {
|
|
1355
|
+
return yield this.createWithJson(body);
|
|
1356
|
+
}
|
|
1357
|
+
else {
|
|
1358
|
+
return yield this.createWithFormData(body, filePropertyKeys, entity);
|
|
1359
|
+
}
|
|
1360
|
+
});
|
|
1361
|
+
}
|
|
1362
|
+
// TODO: Find a way to use blobs with jest
|
|
1363
|
+
/* istanbul ignore next */
|
|
1364
|
+
/**
|
|
1365
|
+
* Creates the entity with form data when the entity contains files in contrast to creating it with a normal json body.
|
|
1366
|
+
* All file values are stored inside their respective property key and their name.
|
|
1367
|
+
* Form data is able to handle setting multiple files to the same key.
|
|
1368
|
+
*
|
|
1369
|
+
* @param body - The body Of the request.
|
|
1370
|
+
* @param filePropertyKeys - All property keys that are files and need to be added to the form data.
|
|
1371
|
+
* @param entity - The entity to create. This is needed in addition to the body because the body doesn't contain any metadata.
|
|
1372
|
+
* @returns The created entity from the server.
|
|
1373
|
+
*/
|
|
1374
|
+
createWithFormData(body, filePropertyKeys, entity) {
|
|
1375
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1376
|
+
const formData = new FormData();
|
|
1377
|
+
formData.append('body', JSON.stringify(LodashUtilities.omit(body, filePropertyKeys)));
|
|
1378
|
+
for (const key of filePropertyKeys) {
|
|
1379
|
+
if (EntityUtilities.getPropertyMetadata(entity, key, DecoratorTypes.FILE_DEFAULT).multiple) {
|
|
1380
|
+
const fileDataValues = body[key];
|
|
1381
|
+
for (const value of fileDataValues) {
|
|
1382
|
+
formData.append(key, (yield FileUtilities.getFileData(value)).file, value.name);
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
else {
|
|
1386
|
+
const fileData = body[key];
|
|
1387
|
+
formData.append(key, (yield FileUtilities.getFileData(fileData)).file, fileData.name);
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
const e = yield firstValueFrom(this.http.post(this.baseUrl, formData));
|
|
1391
|
+
this.entities.push(e);
|
|
1392
|
+
this.entitiesSubject.next(this.entities);
|
|
1393
|
+
return e;
|
|
1394
|
+
});
|
|
1395
|
+
}
|
|
1396
|
+
/**
|
|
1397
|
+
* Creates the entity with a normal json body in contrast to creating it with form data when the entity contains files.
|
|
1398
|
+
*
|
|
1399
|
+
* @param body - The body Of the request.
|
|
1400
|
+
* @returns The created entity from the server.
|
|
1401
|
+
*/
|
|
1402
|
+
createWithJson(body) {
|
|
1403
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
914
1404
|
const e = yield firstValueFrom(this.http.post(this.baseUrl, body));
|
|
915
1405
|
this.entities.push(e);
|
|
916
1406
|
this.entitiesSubject.next(this.entities);
|
|
@@ -939,23 +1429,75 @@ class EntityService {
|
|
|
939
1429
|
*/
|
|
940
1430
|
update(entity, entityPriorChanges) {
|
|
941
1431
|
return __awaiter(this, void 0, void 0, function* () {
|
|
942
|
-
const
|
|
943
|
-
const
|
|
944
|
-
|
|
945
|
-
|
|
1432
|
+
const body = LodashUtilities.omit(yield EntityUtilities.difference(entity, entityPriorChanges), EntityUtilities.getOmitForUpdate(entity));
|
|
1433
|
+
const filePropertyKeys = EntityUtilities.getFileProperties(entityPriorChanges);
|
|
1434
|
+
if (!filePropertyKeys.length) {
|
|
1435
|
+
yield this.updateWithJson(body, entityPriorChanges[this.idKey]);
|
|
1436
|
+
}
|
|
1437
|
+
else {
|
|
1438
|
+
yield this.updateWithFormData(body, filePropertyKeys, entity, entityPriorChanges[this.idKey]);
|
|
1439
|
+
}
|
|
946
1440
|
});
|
|
947
1441
|
}
|
|
1442
|
+
// TODO: Find a way to use blobs with jest
|
|
1443
|
+
/* istanbul ignore next */
|
|
948
1444
|
/**
|
|
949
|
-
*
|
|
1445
|
+
* Updates the entity with form data when the entity contains files in contrast to creating it with a normal json body.
|
|
1446
|
+
* All file values are stored inside their respective property key and their name.
|
|
1447
|
+
* Form data is able to handle setting multiple files to the same key.
|
|
950
1448
|
*
|
|
951
|
-
* @param
|
|
1449
|
+
* @param body - The request body. Already contains only properties that have changed.
|
|
1450
|
+
* @param filePropertyKeys - The keys of all properties which are files and need to separately be appended to the form data.
|
|
1451
|
+
* @param entity - The original entity. Is needed to get the metadata of all the files.
|
|
1452
|
+
* @param id - The id of the entity to update.
|
|
952
1453
|
*/
|
|
953
|
-
|
|
1454
|
+
updateWithFormData(body, filePropertyKeys, entity, id) {
|
|
954
1455
|
return __awaiter(this, void 0, void 0, function* () {
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
1456
|
+
const formData = new FormData();
|
|
1457
|
+
formData.append('body', JSON.stringify(LodashUtilities.omitBy(body, LodashUtilities.isNil)));
|
|
1458
|
+
for (const key of filePropertyKeys) {
|
|
1459
|
+
if (EntityUtilities.getPropertyMetadata(entity, key, DecoratorTypes.FILE_DEFAULT).multiple) {
|
|
1460
|
+
// eslint-disable-next-line max-len
|
|
1461
|
+
const fileDataValues = body[key];
|
|
1462
|
+
for (const value of fileDataValues) {
|
|
1463
|
+
formData.append(key, (yield FileUtilities.getFileData(value)).file, value.name);
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
else {
|
|
1467
|
+
// eslint-disable-next-line max-len
|
|
1468
|
+
const fileData = body[key];
|
|
1469
|
+
formData.append(key, (yield FileUtilities.getFileData(fileData)).file, fileData.name);
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
const updatedEntity = yield firstValueFrom(this.http.patch(`${this.baseUrl}/${id}`, formData));
|
|
1473
|
+
this.entities[this.entities.findIndex(e => e[this.idKey] === id)] = updatedEntity;
|
|
1474
|
+
this.entitiesSubject.next(this.entities);
|
|
1475
|
+
});
|
|
1476
|
+
}
|
|
1477
|
+
/**
|
|
1478
|
+
* Updates the entity with a normal json body in contrast to updating it with form data when the entity contains files.
|
|
1479
|
+
*
|
|
1480
|
+
* @param body - The body of the Request. Has already removed all unnecessary values.
|
|
1481
|
+
* @param id - The id of the entity to update.
|
|
1482
|
+
*/
|
|
1483
|
+
updateWithJson(body, id) {
|
|
1484
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1485
|
+
const updatedEntity = yield firstValueFrom(this.http.patch(`${this.baseUrl}/${id}`, LodashUtilities.omitBy(body, LodashUtilities.isNil)));
|
|
1486
|
+
this.entities[this.entities.findIndex(e => e[this.idKey] === id)] = updatedEntity;
|
|
1487
|
+
this.entitiesSubject.next(this.entities);
|
|
1488
|
+
});
|
|
1489
|
+
}
|
|
1490
|
+
/**
|
|
1491
|
+
* Deletes a specific Entity.
|
|
1492
|
+
*
|
|
1493
|
+
* @param entity - The entity to delete.
|
|
1494
|
+
*/
|
|
1495
|
+
delete(entity) {
|
|
1496
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1497
|
+
yield firstValueFrom(this.http.delete(`${this.baseUrl}/${entity[this.idKey]}`));
|
|
1498
|
+
// the == comparison instead of === is to catch ids that are numbers.
|
|
1499
|
+
this.entities.splice(this.entities.findIndex(e => e[this.idKey] === entity[this.idKey]), 1);
|
|
1500
|
+
this.entitiesSubject.next(this.entities);
|
|
959
1501
|
});
|
|
960
1502
|
}
|
|
961
1503
|
}
|
|
@@ -979,7 +1521,6 @@ class BaseBuilder {
|
|
|
979
1521
|
validateInput(data) {
|
|
980
1522
|
// By default, no validation is done
|
|
981
1523
|
}
|
|
982
|
-
;
|
|
983
1524
|
/**
|
|
984
1525
|
* Sets the value for the given key if no user value was provided.
|
|
985
1526
|
*
|
|
@@ -988,7 +1529,7 @@ class BaseBuilder {
|
|
|
988
1529
|
* @returns The Builder.
|
|
989
1530
|
*/
|
|
990
1531
|
withDefault(key, value) {
|
|
991
|
-
if (
|
|
1532
|
+
if (this.inputData == null || this.inputData[key] == null) {
|
|
992
1533
|
this.data[key] = value;
|
|
993
1534
|
}
|
|
994
1535
|
return this;
|
|
@@ -1026,18 +1567,19 @@ class ConfirmDialogDataBuilder extends BaseBuilder {
|
|
|
1026
1567
|
}
|
|
1027
1568
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
1028
1569
|
generateBaseData(data) {
|
|
1029
|
-
|
|
1570
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1571
|
+
return new ConfirmDialogDataInternal((_a = data === null || data === void 0 ? void 0 : data.text) !== null && _a !== void 0 ? _a : ['Do you really want to do this?'], (_b = data === null || data === void 0 ? void 0 : data.type) !== null && _b !== void 0 ? _b : 'default', (_c = data === null || data === void 0 ? void 0 : data.confirmButtonLabel) !== null && _c !== void 0 ? _c : 'Confirm', (_d = data === null || data === void 0 ? void 0 : data.cancelButtonLabel) !== null && _d !== void 0 ? _d : 'Cancel', (_e = data === null || data === void 0 ? void 0 : data.title) !== null && _e !== void 0 ? _e : 'Confirmation', (_f = data === null || data === void 0 ? void 0 : data.requireConfirmation) !== null && _f !== void 0 ? _f : false, data === null || data === void 0 ? void 0 : data.confirmationText);
|
|
1030
1572
|
}
|
|
1031
1573
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
1032
1574
|
validateInput(data) {
|
|
1033
1575
|
if (!data) {
|
|
1034
1576
|
return;
|
|
1035
1577
|
}
|
|
1036
|
-
if (data.requireConfirmation && !data.confirmationText) {
|
|
1578
|
+
if (data.requireConfirmation === true && !data.confirmationText) {
|
|
1037
1579
|
throw new Error(`Missing required Input data "confirmationText".
|
|
1038
1580
|
You can only omit this value when "requireConfirmation" is false.`);
|
|
1039
1581
|
}
|
|
1040
|
-
if (
|
|
1582
|
+
if (data.requireConfirmation !== true && data.confirmationText) {
|
|
1041
1583
|
throw new Error('The "confirmationText" will never be shown because "requireConfirmation" is not set to true');
|
|
1042
1584
|
}
|
|
1043
1585
|
if (data.type === 'info-only' && data.cancelButtonLabel) {
|
|
@@ -1075,10 +1617,10 @@ class NgxMatEntityConfirmDialogComponent {
|
|
|
1075
1617
|
}
|
|
1076
1618
|
}
|
|
1077
1619
|
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 });
|
|
1078
|
-
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:
|
|
1620
|
+
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 *ngIf=\"data.type !== 'info-only'\" 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: i4.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: i4$1.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: i4$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.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]" }] });
|
|
1079
1621
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityConfirmDialogComponent, decorators: [{
|
|
1080
1622
|
type: Component,
|
|
1081
|
-
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"] }]
|
|
1623
|
+
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 *ngIf=\"data.type !== 'info-only'\" 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"] }]
|
|
1082
1624
|
}], ctorParameters: function () {
|
|
1083
1625
|
return [{ type: i1.MatDialogRef }, { type: undefined, decorators: [{
|
|
1084
1626
|
type: Inject,
|
|
@@ -1158,12 +1700,13 @@ class CreateDialogDataBuilder extends BaseBuilder {
|
|
|
1158
1700
|
}
|
|
1159
1701
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
1160
1702
|
generateBaseData(data) {
|
|
1703
|
+
var _a, _b, _c, _d;
|
|
1161
1704
|
const confirmCreateDialogData = new ConfirmDialogDataBuilder(data === null || data === void 0 ? void 0 : data.confirmCreateDialogData)
|
|
1162
1705
|
.withDefault('confirmButtonLabel', 'create')
|
|
1163
1706
|
.withDefault('text', ['Do you really want to create this entity?'])
|
|
1164
1707
|
.withDefault('title', 'Create')
|
|
1165
1708
|
.getResult();
|
|
1166
|
-
return new CreateDialogDataInternal((data === null || data === void 0 ? void 0 : data.title) ?
|
|
1709
|
+
return new CreateDialogDataInternal((_a = data === null || data === void 0 ? void 0 : data.title) !== null && _a !== void 0 ? _a : 'Create', (_b = data === null || data === void 0 ? void 0 : data.createButtonLabel) !== null && _b !== void 0 ? _b : 'Create', (_c = data === null || data === void 0 ? void 0 : data.cancelButtonLabel) !== null && _c !== void 0 ? _c : 'Cancel', (_d = data === null || data === void 0 ? void 0 : data.createRequiresConfirmDialog) !== null && _d !== void 0 ? _d : false, confirmCreateDialogData);
|
|
1167
1710
|
}
|
|
1168
1711
|
}
|
|
1169
1712
|
|
|
@@ -1186,187 +1729,1347 @@ class AddArrayItemDialogDataBuilder extends BaseBuilder {
|
|
|
1186
1729
|
}
|
|
1187
1730
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
1188
1731
|
generateBaseData(data) {
|
|
1732
|
+
var _a;
|
|
1189
1733
|
const createDialogData = new CreateDialogDataBuilder(data.createDialogData)
|
|
1190
1734
|
.withDefault('createButtonLabel', 'Add')
|
|
1191
1735
|
.withDefault('title', 'Add to array')
|
|
1192
1736
|
.getResult();
|
|
1193
|
-
return new AddArrayItemDialogDataInternal(data.entity, createDialogData, data.getValidationErrorMessage ?
|
|
1737
|
+
return new AddArrayItemDialogDataInternal(data.entity, createDialogData, (_a = data.getValidationErrorMessage) !== null && _a !== void 0 ? _a : getValidationErrorMessage);
|
|
1194
1738
|
}
|
|
1195
1739
|
}
|
|
1196
1740
|
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1741
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
1742
|
+
class StringInputComponent {
|
|
1743
|
+
constructor() {
|
|
1744
|
+
this.inputChangeEvent = new EventEmitter();
|
|
1745
|
+
}
|
|
1746
|
+
ngOnInit() {
|
|
1747
|
+
this.metadata = EntityUtilities.getPropertyMetadata(this.entity, this.key, DecoratorTypes.STRING);
|
|
1748
|
+
}
|
|
1749
|
+
emitChange() {
|
|
1750
|
+
this.inputChangeEvent.emit();
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
StringInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: StringInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1754
|
+
StringInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: StringInputComponent, selector: "string-input", inputs: { entity: "entity", key: "key", getValidationErrorMessage: "getValidationErrorMessage" }, outputs: { inputChangeEvent: "inputChangeEvent" }, ngImport: i0, template: "<mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n [(ngModel)]=\"entity[key]\"\n [name]=\"key.toString()\"\n #model=\"ngModel\"\n [required]=\"metadata.required\"\n [pattern]=\"metadata.regex ?? '[\\\\s\\\\S]*'\"\n [minlength]=\"metadata.minLength ?? null\"\n [maxlength]=\"metadata.maxLength ?? null\"\n (ngModelChange)=\"emitChange()\"\n />\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n</mat-form-field>", styles: ["mat-form-field{width:100%}\n"], components: [{ type: i1$1.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }], directives: [{ type: i1$1.MatLabel, selector: "mat-label" }, { type: i4$2.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: i3.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: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i3.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i3.PatternValidator, selector: "[pattern][formControlName],[pattern][formControl],[pattern][ngModel]", inputs: ["pattern"] }, { type: i3.MinLengthValidator, selector: "[minlength][formControlName],[minlength][formControl],[minlength][ngModel]", inputs: ["minlength"] }, { type: i3.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { type: i1$1.MatError, selector: "mat-error", inputs: ["id"] }] });
|
|
1755
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: StringInputComponent, decorators: [{
|
|
1756
|
+
type: Component,
|
|
1757
|
+
args: [{ selector: 'string-input', template: "<mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n [(ngModel)]=\"entity[key]\"\n [name]=\"key.toString()\"\n #model=\"ngModel\"\n [required]=\"metadata.required\"\n [pattern]=\"metadata.regex ?? '[\\\\s\\\\S]*'\"\n [minlength]=\"metadata.minLength ?? null\"\n [maxlength]=\"metadata.maxLength ?? null\"\n (ngModelChange)=\"emitChange()\"\n />\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n</mat-form-field>", styles: ["mat-form-field{width:100%}\n"] }]
|
|
1758
|
+
}], ctorParameters: function () { return []; }, propDecorators: { entity: [{
|
|
1759
|
+
type: Input
|
|
1760
|
+
}], key: [{
|
|
1761
|
+
type: Input
|
|
1762
|
+
}], getValidationErrorMessage: [{
|
|
1763
|
+
type: Input
|
|
1764
|
+
}], inputChangeEvent: [{
|
|
1765
|
+
type: Output
|
|
1766
|
+
}] } });
|
|
1767
|
+
|
|
1768
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
1769
|
+
class StringTextboxInputComponent {
|
|
1770
|
+
constructor() {
|
|
1771
|
+
this.inputChangeEvent = new EventEmitter();
|
|
1772
|
+
}
|
|
1773
|
+
ngOnInit() {
|
|
1774
|
+
this.metadata = EntityUtilities.getPropertyMetadata(this.entity, this.key, DecoratorTypes.STRING_TEXTBOX);
|
|
1775
|
+
}
|
|
1776
|
+
emitChange() {
|
|
1777
|
+
this.inputChangeEvent.emit();
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
StringTextboxInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: StringTextboxInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1781
|
+
StringTextboxInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: StringTextboxInputComponent, selector: "string-textbox-input", inputs: { entity: "entity", key: "key", getValidationErrorMessage: "getValidationErrorMessage" }, outputs: { inputChangeEvent: "inputChangeEvent" }, ngImport: i0, template: "<mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <textarea\n matInput\n [(ngModel)]=\"entity[key]\"\n [name]=\"key.toString()\"\n #model=\"ngModel\"\n cdkTextareaAutosize\n cdkAutosizeMinRows=\"10\"\n [required]=\"metadata.required\"\n [minlength]=\"metadata.minLength ?? null\"\n [maxlength]=\"metadata.maxLength ?? null\"\n (ngModelChange)=\"emitChange()\"\n >\n </textarea>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n</mat-form-field>", styles: ["mat-form-field{width:100%}\n"], components: [{ type: i1$1.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }], directives: [{ type: i1$1.MatLabel, selector: "mat-label" }, { type: i4$2.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: i3$1.CdkTextareaAutosize, selector: "textarea[cdkTextareaAutosize]", inputs: ["cdkAutosizeMinRows", "cdkAutosizeMaxRows", "cdkTextareaAutosize", "placeholder"], exportAs: ["cdkTextareaAutosize"] }, { type: i3.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: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i3.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i3.MinLengthValidator, selector: "[minlength][formControlName],[minlength][formControl],[minlength][ngModel]", inputs: ["minlength"] }, { type: i3.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { type: i1$1.MatError, selector: "mat-error", inputs: ["id"] }] });
|
|
1782
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: StringTextboxInputComponent, decorators: [{
|
|
1783
|
+
type: Component,
|
|
1784
|
+
args: [{ selector: 'string-textbox-input', template: "<mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <textarea\n matInput\n [(ngModel)]=\"entity[key]\"\n [name]=\"key.toString()\"\n #model=\"ngModel\"\n cdkTextareaAutosize\n cdkAutosizeMinRows=\"10\"\n [required]=\"metadata.required\"\n [minlength]=\"metadata.minLength ?? null\"\n [maxlength]=\"metadata.maxLength ?? null\"\n (ngModelChange)=\"emitChange()\"\n >\n </textarea>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n</mat-form-field>", styles: ["mat-form-field{width:100%}\n"] }]
|
|
1785
|
+
}], ctorParameters: function () { return []; }, propDecorators: { entity: [{
|
|
1786
|
+
type: Input
|
|
1787
|
+
}], key: [{
|
|
1788
|
+
type: Input
|
|
1789
|
+
}], getValidationErrorMessage: [{
|
|
1790
|
+
type: Input
|
|
1791
|
+
}], inputChangeEvent: [{
|
|
1792
|
+
type: Output
|
|
1793
|
+
}] } });
|
|
1794
|
+
|
|
1795
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
1796
|
+
class StringAutocompleteInputComponent {
|
|
1797
|
+
constructor() {
|
|
1798
|
+
this.inputChangeEvent = new EventEmitter();
|
|
1799
|
+
}
|
|
1800
|
+
ngOnInit() {
|
|
1801
|
+
this.metadata = EntityUtilities.getPropertyMetadata(this.entity, this.key, DecoratorTypes.STRING_AUTOCOMPLETE);
|
|
1802
|
+
this.autocompleteStrings = this.metadata.autocompleteValues;
|
|
1803
|
+
this.filteredAutocompleteStrings = LodashUtilities.cloneDeep(this.autocompleteStrings);
|
|
1214
1804
|
}
|
|
1215
1805
|
/**
|
|
1216
|
-
*
|
|
1806
|
+
* Dynamically filters the Autocomplete options when the user inputs something.
|
|
1217
1807
|
*
|
|
1218
|
-
* @param
|
|
1219
|
-
* @returns The index.
|
|
1808
|
+
* @param input - The input of the user.
|
|
1220
1809
|
*/
|
|
1221
|
-
|
|
1222
|
-
|
|
1810
|
+
filterAutocompleteStrings(input) {
|
|
1811
|
+
const inputString = input;
|
|
1812
|
+
if (inputString) {
|
|
1813
|
+
const filterValue = inputString.toLowerCase();
|
|
1814
|
+
this.filteredAutocompleteStrings = this.autocompleteStrings.filter(s => s.toLowerCase().includes(filterValue));
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
emitChange() {
|
|
1818
|
+
this.inputChangeEvent.emit();
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
StringAutocompleteInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: StringAutocompleteInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1822
|
+
StringAutocompleteInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: StringAutocompleteInputComponent, selector: "string-autocomplete-input", inputs: { entity: "entity", key: "key", getValidationErrorMessage: "getValidationErrorMessage" }, outputs: { inputChangeEvent: "inputChangeEvent" }, ngImport: i0, template: "<mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n [(ngModel)]=\"entity[key]\"\n [name]=\"key.toString()\"\n #model=\"ngModel\"\n [matAutocomplete]=\"auto\"\n (keyup)=\"filterAutocompleteStrings(entity[key])\"\n [required]=\"metadata.required\"\n [minlength]=\"metadata.minLength ?? null\"\n [maxlength]=\"metadata.maxLength ?? null\"\n [pattern]=\"metadata.regex ?? '[\\\\s\\\\S]*'\"\n (ngModelChange)=\"emitChange()\"\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>", 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$2.MatOption, selector: "mat-option", exportAs: ["matOption"] }], directives: [{ type: i1$1.MatLabel, selector: "mat-label" }, { type: i4$2.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: i3.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: i2.MatAutocompleteTrigger, selector: "input[matAutocomplete], textarea[matAutocomplete]", exportAs: ["matAutocompleteTrigger"] }, { type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i3.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i3.MinLengthValidator, selector: "[minlength][formControlName],[minlength][formControl],[minlength][ngModel]", inputs: ["minlength"] }, { type: i3.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { type: i3.PatternValidator, selector: "[pattern][formControlName],[pattern][formControl],[pattern][ngModel]", inputs: ["pattern"] }, { type: i4$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i1$1.MatError, selector: "mat-error", inputs: ["id"] }] });
|
|
1823
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: StringAutocompleteInputComponent, decorators: [{
|
|
1824
|
+
type: Component,
|
|
1825
|
+
args: [{ selector: 'string-autocomplete-input', template: "<mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n [(ngModel)]=\"entity[key]\"\n [name]=\"key.toString()\"\n #model=\"ngModel\"\n [matAutocomplete]=\"auto\"\n (keyup)=\"filterAutocompleteStrings(entity[key])\"\n [required]=\"metadata.required\"\n [minlength]=\"metadata.minLength ?? null\"\n [maxlength]=\"metadata.maxLength ?? null\"\n [pattern]=\"metadata.regex ?? '[\\\\s\\\\S]*'\"\n (ngModelChange)=\"emitChange()\"\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>", styles: ["mat-form-field{width:100%}\n"] }]
|
|
1826
|
+
}], ctorParameters: function () { return []; }, propDecorators: { entity: [{
|
|
1827
|
+
type: Input
|
|
1828
|
+
}], key: [{
|
|
1829
|
+
type: Input
|
|
1830
|
+
}], getValidationErrorMessage: [{
|
|
1831
|
+
type: Input
|
|
1832
|
+
}], inputChangeEvent: [{
|
|
1833
|
+
type: Output
|
|
1834
|
+
}] } });
|
|
1835
|
+
|
|
1836
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
1837
|
+
class StringDropdownInputComponent {
|
|
1838
|
+
constructor() {
|
|
1839
|
+
this.inputChangeEvent = new EventEmitter();
|
|
1223
1840
|
}
|
|
1224
1841
|
ngOnInit() {
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1842
|
+
this.metadata = EntityUtilities.getPropertyMetadata(this.entity, this.key, DecoratorTypes.STRING_DROPDOWN);
|
|
1843
|
+
}
|
|
1844
|
+
emitChange() {
|
|
1845
|
+
this.inputChangeEvent.emit();
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1848
|
+
StringDropdownInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: StringDropdownInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1849
|
+
StringDropdownInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: StringDropdownInputComponent, selector: "string-dropdown-input", inputs: { entity: "entity", key: "key", getValidationErrorMessage: "getValidationErrorMessage" }, outputs: { inputChangeEvent: "inputChangeEvent" }, ngImport: i0, template: "<mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-select (ngModelChange)=\"emitChange()\" [(ngModel)]=\"entity[key]\" [name]=\"key.toString()\" #model=\"ngModel\" [required]=\"metadata.required\">\n <mat-option *ngFor=\"let value of metadata.dropdownValues\" [value]=\"value.value\">{{value.displayName}}</mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n</mat-form-field>", 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$1.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { type: i3$2.MatOption, selector: "mat-option", exportAs: ["matOption"] }], directives: [{ type: i1$1.MatLabel, selector: "mat-label" }, { type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i3.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i4$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i1$1.MatError, selector: "mat-error", inputs: ["id"] }] });
|
|
1850
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: StringDropdownInputComponent, decorators: [{
|
|
1851
|
+
type: Component,
|
|
1852
|
+
args: [{ selector: 'string-dropdown-input', template: "<mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-select (ngModelChange)=\"emitChange()\" [(ngModel)]=\"entity[key]\" [name]=\"key.toString()\" #model=\"ngModel\" [required]=\"metadata.required\">\n <mat-option *ngFor=\"let value of metadata.dropdownValues\" [value]=\"value.value\">{{value.displayName}}</mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n</mat-form-field>", styles: ["mat-form-field{width:100%}\n"] }]
|
|
1853
|
+
}], ctorParameters: function () { return []; }, propDecorators: { entity: [{
|
|
1854
|
+
type: Input
|
|
1855
|
+
}], key: [{
|
|
1856
|
+
type: Input
|
|
1857
|
+
}], getValidationErrorMessage: [{
|
|
1858
|
+
type: Input
|
|
1859
|
+
}], inputChangeEvent: [{
|
|
1860
|
+
type: Output
|
|
1861
|
+
}] } });
|
|
1862
|
+
|
|
1863
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
1864
|
+
class BooleanCheckboxInputComponent {
|
|
1865
|
+
constructor() {
|
|
1866
|
+
this.inputChangeEvent = new EventEmitter();
|
|
1867
|
+
}
|
|
1868
|
+
ngOnInit() {
|
|
1869
|
+
this.metadata = EntityUtilities.getPropertyMetadata(this.entity, this.key, DecoratorTypes.BOOLEAN_CHECKBOX);
|
|
1870
|
+
if (this.entity[this.key] == null) {
|
|
1871
|
+
this.entity[this.key] = false;
|
|
1228
1872
|
}
|
|
1229
|
-
|
|
1230
|
-
|
|
1873
|
+
}
|
|
1874
|
+
emitChange() {
|
|
1875
|
+
this.inputChangeEvent.emit();
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
BooleanCheckboxInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: BooleanCheckboxInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1879
|
+
BooleanCheckboxInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: BooleanCheckboxInputComponent, selector: "boolean-checkbox-input", inputs: { entity: "entity", key: "key", getValidationErrorMessage: "getValidationErrorMessage" }, outputs: { inputChangeEvent: "inputChangeEvent" }, ngImport: i0, template: "<mat-form-field class=\"hideUnderline\">\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-checkbox (ngModelChange)=\"emitChange()\" (click)=\"model.control.markAsTouched()\" [(ngModel)]=\"entity[key]\" [name]=\"key.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[key]\"\n [name]=\"key.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>", styles: ["::ng-deep .hideUnderline .mat-form-field-underline{opacity:0%}mat-form-field{width:100%}\n"], components: [{ type: i1$1.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { 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"] }], directives: [{ type: i1$1.MatLabel, selector: "mat-label" }, { type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i4$2.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: i3.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: i3.PatternValidator, selector: "[pattern][formControlName],[pattern][formControl],[pattern][ngModel]", inputs: ["pattern"] }, { type: i3.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i1$1.MatError, selector: "mat-error", inputs: ["id"] }] });
|
|
1880
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: BooleanCheckboxInputComponent, decorators: [{
|
|
1881
|
+
type: Component,
|
|
1882
|
+
args: [{ selector: 'boolean-checkbox-input', template: "<mat-form-field class=\"hideUnderline\">\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-checkbox (ngModelChange)=\"emitChange()\" (click)=\"model.control.markAsTouched()\" [(ngModel)]=\"entity[key]\" [name]=\"key.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[key]\"\n [name]=\"key.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>", styles: ["::ng-deep .hideUnderline .mat-form-field-underline{opacity:0%}mat-form-field{width:100%}\n"] }]
|
|
1883
|
+
}], ctorParameters: function () { return []; }, propDecorators: { entity: [{
|
|
1884
|
+
type: Input
|
|
1885
|
+
}], key: [{
|
|
1886
|
+
type: Input
|
|
1887
|
+
}], getValidationErrorMessage: [{
|
|
1888
|
+
type: Input
|
|
1889
|
+
}], inputChangeEvent: [{
|
|
1890
|
+
type: Output
|
|
1891
|
+
}] } });
|
|
1892
|
+
|
|
1893
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
1894
|
+
class BooleanToggleInputComponent {
|
|
1895
|
+
constructor() {
|
|
1896
|
+
this.inputChangeEvent = new EventEmitter();
|
|
1897
|
+
}
|
|
1898
|
+
ngOnInit() {
|
|
1899
|
+
this.metadata = EntityUtilities.getPropertyMetadata(this.entity, this.key, DecoratorTypes.BOOLEAN_TOGGLE);
|
|
1900
|
+
if (this.entity[this.key] == null) {
|
|
1901
|
+
this.entity[this.key] = false;
|
|
1231
1902
|
}
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
this.
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1903
|
+
}
|
|
1904
|
+
emitChange() {
|
|
1905
|
+
this.inputChangeEvent.emit();
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
BooleanToggleInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: BooleanToggleInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1909
|
+
BooleanToggleInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: BooleanToggleInputComponent, selector: "boolean-toggle-input", inputs: { entity: "entity", key: "key", getValidationErrorMessage: "getValidationErrorMessage" }, outputs: { inputChangeEvent: "inputChangeEvent" }, ngImport: i0, template: "<mat-form-field class=\"hideUnderline\">\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-slide-toggle (click)=\"model.control.markAsTouched()\" [(ngModel)]=\"entity[key]\" [name]=\"key.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[key]\"\n [name]=\"key.toString() + 'Helper'\"\n #model=\"ngModel\"\n [pattern]=\"metadata.required ? 'true' : '[\\\\s\\\\S]*'\"\n [required]=\"metadata.required\"\n (ngModelChange)=\"emitChange\"\n >\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n</mat-form-field>", styles: ["::ng-deep .hideUnderline .mat-form-field-underline{opacity:0%}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$2.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"] }], directives: [{ type: i1$1.MatLabel, selector: "mat-label" }, { type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i4$2.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: i3.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: i3.PatternValidator, selector: "[pattern][formControlName],[pattern][formControl],[pattern][ngModel]", inputs: ["pattern"] }, { type: i3.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i1$1.MatError, selector: "mat-error", inputs: ["id"] }] });
|
|
1910
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: BooleanToggleInputComponent, decorators: [{
|
|
1911
|
+
type: Component,
|
|
1912
|
+
args: [{ selector: 'boolean-toggle-input', template: "<mat-form-field class=\"hideUnderline\">\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-slide-toggle (click)=\"model.control.markAsTouched()\" [(ngModel)]=\"entity[key]\" [name]=\"key.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[key]\"\n [name]=\"key.toString() + 'Helper'\"\n #model=\"ngModel\"\n [pattern]=\"metadata.required ? 'true' : '[\\\\s\\\\S]*'\"\n [required]=\"metadata.required\"\n (ngModelChange)=\"emitChange\"\n >\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n</mat-form-field>", styles: ["::ng-deep .hideUnderline .mat-form-field-underline{opacity:0%}mat-form-field{width:100%}\n"] }]
|
|
1913
|
+
}], ctorParameters: function () { return []; }, propDecorators: { entity: [{
|
|
1914
|
+
type: Input
|
|
1915
|
+
}], key: [{
|
|
1916
|
+
type: Input
|
|
1917
|
+
}], getValidationErrorMessage: [{
|
|
1918
|
+
type: Input
|
|
1919
|
+
}], inputChangeEvent: [{
|
|
1920
|
+
type: Output
|
|
1921
|
+
}] } });
|
|
1922
|
+
|
|
1923
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
1924
|
+
class BooleanDropdownInputComponent {
|
|
1925
|
+
constructor() {
|
|
1926
|
+
this.inputChangeEvent = new EventEmitter();
|
|
1927
|
+
}
|
|
1928
|
+
ngOnInit() {
|
|
1929
|
+
this.metadata = EntityUtilities.getPropertyMetadata(this.entity, this.key, DecoratorTypes.BOOLEAN_DROPDOWN);
|
|
1930
|
+
}
|
|
1931
|
+
emitChange() {
|
|
1932
|
+
this.inputChangeEvent.emit();
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
BooleanDropdownInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: BooleanDropdownInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1936
|
+
BooleanDropdownInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: BooleanDropdownInputComponent, selector: "boolean-dropdown-input", inputs: { entity: "entity", key: "key", getValidationErrorMessage: "getValidationErrorMessage" }, outputs: { inputChangeEvent: "inputChangeEvent" }, ngImport: i0, template: "<mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-select (ngModelChange)=\"emitChange()\" [(ngModel)]=\"entity[key]\" [name]=\"key.toString()\" #model=\"ngModel\" [required]=\"metadata.required\">\n <mat-option [value]=\"undefined\">-</mat-option>\n <mat-option [value]=\"true\">{{metadata.dropdownTrue}}</mat-option>\n <mat-option [value]=\"false\">{{metadata.dropdownFalse}}</mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n</mat-form-field>", 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$1.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { type: i3$2.MatOption, selector: "mat-option", exportAs: ["matOption"] }], directives: [{ type: i1$1.MatLabel, selector: "mat-label" }, { type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i3.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i1$1.MatError, selector: "mat-error", inputs: ["id"] }] });
|
|
1937
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: BooleanDropdownInputComponent, decorators: [{
|
|
1938
|
+
type: Component,
|
|
1939
|
+
args: [{ selector: 'boolean-dropdown-input', template: "<mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-select (ngModelChange)=\"emitChange()\" [(ngModel)]=\"entity[key]\" [name]=\"key.toString()\" #model=\"ngModel\" [required]=\"metadata.required\">\n <mat-option [value]=\"undefined\">-</mat-option>\n <mat-option [value]=\"true\">{{metadata.dropdownTrue}}</mat-option>\n <mat-option [value]=\"false\">{{metadata.dropdownFalse}}</mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n</mat-form-field>", styles: ["mat-form-field{width:100%}\n"] }]
|
|
1940
|
+
}], ctorParameters: function () { return []; }, propDecorators: { entity: [{
|
|
1941
|
+
type: Input
|
|
1942
|
+
}], key: [{
|
|
1943
|
+
type: Input
|
|
1944
|
+
}], getValidationErrorMessage: [{
|
|
1945
|
+
type: Input
|
|
1946
|
+
}], inputChangeEvent: [{
|
|
1947
|
+
type: Output
|
|
1948
|
+
}] } });
|
|
1949
|
+
|
|
1950
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
1951
|
+
class NumberInputComponent {
|
|
1952
|
+
constructor() {
|
|
1953
|
+
this.inputChangeEvent = new EventEmitter();
|
|
1954
|
+
}
|
|
1955
|
+
ngOnInit() {
|
|
1956
|
+
this.metadata = EntityUtilities.getPropertyMetadata(this.entity, this.key, DecoratorTypes.NUMBER);
|
|
1957
|
+
}
|
|
1958
|
+
emitChange() {
|
|
1959
|
+
this.inputChangeEvent.emit();
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
NumberInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NumberInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1963
|
+
NumberInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: NumberInputComponent, selector: "number-input", inputs: { entity: "entity", key: "key", getValidationErrorMessage: "getValidationErrorMessage" }, outputs: { inputChangeEvent: "inputChangeEvent" }, ngImport: i0, template: "<mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n type=\"number\"\n [(ngModel)]=\"entity[key]\"\n [name]=\"key.toString()\"\n #model=\"ngModel\"\n [required]=\"metadata.required\"\n [min]=\"metadata.min ?? null\"\n [max]=\"metadata.max ?? null\"\n (ngModelChange)=\"emitChange()\"\n />\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n</mat-form-field>", styles: ["mat-form-field{width:100%}\n"], components: [{ type: i1$1.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }], directives: [{ type: i1$1.MatLabel, selector: "mat-label" }, { type: i4$2.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: i3.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { type: i3.MinValidator, selector: "input[type=number][min][formControlName],input[type=number][min][formControl],input[type=number][min][ngModel]", inputs: ["min"] }, { type: i3.MaxValidator, selector: "input[type=number][max][formControlName],input[type=number][max][formControl],input[type=number][max][ngModel]", inputs: ["max"] }, { type: i3.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: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i3.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i1$1.MatError, selector: "mat-error", inputs: ["id"] }] });
|
|
1964
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NumberInputComponent, decorators: [{
|
|
1965
|
+
type: Component,
|
|
1966
|
+
args: [{ selector: 'number-input', template: "<mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n type=\"number\"\n [(ngModel)]=\"entity[key]\"\n [name]=\"key.toString()\"\n #model=\"ngModel\"\n [required]=\"metadata.required\"\n [min]=\"metadata.min ?? null\"\n [max]=\"metadata.max ?? null\"\n (ngModelChange)=\"emitChange()\"\n />\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n</mat-form-field>", styles: ["mat-form-field{width:100%}\n"] }]
|
|
1967
|
+
}], ctorParameters: function () { return []; }, propDecorators: { entity: [{
|
|
1968
|
+
type: Input
|
|
1969
|
+
}], key: [{
|
|
1970
|
+
type: Input
|
|
1971
|
+
}], getValidationErrorMessage: [{
|
|
1972
|
+
type: Input
|
|
1973
|
+
}], inputChangeEvent: [{
|
|
1974
|
+
type: Output
|
|
1975
|
+
}] } });
|
|
1976
|
+
|
|
1977
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
1978
|
+
class NumberDropdownInputComponent {
|
|
1979
|
+
constructor() {
|
|
1980
|
+
this.inputChangeEvent = new EventEmitter();
|
|
1981
|
+
}
|
|
1982
|
+
ngOnInit() {
|
|
1983
|
+
this.metadata = EntityUtilities.getPropertyMetadata(this.entity, this.key, DecoratorTypes.NUMBER_DROPDOWN);
|
|
1984
|
+
}
|
|
1985
|
+
emitChange() {
|
|
1986
|
+
this.inputChangeEvent.emit();
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
NumberDropdownInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NumberDropdownInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1990
|
+
NumberDropdownInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: NumberDropdownInputComponent, selector: "number-dropdown-input", inputs: { entity: "entity", key: "key", getValidationErrorMessage: "getValidationErrorMessage" }, outputs: { inputChangeEvent: "inputChangeEvent" }, ngImport: i0, template: "<mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-select (ngModelChange)=\"emitChange()\" [(ngModel)]=\"entity[key]\" [name]=\"key.toString()\" #model=\"ngModel\" [required]=\"metadata.required\">\n <mat-option *ngFor=\"let value of metadata.dropdownValues\" [value]=\"value.value\">{{value.displayName}}</mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n</mat-form-field>", 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$1.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { type: i3$2.MatOption, selector: "mat-option", exportAs: ["matOption"] }], directives: [{ type: i1$1.MatLabel, selector: "mat-label" }, { type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i3.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i4$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i1$1.MatError, selector: "mat-error", inputs: ["id"] }] });
|
|
1991
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NumberDropdownInputComponent, decorators: [{
|
|
1992
|
+
type: Component,
|
|
1993
|
+
args: [{ selector: 'number-dropdown-input', template: "<mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-select (ngModelChange)=\"emitChange()\" [(ngModel)]=\"entity[key]\" [name]=\"key.toString()\" #model=\"ngModel\" [required]=\"metadata.required\">\n <mat-option *ngFor=\"let value of metadata.dropdownValues\" [value]=\"value.value\">{{value.displayName}}</mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n</mat-form-field>", styles: ["mat-form-field{width:100%}\n"] }]
|
|
1994
|
+
}], ctorParameters: function () { return []; }, propDecorators: { entity: [{
|
|
1995
|
+
type: Input
|
|
1996
|
+
}], key: [{
|
|
1997
|
+
type: Input
|
|
1998
|
+
}], getValidationErrorMessage: [{
|
|
1999
|
+
type: Input
|
|
2000
|
+
}], inputChangeEvent: [{
|
|
2001
|
+
type: Output
|
|
2002
|
+
}] } });
|
|
2003
|
+
|
|
2004
|
+
/**
|
|
2005
|
+
* The base data needed for all arrays that are displayed as a table.
|
|
2006
|
+
*/
|
|
2007
|
+
class ArrayTable {
|
|
2008
|
+
constructor(matDialog) {
|
|
2009
|
+
this.matDialog = matDialog;
|
|
2010
|
+
this.input = undefined;
|
|
2011
|
+
this.dataSource = new MatTableDataSource();
|
|
2012
|
+
this.selection = new SelectionModel(true, []);
|
|
2013
|
+
}
|
|
2014
|
+
init() {
|
|
2015
|
+
this.metadata = EntityUtilities.getPropertyMetadata(this.entity, this.key);
|
|
2016
|
+
if (this.entity[this.key] == null) {
|
|
2017
|
+
this.entity[this.key] = [];
|
|
1251
2018
|
}
|
|
1252
|
-
this.
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
this.displayedColumns = ['select'].concat(givenDisplayColumns);
|
|
1272
|
-
this.dataSource = new MatTableDataSource();
|
|
1273
|
-
this.dataSource.data = this.entityArrayValues;
|
|
1274
|
-
this.arrayItem = new this.metadataEntityArray.EntityClass();
|
|
1275
|
-
this.arrayItemInlineRows = EntityUtilities.getEntityRows(this.arrayItem, this.hideOmitForCreate === false ? false : true, this.hideOmitForEdit ? true : false);
|
|
1276
|
-
this.arrayItemPriorChanges = cloneDeep(this.arrayItem);
|
|
1277
|
-
this.dialogInputData = {
|
|
1278
|
-
entity: this.arrayItem,
|
|
1279
|
-
createDialogData: this.metadataEntityArray.createDialogData,
|
|
1280
|
-
getValidationErrorMessage: this.getValidationErrorMessage
|
|
1281
|
-
};
|
|
1282
|
-
this.dialogData = new AddArrayItemDialogDataBuilder(this.dialogInputData).getResult();
|
|
1283
|
-
this.arrayItemDialogRows = EntityUtilities.getEntityRows(this.dialogData.entity, true);
|
|
1284
|
-
}
|
|
1285
|
-
this.metadataStringChipsArray = this.metadata;
|
|
1286
|
-
if ((this.type === DecoratorTypes.ARRAY_STRING_CHIPS || this.type === DecoratorTypes.ARRAY_STRING_AUTOCOMPLETE_CHIPS)
|
|
1287
|
-
&& ((_a = this.entity[this.propertyKey]) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
1288
|
-
this.stringChipsArrayValues = this.entity[this.propertyKey];
|
|
1289
|
-
}
|
|
1290
|
-
this.metadataAutocompleteStringChipsArray = this.metadata;
|
|
1291
|
-
if (!this.getValidationErrorMessage) {
|
|
1292
|
-
this.getValidationErrorMessage = getValidationErrorMessage;
|
|
1293
|
-
}
|
|
1294
|
-
this.metadataDefaultDate = this.metadata;
|
|
1295
|
-
this.metadataDateRangeDate = this.metadata;
|
|
1296
|
-
this.metadataDateTimeDate = this.metadata;
|
|
1297
|
-
if (this.type === DecoratorTypes.DATE_RANGE) {
|
|
1298
|
-
this.dateRange = cloneDeep(this.entity[this.propertyKey]);
|
|
1299
|
-
if (!this.dateRange) {
|
|
1300
|
-
this.dateRange = {
|
|
1301
|
-
start: undefined,
|
|
1302
|
-
end: undefined,
|
|
1303
|
-
values: undefined
|
|
1304
|
-
};
|
|
1305
|
-
}
|
|
1306
|
-
this.dateRangeStart = new Date(this.dateRange.start);
|
|
1307
|
-
this.dateRangeEnd = new Date(this.dateRange.end);
|
|
1308
|
-
this.setDateRangeValues();
|
|
2019
|
+
this.arrayValues = this.entity[this.key];
|
|
2020
|
+
const givenDisplayColumns = this.metadata.displayColumns.map((v) => v.displayName);
|
|
2021
|
+
if (givenDisplayColumns.find(s => s === 'select')) {
|
|
2022
|
+
throw new Error(`The name "select" for a display column is reserved.
|
|
2023
|
+
Please choose a different name.`);
|
|
2024
|
+
}
|
|
2025
|
+
this.displayedColumns = ['select'].concat(givenDisplayColumns);
|
|
2026
|
+
this.dataSource.data = this.arrayValues;
|
|
2027
|
+
}
|
|
2028
|
+
/**
|
|
2029
|
+
* Toggles all array-items in the table.
|
|
2030
|
+
*
|
|
2031
|
+
*/
|
|
2032
|
+
masterToggle() {
|
|
2033
|
+
if (this.isAllSelected()) {
|
|
2034
|
+
this.selection.clear();
|
|
2035
|
+
}
|
|
2036
|
+
else {
|
|
2037
|
+
this.dataSource.data.forEach(row => this.selection.select(row));
|
|
1309
2038
|
}
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
2039
|
+
}
|
|
2040
|
+
/**
|
|
2041
|
+
* Checks if all array-items in the table have been selected.
|
|
2042
|
+
* This is needed to display the "masterToggle"-checkbox correctly.
|
|
2043
|
+
*
|
|
2044
|
+
* @returns Whether or not all array-items in the table have been selected.
|
|
2045
|
+
*/
|
|
2046
|
+
isAllSelected() {
|
|
2047
|
+
const numSelected = this.selection.selected.length;
|
|
2048
|
+
const numRows = this.dataSource.data.length;
|
|
2049
|
+
return numSelected === numRows;
|
|
2050
|
+
}
|
|
2051
|
+
/**
|
|
2052
|
+
* Tries to add an item to the array.
|
|
2053
|
+
*/
|
|
2054
|
+
add() {
|
|
2055
|
+
if (this.input != null) {
|
|
2056
|
+
if (!this.metadata.allowDuplicates
|
|
2057
|
+
&& this.arrayValues.find((v) => __awaiter(this, void 0, void 0, function* () { return yield EntityUtilities.isEqual(this.input, v, this.metadata, this.metadata.itemType); })) != null) {
|
|
2058
|
+
this.matDialog.open(NgxMatEntityConfirmDialogComponent, {
|
|
2059
|
+
data: this.metadata.duplicatesErrorDialog,
|
|
2060
|
+
autoFocus: false,
|
|
2061
|
+
restoreFocus: false
|
|
2062
|
+
});
|
|
2063
|
+
return;
|
|
1315
2064
|
}
|
|
2065
|
+
this.arrayValues.push(LodashUtilities.cloneDeep(this.input));
|
|
2066
|
+
this.dataSource.data = this.arrayValues;
|
|
2067
|
+
this.resetInput();
|
|
2068
|
+
this.emitChange();
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
/**
|
|
2072
|
+
* Is split up from the add method to override this functionality more easily.
|
|
2073
|
+
*/
|
|
2074
|
+
resetInput() {
|
|
2075
|
+
this.input = undefined;
|
|
2076
|
+
}
|
|
2077
|
+
/**
|
|
2078
|
+
* Removes all selected entries from the entity array.
|
|
2079
|
+
*/
|
|
2080
|
+
remove() {
|
|
2081
|
+
this.selection.selected.forEach(s => {
|
|
2082
|
+
this.arrayValues.splice(this.arrayValues.indexOf(s), 1);
|
|
2083
|
+
});
|
|
2084
|
+
this.dataSource.data = this.arrayValues;
|
|
2085
|
+
this.selection.clear();
|
|
2086
|
+
this.emitChange();
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
|
|
2090
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
2091
|
+
class ArrayDateInputComponent extends ArrayTable {
|
|
2092
|
+
constructor(dialog) {
|
|
2093
|
+
super(dialog);
|
|
2094
|
+
this.dialog = dialog;
|
|
2095
|
+
this.DateUtilities = DateUtilities;
|
|
2096
|
+
this.inputChangeEvent = new EventEmitter();
|
|
2097
|
+
}
|
|
2098
|
+
ngOnInit() {
|
|
2099
|
+
this.init();
|
|
2100
|
+
}
|
|
2101
|
+
emitChange() {
|
|
2102
|
+
this.inputChangeEvent.emit();
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
ArrayDateInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ArrayDateInputComponent, deps: [{ token: i1.MatDialog }], target: i0.ɵɵFactoryTarget.Component });
|
|
2106
|
+
ArrayDateInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: ArrayDateInputComponent, selector: "array-date-input", inputs: { entity: "entity", key: "key", getValidationErrorMessage: "getValidationErrorMessage" }, outputs: { inputChangeEvent: "inputChangeEvent" }, usesInheritance: true, ngImport: i0, template: "<div class=\"mat-elevation-z8\" style=\"border-radius: 5px;padding: 15px;margin-bottom: 15px;margin-top: 15px;\">\n <mat-form-field appearance=\"standard\">\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n [(ngModel)]=\"input\"\n [name]=\"key.toString()\"\n #model=\"ngModel\"\n [matDatepicker]=\"picker\"\n [required]=\"metadata.required\"\n [min]=\"metadata.min ? metadata.min(input) : undefined\"\n [max]=\"metadata.max ? metadata.max(input) : undefined\"\n [matDatepickerFilter]=\"metadata.filter ?? DateUtilities.defaultDateFilter\"\n >\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-datepicker #picker></mat-datepicker>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n \n <div class=\"buttons\">\n <button mat-raised-button\n [disabled]=\"model.errors\"\n (click)=\"add()\">\n {{metadata.addButtonLabel}}\n </button>\n <button mat-raised-button\n [disabled]=\"!selection.selected.length\"\n (click)=\"remove()\">\n {{metadata.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\">\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}}\n </div>\n</div>", styles: ["mat-form-field{width:100%}.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.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: i1$1.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i3$3.MatDatepickerToggle, selector: "mat-datepicker-toggle", inputs: ["for", "tabIndex", "aria-label", "disabled", "disableRipple"], exportAs: ["matDatepickerToggle"] }, { type: i3$3.MatDatepicker, selector: "mat-datepicker", exportAs: ["matDatepicker"] }, { type: i4.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: i5.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: i5.MatHeaderRow, selector: "mat-header-row, tr[mat-header-row]", exportAs: ["matHeaderRow"] }, { type: i5.MatRow, selector: "mat-row, tr[mat-row]", exportAs: ["matRow"] }], directives: [{ type: i1$1.MatLabel, selector: "mat-label" }, { type: i4$2.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: i3.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: i3$3.MatDatepickerInput, selector: "input[matDatepicker]", inputs: ["matDatepicker", "min", "max", "matDatepickerFilter"], exportAs: ["matDatepickerInput"] }, { type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i3.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i1$1.MatSuffix, selector: "[matSuffix]" }, { type: i1$1.MatError, selector: "mat-error", inputs: ["id"] }, { type: i5.MatColumnDef, selector: "[matColumnDef]", inputs: ["sticky", "matColumnDef"] }, { type: i5.MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { type: i5.MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { type: i5.MatCellDef, selector: "[matCellDef]" }, { type: i5.MatCell, selector: "mat-cell, td[mat-cell]" }, { type: i4$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5.MatHeaderRowDef, selector: "[matHeaderRowDef]", inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"] }, { type: i5.MatRowDef, selector: "[matRowDef]", inputs: ["matRowDefColumns", "matRowDefWhen"] }, { type: i4$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
|
|
2107
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ArrayDateInputComponent, decorators: [{
|
|
2108
|
+
type: Component,
|
|
2109
|
+
args: [{ selector: 'array-date-input', template: "<div class=\"mat-elevation-z8\" style=\"border-radius: 5px;padding: 15px;margin-bottom: 15px;margin-top: 15px;\">\n <mat-form-field appearance=\"standard\">\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n [(ngModel)]=\"input\"\n [name]=\"key.toString()\"\n #model=\"ngModel\"\n [matDatepicker]=\"picker\"\n [required]=\"metadata.required\"\n [min]=\"metadata.min ? metadata.min(input) : undefined\"\n [max]=\"metadata.max ? metadata.max(input) : undefined\"\n [matDatepickerFilter]=\"metadata.filter ?? DateUtilities.defaultDateFilter\"\n >\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-datepicker #picker></mat-datepicker>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n \n <div class=\"buttons\">\n <button mat-raised-button\n [disabled]=\"model.errors\"\n (click)=\"add()\">\n {{metadata.addButtonLabel}}\n </button>\n <button mat-raised-button\n [disabled]=\"!selection.selected.length\"\n (click)=\"remove()\">\n {{metadata.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\">\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}}\n </div>\n</div>", styles: ["mat-form-field{width:100%}.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.8px;border:1px solid #E0E0E0;background-color:#f8d3d7;color:#721c24;height:25.8px;border-bottom-left-radius:5px;border-bottom-right-radius:5px}\n"] }]
|
|
2110
|
+
}], ctorParameters: function () { return [{ type: i1.MatDialog }]; }, propDecorators: { entity: [{
|
|
2111
|
+
type: Input
|
|
2112
|
+
}], key: [{
|
|
2113
|
+
type: Input
|
|
2114
|
+
}], getValidationErrorMessage: [{
|
|
2115
|
+
type: Input
|
|
2116
|
+
}], inputChangeEvent: [{
|
|
2117
|
+
type: Output
|
|
2118
|
+
}] } });
|
|
2119
|
+
|
|
2120
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
2121
|
+
class ArrayDateTimeInputComponent extends ArrayTable {
|
|
2122
|
+
constructor(dialog) {
|
|
2123
|
+
super(dialog);
|
|
2124
|
+
this.dialog = dialog;
|
|
2125
|
+
this.DateUtilities = DateUtilities;
|
|
2126
|
+
this.inputChangeEvent = new EventEmitter();
|
|
2127
|
+
}
|
|
2128
|
+
ngOnInit() {
|
|
2129
|
+
this.init();
|
|
2130
|
+
this.time = DateUtilities.getTimeFromDate(this.entity[this.key]);
|
|
2131
|
+
this.timeDropdownValues = this.metadata.times;
|
|
2132
|
+
if (this.entity[this.key] != null) {
|
|
2133
|
+
this.dateTime = new Date(this.entity[this.key]);
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2136
|
+
resetInput() {
|
|
2137
|
+
this.input = undefined;
|
|
2138
|
+
this.time = undefined;
|
|
2139
|
+
}
|
|
2140
|
+
/**
|
|
2141
|
+
* Adds a date time to the array.
|
|
2142
|
+
*/
|
|
2143
|
+
addDateTime() {
|
|
2144
|
+
if (this.input && this.time) {
|
|
2145
|
+
this.input = new Date(this.input);
|
|
2146
|
+
this.input.setHours(this.time.hours, this.time.minutes, 0, 0);
|
|
2147
|
+
this.add();
|
|
1316
2148
|
}
|
|
1317
2149
|
}
|
|
2150
|
+
emitChange() {
|
|
2151
|
+
this.inputChangeEvent.emit();
|
|
2152
|
+
}
|
|
2153
|
+
}
|
|
2154
|
+
ArrayDateTimeInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ArrayDateTimeInputComponent, deps: [{ token: i1.MatDialog }], target: i0.ɵɵFactoryTarget.Component });
|
|
2155
|
+
ArrayDateTimeInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: ArrayDateTimeInputComponent, selector: "array-date-time-input", inputs: { entity: "entity", key: "key", getValidationErrorMessage: "getValidationErrorMessage" }, outputs: { inputChangeEvent: "inputChangeEvent" }, usesInheritance: true, ngImport: i0, template: "<div class=\"mat-elevation-z8\" style=\"border-radius: 5px;padding: 15px;margin-bottom: 15px;margin-top: 15px;\">\n \n <div class=\"date-time\">\n <mat-form-field appearance=\"standard\">\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n [(ngModel)]=\"input\"\n [name]=\"key.toString()\"\n #model=\"ngModel\"\n [matDatepicker]=\"picker\"\n [required]=\"metadata.required\"\n [min]=\"metadata.minDate ? metadata.minDate(input) : undefined\"\n [max]=\"metadata.maxDate ? metadata.maxDate(input) : undefined\"\n [matDatepickerFilter]=\"metadata.filterDate ?? DateUtilities.defaultDateFilter\"\n >\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-datepicker #picker></mat-datepicker>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n <mat-form-field class=\"timepicker\">\n <mat-label>{{metadata.timeDisplayName}}</mat-label>\n <mat-select\n [(ngModel)]=\"time\"\n [name]=\"key.toString() + 'time'\"\n #timeModel=\"ngModel\"\n [required]=\"metadata.required\"\n >\n <mat-option *ngFor=\"let validTime of DateUtilities.getValidTimesForDropdown(\n DateUtilities.asDate(input),\n metadata.times,\n metadata.minTime,\n metadata.maxTime,\n metadata.filterTime\n )\"\n [value]=\"validTime.value\"\n >\n {{validTime.displayName}}\n </mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(timeModel)}}</mat-error>\n </mat-form-field>\n </div>\n <div class=\"buttons\">\n <button mat-raised-button\n [disabled]=\"model.errors || timeModel.errors || DateUtilities.timeIsUnprocessable(time)\"\n (click)=\"addDateTime()\">\n {{metadata.addButtonLabel}}\n </button>\n <button mat-raised-button\n [disabled]=\"!selection.selected.length\"\n (click)=\"remove()\">\n {{metadata.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\">\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}}\n </div>\n</div>", styles: ["mat-form-field{width:100%}.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.8px;border:1px solid #E0E0E0;background-color:#f8d3d7;color:#721c24;height:25.8px;border-bottom-left-radius:5px;border-bottom-right-radius:5px}.date-time{display:flex;align-items:baseline}.date-time .timepicker{margin-left:10px}\n"], components: [{ type: i1$1.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i3$3.MatDatepickerToggle, selector: "mat-datepicker-toggle", inputs: ["for", "tabIndex", "aria-label", "disabled", "disableRipple"], exportAs: ["matDatepickerToggle"] }, { type: i3$3.MatDatepicker, selector: "mat-datepicker", exportAs: ["matDatepicker"] }, { type: i2$1.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { type: i3$2.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { type: i4.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: i5.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: i5.MatHeaderRow, selector: "mat-header-row, tr[mat-header-row]", exportAs: ["matHeaderRow"] }, { type: i5.MatRow, selector: "mat-row, tr[mat-row]", exportAs: ["matRow"] }], directives: [{ type: i1$1.MatLabel, selector: "mat-label" }, { type: i4$2.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: i3.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: i3$3.MatDatepickerInput, selector: "input[matDatepicker]", inputs: ["matDatepicker", "min", "max", "matDatepickerFilter"], exportAs: ["matDatepickerInput"] }, { type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i3.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i1$1.MatSuffix, selector: "[matSuffix]" }, { type: i1$1.MatError, selector: "mat-error", inputs: ["id"] }, { type: i4$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5.MatColumnDef, selector: "[matColumnDef]", inputs: ["sticky", "matColumnDef"] }, { type: i5.MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { type: i5.MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { type: i5.MatCellDef, selector: "[matCellDef]" }, { type: i5.MatCell, selector: "mat-cell, td[mat-cell]" }, { type: i5.MatHeaderRowDef, selector: "[matHeaderRowDef]", inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"] }, { type: i5.MatRowDef, selector: "[matRowDef]", inputs: ["matRowDefColumns", "matRowDefWhen"] }, { type: i4$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
|
|
2156
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ArrayDateTimeInputComponent, decorators: [{
|
|
2157
|
+
type: Component,
|
|
2158
|
+
args: [{ selector: 'array-date-time-input', template: "<div class=\"mat-elevation-z8\" style=\"border-radius: 5px;padding: 15px;margin-bottom: 15px;margin-top: 15px;\">\n \n <div class=\"date-time\">\n <mat-form-field appearance=\"standard\">\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n [(ngModel)]=\"input\"\n [name]=\"key.toString()\"\n #model=\"ngModel\"\n [matDatepicker]=\"picker\"\n [required]=\"metadata.required\"\n [min]=\"metadata.minDate ? metadata.minDate(input) : undefined\"\n [max]=\"metadata.maxDate ? metadata.maxDate(input) : undefined\"\n [matDatepickerFilter]=\"metadata.filterDate ?? DateUtilities.defaultDateFilter\"\n >\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-datepicker #picker></mat-datepicker>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n <mat-form-field class=\"timepicker\">\n <mat-label>{{metadata.timeDisplayName}}</mat-label>\n <mat-select\n [(ngModel)]=\"time\"\n [name]=\"key.toString() + 'time'\"\n #timeModel=\"ngModel\"\n [required]=\"metadata.required\"\n >\n <mat-option *ngFor=\"let validTime of DateUtilities.getValidTimesForDropdown(\n DateUtilities.asDate(input),\n metadata.times,\n metadata.minTime,\n metadata.maxTime,\n metadata.filterTime\n )\"\n [value]=\"validTime.value\"\n >\n {{validTime.displayName}}\n </mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(timeModel)}}</mat-error>\n </mat-form-field>\n </div>\n <div class=\"buttons\">\n <button mat-raised-button\n [disabled]=\"model.errors || timeModel.errors || DateUtilities.timeIsUnprocessable(time)\"\n (click)=\"addDateTime()\">\n {{metadata.addButtonLabel}}\n </button>\n <button mat-raised-button\n [disabled]=\"!selection.selected.length\"\n (click)=\"remove()\">\n {{metadata.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\">\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}}\n </div>\n</div>", styles: ["mat-form-field{width:100%}.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.8px;border:1px solid #E0E0E0;background-color:#f8d3d7;color:#721c24;height:25.8px;border-bottom-left-radius:5px;border-bottom-right-radius:5px}.date-time{display:flex;align-items:baseline}.date-time .timepicker{margin-left:10px}\n"] }]
|
|
2159
|
+
}], ctorParameters: function () { return [{ type: i1.MatDialog }]; }, propDecorators: { entity: [{
|
|
2160
|
+
type: Input
|
|
2161
|
+
}], key: [{
|
|
2162
|
+
type: Input
|
|
2163
|
+
}], getValidationErrorMessage: [{
|
|
2164
|
+
type: Input
|
|
2165
|
+
}], inputChangeEvent: [{
|
|
2166
|
+
type: Output
|
|
2167
|
+
}] } });
|
|
2168
|
+
|
|
2169
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
2170
|
+
class ArrayDateRangeInputComponent extends ArrayTable {
|
|
2171
|
+
constructor(dialog) {
|
|
2172
|
+
super(dialog);
|
|
2173
|
+
this.dialog = dialog;
|
|
2174
|
+
this.DateUtilities = DateUtilities;
|
|
2175
|
+
this.inputChangeEvent = new EventEmitter();
|
|
2176
|
+
}
|
|
2177
|
+
ngOnInit() {
|
|
2178
|
+
this.init();
|
|
2179
|
+
this.input = {
|
|
2180
|
+
start: undefined,
|
|
2181
|
+
end: undefined,
|
|
2182
|
+
values: undefined
|
|
2183
|
+
};
|
|
2184
|
+
}
|
|
2185
|
+
/**
|
|
2186
|
+
* Adds a DateRange to the array.
|
|
2187
|
+
*/
|
|
2188
|
+
addDateRange() {
|
|
2189
|
+
if (this.input && this.dateRangeStart && this.dateRangeEnd) {
|
|
2190
|
+
this.input.start = new Date(this.dateRangeStart);
|
|
2191
|
+
this.input.end = new Date(this.dateRangeEnd);
|
|
2192
|
+
const values = DateUtilities.getDatesBetween(this.input.start, this.input.end, this.metadata.filter);
|
|
2193
|
+
this.input.values = values.length ? values : undefined;
|
|
2194
|
+
this.add();
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
resetInput() {
|
|
2198
|
+
this.input = undefined;
|
|
2199
|
+
this.dateRangeStart = undefined;
|
|
2200
|
+
this.dateRangeEnd = undefined;
|
|
2201
|
+
}
|
|
2202
|
+
emitChange() {
|
|
2203
|
+
this.inputChangeEvent.emit();
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
ArrayDateRangeInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ArrayDateRangeInputComponent, deps: [{ token: i1.MatDialog }], target: i0.ɵɵFactoryTarget.Component });
|
|
2207
|
+
ArrayDateRangeInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: ArrayDateRangeInputComponent, selector: "array-date-range-input", inputs: { entity: "entity", key: "key", metadata: "metadata", getValidationErrorMessage: "getValidationErrorMessage" }, outputs: { inputChangeEvent: "inputChangeEvent" }, usesInheritance: true, ngImport: i0, template: "<div class=\"mat-elevation-z8\" style=\"border-radius: 5px;padding: 15px;margin-bottom: 15px;margin-top: 15px;\">\n\n <mat-form-field appearance=\"standard\">\n <mat-label>{{metadata.displayName}}</mat-label>\n \n <mat-date-range-input [rangePicker]=\"picker\" [required]=\"metadata.required\" [dateFilter]=\"metadata.filter ? metadata.filter : DateUtilities.defaultDateFilter\">\n <input matStartDate\n [(ngModel)]=\"dateRangeStart\"\n [name]=\"key.toString() + 'start'\"\n #startModel=\"ngModel\"\n [required]=\"metadata.required\"\n [min]=\"metadata.minStart ? metadata.minStart(input?.start) : undefined\"\n [max]=\"metadata.maxStart ? metadata.maxStart(input?.start) : undefined\"\n [placeholder]=\"metadata.placeholderStart\"\n >\n <input matEndDate\n [(ngModel)]=\"dateRangeEnd\"\n [name]=\"key.toString() + 'end'\"\n #endModel=\"ngModel\"\n [required]=\"metadata.required\"\n [min]=\"metadata.minEnd ? metadata.minEnd(input?.end) : undefined\"\n [max]=\"metadata.maxEnd ? metadata.maxEnd(input?.end) : undefined\"\n [placeholder]=\"metadata.placeholderEnd\"\n >\n </mat-date-range-input>\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-date-range-picker #picker></mat-date-range-picker>\n\n <mat-error *ngIf=\"startModel.errors\">{{getValidationErrorMessage(startModel)}}</mat-error>\n <mat-error *ngIf=\"!startModel.errors && endModel.errors\">{{getValidationErrorMessage(endModel)}}</mat-error>\n </mat-form-field>\n \n <div class=\"buttons\">\n <button mat-raised-button\n [disabled]=\"startModel.errors || endModel.errors\"\n (click)=\"addDateRange()\">\n {{metadata.addButtonLabel}}\n </button>\n <button mat-raised-button\n [disabled]=\"!selection.selected.length\"\n (click)=\"remove()\">\n {{metadata.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\">\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}}\n </div>\n</div>", styles: ["mat-form-field{width:100%}.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.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: i1$1.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i3$3.MatDateRangeInput, selector: "mat-date-range-input", inputs: ["rangePicker", "required", "dateFilter", "min", "max", "disabled", "separator", "comparisonStart", "comparisonEnd"], exportAs: ["matDateRangeInput"] }, { type: i3$3.MatDatepickerToggle, selector: "mat-datepicker-toggle", inputs: ["for", "tabIndex", "aria-label", "disabled", "disableRipple"], exportAs: ["matDatepickerToggle"] }, { type: i3$3.MatDateRangePicker, selector: "mat-date-range-picker", exportAs: ["matDateRangePicker"] }, { type: i4.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: i5.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: i5.MatHeaderRow, selector: "mat-header-row, tr[mat-header-row]", exportAs: ["matHeaderRow"] }, { type: i5.MatRow, selector: "mat-row, tr[mat-row]", exportAs: ["matRow"] }], directives: [{ type: i1$1.MatLabel, selector: "mat-label" }, { type: i3$3.MatStartDate, selector: "input[matStartDate]", inputs: ["errorStateMatcher"], outputs: ["dateChange", "dateInput"] }, { type: i3.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: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i3.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i3$3.MatEndDate, selector: "input[matEndDate]", inputs: ["errorStateMatcher"], outputs: ["dateChange", "dateInput"] }, { type: i1$1.MatSuffix, selector: "[matSuffix]" }, { type: i4$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1$1.MatError, selector: "mat-error", inputs: ["id"] }, { type: i5.MatColumnDef, selector: "[matColumnDef]", inputs: ["sticky", "matColumnDef"] }, { type: i5.MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { type: i5.MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { type: i5.MatCellDef, selector: "[matCellDef]" }, { type: i5.MatCell, selector: "mat-cell, td[mat-cell]" }, { type: i4$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5.MatHeaderRowDef, selector: "[matHeaderRowDef]", inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"] }, { type: i5.MatRowDef, selector: "[matRowDef]", inputs: ["matRowDefColumns", "matRowDefWhen"] }] });
|
|
2208
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ArrayDateRangeInputComponent, decorators: [{
|
|
2209
|
+
type: Component,
|
|
2210
|
+
args: [{ selector: 'array-date-range-input', template: "<div class=\"mat-elevation-z8\" style=\"border-radius: 5px;padding: 15px;margin-bottom: 15px;margin-top: 15px;\">\n\n <mat-form-field appearance=\"standard\">\n <mat-label>{{metadata.displayName}}</mat-label>\n \n <mat-date-range-input [rangePicker]=\"picker\" [required]=\"metadata.required\" [dateFilter]=\"metadata.filter ? metadata.filter : DateUtilities.defaultDateFilter\">\n <input matStartDate\n [(ngModel)]=\"dateRangeStart\"\n [name]=\"key.toString() + 'start'\"\n #startModel=\"ngModel\"\n [required]=\"metadata.required\"\n [min]=\"metadata.minStart ? metadata.minStart(input?.start) : undefined\"\n [max]=\"metadata.maxStart ? metadata.maxStart(input?.start) : undefined\"\n [placeholder]=\"metadata.placeholderStart\"\n >\n <input matEndDate\n [(ngModel)]=\"dateRangeEnd\"\n [name]=\"key.toString() + 'end'\"\n #endModel=\"ngModel\"\n [required]=\"metadata.required\"\n [min]=\"metadata.minEnd ? metadata.minEnd(input?.end) : undefined\"\n [max]=\"metadata.maxEnd ? metadata.maxEnd(input?.end) : undefined\"\n [placeholder]=\"metadata.placeholderEnd\"\n >\n </mat-date-range-input>\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-date-range-picker #picker></mat-date-range-picker>\n\n <mat-error *ngIf=\"startModel.errors\">{{getValidationErrorMessage(startModel)}}</mat-error>\n <mat-error *ngIf=\"!startModel.errors && endModel.errors\">{{getValidationErrorMessage(endModel)}}</mat-error>\n </mat-form-field>\n \n <div class=\"buttons\">\n <button mat-raised-button\n [disabled]=\"startModel.errors || endModel.errors\"\n (click)=\"addDateRange()\">\n {{metadata.addButtonLabel}}\n </button>\n <button mat-raised-button\n [disabled]=\"!selection.selected.length\"\n (click)=\"remove()\">\n {{metadata.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\">\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}}\n </div>\n</div>", styles: ["mat-form-field{width:100%}.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.8px;border:1px solid #E0E0E0;background-color:#f8d3d7;color:#721c24;height:25.8px;border-bottom-left-radius:5px;border-bottom-right-radius:5px}\n"] }]
|
|
2211
|
+
}], ctorParameters: function () { return [{ type: i1.MatDialog }]; }, propDecorators: { entity: [{
|
|
2212
|
+
type: Input
|
|
2213
|
+
}], key: [{
|
|
2214
|
+
type: Input
|
|
2215
|
+
}], metadata: [{
|
|
2216
|
+
type: Input
|
|
2217
|
+
}], getValidationErrorMessage: [{
|
|
2218
|
+
type: Input
|
|
2219
|
+
}], inputChangeEvent: [{
|
|
2220
|
+
type: Output
|
|
2221
|
+
}] } });
|
|
2222
|
+
|
|
2223
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
2224
|
+
class ArrayStringChipsInputComponent {
|
|
2225
|
+
constructor() {
|
|
2226
|
+
this.inputChangeEvent = new EventEmitter();
|
|
2227
|
+
this.chipsInput = '';
|
|
2228
|
+
}
|
|
2229
|
+
ngOnInit() {
|
|
2230
|
+
var _a;
|
|
2231
|
+
this.metadata = EntityUtilities.getPropertyMetadata(this.entity, this.key, DecoratorTypes.ARRAY_STRING_CHIPS);
|
|
2232
|
+
if ((_a = this.entity[this.key]) === null || _a === void 0 ? void 0 : _a.length) {
|
|
2233
|
+
this.stringChipsArrayValues = this.entity[this.key];
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
/**
|
|
2237
|
+
* Handles adding strings to the chipsArray.
|
|
2238
|
+
* Checks validation and also creates a new array if it is undefined.
|
|
2239
|
+
* This is needed because two things are validated: The array itself
|
|
2240
|
+
* and the contents of the array. And we need a way to display an
|
|
2241
|
+
* mat-error. As the only validation for the array is whether or not
|
|
2242
|
+
* it contains values, we can set it to undefined when the last element is removed
|
|
2243
|
+
* (removeStringChipArrayValue). That way we can use the "required" validator.
|
|
2244
|
+
*
|
|
2245
|
+
* @param event - The event that fires when a new chip is completed.
|
|
2246
|
+
*/
|
|
2247
|
+
addStringChipArrayValue(event) {
|
|
2248
|
+
var _a;
|
|
2249
|
+
const value = (event.value || '').trim();
|
|
2250
|
+
if (value) {
|
|
2251
|
+
if (this.metadata.minLength && value.length < this.metadata.minLength) {
|
|
2252
|
+
return;
|
|
2253
|
+
}
|
|
2254
|
+
if (this.metadata.maxLength && value.length > this.metadata.maxLength) {
|
|
2255
|
+
return;
|
|
2256
|
+
}
|
|
2257
|
+
if (this.metadata.regex && !value.match(this.metadata.regex)) {
|
|
2258
|
+
return;
|
|
2259
|
+
}
|
|
2260
|
+
if (!this.stringChipsArrayValues) {
|
|
2261
|
+
if (this.entity[this.key] == null) {
|
|
2262
|
+
this.entity[this.key] = [];
|
|
2263
|
+
}
|
|
2264
|
+
this.stringChipsArrayValues = this.entity[this.key];
|
|
2265
|
+
}
|
|
2266
|
+
this.stringChipsArrayValues.push(value);
|
|
2267
|
+
}
|
|
2268
|
+
(_a = event.chipInput) === null || _a === void 0 ? void 0 : _a.clear();
|
|
2269
|
+
}
|
|
2270
|
+
/**
|
|
2271
|
+
* Removes the given value from the array.
|
|
2272
|
+
* Sets the array to undefined if it is now empty.
|
|
2273
|
+
* This is needed because two things are validated: The array itself
|
|
2274
|
+
* and the contents of the array. And we need a way to display an
|
|
2275
|
+
* mat-error. As the only validation for the array is whether or not
|
|
2276
|
+
* it is empty, setting it to undefined here enables us to use the "required" validator.
|
|
2277
|
+
*
|
|
2278
|
+
* @param value - The string to remove from the array.
|
|
2279
|
+
*/
|
|
2280
|
+
removeStringChipArrayValue(value) {
|
|
2281
|
+
var _a, _b;
|
|
2282
|
+
(_a = this.stringChipsArrayValues) === null || _a === void 0 ? void 0 : _a.splice(this.stringChipsArrayValues.indexOf(value), 1);
|
|
2283
|
+
if (!((_b = this.stringChipsArrayValues) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
2284
|
+
this.entity[this.key] = undefined;
|
|
2285
|
+
this.stringChipsArrayValues = this.entity[this.key];
|
|
2286
|
+
}
|
|
2287
|
+
}
|
|
2288
|
+
/**
|
|
2289
|
+
* Handles adding a string to the array when an autocomplete value has been selected.
|
|
2290
|
+
*
|
|
2291
|
+
* @param event - The autocomplete selected event.
|
|
2292
|
+
* @param chipsInput - The element where the user typed the value.
|
|
2293
|
+
*/
|
|
2294
|
+
selected(event, chipsInput) {
|
|
2295
|
+
const value = (event.option.viewValue || '').trim();
|
|
2296
|
+
if (this.metadata.minLength && value.length < this.metadata.minLength) {
|
|
2297
|
+
return;
|
|
2298
|
+
}
|
|
2299
|
+
if (this.metadata.maxLength && value.length > this.metadata.maxLength) {
|
|
2300
|
+
return;
|
|
2301
|
+
}
|
|
2302
|
+
if (this.metadata.regex && !value.match(this.metadata.regex)) {
|
|
2303
|
+
return;
|
|
2304
|
+
}
|
|
2305
|
+
if (!this.stringChipsArrayValues) {
|
|
2306
|
+
if (this.entity[this.key] == null) {
|
|
2307
|
+
this.entity[this.key] = [];
|
|
2308
|
+
}
|
|
2309
|
+
this.stringChipsArrayValues = this.entity[this.key];
|
|
2310
|
+
}
|
|
2311
|
+
this.stringChipsArrayValues.push(value);
|
|
2312
|
+
chipsInput.value = '';
|
|
2313
|
+
}
|
|
2314
|
+
emitChange() {
|
|
2315
|
+
this.inputChangeEvent.emit();
|
|
2316
|
+
}
|
|
2317
|
+
}
|
|
2318
|
+
ArrayStringChipsInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ArrayStringChipsInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2319
|
+
ArrayStringChipsInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: ArrayStringChipsInputComponent, selector: "array-string-chips-input", inputs: { entity: "entity", key: "key", getValidationErrorMessage: "getValidationErrorMessage" }, outputs: { inputChangeEvent: "inputChangeEvent" }, ngImport: i0, template: "<mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-chip-list #chipList\n (ngModelChange)=\"emitChange()\"\n [(ngModel)]=\"entity[key]\" [name]=\"key.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=\"{{metadata.deleteIcon}}\"></i>\n </button>\n </mat-chip>\n <input matInput\n [matChipInputFor]=\"chipList\"\n [matChipInputAddOnBlur]=\"true\"\n (matChipInputTokenEnd)=\"addStringChipArrayValue($event)\"\n [(ngModel)]=\"chipsInput\" [name]=\"key.toString()\" #chipsModel=\"ngModel\"\n [minlength]='metadata.minLength ?? null'\n [maxlength]='metadata.maxLength ?? null'\n [pattern]=\"metadata.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>", 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$3.MatChipList, selector: "mat-chip-list", inputs: ["errorStateMatcher", "multiple", "compareWith", "value", "required", "placeholder", "disabled", "aria-orientation", "selectable", "tabIndex"], outputs: ["change", "valueChange"], exportAs: ["matChipList"] }], directives: [{ type: i1$1.MatLabel, selector: "mat-label" }, { type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i3.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i4$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2$3.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: i2$3.MatChipRemove, selector: "[matChipRemove]" }, { type: i4$2.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: i2$3.MatChipInput, selector: "input[matChipInputFor]", inputs: ["matChipInputFor", "matChipInputAddOnBlur", "matChipInputSeparatorKeyCodes", "placeholder", "id", "disabled"], outputs: ["matChipInputTokenEnd"], exportAs: ["matChipInput", "matChipInputFor"] }, { type: i3.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: i3.MinLengthValidator, selector: "[minlength][formControlName],[minlength][formControl],[minlength][ngModel]", inputs: ["minlength"] }, { type: i3.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { type: i3.PatternValidator, selector: "[pattern][formControlName],[pattern][formControl],[pattern][ngModel]", inputs: ["pattern"] }, { type: i4$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1$1.MatError, selector: "mat-error", inputs: ["id"] }] });
|
|
2320
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ArrayStringChipsInputComponent, decorators: [{
|
|
2321
|
+
type: Component,
|
|
2322
|
+
args: [{ selector: 'array-string-chips-input', template: "<mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-chip-list #chipList\n (ngModelChange)=\"emitChange()\"\n [(ngModel)]=\"entity[key]\" [name]=\"key.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=\"{{metadata.deleteIcon}}\"></i>\n </button>\n </mat-chip>\n <input matInput\n [matChipInputFor]=\"chipList\"\n [matChipInputAddOnBlur]=\"true\"\n (matChipInputTokenEnd)=\"addStringChipArrayValue($event)\"\n [(ngModel)]=\"chipsInput\" [name]=\"key.toString()\" #chipsModel=\"ngModel\"\n [minlength]='metadata.minLength ?? null'\n [maxlength]='metadata.maxLength ?? null'\n [pattern]=\"metadata.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>", styles: ["mat-form-field{width:100%}\n"] }]
|
|
2323
|
+
}], ctorParameters: function () { return []; }, propDecorators: { entity: [{
|
|
2324
|
+
type: Input
|
|
2325
|
+
}], key: [{
|
|
2326
|
+
type: Input
|
|
2327
|
+
}], getValidationErrorMessage: [{
|
|
2328
|
+
type: Input
|
|
2329
|
+
}], inputChangeEvent: [{
|
|
2330
|
+
type: Output
|
|
2331
|
+
}] } });
|
|
2332
|
+
|
|
2333
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
2334
|
+
class ArrayStringAutocompleteChipsComponent {
|
|
2335
|
+
constructor() {
|
|
2336
|
+
this.inputChangeEvent = new EventEmitter();
|
|
2337
|
+
this.chipsInput = '';
|
|
2338
|
+
}
|
|
2339
|
+
ngOnInit() {
|
|
2340
|
+
var _a;
|
|
2341
|
+
this.metadata = EntityUtilities.getPropertyMetadata(this.entity, this.key, DecoratorTypes.ARRAY_STRING_AUTOCOMPLETE_CHIPS);
|
|
2342
|
+
this.filteredAutocompleteStrings = LodashUtilities.cloneDeep(this.metadata.autocompleteValues);
|
|
2343
|
+
if ((_a = this.entity[this.key]) === null || _a === void 0 ? void 0 : _a.length) {
|
|
2344
|
+
this.stringChipsArrayValues = this.entity[this.key];
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
/**
|
|
2348
|
+
* Handles adding strings to the chipsArray.
|
|
2349
|
+
* Checks validation and also creates a new array if it is undefined.
|
|
2350
|
+
* This is needed because two things are validated: The array itself
|
|
2351
|
+
* and the contents of the array. And we need a way to display an
|
|
2352
|
+
* mat-error. As the only validation for the array is whether or not
|
|
2353
|
+
* it contains values, we can set it to undefined when the last element is removed
|
|
2354
|
+
* (removeStringChipArrayValue). That way we can use the "required" validator.
|
|
2355
|
+
*
|
|
2356
|
+
* @param event - The event that fires when a new chip is completed.
|
|
2357
|
+
*/
|
|
2358
|
+
addStringChipArrayValue(event) {
|
|
2359
|
+
var _a;
|
|
2360
|
+
const value = (event.value || '').trim();
|
|
2361
|
+
if (value) {
|
|
2362
|
+
if (this.metadata.minLength && value.length < this.metadata.minLength) {
|
|
2363
|
+
return;
|
|
2364
|
+
}
|
|
2365
|
+
if (this.metadata.maxLength && value.length > this.metadata.maxLength) {
|
|
2366
|
+
return;
|
|
2367
|
+
}
|
|
2368
|
+
if (this.metadata.regex && !value.match(this.metadata.regex)) {
|
|
2369
|
+
return;
|
|
2370
|
+
}
|
|
2371
|
+
if (!this.stringChipsArrayValues) {
|
|
2372
|
+
if (this.entity[this.key] == null) {
|
|
2373
|
+
this.entity[this.key] = [];
|
|
2374
|
+
}
|
|
2375
|
+
this.stringChipsArrayValues = this.entity[this.key];
|
|
2376
|
+
}
|
|
2377
|
+
this.stringChipsArrayValues.push(value);
|
|
2378
|
+
}
|
|
2379
|
+
(_a = event.chipInput) === null || _a === void 0 ? void 0 : _a.clear();
|
|
2380
|
+
}
|
|
2381
|
+
/**
|
|
2382
|
+
* Removes the given value from the array.
|
|
2383
|
+
* Sets the array to undefined if it is now empty.
|
|
2384
|
+
* This is needed because two things are validated: The array itself
|
|
2385
|
+
* and the contents of the array. And we need a way to display an
|
|
2386
|
+
* mat-error. As the only validation for the array is whether or not
|
|
2387
|
+
* it is empty, setting it to undefined here enables us to use the "required" validator.
|
|
2388
|
+
*
|
|
2389
|
+
* @param value - The string to remove from the array.
|
|
2390
|
+
*/
|
|
2391
|
+
removeStringChipArrayValue(value) {
|
|
2392
|
+
var _a, _b;
|
|
2393
|
+
(_a = this.stringChipsArrayValues) === null || _a === void 0 ? void 0 : _a.splice(this.stringChipsArrayValues.indexOf(value), 1);
|
|
2394
|
+
if (!((_b = this.stringChipsArrayValues) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
2395
|
+
this.entity[this.key] = undefined;
|
|
2396
|
+
this.stringChipsArrayValues = this.entity[this.key];
|
|
2397
|
+
}
|
|
2398
|
+
}
|
|
2399
|
+
/**
|
|
2400
|
+
* Handles adding a string to the array when an autocomplete value has been selected.
|
|
2401
|
+
*
|
|
2402
|
+
* @param event - The autocomplete selected event.
|
|
2403
|
+
* @param chipsInput - The element where the user typed the value.
|
|
2404
|
+
*/
|
|
2405
|
+
selected(event, chipsInput) {
|
|
2406
|
+
const value = (event.option.viewValue || '').trim();
|
|
2407
|
+
if (this.metadata.minLength && value.length < this.metadata.minLength) {
|
|
2408
|
+
return;
|
|
2409
|
+
}
|
|
2410
|
+
if (this.metadata.maxLength && value.length > this.metadata.maxLength) {
|
|
2411
|
+
return;
|
|
2412
|
+
}
|
|
2413
|
+
if (this.metadata.regex && !value.match(this.metadata.regex)) {
|
|
2414
|
+
return;
|
|
2415
|
+
}
|
|
2416
|
+
if (!this.stringChipsArrayValues) {
|
|
2417
|
+
if (this.entity[this.key] == null) {
|
|
2418
|
+
this.entity[this.key] = [];
|
|
2419
|
+
}
|
|
2420
|
+
this.stringChipsArrayValues = this.entity[this.key];
|
|
2421
|
+
}
|
|
2422
|
+
this.stringChipsArrayValues.push(value);
|
|
2423
|
+
chipsInput.value = '';
|
|
2424
|
+
}
|
|
2425
|
+
/**
|
|
2426
|
+
* Dynamically filters the Autocomplete options when the user inputs something.
|
|
2427
|
+
*
|
|
2428
|
+
* @param input - The input of the user.
|
|
2429
|
+
*/
|
|
2430
|
+
filterAutocompleteStrings(input) {
|
|
2431
|
+
if (input != null) {
|
|
2432
|
+
const filterValue = input.toLowerCase();
|
|
2433
|
+
this.filteredAutocompleteStrings = this.metadata.autocompleteValues.filter(s => s.toLowerCase().includes(filterValue));
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2436
|
+
emitChange() {
|
|
2437
|
+
this.inputChangeEvent.emit();
|
|
2438
|
+
}
|
|
2439
|
+
}
|
|
2440
|
+
ArrayStringAutocompleteChipsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ArrayStringAutocompleteChipsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2441
|
+
ArrayStringAutocompleteChipsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: ArrayStringAutocompleteChipsComponent, selector: "array-string-autocomplete-chips", inputs: { entity: "entity", key: "key", getValidationErrorMessage: "getValidationErrorMessage" }, outputs: { inputChangeEvent: "inputChangeEvent" }, ngImport: i0, template: "<mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-chip-list #chipList\n (ngModelChange)=\"emitChange()\"\n [(ngModel)]=\"entity[key]\" [name]=\"key.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=\"{{metadata.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]=\"key.toString()\" #chipsModel=\"ngModel\"\n #chipsElement\n [minlength]='metadata.minLength ?? null'\n [maxlength]='metadata.maxLength ?? null'\n [pattern]=\"metadata.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 metadata.autocompleteValues\" [value]=\"value\">\n {{value}}\n </mat-option>\n </mat-autocomplete>\n <mat-error *ngIf=\"!chipsModel.errors\">{{getValidationErrorMessage(model)}}</mat-error>\n</mat-form-field>", 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$3.MatChipList, selector: "mat-chip-list", inputs: ["errorStateMatcher", "multiple", "compareWith", "value", "required", "placeholder", "disabled", "aria-orientation", "selectable", "tabIndex"], outputs: ["change", "valueChange"], exportAs: ["matChipList"] }, { type: i2.MatAutocomplete, selector: "mat-autocomplete", inputs: ["disableRipple"], exportAs: ["matAutocomplete"] }, { type: i3$2.MatOption, selector: "mat-option", exportAs: ["matOption"] }], directives: [{ type: i1$1.MatLabel, selector: "mat-label" }, { type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i3.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i4$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2$3.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: i2$3.MatChipRemove, selector: "[matChipRemove]" }, { type: i4$2.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: i2$3.MatChipInput, selector: "input[matChipInputFor]", inputs: ["matChipInputFor", "matChipInputAddOnBlur", "matChipInputSeparatorKeyCodes", "placeholder", "id", "disabled"], outputs: ["matChipInputTokenEnd"], exportAs: ["matChipInput", "matChipInputFor"] }, { type: i2.MatAutocompleteTrigger, selector: "input[matAutocomplete], textarea[matAutocomplete]", exportAs: ["matAutocompleteTrigger"] }, { type: i3.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: i3.MinLengthValidator, selector: "[minlength][formControlName],[minlength][formControl],[minlength][ngModel]", inputs: ["minlength"] }, { type: i3.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { type: i3.PatternValidator, selector: "[pattern][formControlName],[pattern][formControl],[pattern][ngModel]", inputs: ["pattern"] }, { type: i4$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1$1.MatError, selector: "mat-error", inputs: ["id"] }] });
|
|
2442
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ArrayStringAutocompleteChipsComponent, decorators: [{
|
|
2443
|
+
type: Component,
|
|
2444
|
+
args: [{ selector: 'array-string-autocomplete-chips', template: "<mat-form-field>\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-chip-list #chipList\n (ngModelChange)=\"emitChange()\"\n [(ngModel)]=\"entity[key]\" [name]=\"key.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=\"{{metadata.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]=\"key.toString()\" #chipsModel=\"ngModel\"\n #chipsElement\n [minlength]='metadata.minLength ?? null'\n [maxlength]='metadata.maxLength ?? null'\n [pattern]=\"metadata.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 metadata.autocompleteValues\" [value]=\"value\">\n {{value}}\n </mat-option>\n </mat-autocomplete>\n <mat-error *ngIf=\"!chipsModel.errors\">{{getValidationErrorMessage(model)}}</mat-error>\n</mat-form-field>", styles: ["mat-form-field{width:100%}\n"] }]
|
|
2445
|
+
}], ctorParameters: function () { return []; }, propDecorators: { entity: [{
|
|
2446
|
+
type: Input
|
|
2447
|
+
}], key: [{
|
|
2448
|
+
type: Input
|
|
2449
|
+
}], getValidationErrorMessage: [{
|
|
2450
|
+
type: Input
|
|
2451
|
+
}], inputChangeEvent: [{
|
|
2452
|
+
type: Output
|
|
2453
|
+
}] } });
|
|
2454
|
+
|
|
2455
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
2456
|
+
class DateInputComponent {
|
|
2457
|
+
constructor() {
|
|
2458
|
+
this.DateUtilities = DateUtilities;
|
|
2459
|
+
this.inputChangeEvent = new EventEmitter();
|
|
2460
|
+
this.defaultDateFilter = () => true;
|
|
2461
|
+
}
|
|
2462
|
+
ngOnInit() {
|
|
2463
|
+
this.metadata = EntityUtilities.getPropertyMetadata(this.entity, this.key, DecoratorTypes.DATE);
|
|
2464
|
+
}
|
|
2465
|
+
emitChange() {
|
|
2466
|
+
this.inputChangeEvent.emit();
|
|
2467
|
+
}
|
|
2468
|
+
}
|
|
2469
|
+
DateInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DateInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2470
|
+
DateInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: DateInputComponent, selector: "date-input", inputs: { entity: "entity", key: "key", getValidationErrorMessage: "getValidationErrorMessage" }, outputs: { inputChangeEvent: "inputChangeEvent" }, ngImport: i0, template: "<mat-form-field appearance=\"standard\">\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n (ngModelChange)=\"emitChange()\"\n matInput\n [(ngModel)]=\"entity[key]\"\n [name]=\"key.toString()\"\n #model=\"ngModel\"\n [matDatepicker]=\"picker\"\n [required]=\"metadata.required\"\n [min]=\"metadata.min ? metadata.min(DateUtilities.asDate(entity[key])) : undefined\"\n [max]=\"metadata.max ? metadata.max(DateUtilities.asDate(entity[key])) : undefined\"\n [matDatepickerFilter]=\"metadata.filter ?? defaultDateFilter\"\n >\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-datepicker #picker></mat-datepicker>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n</mat-form-field>", 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: i3$3.MatDatepickerToggle, selector: "mat-datepicker-toggle", inputs: ["for", "tabIndex", "aria-label", "disabled", "disableRipple"], exportAs: ["matDatepickerToggle"] }, { type: i3$3.MatDatepicker, selector: "mat-datepicker", exportAs: ["matDatepicker"] }], directives: [{ type: i1$1.MatLabel, selector: "mat-label" }, { type: i4$2.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: i3.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: i3$3.MatDatepickerInput, selector: "input[matDatepicker]", inputs: ["matDatepicker", "min", "max", "matDatepickerFilter"], exportAs: ["matDatepickerInput"] }, { type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i3.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i1$1.MatSuffix, selector: "[matSuffix]" }, { type: i1$1.MatError, selector: "mat-error", inputs: ["id"] }] });
|
|
2471
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DateInputComponent, decorators: [{
|
|
2472
|
+
type: Component,
|
|
2473
|
+
args: [{ selector: 'date-input', template: "<mat-form-field appearance=\"standard\">\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n (ngModelChange)=\"emitChange()\"\n matInput\n [(ngModel)]=\"entity[key]\"\n [name]=\"key.toString()\"\n #model=\"ngModel\"\n [matDatepicker]=\"picker\"\n [required]=\"metadata.required\"\n [min]=\"metadata.min ? metadata.min(DateUtilities.asDate(entity[key])) : undefined\"\n [max]=\"metadata.max ? metadata.max(DateUtilities.asDate(entity[key])) : undefined\"\n [matDatepickerFilter]=\"metadata.filter ?? defaultDateFilter\"\n >\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-datepicker #picker></mat-datepicker>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n</mat-form-field>", styles: ["mat-form-field{width:100%}\n"] }]
|
|
2474
|
+
}], ctorParameters: function () { return []; }, propDecorators: { entity: [{
|
|
2475
|
+
type: Input
|
|
2476
|
+
}], key: [{
|
|
2477
|
+
type: Input
|
|
2478
|
+
}], getValidationErrorMessage: [{
|
|
2479
|
+
type: Input
|
|
2480
|
+
}], inputChangeEvent: [{
|
|
2481
|
+
type: Output
|
|
2482
|
+
}] } });
|
|
2483
|
+
|
|
2484
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
2485
|
+
const EMPTY_DATERANGE = {
|
|
2486
|
+
start: undefined,
|
|
2487
|
+
end: undefined,
|
|
2488
|
+
values: undefined
|
|
2489
|
+
};
|
|
2490
|
+
class DateRangeInputComponent {
|
|
2491
|
+
constructor() {
|
|
2492
|
+
this.inputChangeEvent = new EventEmitter();
|
|
2493
|
+
this.defaultDateFilter = () => true;
|
|
2494
|
+
}
|
|
2495
|
+
ngOnInit() {
|
|
2496
|
+
var _a;
|
|
2497
|
+
this.metadata = EntityUtilities.getPropertyMetadata(this.entity, this.key, DecoratorTypes.DATE_RANGE);
|
|
2498
|
+
this.dateRange = (_a = LodashUtilities.cloneDeep(this.entity[this.key])) !== null && _a !== void 0 ? _a : EMPTY_DATERANGE;
|
|
2499
|
+
this.dateRangeStart = new Date(this.dateRange.start);
|
|
2500
|
+
this.dateRangeEnd = new Date(this.dateRange.end);
|
|
2501
|
+
this.setDateRangeValues();
|
|
2502
|
+
}
|
|
2503
|
+
/**
|
|
2504
|
+
* Updates the date range values based on the start and end date.
|
|
2505
|
+
*/
|
|
2506
|
+
setDateRangeValues() {
|
|
2507
|
+
if (this.dateRangeStart && this.dateRangeEnd) {
|
|
2508
|
+
this.dateRange.start = new Date(this.dateRangeStart);
|
|
2509
|
+
this.dateRange.end = new Date(this.dateRangeEnd);
|
|
2510
|
+
const values = DateUtilities.getDatesBetween(new Date(this.dateRange.start), new Date(this.dateRange.end), this.metadata.filter);
|
|
2511
|
+
this.dateRange.values = values.length ? values : undefined;
|
|
2512
|
+
}
|
|
2513
|
+
else {
|
|
2514
|
+
this.dateRange.values = undefined;
|
|
2515
|
+
}
|
|
2516
|
+
this.entity[this.key] = this.dateRange;
|
|
2517
|
+
this.emitChange();
|
|
2518
|
+
}
|
|
2519
|
+
emitChange() {
|
|
2520
|
+
this.inputChangeEvent.emit();
|
|
2521
|
+
}
|
|
2522
|
+
}
|
|
2523
|
+
DateRangeInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DateRangeInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2524
|
+
DateRangeInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: DateRangeInputComponent, selector: "date-range-input", inputs: { entity: "entity", key: "key", getValidationErrorMessage: "getValidationErrorMessage" }, outputs: { inputChangeEvent: "inputChangeEvent" }, ngImport: i0, template: "<mat-form-field appearance=\"standard\">\n <mat-label>{{metadata.displayName}}</mat-label>\n \n <mat-date-range-input [rangePicker]=\"picker\" [required]=\"metadata.required\" [dateFilter]=\"metadata.filter ?? defaultDateFilter\">\n <input matStartDate\n [(ngModel)]=\"dateRangeStart\"\n [name]=\"key.toString() + 'start'\"\n #startModel=\"ngModel\"\n [required]=\"metadata.required\"\n [min]=\"metadata.minStart ? metadata.minStart(dateRange.start) : undefined\"\n [max]=\"metadata.maxStart ? metadata.maxStart(dateRange.start) : undefined\"\n [placeholder]=\"metadata.placeholderStart\"\n (ngModelChange)=\"setDateRangeValues()\"\n >\n <input matEndDate\n [(ngModel)]=\"dateRangeEnd\"\n [name]=\"key.toString() + 'end'\"\n #endModel=\"ngModel\"\n [required]=\"metadata.required\"\n [min]=\"metadata.minEnd ? metadata.minEnd(dateRange.end) : undefined\"\n [max]=\"metadata.maxEnd ? metadata.maxEnd(dateRange.end) : undefined\"\n [placeholder]=\"metadata.placeholderEnd\"\n (ngModelChange)=\"setDateRangeValues()\"\n >\n </mat-date-range-input>\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-date-range-picker #picker></mat-date-range-picker>\n\n <mat-error *ngIf=\"startModel.errors\">{{getValidationErrorMessage(startModel)}}</mat-error>\n <mat-error *ngIf=\"!startModel.errors && endModel.errors\">{{getValidationErrorMessage(endModel)}}</mat-error>\n</mat-form-field>", 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: i3$3.MatDateRangeInput, selector: "mat-date-range-input", inputs: ["rangePicker", "required", "dateFilter", "min", "max", "disabled", "separator", "comparisonStart", "comparisonEnd"], exportAs: ["matDateRangeInput"] }, { type: i3$3.MatDatepickerToggle, selector: "mat-datepicker-toggle", inputs: ["for", "tabIndex", "aria-label", "disabled", "disableRipple"], exportAs: ["matDatepickerToggle"] }, { type: i3$3.MatDateRangePicker, selector: "mat-date-range-picker", exportAs: ["matDateRangePicker"] }], directives: [{ type: i1$1.MatLabel, selector: "mat-label" }, { type: i3$3.MatStartDate, selector: "input[matStartDate]", inputs: ["errorStateMatcher"], outputs: ["dateChange", "dateInput"] }, { type: i3.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: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i3.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i3$3.MatEndDate, selector: "input[matEndDate]", inputs: ["errorStateMatcher"], outputs: ["dateChange", "dateInput"] }, { type: i1$1.MatSuffix, selector: "[matSuffix]" }, { type: i4$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1$1.MatError, selector: "mat-error", inputs: ["id"] }] });
|
|
2525
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DateRangeInputComponent, decorators: [{
|
|
2526
|
+
type: Component,
|
|
2527
|
+
args: [{ selector: 'date-range-input', template: "<mat-form-field appearance=\"standard\">\n <mat-label>{{metadata.displayName}}</mat-label>\n \n <mat-date-range-input [rangePicker]=\"picker\" [required]=\"metadata.required\" [dateFilter]=\"metadata.filter ?? defaultDateFilter\">\n <input matStartDate\n [(ngModel)]=\"dateRangeStart\"\n [name]=\"key.toString() + 'start'\"\n #startModel=\"ngModel\"\n [required]=\"metadata.required\"\n [min]=\"metadata.minStart ? metadata.minStart(dateRange.start) : undefined\"\n [max]=\"metadata.maxStart ? metadata.maxStart(dateRange.start) : undefined\"\n [placeholder]=\"metadata.placeholderStart\"\n (ngModelChange)=\"setDateRangeValues()\"\n >\n <input matEndDate\n [(ngModel)]=\"dateRangeEnd\"\n [name]=\"key.toString() + 'end'\"\n #endModel=\"ngModel\"\n [required]=\"metadata.required\"\n [min]=\"metadata.minEnd ? metadata.minEnd(dateRange.end) : undefined\"\n [max]=\"metadata.maxEnd ? metadata.maxEnd(dateRange.end) : undefined\"\n [placeholder]=\"metadata.placeholderEnd\"\n (ngModelChange)=\"setDateRangeValues()\"\n >\n </mat-date-range-input>\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-date-range-picker #picker></mat-date-range-picker>\n\n <mat-error *ngIf=\"startModel.errors\">{{getValidationErrorMessage(startModel)}}</mat-error>\n <mat-error *ngIf=\"!startModel.errors && endModel.errors\">{{getValidationErrorMessage(endModel)}}</mat-error>\n</mat-form-field>", styles: ["mat-form-field{width:100%}\n"] }]
|
|
2528
|
+
}], ctorParameters: function () { return []; }, propDecorators: { entity: [{
|
|
2529
|
+
type: Input
|
|
2530
|
+
}], key: [{
|
|
2531
|
+
type: Input
|
|
2532
|
+
}], getValidationErrorMessage: [{
|
|
2533
|
+
type: Input
|
|
2534
|
+
}], inputChangeEvent: [{
|
|
2535
|
+
type: Output
|
|
2536
|
+
}] } });
|
|
2537
|
+
|
|
2538
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
2539
|
+
class DateTimeInputComponent {
|
|
2540
|
+
constructor() {
|
|
2541
|
+
this.DateUtilities = DateUtilities;
|
|
2542
|
+
this.inputChangeEvent = new EventEmitter();
|
|
2543
|
+
this.defaultDateFilter = () => true;
|
|
2544
|
+
}
|
|
2545
|
+
ngOnInit() {
|
|
2546
|
+
this.metadata = EntityUtilities.getPropertyMetadata(this.entity, this.key, DecoratorTypes.DATE_TIME);
|
|
2547
|
+
this.time = DateUtilities.getTimeFromDate(this.entity[this.key]);
|
|
2548
|
+
this.timeDropdownValues = this.metadata.times;
|
|
2549
|
+
if (this.entity[this.key] != null) {
|
|
2550
|
+
this.dateTime = new Date(this.entity[this.key]);
|
|
2551
|
+
}
|
|
2552
|
+
}
|
|
2553
|
+
/**
|
|
2554
|
+
* Checks if two times are equal. Is needed for the dropdown.
|
|
2555
|
+
*
|
|
2556
|
+
* @param time1 - The first time to compare.
|
|
2557
|
+
* @param time2 - The second time to compare.
|
|
2558
|
+
* @returns Whether or not the time objects are the same.
|
|
2559
|
+
*/
|
|
2560
|
+
compareTimes(time1, time2) {
|
|
2561
|
+
return time1.hours === time2.hours && time1.minutes === time2.minutes;
|
|
2562
|
+
}
|
|
2563
|
+
/**
|
|
2564
|
+
* Sets the time on a datetime property.
|
|
2565
|
+
*/
|
|
2566
|
+
setTime() {
|
|
2567
|
+
var _a, _b;
|
|
2568
|
+
if (!this.dateTime) {
|
|
2569
|
+
this.entity[this.key] = undefined;
|
|
2570
|
+
this.emitChange();
|
|
2571
|
+
return;
|
|
2572
|
+
}
|
|
2573
|
+
this.entity[this.key] = new Date(this.dateTime);
|
|
2574
|
+
if (((_a = this.time) === null || _a === void 0 ? void 0 : _a.hours) != null && ((_b = this.time) === null || _b === void 0 ? void 0 : _b.minutes) != null) {
|
|
2575
|
+
this.entity[this.key].setHours(this.time.hours, this.time.minutes, 0, 0);
|
|
2576
|
+
}
|
|
2577
|
+
else {
|
|
2578
|
+
this.entity[this.key].setHours(0, 0, 0, 0);
|
|
2579
|
+
}
|
|
2580
|
+
this.emitChange();
|
|
2581
|
+
}
|
|
2582
|
+
emitChange() {
|
|
2583
|
+
this.inputChangeEvent.emit();
|
|
2584
|
+
}
|
|
2585
|
+
}
|
|
2586
|
+
DateTimeInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DateTimeInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2587
|
+
DateTimeInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: DateTimeInputComponent, selector: "date-time-input", inputs: { entity: "entity", key: "key", getValidationErrorMessage: "getValidationErrorMessage" }, outputs: { inputChangeEvent: "inputChangeEvent" }, ngImport: i0, template: "<div class=\"date-time\">\n <mat-form-field appearance=\"standard\">\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n [(ngModel)]=\"dateTime\"\n [name]=\"key.toString()\"\n #model=\"ngModel\"\n [matDatepicker]=\"picker\"\n [required]=\"metadata.required\"\n [min]=\"metadata.minDate ? metadata.minDate(dateTime) : undefined\"\n [max]=\"metadata.maxDate ? metadata.maxDate(dateTime) : undefined\"\n [matDatepickerFilter]=\"metadata.filterDate ?? defaultDateFilter\"\n (dateInput)=\"setTime()\"\n >\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-datepicker #picker></mat-datepicker>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n <mat-form-field class=\"timepicker\">\n <mat-label>{{metadata.timeDisplayName}}</mat-label>\n <mat-select\n [(ngModel)]=\"time\"\n [name]=\"key.toString() + 'time'\"\n #timeModel=\"ngModel\"\n [required]=\"metadata.required\"\n [compareWith]=\"compareTimes\"\n (ngModelChange)=\"setTime()\"\n >\n <mat-option *ngFor=\"let validTime of DateUtilities.getValidTimesForDropdown(\n DateUtilities.asDate(entity[key]),\n metadata.times,\n metadata.minTime,\n metadata.maxTime,\n metadata.filterTime\n )\"\n [value]=\"validTime.value\"\n >\n {{validTime.displayName}}\n </mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(timeModel)}}</mat-error>\n </mat-form-field>\n</div>", styles: ["mat-form-field{width:100%}.date-time{display:flex;align-items:baseline}.date-time .timepicker{margin-left:10px}\n"], components: [{ type: i1$1.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i3$3.MatDatepickerToggle, selector: "mat-datepicker-toggle", inputs: ["for", "tabIndex", "aria-label", "disabled", "disableRipple"], exportAs: ["matDatepickerToggle"] }, { type: i3$3.MatDatepicker, selector: "mat-datepicker", exportAs: ["matDatepicker"] }, { type: i2$1.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { type: i3$2.MatOption, selector: "mat-option", exportAs: ["matOption"] }], directives: [{ type: i1$1.MatLabel, selector: "mat-label" }, { type: i4$2.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: i3.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: i3$3.MatDatepickerInput, selector: "input[matDatepicker]", inputs: ["matDatepicker", "min", "max", "matDatepickerFilter"], exportAs: ["matDatepickerInput"] }, { type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i3.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i1$1.MatSuffix, selector: "[matSuffix]" }, { type: i1$1.MatError, selector: "mat-error", inputs: ["id"] }, { type: i4$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
|
|
2588
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DateTimeInputComponent, decorators: [{
|
|
2589
|
+
type: Component,
|
|
2590
|
+
args: [{ selector: 'date-time-input', template: "<div class=\"date-time\">\n <mat-form-field appearance=\"standard\">\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n [(ngModel)]=\"dateTime\"\n [name]=\"key.toString()\"\n #model=\"ngModel\"\n [matDatepicker]=\"picker\"\n [required]=\"metadata.required\"\n [min]=\"metadata.minDate ? metadata.minDate(dateTime) : undefined\"\n [max]=\"metadata.maxDate ? metadata.maxDate(dateTime) : undefined\"\n [matDatepickerFilter]=\"metadata.filterDate ?? defaultDateFilter\"\n (dateInput)=\"setTime()\"\n >\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-datepicker #picker></mat-datepicker>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n <mat-form-field class=\"timepicker\">\n <mat-label>{{metadata.timeDisplayName}}</mat-label>\n <mat-select\n [(ngModel)]=\"time\"\n [name]=\"key.toString() + 'time'\"\n #timeModel=\"ngModel\"\n [required]=\"metadata.required\"\n [compareWith]=\"compareTimes\"\n (ngModelChange)=\"setTime()\"\n >\n <mat-option *ngFor=\"let validTime of DateUtilities.getValidTimesForDropdown(\n DateUtilities.asDate(entity[key]),\n metadata.times,\n metadata.minTime,\n metadata.maxTime,\n metadata.filterTime\n )\"\n [value]=\"validTime.value\"\n >\n {{validTime.displayName}}\n </mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(timeModel)}}</mat-error>\n </mat-form-field>\n</div>", styles: ["mat-form-field{width:100%}.date-time{display:flex;align-items:baseline}.date-time .timepicker{margin-left:10px}\n"] }]
|
|
2591
|
+
}], ctorParameters: function () { return []; }, propDecorators: { entity: [{
|
|
2592
|
+
type: Input
|
|
2593
|
+
}], key: [{
|
|
2594
|
+
type: Input
|
|
2595
|
+
}], getValidationErrorMessage: [{
|
|
2596
|
+
type: Input
|
|
2597
|
+
}], inputChangeEvent: [{
|
|
2598
|
+
type: Output
|
|
2599
|
+
}] } });
|
|
2600
|
+
|
|
2601
|
+
/**
|
|
2602
|
+
* Adds drag and drop functionality to an element.
|
|
2603
|
+
*/
|
|
2604
|
+
class DragDropDirective {
|
|
2605
|
+
constructor() {
|
|
2606
|
+
/**
|
|
2607
|
+
* Emits the dropped files to the parent.
|
|
2608
|
+
*/
|
|
2609
|
+
this.files = new EventEmitter();
|
|
2610
|
+
}
|
|
2611
|
+
/**
|
|
2612
|
+
* Prevents the event default.
|
|
2613
|
+
*
|
|
2614
|
+
* @param evt - The Event when dragged files hover over the parent.
|
|
2615
|
+
*/
|
|
2616
|
+
onDragOver(evt) {
|
|
2617
|
+
evt.preventDefault();
|
|
2618
|
+
evt.stopPropagation();
|
|
2619
|
+
}
|
|
2620
|
+
/**
|
|
2621
|
+
* Prevents the event default.
|
|
2622
|
+
*
|
|
2623
|
+
* @param evt - The Event when dragged files leave the parent.
|
|
2624
|
+
*/
|
|
2625
|
+
onDragLeave(evt) {
|
|
2626
|
+
evt.preventDefault();
|
|
2627
|
+
evt.stopPropagation();
|
|
2628
|
+
}
|
|
2629
|
+
/**
|
|
2630
|
+
* Prevents the event default and emits the dropped files with the output.
|
|
2631
|
+
*
|
|
2632
|
+
* @param evt - The Event when files are dropped.
|
|
2633
|
+
*/
|
|
2634
|
+
onDrop(evt) {
|
|
2635
|
+
evt.preventDefault();
|
|
2636
|
+
evt.stopPropagation();
|
|
2637
|
+
if (evt.dataTransfer && evt.dataTransfer.files.length > 0) {
|
|
2638
|
+
this.files.emit(Array.from(evt.dataTransfer.files));
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
}
|
|
2642
|
+
DragDropDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DragDropDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2643
|
+
DragDropDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.11", type: DragDropDirective, selector: "[dragDrop]", outputs: { files: "files" }, host: { listeners: { "dragover": "onDragOver($event)", "dragleave": "onDragLeave($event)", "drop": "onDrop($event)" } }, ngImport: i0 });
|
|
2644
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DragDropDirective, decorators: [{
|
|
2645
|
+
type: Directive,
|
|
2646
|
+
args: [{
|
|
2647
|
+
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
2648
|
+
selector: '[dragDrop]'
|
|
2649
|
+
}]
|
|
2650
|
+
}], ctorParameters: function () { return []; }, propDecorators: { files: [{
|
|
2651
|
+
type: Output
|
|
2652
|
+
}], onDragOver: [{
|
|
2653
|
+
type: HostListener,
|
|
2654
|
+
args: ['dragover', ['$event']]
|
|
2655
|
+
}], onDragLeave: [{
|
|
2656
|
+
type: HostListener,
|
|
2657
|
+
args: ['dragleave', ['$event']]
|
|
2658
|
+
}], onDrop: [{
|
|
2659
|
+
type: HostListener,
|
|
2660
|
+
args: ['drop', ['$event']]
|
|
2661
|
+
}] } });
|
|
2662
|
+
|
|
2663
|
+
class FileInputComponent {
|
|
2664
|
+
constructor(dialog) {
|
|
2665
|
+
this.dialog = dialog;
|
|
2666
|
+
this.FileUtilities = FileUtilities;
|
|
2667
|
+
this.fileDataChangeEvent = new EventEmitter();
|
|
2668
|
+
}
|
|
2669
|
+
ngOnInit() {
|
|
2670
|
+
var _a;
|
|
2671
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2672
|
+
this.metadata = EntityUtilities.getPropertyMetadata(this.entity, this.key, DecoratorTypes.FILE_DEFAULT);
|
|
2673
|
+
if (this.metadata.multiple) {
|
|
2674
|
+
this.initMultiFile();
|
|
2675
|
+
}
|
|
2676
|
+
else {
|
|
2677
|
+
this.initSingleFile();
|
|
2678
|
+
}
|
|
2679
|
+
this.fileDataChangeEvent.emit((_a = this.singleFileData) !== null && _a !== void 0 ? _a : this.multiFileData);
|
|
2680
|
+
});
|
|
2681
|
+
}
|
|
2682
|
+
initMultiFile() {
|
|
2683
|
+
this.multiFileData = this.entity[this.key];
|
|
2684
|
+
if (this.multiFileData) {
|
|
2685
|
+
this.filenames = this.multiFileData.map(f => f.name);
|
|
2686
|
+
}
|
|
2687
|
+
}
|
|
2688
|
+
initSingleFile() {
|
|
2689
|
+
this.singleFileData = this.entity[this.key];
|
|
2690
|
+
if (this.singleFileData) {
|
|
2691
|
+
this.filenames = LodashUtilities.cloneDeep([this.singleFileData.name]);
|
|
2692
|
+
}
|
|
2693
|
+
}
|
|
2694
|
+
setFileFromInput(event) {
|
|
2695
|
+
var _a;
|
|
2696
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2697
|
+
const files = (_a = event.target.files) !== null && _a !== void 0 ? _a : [];
|
|
2698
|
+
yield this.setFile(Array.from(files));
|
|
2699
|
+
});
|
|
2700
|
+
}
|
|
2701
|
+
setFile(files) {
|
|
2702
|
+
var _a;
|
|
2703
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2704
|
+
// validation done inline
|
|
2705
|
+
if (files.find(f => !FileUtilities.isMimeTypeValid(f.type, this.metadata.allowedMimeTypes))) {
|
|
2706
|
+
this.dialog.open(NgxMatEntityConfirmDialogComponent, {
|
|
2707
|
+
data: this.metadata.mimeTypeErrorDialog,
|
|
2708
|
+
autoFocus: false,
|
|
2709
|
+
restoreFocus: false
|
|
2710
|
+
});
|
|
2711
|
+
this.resetFileInputs();
|
|
2712
|
+
return;
|
|
2713
|
+
}
|
|
2714
|
+
if (files.find(f => f.size > (this.metadata.maxSize * 1000000))) {
|
|
2715
|
+
this.dialog.open(NgxMatEntityConfirmDialogComponent, {
|
|
2716
|
+
data: this.metadata.maxSizeErrorDialog,
|
|
2717
|
+
autoFocus: false,
|
|
2718
|
+
restoreFocus: false
|
|
2719
|
+
});
|
|
2720
|
+
this.resetFileInputs();
|
|
2721
|
+
return;
|
|
2722
|
+
}
|
|
2723
|
+
let fileSizeTotal = 0;
|
|
2724
|
+
for (const file of files) {
|
|
2725
|
+
fileSizeTotal += file.size;
|
|
2726
|
+
}
|
|
2727
|
+
if (fileSizeTotal > (this.metadata.maxSizeTotal * 1000000)) {
|
|
2728
|
+
this.dialog.open(NgxMatEntityConfirmDialogComponent, {
|
|
2729
|
+
data: this.metadata.maxSizeTotalErrorDialog,
|
|
2730
|
+
autoFocus: false,
|
|
2731
|
+
restoreFocus: false
|
|
2732
|
+
});
|
|
2733
|
+
this.resetFileInputs();
|
|
2734
|
+
return;
|
|
2735
|
+
}
|
|
2736
|
+
if (this.metadata.multiple) {
|
|
2737
|
+
yield this.setMultiFile(Array.from(files));
|
|
2738
|
+
}
|
|
2739
|
+
else {
|
|
2740
|
+
yield this.setSingleFile(files[0]);
|
|
2741
|
+
}
|
|
2742
|
+
this.fileDataChangeEvent.emit((_a = this.singleFileData) !== null && _a !== void 0 ? _a : this.multiFileData);
|
|
2743
|
+
});
|
|
2744
|
+
}
|
|
2745
|
+
resetFileInputs() {
|
|
2746
|
+
this.filenames = undefined;
|
|
2747
|
+
this.singleFileData = undefined;
|
|
2748
|
+
this.multiFileData = undefined;
|
|
2749
|
+
this.fileDataChangeEvent.emit();
|
|
2750
|
+
}
|
|
2751
|
+
setMultiFile(files) {
|
|
2752
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2753
|
+
const data = [];
|
|
2754
|
+
for (const file of files) {
|
|
2755
|
+
const fileData = {
|
|
2756
|
+
file: file,
|
|
2757
|
+
name: file.name,
|
|
2758
|
+
type: file.type,
|
|
2759
|
+
size: file.size
|
|
2760
|
+
};
|
|
2761
|
+
data.push(fileData);
|
|
2762
|
+
}
|
|
2763
|
+
this.multiFileData = LodashUtilities.cloneDeep(data);
|
|
2764
|
+
this.filenames = this.multiFileData.map(f => f.name);
|
|
2765
|
+
});
|
|
2766
|
+
}
|
|
2767
|
+
setSingleFile(file) {
|
|
2768
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2769
|
+
this.singleFileData = {
|
|
2770
|
+
file: file,
|
|
2771
|
+
name: file.name,
|
|
2772
|
+
type: file.type,
|
|
2773
|
+
size: file.size
|
|
2774
|
+
};
|
|
2775
|
+
this.filenames = LodashUtilities.cloneDeep([this.singleFileData.name]);
|
|
2776
|
+
});
|
|
2777
|
+
}
|
|
2778
|
+
removeFile(name) {
|
|
2779
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2780
|
+
if (this.metadata.multiple) {
|
|
2781
|
+
(_a = this.filenames) === null || _a === void 0 ? void 0 : _a.splice(this.filenames.indexOf(name), 1);
|
|
2782
|
+
if (!((_b = this.filenames) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
2783
|
+
this.filenames = undefined;
|
|
2784
|
+
}
|
|
2785
|
+
const fileDataToRemove = (_c = this.multiFileData) === null || _c === void 0 ? void 0 : _c.find(f => f.name === name);
|
|
2786
|
+
(_d = this.multiFileData) === null || _d === void 0 ? void 0 : _d.splice(this.multiFileData.indexOf(fileDataToRemove), 1);
|
|
2787
|
+
if (!((_e = this.multiFileData) === null || _e === void 0 ? void 0 : _e.length)) {
|
|
2788
|
+
this.multiFileData = undefined;
|
|
2789
|
+
}
|
|
2790
|
+
}
|
|
2791
|
+
else {
|
|
2792
|
+
this.filenames = undefined;
|
|
2793
|
+
this.singleFileData = undefined;
|
|
2794
|
+
}
|
|
2795
|
+
this.fileDataChangeEvent.emit((_f = this.singleFileData) !== null && _f !== void 0 ? _f : this.multiFileData);
|
|
2796
|
+
}
|
|
2797
|
+
}
|
|
2798
|
+
FileInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: FileInputComponent, deps: [{ token: i1.MatDialog }], target: i0.ɵɵFactoryTarget.Component });
|
|
2799
|
+
FileInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: FileInputComponent, selector: "file-input", inputs: { entity: "entity", key: "key", getValidationErrorMessage: "getValidationErrorMessage" }, outputs: { fileDataChangeEvent: "fileDataChangeEvent" }, ngImport: i0, template: "<input #fileInput\n type=\"file\" hidden\n [multiple]=\"metadata.multiple\"\n [accept]=\"FileUtilities.getAcceptString(metadata.allowedMimeTypes)\"\n (change)=\"setFileFromInput($event)\"\n>\n\n<mat-form-field floatLabel=\"always\" (click)=\"fileInput.click()\">\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-chip-list #chipList\n [(ngModel)]=\"filenames\"\n [name]=\"key.toString()\"\n #model=\"ngModel\"\n [required]=\"metadata.required\"\n >\n <mat-chip *ngFor=\"let name of filenames\" (removed)=\"removeFile(name)\">\n {{name}}\n <button matChipRemove>\n <i class=\"{{metadata.deleteIcon}}\"></i>\n </button>\n </mat-chip>\n <input [matChipInputFor]=\"chipList\" [readonly]=\"true\">\n </mat-chip-list>\n <button mat-icon-button matSuffix>\n <i class=\"fas fa-upload\"></i>\n </button>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n</mat-form-field>\n\n<div *ngIf=\"metadata.dragAndDrop\" class=\"dropdown\" dragDrop (files)=\"setFile($event)\">\n <i class=\"fas fa-file-arrow-up\"></i>\n</div>", styles: ["mat-form-field{width:100%}input:hover,mat-form-field:hover{cursor:pointer}i{color:#757575}.dropdown{display:flex;align-items:center;justify-content:center;height:200px;border:2px dashed #757575;border-radius:15px;margin-top:5px;margin-bottom:5px}.dropdown i{font-size:30px}\n"], components: [{ type: i1$1.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i2$3.MatChipList, selector: "mat-chip-list", inputs: ["errorStateMatcher", "multiple", "compareWith", "value", "required", "placeholder", "disabled", "aria-orientation", "selectable", "tabIndex"], outputs: ["change", "valueChange"], exportAs: ["matChipList"] }, { type: i4.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$1.MatLabel, selector: "mat-label" }, { type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i3.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i4$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2$3.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: i2$3.MatChipRemove, selector: "[matChipRemove]" }, { type: i2$3.MatChipInput, selector: "input[matChipInputFor]", inputs: ["matChipInputFor", "matChipInputAddOnBlur", "matChipInputSeparatorKeyCodes", "placeholder", "id", "disabled"], outputs: ["matChipInputTokenEnd"], exportAs: ["matChipInput", "matChipInputFor"] }, { type: i1$1.MatSuffix, selector: "[matSuffix]" }, { type: i1$1.MatError, selector: "mat-error", inputs: ["id"] }, { type: i4$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: DragDropDirective, selector: "[dragDrop]", outputs: ["files"] }] });
|
|
2800
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: FileInputComponent, decorators: [{
|
|
2801
|
+
type: Component,
|
|
2802
|
+
args: [{ selector: 'file-input', template: "<input #fileInput\n type=\"file\" hidden\n [multiple]=\"metadata.multiple\"\n [accept]=\"FileUtilities.getAcceptString(metadata.allowedMimeTypes)\"\n (change)=\"setFileFromInput($event)\"\n>\n\n<mat-form-field floatLabel=\"always\" (click)=\"fileInput.click()\">\n <mat-label>{{metadata.displayName}}</mat-label>\n <mat-chip-list #chipList\n [(ngModel)]=\"filenames\"\n [name]=\"key.toString()\"\n #model=\"ngModel\"\n [required]=\"metadata.required\"\n >\n <mat-chip *ngFor=\"let name of filenames\" (removed)=\"removeFile(name)\">\n {{name}}\n <button matChipRemove>\n <i class=\"{{metadata.deleteIcon}}\"></i>\n </button>\n </mat-chip>\n <input [matChipInputFor]=\"chipList\" [readonly]=\"true\">\n </mat-chip-list>\n <button mat-icon-button matSuffix>\n <i class=\"fas fa-upload\"></i>\n </button>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n</mat-form-field>\n\n<div *ngIf=\"metadata.dragAndDrop\" class=\"dropdown\" dragDrop (files)=\"setFile($event)\">\n <i class=\"fas fa-file-arrow-up\"></i>\n</div>", styles: ["mat-form-field{width:100%}input:hover,mat-form-field:hover{cursor:pointer}i{color:#757575}.dropdown{display:flex;align-items:center;justify-content:center;height:200px;border:2px dashed #757575;border-radius:15px;margin-top:5px;margin-bottom:5px}.dropdown i{font-size:30px}\n"] }]
|
|
2803
|
+
}], ctorParameters: function () { return [{ type: i1.MatDialog }]; }, propDecorators: { entity: [{
|
|
2804
|
+
type: Input
|
|
2805
|
+
}], key: [{
|
|
2806
|
+
type: Input
|
|
2807
|
+
}], getValidationErrorMessage: [{
|
|
2808
|
+
type: Input
|
|
2809
|
+
}], fileDataChangeEvent: [{
|
|
2810
|
+
type: Output
|
|
2811
|
+
}] } });
|
|
2812
|
+
|
|
2813
|
+
class FileDefaultInputComponent {
|
|
2814
|
+
constructor() {
|
|
2815
|
+
this.FileUtilities = FileUtilities;
|
|
2816
|
+
this.inputChangeEvent = new EventEmitter();
|
|
2817
|
+
}
|
|
2818
|
+
ngOnInit() {
|
|
2819
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2820
|
+
this.metadata = EntityUtilities.getPropertyMetadata(this.entity, this.key, DecoratorTypes.FILE_DEFAULT);
|
|
2821
|
+
});
|
|
2822
|
+
}
|
|
2823
|
+
refreshFileData(fileData) {
|
|
2824
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2825
|
+
this.entity[this.key] = fileData;
|
|
2826
|
+
this.emitChange();
|
|
2827
|
+
});
|
|
2828
|
+
}
|
|
2829
|
+
emitChange() {
|
|
2830
|
+
this.inputChangeEvent.emit();
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2833
|
+
FileDefaultInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: FileDefaultInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2834
|
+
FileDefaultInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: FileDefaultInputComponent, selector: "file-default-input", inputs: { entity: "entity", key: "key", getValidationErrorMessage: "getValidationErrorMessage" }, outputs: { inputChangeEvent: "inputChangeEvent" }, ngImport: i0, template: "<div *ngIf=\"metadata.dragAndDrop\" class=\"file-input mat-elevation-z8\">\n <file-input (fileDataChangeEvent)=\"refreshFileData($event)\" [entity]=\"entity\" [key]=\"key\" [getValidationErrorMessage]=\"getValidationErrorMessage\"></file-input>\n</div>\n\n<div *ngIf=\"!metadata.dragAndDrop\">\n <file-input (fileDataChangeEvent)=\"refreshFileData($event)\" [entity]=\"entity\" [key]=\"key\" [getValidationErrorMessage]=\"getValidationErrorMessage\"></file-input>\n</div>", styles: [".file-input{margin-top:15px;margin-bottom:15px;padding:15px;border-radius:5px}\n"], components: [{ type: FileInputComponent, selector: "file-input", inputs: ["entity", "key", "getValidationErrorMessage"], outputs: ["fileDataChangeEvent"] }], directives: [{ type: i4$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
|
|
2835
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: FileDefaultInputComponent, decorators: [{
|
|
2836
|
+
type: Component,
|
|
2837
|
+
args: [{ selector: 'file-default-input', template: "<div *ngIf=\"metadata.dragAndDrop\" class=\"file-input mat-elevation-z8\">\n <file-input (fileDataChangeEvent)=\"refreshFileData($event)\" [entity]=\"entity\" [key]=\"key\" [getValidationErrorMessage]=\"getValidationErrorMessage\"></file-input>\n</div>\n\n<div *ngIf=\"!metadata.dragAndDrop\">\n <file-input (fileDataChangeEvent)=\"refreshFileData($event)\" [entity]=\"entity\" [key]=\"key\" [getValidationErrorMessage]=\"getValidationErrorMessage\"></file-input>\n</div>", styles: [".file-input{margin-top:15px;margin-bottom:15px;padding:15px;border-radius:5px}\n"] }]
|
|
2838
|
+
}], ctorParameters: function () { return []; }, propDecorators: { entity: [{
|
|
2839
|
+
type: Input
|
|
2840
|
+
}], key: [{
|
|
2841
|
+
type: Input
|
|
2842
|
+
}], getValidationErrorMessage: [{
|
|
2843
|
+
type: Input
|
|
2844
|
+
}], inputChangeEvent: [{
|
|
2845
|
+
type: Output
|
|
2846
|
+
}] } });
|
|
2847
|
+
|
|
2848
|
+
// eslint-disable-next-line max-len
|
|
2849
|
+
const placeholder = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABLAAAAMgCAMAAAAEPmswAAAANlBMVEXx8/XCy9LFztXu8PPs7/Lp7e/W3OHL0tnZ3+PN1NrS2d7i5urn6u7f5OjI0Nfc4ebP1tzk6excnoRZAAAXh0lEQVR42uzUAQ0AAAzDoN+/6eloAiK4B4gQFpAhLCBDWECGsIAMYQEZwgIyhAVkCAvIEBaQISwgQ1hAhrCADGEBGcICMoQFZAgLyBAWkCEsIENYQIawgAxhARnCAjKEBWQIC8gQFpAhLCBDWECGsIAMYQEZwgIyhAVkCAvIEBaQISwgQ1hAhrCADGEBGcICMoQFZAgLyBAWkCEsIENYQIawgAxhARnCAjKEBWQIC8gQFpAhLGDs1AEJAAAAgKD/r9sR6Ag3hAVsCAvYEBawISxgQ1jAhrCADWEBG8ICNoQFbAgL2BAWsCEsYENYwIawgA1hARvCAjaEBWwIC9gQFrAhLGBDWMCGsIANYQEbwgI2hAVsCAvYEBawISxgQ1jAhrCADWEBG8ICNoQFbAgL2BAWsCEsYENYwIawgA1hARvCAjaEBWwIC9gQFrAhLGBDWMCGsIANYQEbwgI2hAVsCAvYEBbETh2QAAAAAAj6/7odgY6QDWEBG8ICNoQFbAgL2BAWsCEsYENYwIawgA1hARvCAjaEBWwIC9gQFrAhLGBDWMCGsIANYQEbwgI2hAVsCAvYEBawISxgQ1jAhrCADWEBG8ICNoQFbAgL2BAWsCEsYENYwIawgA1hARvCAjaEBWwIC9gQFrAhLGBDWMCGsIANYQEbwgI2hAVsCAvYEBawISxgQ1jAhrCADWEBG8ICNoRF7NQBCQAAAICg/6/bEegIYUNYwIawgA1hARvCAjaEBWwIC9gQFrAhLGBDWMCGsIANYQEbwgI2hAVsCAvYEBawISxgQ1jAhrCADWEBG8ICNoQFbAgL2BAWsCEsYENYwIawgA1hARvCAjaEBWwIC9gQFrAhLGBDWMCGsIANYQEbwgI2hAVsCAvYEBawISxgQ1jAhrCADWEBG8ICNoQFbAgL2BAWsCEsYENYwIawgA1hxc6dJtcKAgEURgREwGn/m32Vd1Op/Ih3cO72fIs4BU0rADEIFgAxCBYAMQgWADEIFgAxCBbwm+3bFOKQ8zSV4r13zvky5a4bYgxjYyuch2ABD7ZJMRdnXnIlDyE1FY5HsADbhmFy5lM+x7GvcCSChXtrQufNCnXpQlvhIAQLt2XHONVmE2VIzLaOQLBwT230ZlsuBy6IeyNYuB+bOmd24TpOWrsiWLiZJhazKz8w09oNwcKd9NGbA9SZg9Y+CBZuw4ZijlMiE63tESzcg02TOZqnWVsjWLiDpqvNKXxkI35LBAv6pWJO5APzrM0QLChnozNnm5jBb4RgQbU2m0uoO3YdtkCwoFjy5jp85Ji1GsGCWpfK1X95rLAKwYJS4XK54pi1HsGCSuH8SfucjkWH5QgWFLpwrr6UVGEZggV10rVz9cVxM1yGYEGZthgJ6oHPdhYgWFClv8jeFcOsfRAsKGIHI8rENumHCBb0iLWRhvn7ZwgWtGgvuXj1kidZHyBY0MF2RiqS9T6CBRWCvNsgyVqAYEGBRsYqA8lajWBBPGlvg38rvBi+gWBBuvb6i+3vmdjLeolgQTYdx6tvme33FwgWRBO6yzBr4BvDpwgWJNN0vHqo+Sz6GYIFuRplx6sHx4PhPIIFsaJRigfDWQQLQvXid6+Yvn+OYEGmUfRq+2uMsv5EsCCSvmk7o6x3ECwIpPo6yCLpEwQL8iTl10G2smYRLIij/zrIvXAOwYIwvcrlq1kT74W/ESzIMmr51Plddazwg2BBlGDux7NH+oNgQRK5/0Fm+L4JgvWPvbvRSRiGAjBaBoqK+PP+L2s0xGSj3QiQ9I57zkN86brblvVItn1l8/2cYLEar1mmGWoOFlm/BIu1yLh9ZZE1IVisRNLtK4usEcFiFYbvwtYiS7BYg7zb7WPfFlmCRXj7bNOiFlkNgkV8j373lZ2siwkW4SX/PTi1+9pkJljEluhyhgsdMy+yBIvQDoWpXeLThYJFYMYZ6vJe4SBYxDWkuAv5Gu9Z78kSLMIajF8ZcBgRLOL6MH5l731MsAhrb/zK3vuEYBFV6ttk7L3XCRZBvRUcLpwSLGLSK3PvFYJFSHrls7BGsIhIr3wWVgkWATnu7G9hnWARj175LGwQLMLRK5+FLYJFNHp1jd1+k4NgEYpeXel5k4JgEYleXe24yUCwCESvXDkzR7CIxPzVTbYJxt4FizD0ynzDPMEiDr3yCtgCwSKMr8Ltnh58I0uwiOG1cA/bxz6oI1iE4L4+E1nLBIsY3IdsIusCgkUI3pu4q/fH3XoXLPob9OqXo4VLBIsAvD944tnCBYJFAN53PjFDukCw6O9Q+GPrfYlg0d2x8M+tfrMEi94+CyOm3tsEi65cKDNl6n2OYNGTA89Vpt5bBIuOHCCs8rOwSbDoaW9gtMbPwhbBohsD7k1+FjYIFv0MBkbb/CysESx6MTA6z8nCCsGiEwNYS7xOcU6w6OWlsMB4ww9794LdJgyEUXgwAsfFL/a/2Z4+T2zjWCMgnl/cbwttbxppNNwjWHgLBrByMN5wj2Ct4HztL+OxS621qTuOp/5a06HnItgw+v0uTRUI1qL2/dDao3b8qO+RRDkGGt5haGpAsJZzPbX2XDvUc/I5ExuwsrE4+QbBWsz+I9kr6VLR/XI5Nsq8SVdBsQjWIg6D5Rn5bxYbGpwYyPqPYC3iMFq+4+aTxSeevdg38xfBWsB5MJ+j/s+5Oc5cEDoxQvoPwZrvozW3SwWHCWX4RM67iX9Oh2DNc+isRFL/QVduNBRg6P0XgjVTv/nJYx9eEAYgXSyCNcNu2PpUjBMXhCEo/7AkWKVm78tM8jc2XqxEDkL4mQ7BKnZot35j48QFYRi6z3QIVqlru/kbGx8uCAORLRbBKvSD808nVoxGorrpnWCVuTIV48TKvlhEL30IVoEl1zlt5xyLlX2xaBaLYJU4J153+bCyLx7J5Q0Ey23hw+Ok+NfGiwP3iBSLRbAKDLaksdkCDtwDSnrLuwmWX29mDB57MOEelF6xCJbTGocx9R9jMeEelNxKP4Ll1tlvHGPl4psTgbVixSJYXr39wS+FuVgpE5lYsQiW0661FcgdJTiwUiY2rd8KCZbTyf7ipjAPO9yjk/o/FsHy2dstBt5fYEVDfErFIlg+g63j2FSLidHwhJ5bECyXs33GaMNLfDRVgk6xCJbLyT7jFOsVJkZFyBSLYHnsbD1C5wgOe4MElWIRLI/e7rFn+ws8eRYiUiyC5dHZelJTIZ4869C4KyRYDnu7x2TDF9gxqkWiWATL4WJrOjW14cmzFoViESyHZGtqm8rw5FmNwCsdgpXvbI8YxXqGJ8+C4heLYOXr7RE7G57gAEtS+I1+BCvfyaYwOzqFAyxR0YtFsPIle8Qh1iQOsGQFLxbByrazCQy7T2ICS1fsb+kQrGwHe4rPQN/iCaGy0MUiWNl6m8Kp+yN2YGmL/E1ogpXtYtMYHb3HDixxgYtFsLIN9gRb/G6xxF1e3AtrgpXtaM/w/vkzlrhXYGiCIljZOntAsKbsOMDSF7VYBCtbsrVV8ofBk5waBD1QreTfyPoIVh6e5NQi5kbJOv6NfAtbX9zLmVw8yanHT/buBDt1GIbCsJwRCOP+N/t62vNaphLbSZEs/98O2gOXyJFkk102BFYkAisGIzmeDMEeAitaK09REl5hJMcVg6MXHr4jb8EZVgRGcpyxl1gOviPv0stzrGv4MdLR4Iu5pZIEViQaR+cxkuOOucu/CKxIjObMYiTHIWsXUxBY0TbynPtevUiM5LhkbKEfgRWJ9TIz6GhwytZ6LAIrEgv8ZtDR4JWpZTMEViRWJM/ZCXyytGyGwIrFJRSvsGTUM0OHqwRWLK75eoUdDa7ZGYQmsOLt5CnO3EOgxd05M59NAisWV9W/MgpcszIITWAl6OUeR1ifaHH37xxMILASnOSBz5NNY/8ZGGBkSIfASjDKDZ8/YelY2lcFG0M6BFaKXh4w+UyLeyU6Cw2kBFaKQW75fHOc7CCogYUhHQIrRSN3aHMPtLjXw0CnIIGV5CT3vN8DN4eCsCb6L4YIrCRHuUYTVgi0uFdFvYGUwEpzkP/cPWxnocW9MkPQRGClGuUKPQ1sca/OOSgisJId5BsnWB/2gqqoNpASWMmaVv6ArTW00biXvkLtMaghsNIN8snXUWYeZp6rpNiORWBl2Mva+lAqZp5rtA9aCKxk36s1aWlg5rlWU1BCYOXYyQcKQmae63UKOgisLAcRoQWLgrBiQ1BBYGVpem8z8BkoCKt2DhoIrDzHztmWoXQUhHXT+dwSWJnGtvoDd2ae66ZSGRBYubbVX/ZMQVg5jXYsAivbueyzSyN/Pwo2hbcjsPJt25qfrygIodDcQGAtMHZlj5EuwFZkqBQIBNYSx16W6Ip9P0hBCJ3mBgJrkeYg+S7F9l9REEKpuYHAWmiobx4nBApCKDU3EFhLjb3k6As+vuKaHGhtbiCwlhvayh6vKAihdZEOgbWCZpI0l2L3i36ZBFD59SWwVjFOKXFVdDUYKAih101IYK0iIbKm0uMqNFyTA615WAJrNcdNL3O6TcGtV18oCKH4qpDAWtP21MnvukOxdw/+oCCE5qtCAmtlx2Hq5FE7DQ6erUKgIITqHDSB9Qea7XCaLvu+a7u+30+nYVtwT/stCkKovioksJCAgvAfe3eU6ygMBFG0GhtCSAxh/5udUWby8Z4COGCgI92ziJLLuBuc+6mQwEI+nozi9KlCAgu5KIQ4/VMhgYVMFEKc/6mQwEIeCiEcTBUSWMhDIYSDBaQEFrJQCOFhASmBhRwUQiwLve2LwEIetozCxb8KCSxk4LcT8DGjQ2BhGYUQTmZ0CCwsoxDCyYwOgYVFFEJ4mdEhsLCEQgg3MzoEFpZQCPGJ0XZDYGERhRCfGWwvBBaWUAjh6OKdwMI8CiE+drF9EFhYQCGEp4t3AgtzKIRwdfFOYGEOhRCuLt4JLMy6CvBz8U5gYU5VC/Dz4p3AwpxBgKNVMwQWJlEI4W3VDIGFGRRC+Fo1Q2BhCoUQ7na8E1iYdBHga8c7gYUJFEL4u3gnsDClFeDs4p3AwjsUQrj8uarsCP21a4Z0G+sYQwiSQoixvo9paJvHpTI4RCFEAVcrSrar/tEMY9SCeL+1zaM3OEIhhMPFDbK9VF07Bn2kTs2V45YPFEJ4XNwg20PfpKgJOallONtdgL/FDbLSqi7V2qpOHUetU1AI8eR0cYOsqKq7BRVybzlpHY5CiH+cvh+VlVN1o8oKt4ar+CNRCPHi8/2orJRrCtpDTA/DISiE2EeyUmRFVG3UfgKZdQAKIX7y+H5UVkA/BP1GZn0vCiGeHP74S7bZJek9Mus7NQL+8vh+VLZRlXSckC6GnfUCnhyOQcu2aYOOVTc80CqOQoj33O0flW3RRR0vJN5nlUUhxAR3Y9Cy9aqb8nHM+g59EPDi7hpLtloXdCKOWYVQCDHP1Ri0LJOf49VL3Rm2ohBiga9rLFkeX8er/yLNcBsKIXI4+o2ObAU//38KA7OGJY0CfvM0Bi1bofd00cHTrLUohDja3TaSfe4R5crIC/gVKIR/2Lvb5NRhGArD54RvCC3sf7N3Op07UyhJ7PQHsvU+W4BxIvlIQbkw2/zkMrFH+em/V6MgRKlIbSy50hDzX82RVYeCEMUitbHkOh9hP/60ozAsRkGIGoHaWHKVQ7D21YORI6sCkVGUC9PGkqcFTV9xZP0RBSGqRWljyb+1/J/myKrAllG8w2bwavKEwGnReXdyWXMoCPF2o1eTi719eLDUlYGdOa1kVdCvo9eSH/RwXkmbI0fWSxSEiOHmleRnTcWvpmz3RoWwYRX0afVuLLnI0FyLg1jWMwpCxHH3OnKJocUn8Ej3/QcKQoRy9Cryt/7OK7rvDygIEcvJa8hf+jyvaGX91HpcBZ1Z18aS7W7PK0kjq9+XnAS8wcUryO75vKIutE1BiJD2rifb7ut+8NmGupCCEBEdXE3dn1eSdtSFFISIZze4lvxf10soqQsnDJH3BaF3V9dSivNK2rKR9KWrgPc5u5LcyfzgogsfBPvtJuB96hcmK08/luY7BSGi2bmOMk2YMazT8Rs02vTpKvKks/pzNPr+hdGam2soWXuDhAOfyUEodSM68oRTr//mTxIOvV0Bo2l3V5BfO/R6XvGS1dAnRZDC3uWU8fro02AJFsI4uJhSfkNlx3UhM88Io2JER0nzz+mvC/vK2KFtV5dSigAWL1nMPCOyswspbzwn80tW3z1KNKd4REeJH75j3ulCIu6IZXQZ+dlHnofvJusKhyTv0GjI0UXU20bkOpeUKVIi7ojn5BJKXixsM6ZIOw+toEllIzpKeEGYPUWa7zdGC64uIJob2XrvaS5V0JizlynLBCGb/Ug0ILbN4EXK23BP2ntP1qREQ+5eJPaNfNmmyb2zowFx7b1ENGO/JSkLcxb9aMXBC5S74Z6uLMxa9KMNOy8Qz95MkSx2NCC2q+cpfcM90zh0n3v60ZObZ4nLox/ufZeFQ/aXaMS3EHgXl0d5ysK8t8Box8VzRPo5zW1h6ltgNGPvGSL9nOW2kAYWmjC7zE80sJIsT+ahhEaMniZqhSR7/f6xdy+4iQNBEEDdQYEA4Xf/y+5ukk2AYAkFKXKX3ztEWe6p6THAoouXGjUYYM1j5YyPEn2saszgX2EWK2cMsGhk/KHCwb/CTYtjJfFRopVDjRj8K8yh9m4pMr0c67bBAGsG/QZXCGlmrPA++FcY9ZwyyJr5Hg462tZNA/GDLK960dCmvhNYMxhk2cNBR7cK7wJrBoOs3QANneobgZU/yLKHg6aWdU1gxQ+ynALT1qquCKz0jTMao/T1WlcE1l121ZbGKI291CWBdZ/XrqN3A3daW9UFgZX90KqBO7091wWBFb0jy8Cd7g51TmAld0g13OlvXWcEVnCHVMOdABe3oAVW8Ojdon4S7OqLwModvdtzRoZjfRJYsaN3K2UIcfZTKLBSR+8OCImxrf8EVmjr3QEhQTb1QWBljt4dEJJk8VTvBFbm6N1DSETZ1juBFblwxpsThNnUG4GVuHBGoYE0Hz+FAivwsNCNZ/Js6x+B9VPbmiqP0pNoWX8JrLjDwpVCA4nefgoFVtph4d5KZDKdqkpgPWCxrslRwCLWskpgPWRyNwufrHAn1mJfAivqsFBekexUAivqZqGCO9GWAutRpwkdFtrYR7bFXmDlPGXvSS/SnQRWTL1BXpHPNY6Uu9AuPDMDatEhd6HlFdCl3iCvgC71BnkFdLkLbd4OdKk3yCugS71BXgFd6g367UCTeoP7zsAPHeoe9l8BU7CrX7WyXxRoUm9Yu6gA/GHvDnMThmEwgNZpF9LQUrj/ZfdvmmBMDEabSu8dIkrsz85O4g3VeQW8ZhjjPv+lAk3pa9whzgA0J8ePxBmABs3xZqP2ILCTVe/2LgI7aRYm04NA1+1iFvog3Q503S6ahZ6DwJe2FycnaQbgLY4p/lnVHQS+abj07noFXGl2TsfsIHCrydS76xVwq8lCViquV8D7fRwU24HdyPGa0aQzsJrpFM8bFa+ANfUlnnS+dADrGmo8oZobBLYwLKf4k1NRagc2M9UUD0rZWxDYVj8/cmalOotdAS2Yyhi/OBcpBqAh/WXJY4or6ZwXhxXQpGE6znMpOZdlmY+TVyAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPDJHhwIAAAAAAD5vzaCqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqwBwcCAAAAAED+r42gqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqirswYEAAAAAAJD/ayOoqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkp7cCAAAAAAIMjfepArAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgKcAnTNeiLeG1rEAAAAASUVORK5CYII=';
|
|
2850
|
+
|
|
2851
|
+
class FileImageInputComponent {
|
|
2852
|
+
constructor() {
|
|
2853
|
+
this.FileUtilities = FileUtilities;
|
|
2854
|
+
this.inputChangeEvent = new EventEmitter();
|
|
2855
|
+
this.imageIndex = 0;
|
|
2856
|
+
this.placeHolder = placeholder;
|
|
2857
|
+
}
|
|
2858
|
+
ngOnInit() {
|
|
2859
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2860
|
+
this.metadata = EntityUtilities.getPropertyMetadata(this.entity, this.key, DecoratorTypes.FILE_IMAGE);
|
|
2861
|
+
// setting the image is done inside the refresh method
|
|
2862
|
+
});
|
|
2863
|
+
}
|
|
2864
|
+
setSinglePreviewImage() {
|
|
2865
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2866
|
+
let singleFileData = this.entity[this.key];
|
|
2867
|
+
if (singleFileData) {
|
|
2868
|
+
singleFileData = yield FileUtilities.getFileData(singleFileData);
|
|
2869
|
+
this.singlePreviewImage = yield FileUtilities.getDataURLFromFile(singleFileData.file);
|
|
2870
|
+
}
|
|
2871
|
+
else {
|
|
2872
|
+
this.singlePreviewImage = undefined;
|
|
2873
|
+
}
|
|
2874
|
+
});
|
|
2875
|
+
}
|
|
2876
|
+
setMultiPreviewImages(index) {
|
|
2877
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2878
|
+
const multiFileData = this.entity[this.key];
|
|
2879
|
+
const previewImages = [];
|
|
2880
|
+
if (multiFileData === null || multiFileData === void 0 ? void 0 : multiFileData.length) {
|
|
2881
|
+
for (let i = 0; i < multiFileData.length; i++) {
|
|
2882
|
+
if (i === index) {
|
|
2883
|
+
multiFileData[index] = yield FileUtilities.getFileData(multiFileData[index]);
|
|
2884
|
+
previewImages.push(yield FileUtilities.getDataURLFromFile(multiFileData[index].file));
|
|
2885
|
+
}
|
|
2886
|
+
else {
|
|
2887
|
+
previewImages.push('empty');
|
|
2888
|
+
}
|
|
2889
|
+
}
|
|
2890
|
+
}
|
|
2891
|
+
this.multiPreviewImages = previewImages;
|
|
2892
|
+
});
|
|
2893
|
+
}
|
|
2894
|
+
refreshFileData(fileData) {
|
|
2895
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2896
|
+
this.entity[this.key] = fileData;
|
|
2897
|
+
this.emitChange();
|
|
2898
|
+
if (this.metadata.multiple) {
|
|
2899
|
+
if (!(fileData === null || fileData === void 0 ? void 0 : fileData[this.imageIndex])) {
|
|
2900
|
+
this.imageIndex = 0;
|
|
2901
|
+
}
|
|
2902
|
+
yield this.setMultiPreviewImages(this.imageIndex);
|
|
2903
|
+
}
|
|
2904
|
+
else {
|
|
2905
|
+
yield this.setSinglePreviewImage();
|
|
2906
|
+
}
|
|
2907
|
+
});
|
|
2908
|
+
}
|
|
2909
|
+
prev() {
|
|
2910
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2911
|
+
if (this.imageIndex > 0) {
|
|
2912
|
+
yield this.setMultiPreviewImages(this.imageIndex - 1);
|
|
2913
|
+
this.imageIndex--;
|
|
2914
|
+
}
|
|
2915
|
+
});
|
|
2916
|
+
}
|
|
2917
|
+
next() {
|
|
2918
|
+
var _a;
|
|
2919
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2920
|
+
if (((_a = this.multiPreviewImages) === null || _a === void 0 ? void 0 : _a.length) && this.imageIndex !== (this.multiPreviewImages.length - 1)) {
|
|
2921
|
+
yield this.setMultiPreviewImages(this.imageIndex + 1);
|
|
2922
|
+
this.imageIndex++;
|
|
2923
|
+
}
|
|
2924
|
+
});
|
|
2925
|
+
}
|
|
2926
|
+
setIndex(index) {
|
|
2927
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2928
|
+
yield this.setMultiPreviewImages(index);
|
|
2929
|
+
this.imageIndex = index;
|
|
2930
|
+
});
|
|
2931
|
+
}
|
|
2932
|
+
emitChange() {
|
|
2933
|
+
this.inputChangeEvent.emit();
|
|
2934
|
+
}
|
|
2935
|
+
}
|
|
2936
|
+
FileImageInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: FileImageInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2937
|
+
FileImageInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: FileImageInputComponent, selector: "file-image-input", inputs: { entity: "entity", key: "key", getValidationErrorMessage: "getValidationErrorMessage" }, outputs: { inputChangeEvent: "inputChangeEvent" }, ngImport: i0, template: "<div *ngIf=\"!metadata.dragAndDrop && !metadata.preview\">\n <file-input (fileDataChangeEvent)=\"refreshFileData($event)\" [entity]=\"entity\" [key]=\"key\" [getValidationErrorMessage]=\"getValidationErrorMessage\"></file-input>\n</div>\n\n<div *ngIf=\"metadata.dragAndDrop || metadata.preview\" class=\"file-input mat-elevation-z8\">\n <file-input (fileDataChangeEvent)=\"refreshFileData($event)\" [entity]=\"entity\" [key]=\"key\" [getValidationErrorMessage]=\"getValidationErrorMessage\"></file-input>\n\n <div class=\"image-preview\" *ngIf=\"metadata.preview && metadata.multiple\">\n <i (click)=\"prev()\" [class.disabled]=\"imageIndex === 0\" class=\"prev-button fa-solid fa-angle-left\"></i>\n <img *ngIf=\"multiPreviewImages?.[imageIndex]\" class=\"mat-elevation-z2\" [src]=\"multiPreviewImages?.[imageIndex]\">\n <img *ngIf=\"!multiPreviewImages?.[imageIndex]\" class=\"mat-elevation-z2\" [src]=\"metadata.previewPlaceholderUrl ?? placeHolder\">\n <i (click)=\"next()\" [class.disabled]=\"!multiPreviewImages || !multiPreviewImages.length || imageIndex === (multiPreviewImages.length - 1)\" class=\"next-button fa-solid fa-angle-right\"></i>\n </div>\n <div class=\"preview-nav\" *ngIf=\"metadata.preview && metadata.multiple\">\n <button (click)=\"setIndex(imageIndex-4)\" mat-icon-button *ngIf=\"\n this.multiPreviewImages\n && multiPreviewImages[imageIndex-4]\n && imageIndex === (this.multiPreviewImages.length - 1)\"\n >\n <span class=\"dot\"></span>\n <span class=\"image-index\">{{imageIndex - 3}}</span>\n </button>\n <!-- eslint-disable-next-line @angular-eslint/template/conditional-complexity -->\n <button (click)=\"setIndex(imageIndex-3)\" mat-icon-button *ngIf=\"this.multiPreviewImages\n && multiPreviewImages[imageIndex-3]\n && (\n imageIndex === (this.multiPreviewImages.length - 2)\n || imageIndex === (this.multiPreviewImages.length - 1)\n )\"\n >\n <span class=\"dot\"></span>\n <span class=\"image-index\">{{imageIndex - 2}}</span>\n </button>\n <button (click)=\"setIndex(imageIndex-2)\" mat-icon-button *ngIf=\"multiPreviewImages?.[imageIndex-2]\">\n <span class=\"dot\"></span>\n <span class=\"image-index\">{{imageIndex - 1}}</span>\n </button>\n <button (click)=\"setIndex(imageIndex-1)\" mat-icon-button *ngIf=\"multiPreviewImages?.[imageIndex-1]\">\n <i class=\"dot\"></i>\n <span class=\"image-index\">{{imageIndex}}</span>\n </button>\n <button mat-icon-button disabled>\n <i class=\"dot selected\"></i>\n <span class=\"image-index\">{{imageIndex + 1}}</span>\n </button>\n <button (click)=\"setIndex(imageIndex+1)\" mat-icon-button *ngIf=\"multiPreviewImages?.[imageIndex+1]\">\n <span class=\"dot\"></span>\n <span class=\"image-index\">{{imageIndex + 2}}</span>\n </button>\n <button (click)=\"setIndex(imageIndex+2)\" mat-icon-button *ngIf=\"multiPreviewImages?.[imageIndex+2]\">\n <span class=\"dot\"></span>\n <span class=\"image-index\">{{imageIndex + 3}}</span>\n </button>\n <button (click)=\"setIndex(imageIndex+3)\" mat-icon-button *ngIf=\"multiPreviewImages?.[imageIndex+3] && imageIndex <= 1\">\n <span class=\"dot\"></span>\n <span class=\"image-index\">{{imageIndex + 4}}</span>\n </button>\n <button (click)=\"setIndex(imageIndex+4)\" mat-icon-button *ngIf=\"multiPreviewImages?.[imageIndex+4] && imageIndex === 0\">\n <span class=\"dot\"></span>\n <span class=\"image-index\">{{imageIndex + 5}}</span>\n </button>\n </div>\n\n <div class=\"image-preview\" *ngIf=\"metadata.preview && !metadata.multiple\">\n <i class=\"prev-button disabled fa-solid fa-angle-left\"></i>\n <img class=\"mat-elevation-z2\" [src]=\"singlePreviewImage ?? metadata.previewPlaceholderUrl ?? placeHolder\">\n <i class=\"next-button disabled fa-solid fa-angle-right\"></i>\n </div>\n <div class=\"preview-nav\" *ngIf=\"metadata.preview && !metadata.multiple\">\n <button disabled mat-icon-button>\n <span class=\"dot selected\"></span>\n <span class=\"image-index\">1</span>\n </button>\n </div>\n</div>", styles: [".file-input{margin-top:15px;margin-bottom:15px;padding:15px;border-radius:5px}.image-preview{height:250px;display:flex;align-items:center;padding-top:15px;padding-bottom:15px}.image-preview .prev-button{font-size:100px;margin-left:5px}.image-preview .next-button{font-size:100px;margin-right:5px}.image-preview .prev-button:hover,.image-preview .next-button:hover{cursor:pointer}.image-preview .prev-button.disabled,.image-preview .next-button.disabled{color:#00000061}.image-preview .prev-button.disabled:hover,.image-preview .next-button.disabled:hover{cursor:default}.image-preview img{max-width:calc(100% - 100px);max-height:100%;margin-left:auto;margin-right:auto;border-radius:3px}.preview-nav{text-align:center}.preview-nav button{display:inline-block;width:18px;height:18px;margin-left:5px;margin-right:5px}.preview-nav button .dot{height:100%;width:100%;background-color:#00000061;border-radius:50%;display:block}.preview-nav button .dot.selected{background-color:#000000de}.preview-nav button .image-index{position:absolute;height:100%;width:100%;display:block;top:-11.5px;color:#fff}.preview-nav button:hover{background-color:#000}\n"], components: [{ type: FileInputComponent, selector: "file-input", inputs: ["entity", "key", "getValidationErrorMessage"], outputs: ["fileDataChangeEvent"] }, { type: i4.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: i4$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
|
|
2938
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: FileImageInputComponent, decorators: [{
|
|
2939
|
+
type: Component,
|
|
2940
|
+
args: [{ selector: 'file-image-input', template: "<div *ngIf=\"!metadata.dragAndDrop && !metadata.preview\">\n <file-input (fileDataChangeEvent)=\"refreshFileData($event)\" [entity]=\"entity\" [key]=\"key\" [getValidationErrorMessage]=\"getValidationErrorMessage\"></file-input>\n</div>\n\n<div *ngIf=\"metadata.dragAndDrop || metadata.preview\" class=\"file-input mat-elevation-z8\">\n <file-input (fileDataChangeEvent)=\"refreshFileData($event)\" [entity]=\"entity\" [key]=\"key\" [getValidationErrorMessage]=\"getValidationErrorMessage\"></file-input>\n\n <div class=\"image-preview\" *ngIf=\"metadata.preview && metadata.multiple\">\n <i (click)=\"prev()\" [class.disabled]=\"imageIndex === 0\" class=\"prev-button fa-solid fa-angle-left\"></i>\n <img *ngIf=\"multiPreviewImages?.[imageIndex]\" class=\"mat-elevation-z2\" [src]=\"multiPreviewImages?.[imageIndex]\">\n <img *ngIf=\"!multiPreviewImages?.[imageIndex]\" class=\"mat-elevation-z2\" [src]=\"metadata.previewPlaceholderUrl ?? placeHolder\">\n <i (click)=\"next()\" [class.disabled]=\"!multiPreviewImages || !multiPreviewImages.length || imageIndex === (multiPreviewImages.length - 1)\" class=\"next-button fa-solid fa-angle-right\"></i>\n </div>\n <div class=\"preview-nav\" *ngIf=\"metadata.preview && metadata.multiple\">\n <button (click)=\"setIndex(imageIndex-4)\" mat-icon-button *ngIf=\"\n this.multiPreviewImages\n && multiPreviewImages[imageIndex-4]\n && imageIndex === (this.multiPreviewImages.length - 1)\"\n >\n <span class=\"dot\"></span>\n <span class=\"image-index\">{{imageIndex - 3}}</span>\n </button>\n <!-- eslint-disable-next-line @angular-eslint/template/conditional-complexity -->\n <button (click)=\"setIndex(imageIndex-3)\" mat-icon-button *ngIf=\"this.multiPreviewImages\n && multiPreviewImages[imageIndex-3]\n && (\n imageIndex === (this.multiPreviewImages.length - 2)\n || imageIndex === (this.multiPreviewImages.length - 1)\n )\"\n >\n <span class=\"dot\"></span>\n <span class=\"image-index\">{{imageIndex - 2}}</span>\n </button>\n <button (click)=\"setIndex(imageIndex-2)\" mat-icon-button *ngIf=\"multiPreviewImages?.[imageIndex-2]\">\n <span class=\"dot\"></span>\n <span class=\"image-index\">{{imageIndex - 1}}</span>\n </button>\n <button (click)=\"setIndex(imageIndex-1)\" mat-icon-button *ngIf=\"multiPreviewImages?.[imageIndex-1]\">\n <i class=\"dot\"></i>\n <span class=\"image-index\">{{imageIndex}}</span>\n </button>\n <button mat-icon-button disabled>\n <i class=\"dot selected\"></i>\n <span class=\"image-index\">{{imageIndex + 1}}</span>\n </button>\n <button (click)=\"setIndex(imageIndex+1)\" mat-icon-button *ngIf=\"multiPreviewImages?.[imageIndex+1]\">\n <span class=\"dot\"></span>\n <span class=\"image-index\">{{imageIndex + 2}}</span>\n </button>\n <button (click)=\"setIndex(imageIndex+2)\" mat-icon-button *ngIf=\"multiPreviewImages?.[imageIndex+2]\">\n <span class=\"dot\"></span>\n <span class=\"image-index\">{{imageIndex + 3}}</span>\n </button>\n <button (click)=\"setIndex(imageIndex+3)\" mat-icon-button *ngIf=\"multiPreviewImages?.[imageIndex+3] && imageIndex <= 1\">\n <span class=\"dot\"></span>\n <span class=\"image-index\">{{imageIndex + 4}}</span>\n </button>\n <button (click)=\"setIndex(imageIndex+4)\" mat-icon-button *ngIf=\"multiPreviewImages?.[imageIndex+4] && imageIndex === 0\">\n <span class=\"dot\"></span>\n <span class=\"image-index\">{{imageIndex + 5}}</span>\n </button>\n </div>\n\n <div class=\"image-preview\" *ngIf=\"metadata.preview && !metadata.multiple\">\n <i class=\"prev-button disabled fa-solid fa-angle-left\"></i>\n <img class=\"mat-elevation-z2\" [src]=\"singlePreviewImage ?? metadata.previewPlaceholderUrl ?? placeHolder\">\n <i class=\"next-button disabled fa-solid fa-angle-right\"></i>\n </div>\n <div class=\"preview-nav\" *ngIf=\"metadata.preview && !metadata.multiple\">\n <button disabled mat-icon-button>\n <span class=\"dot selected\"></span>\n <span class=\"image-index\">1</span>\n </button>\n </div>\n</div>", styles: [".file-input{margin-top:15px;margin-bottom:15px;padding:15px;border-radius:5px}.image-preview{height:250px;display:flex;align-items:center;padding-top:15px;padding-bottom:15px}.image-preview .prev-button{font-size:100px;margin-left:5px}.image-preview .next-button{font-size:100px;margin-right:5px}.image-preview .prev-button:hover,.image-preview .next-button:hover{cursor:pointer}.image-preview .prev-button.disabled,.image-preview .next-button.disabled{color:#00000061}.image-preview .prev-button.disabled:hover,.image-preview .next-button.disabled:hover{cursor:default}.image-preview img{max-width:calc(100% - 100px);max-height:100%;margin-left:auto;margin-right:auto;border-radius:3px}.preview-nav{text-align:center}.preview-nav button{display:inline-block;width:18px;height:18px;margin-left:5px;margin-right:5px}.preview-nav button .dot{height:100%;width:100%;background-color:#00000061;border-radius:50%;display:block}.preview-nav button .dot.selected{background-color:#000000de}.preview-nav button .image-index{position:absolute;height:100%;width:100%;display:block;top:-11.5px;color:#fff}.preview-nav button:hover{background-color:#000}\n"] }]
|
|
2941
|
+
}], ctorParameters: function () { return []; }, propDecorators: { entity: [{
|
|
2942
|
+
type: Input
|
|
2943
|
+
}], key: [{
|
|
2944
|
+
type: Input
|
|
2945
|
+
}], getValidationErrorMessage: [{
|
|
2946
|
+
type: Input
|
|
2947
|
+
}], inputChangeEvent: [{
|
|
2948
|
+
type: Output
|
|
2949
|
+
}] } });
|
|
2950
|
+
|
|
2951
|
+
/**
|
|
2952
|
+
* The default input component. It gets the metadata of the property from the given @Input "entity" and @Input "propertyKey"
|
|
2953
|
+
* and displays the input field accordingly.
|
|
2954
|
+
*
|
|
2955
|
+
* You can also define a method that generates error-messages and if the input should be hidden when its metadata says
|
|
2956
|
+
* that it should be omitted for creating or updating.
|
|
2957
|
+
* The last part being mostly relevant if you want to use this component inside an ngFor.
|
|
2958
|
+
*/
|
|
2959
|
+
class NgxMatEntityInputComponent {
|
|
2960
|
+
constructor(dialog) {
|
|
2961
|
+
this.dialog = dialog;
|
|
2962
|
+
this.inputChangeEvent = new EventEmitter();
|
|
2963
|
+
this.selection = new SelectionModel(true, []);
|
|
2964
|
+
this.isArrayItemValid = false;
|
|
2965
|
+
this.isDialogArrayItemValid = false;
|
|
2966
|
+
this.DecoratorTypes = DecoratorTypes;
|
|
2967
|
+
this.EntityUtilities = EntityUtilities;
|
|
2968
|
+
this.DateUtilities = DateUtilities;
|
|
2969
|
+
}
|
|
2970
|
+
/**
|
|
2971
|
+
* This is needed for the inputs to work inside an ngFor.
|
|
2972
|
+
*
|
|
2973
|
+
* @param index - The index of the element in the ngFor.
|
|
2974
|
+
* @returns The index.
|
|
2975
|
+
*/
|
|
2976
|
+
trackByFn(index) {
|
|
2977
|
+
return index;
|
|
2978
|
+
}
|
|
2979
|
+
ngOnInit() {
|
|
2980
|
+
var _a;
|
|
2981
|
+
if (!this.entity) {
|
|
2982
|
+
throw new Error('Missing required Input data "entity"');
|
|
2983
|
+
}
|
|
2984
|
+
this.internalEntity = this.entity;
|
|
2985
|
+
if (this.propertyKey == null) {
|
|
2986
|
+
throw new Error('Missing required Input data "propertyKey"');
|
|
2987
|
+
}
|
|
2988
|
+
this.internalPropertyKey = this.propertyKey;
|
|
2989
|
+
this.internalGetValidationErrorMessage = (_a = this.getValidationErrorMessage) !== null && _a !== void 0 ? _a : getValidationErrorMessage;
|
|
2990
|
+
this.type = EntityUtilities.getPropertyType(this.entity, this.propertyKey);
|
|
2991
|
+
this.metadata = EntityUtilities.getPropertyMetadata(this.entity, this.propertyKey, this.type);
|
|
2992
|
+
if (this.type === DecoratorTypes.OBJECT) {
|
|
2993
|
+
this.initObjectInput();
|
|
2994
|
+
}
|
|
2995
|
+
if (this.type === DecoratorTypes.ARRAY) {
|
|
2996
|
+
this.initEntityArray();
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
2999
|
+
initEntityArray() {
|
|
3000
|
+
var _a;
|
|
3001
|
+
this.metadataEntityArray = this.metadata;
|
|
3002
|
+
if (this.internalEntity[this.internalPropertyKey] == null) {
|
|
3003
|
+
this.internalEntity[this.internalPropertyKey] = [];
|
|
3004
|
+
}
|
|
3005
|
+
this.entityArrayValues = this.internalEntity[this.internalPropertyKey];
|
|
3006
|
+
if (!this.metadataEntityArray.createInline && !this.metadataEntityArray.createDialogData) {
|
|
3007
|
+
this.metadataEntityArray.createDialogData = {
|
|
3008
|
+
title: 'Add'
|
|
3009
|
+
};
|
|
3010
|
+
}
|
|
3011
|
+
const givenDisplayColumns = this.metadataEntityArray.displayColumns.map((v) => v.displayName);
|
|
3012
|
+
if (givenDisplayColumns.find(s => s === 'select')) {
|
|
3013
|
+
throw new Error(`The name "select" for a display column is reserved.
|
|
3014
|
+
Please choose a different name.`);
|
|
3015
|
+
}
|
|
3016
|
+
this.displayedColumns = ['select'].concat(givenDisplayColumns);
|
|
3017
|
+
this.dataSource = new MatTableDataSource();
|
|
3018
|
+
this.dataSource.data = this.entityArrayValues;
|
|
3019
|
+
this.arrayItem = new this.metadataEntityArray.EntityClass();
|
|
3020
|
+
this.arrayItemInlineRows = EntityUtilities.getEntityRows(this.arrayItem, (_a = this.hideOmitForCreate) !== null && _a !== void 0 ? _a : true, this.hideOmitForEdit);
|
|
3021
|
+
this.arrayItemPriorChanges = LodashUtilities.cloneDeep(this.arrayItem);
|
|
3022
|
+
this.dialogInputData = {
|
|
3023
|
+
entity: this.arrayItem,
|
|
3024
|
+
createDialogData: this.metadataEntityArray.createDialogData,
|
|
3025
|
+
getValidationErrorMessage: this.getValidationErrorMessage
|
|
3026
|
+
};
|
|
3027
|
+
this.dialogData = new AddArrayItemDialogDataBuilder(this.dialogInputData).getResult();
|
|
3028
|
+
this.arrayItemDialogRows = EntityUtilities.getEntityRows(this.dialogData.entity, true);
|
|
3029
|
+
}
|
|
3030
|
+
initObjectInput() {
|
|
3031
|
+
this.metadataDefaultObject = this.metadata;
|
|
3032
|
+
this.objectProperty = this.internalEntity[this.internalPropertyKey];
|
|
3033
|
+
this.objectPropertyRows = EntityUtilities.getEntityRows(this.objectProperty, this.hideOmitForCreate, this.hideOmitForEdit);
|
|
3034
|
+
}
|
|
1318
3035
|
/**
|
|
1319
|
-
* Checks if
|
|
1320
|
-
*
|
|
1321
|
-
* @param time1 - The first time to compare.
|
|
1322
|
-
* @param time2 - The second time to compare.
|
|
1323
|
-
* @returns Whether or not the time objects are the same.
|
|
3036
|
+
* Checks if the arrayItem is valid.
|
|
1324
3037
|
*/
|
|
1325
|
-
|
|
1326
|
-
|
|
3038
|
+
checkIsArrayItemValid() {
|
|
3039
|
+
this.isArrayItemValid = EntityUtilities.isEntityValid(this.arrayItem, 'create');
|
|
1327
3040
|
}
|
|
1328
3041
|
/**
|
|
1329
|
-
*
|
|
3042
|
+
* Checks if the arrayItem inside the dialog is valid.
|
|
1330
3043
|
*/
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
this.dateRange.start = new Date(this.dateRangeStart);
|
|
1334
|
-
this.dateRange.end = new Date(this.dateRangeEnd);
|
|
1335
|
-
const values = DateUtilities.getDatesBetween(new Date(this.dateRange.start), new Date(this.dateRange.end), this.metadataDateRangeDate);
|
|
1336
|
-
this.dateRange.values = values.length ? values : undefined;
|
|
1337
|
-
}
|
|
1338
|
-
else {
|
|
1339
|
-
this.dateRange.values = undefined;
|
|
1340
|
-
}
|
|
1341
|
-
this.entity[this.propertyKey] = this.dateRange;
|
|
3044
|
+
checkIsDialogArrayItemValid() {
|
|
3045
|
+
this.isDialogArrayItemValid = EntityUtilities.isEntityValid(this.dialogData.entity, 'create');
|
|
1342
3046
|
}
|
|
1343
3047
|
/**
|
|
1344
|
-
*
|
|
3048
|
+
* Emits that a the value has been changed.
|
|
1345
3049
|
*/
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
if (!this.dateTime) {
|
|
1349
|
-
this.entity[this.propertyKey] = undefined;
|
|
1350
|
-
return;
|
|
1351
|
-
}
|
|
1352
|
-
this.entity[this.propertyKey] = new Date(this.dateTime);
|
|
1353
|
-
if (((_a = this.time) === null || _a === void 0 ? void 0 : _a.hours) != null && ((_b = this.time) === null || _b === void 0 ? void 0 : _b.minutes) != null) {
|
|
1354
|
-
DateUtilities.asDate(this.entity[this.propertyKey]).setHours(this.time.hours, this.time.minutes, 0, 0);
|
|
1355
|
-
}
|
|
1356
|
-
else {
|
|
1357
|
-
DateUtilities.asDate(this.entity[this.propertyKey]).setHours(0, 0, 0, 0);
|
|
1358
|
-
}
|
|
3050
|
+
emitChange() {
|
|
3051
|
+
this.inputChangeEvent.emit();
|
|
1359
3052
|
}
|
|
1360
3053
|
/**
|
|
1361
|
-
* Tries to add an item to the array.
|
|
3054
|
+
* Tries to add an item to the entity array.
|
|
1362
3055
|
* Does this either inline if the "createInline"-metadata is set to true
|
|
1363
3056
|
* or in a separate dialog if it is set to false.
|
|
1364
3057
|
*/
|
|
1365
|
-
|
|
3058
|
+
addEntity() {
|
|
1366
3059
|
if (this.metadataEntityArray.createInline) {
|
|
1367
|
-
this.
|
|
3060
|
+
if (!this.metadataEntityArray.allowDuplicates
|
|
3061
|
+
&& this.entityArrayValues.find((v) => __awaiter(this, void 0, void 0, function* () { return yield EntityUtilities.isEqual(this.arrayItem, v, this.metadata, this.metadataEntityArray.itemType); }))) {
|
|
3062
|
+
this.dialog.open(NgxMatEntityConfirmDialogComponent, {
|
|
3063
|
+
data: this.metadataEntityArray.duplicatesErrorDialog,
|
|
3064
|
+
autoFocus: false,
|
|
3065
|
+
restoreFocus: false
|
|
3066
|
+
});
|
|
3067
|
+
return;
|
|
3068
|
+
}
|
|
3069
|
+
this.entityArrayValues.push(LodashUtilities.cloneDeep(this.arrayItem));
|
|
1368
3070
|
this.dataSource.data = this.entityArrayValues;
|
|
1369
3071
|
EntityUtilities.resetChangesOnEntity(this.arrayItem, this.arrayItemPriorChanges);
|
|
3072
|
+
this.emitChange();
|
|
1370
3073
|
}
|
|
1371
3074
|
else {
|
|
1372
3075
|
this.addArrayItemDialogRef = this.dialog.open(this.addArrayItemDialog, {
|
|
@@ -1381,9 +3084,10 @@ class NgxMatEntityInputComponent {
|
|
|
1381
3084
|
*/
|
|
1382
3085
|
addArrayItem() {
|
|
1383
3086
|
this.addArrayItemDialogRef.close();
|
|
1384
|
-
this.entityArrayValues.push(cloneDeep(this.arrayItem));
|
|
3087
|
+
this.entityArrayValues.push(LodashUtilities.cloneDeep(this.arrayItem));
|
|
1385
3088
|
this.dataSource.data = this.entityArrayValues;
|
|
1386
3089
|
EntityUtilities.resetChangesOnEntity(this.arrayItem, this.arrayItemPriorChanges);
|
|
3090
|
+
this.emitChange();
|
|
1387
3091
|
}
|
|
1388
3092
|
/**
|
|
1389
3093
|
* Cancels adding the array item defined in the dialog.
|
|
@@ -1391,132 +3095,59 @@ class NgxMatEntityInputComponent {
|
|
|
1391
3095
|
cancelAddArrayItem() {
|
|
1392
3096
|
this.addArrayItemDialogRef.close();
|
|
1393
3097
|
EntityUtilities.resetChangesOnEntity(this.arrayItem, this.arrayItemPriorChanges);
|
|
3098
|
+
this.emitChange();
|
|
1394
3099
|
}
|
|
1395
3100
|
/**
|
|
1396
|
-
* Removes all selected entries from the array.
|
|
3101
|
+
* Removes all selected entries from the entity array.
|
|
3102
|
+
*
|
|
3103
|
+
* @param selection - The selection containing the items to remove.
|
|
3104
|
+
* @param values - The values of the dataSource.
|
|
3105
|
+
* @param dataSource - The dataSource.
|
|
1397
3106
|
*/
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
3107
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3108
|
+
remove(selection, values, dataSource) {
|
|
3109
|
+
selection.selected.forEach(s => {
|
|
3110
|
+
values.splice(values.indexOf(s), 1);
|
|
1401
3111
|
});
|
|
1402
|
-
|
|
1403
|
-
|
|
3112
|
+
dataSource.data = values;
|
|
3113
|
+
selection.clear();
|
|
3114
|
+
this.emitChange();
|
|
1404
3115
|
}
|
|
1405
3116
|
/**
|
|
1406
3117
|
* Toggles all array-items in the table.
|
|
3118
|
+
*
|
|
3119
|
+
* @param selection - The selection to toggle.
|
|
3120
|
+
* @param dataSource - The dataSource of the selection.
|
|
1407
3121
|
*/
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
3122
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3123
|
+
masterToggle(selection, dataSource) {
|
|
3124
|
+
if (this.isAllSelected(selection, dataSource)) {
|
|
3125
|
+
selection.clear();
|
|
1411
3126
|
}
|
|
1412
3127
|
else {
|
|
1413
|
-
|
|
3128
|
+
dataSource.data.forEach(row => selection.select(row));
|
|
1414
3129
|
}
|
|
1415
3130
|
}
|
|
1416
3131
|
/**
|
|
1417
3132
|
* Checks if all array-items in the table have been selected.
|
|
1418
3133
|
* This is needed to display the "masterToggle"-checkbox correctly.
|
|
1419
3134
|
*
|
|
3135
|
+
* @param selection - The selection to check.
|
|
3136
|
+
* @param dataSource - The dataSource of the selection.
|
|
1420
3137
|
* @returns Whether or not all array-items in the table have been selected.
|
|
1421
3138
|
*/
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
const
|
|
3139
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3140
|
+
isAllSelected(selection, dataSource) {
|
|
3141
|
+
const numSelected = selection.selected.length;
|
|
3142
|
+
const numRows = dataSource.data.length;
|
|
1425
3143
|
return numSelected === numRows;
|
|
1426
3144
|
}
|
|
1427
|
-
/**
|
|
1428
|
-
* Handles adding strings to the chipsArray.
|
|
1429
|
-
* Checks validation and also creates a new array if it is undefined.
|
|
1430
|
-
* This is needed because two things are validated: The array itself
|
|
1431
|
-
* and the contents of the array. And we need a way to display an
|
|
1432
|
-
* mat-error. As the only validation for the array is whether or not
|
|
1433
|
-
* it contains values, we can set it to undefined when the last element is removed
|
|
1434
|
-
* (removeStringChipArrayValue). That way we can use the "required" validator.
|
|
1435
|
-
*
|
|
1436
|
-
* @param event - The event that fires when a new chip is completed.
|
|
1437
|
-
*/
|
|
1438
|
-
addStringChipArrayValue(event) {
|
|
1439
|
-
const value = (event.value || '').trim();
|
|
1440
|
-
if (value) {
|
|
1441
|
-
if (this.metadataStringChipsArray.minLength && value.length < this.metadataStringChipsArray.minLength) {
|
|
1442
|
-
return;
|
|
1443
|
-
}
|
|
1444
|
-
if (this.metadataStringChipsArray.maxLength && value.length > this.metadataStringChipsArray.maxLength) {
|
|
1445
|
-
return;
|
|
1446
|
-
}
|
|
1447
|
-
if (this.metadataStringChipsArray.regex && !value.match(this.metadataStringChipsArray.regex)) {
|
|
1448
|
-
return;
|
|
1449
|
-
}
|
|
1450
|
-
if (!this.stringChipsArrayValues) {
|
|
1451
|
-
if (!this.entity[this.propertyKey]) {
|
|
1452
|
-
this.entity[this.propertyKey] = [];
|
|
1453
|
-
}
|
|
1454
|
-
this.stringChipsArrayValues = this.entity[this.propertyKey];
|
|
1455
|
-
}
|
|
1456
|
-
this.stringChipsArrayValues.push(value);
|
|
1457
|
-
}
|
|
1458
|
-
event.chipInput.clear();
|
|
1459
|
-
}
|
|
1460
|
-
/**
|
|
1461
|
-
* Removes the given value from the array.
|
|
1462
|
-
* Sets the array to undefined if it is now empty.
|
|
1463
|
-
* This is needed because two things are validated: The array itself
|
|
1464
|
-
* and the contents of the array. And we need a way to display an
|
|
1465
|
-
* mat-error. As the only validation for the array is whether or not
|
|
1466
|
-
* it is empty, setting it to undefined here enables us to use the "required" validator.
|
|
1467
|
-
*
|
|
1468
|
-
* @param value - The string to remove from the array.
|
|
1469
|
-
*/
|
|
1470
|
-
removeStringChipArrayValue(value) {
|
|
1471
|
-
this.stringChipsArrayValues.splice(this.stringChipsArrayValues.indexOf(value), 1);
|
|
1472
|
-
if (!this.stringChipsArrayValues.length) {
|
|
1473
|
-
this.entity[this.propertyKey] = undefined;
|
|
1474
|
-
this.stringChipsArrayValues = this.entity[this.propertyKey];
|
|
1475
|
-
}
|
|
1476
|
-
}
|
|
1477
|
-
/**
|
|
1478
|
-
* Handles adding a string to the array when an autocomplete value has been selected.
|
|
1479
|
-
*
|
|
1480
|
-
* @param event - The autocomplete selected event.
|
|
1481
|
-
* @param chipsInput - The element where the user typed the value.
|
|
1482
|
-
*/
|
|
1483
|
-
selected(event, chipsInput) {
|
|
1484
|
-
const value = (event.option.viewValue || '').trim();
|
|
1485
|
-
if (this.metadataStringChipsArray.minLength && value.length < this.metadataStringChipsArray.minLength) {
|
|
1486
|
-
return;
|
|
1487
|
-
}
|
|
1488
|
-
if (this.metadataStringChipsArray.maxLength && value.length > this.metadataStringChipsArray.maxLength) {
|
|
1489
|
-
return;
|
|
1490
|
-
}
|
|
1491
|
-
if (this.metadataStringChipsArray.regex && !value.match(this.metadataStringChipsArray.regex)) {
|
|
1492
|
-
return;
|
|
1493
|
-
}
|
|
1494
|
-
if (!this.stringChipsArrayValues) {
|
|
1495
|
-
if (!this.entity[this.propertyKey]) {
|
|
1496
|
-
this.entity[this.propertyKey] = [];
|
|
1497
|
-
}
|
|
1498
|
-
this.stringChipsArrayValues = this.entity[this.propertyKey];
|
|
1499
|
-
}
|
|
1500
|
-
this.stringChipsArrayValues.push(value);
|
|
1501
|
-
chipsInput.value = '';
|
|
1502
|
-
}
|
|
1503
|
-
/**
|
|
1504
|
-
* Dynamically filters the Autocomplete options when the user inputs something.
|
|
1505
|
-
*
|
|
1506
|
-
* @param input - The input of the user.
|
|
1507
|
-
*/
|
|
1508
|
-
filterAutocompleteStrings(input) {
|
|
1509
|
-
if (input) {
|
|
1510
|
-
const filterValue = input.toLowerCase();
|
|
1511
|
-
this.filteredAutocompleteStrings = this.autocompleteStrings.filter(s => s.toLowerCase().includes(filterValue));
|
|
1512
|
-
}
|
|
1513
|
-
}
|
|
1514
3145
|
}
|
|
1515
3146
|
NgxMatEntityInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityInputComponent, deps: [{ token: i1.MatDialog }], target: i0.ɵɵFactoryTarget.Component });
|
|
1516
|
-
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-{{EntityUtilities.getWidth(objectProperty, key, 'lg')}} col-md-{{EntityUtilities.getWidth(objectProperty, key, 'md')}} col-sm-{{EntityUtilities.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-{{EntityUtilities.getWidth(arrayItem, key, 'lg')}} col-md-{{EntityUtilities.getWidth(arrayItem, key, 'md')}} col-sm-{{EntityUtilities.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 <!-------------------------------------------->\n <!-------------------Dates-------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.DATE\">\n <mat-form-field appearance=\"standard\">\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString()\"\n #model=\"ngModel\"\n [matDatepicker]=\"picker\"\n [required]=\"metadata.required\"\n [min]=\"metadataDefaultDate.min ? metadataDefaultDate.min(DateUtilities.asDate(entity[propertyKey])) : undefined\"\n [max]=\"metadataDefaultDate.max ? metadataDefaultDate.max(DateUtilities.asDate(entity[propertyKey])) : undefined\"\n [matDatepickerFilter]=\"metadataDefaultDate.filter ? metadataDefaultDate.filter : defaultDateFilter\"\n >\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-datepicker #picker></mat-datepicker>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.DATE_RANGE\">\n <mat-form-field appearance=\"standard\">\n <mat-label>{{metadata.displayName}}</mat-label>\n \n <mat-date-range-input [rangePicker]=\"picker\" [required]=\"metadata.required\" [dateFilter]=\"metadataDateRangeDate.filter ? metadataDateRangeDate.filter : defaultDateFilter\">\n <input matStartDate\n [(ngModel)]=\"dateRangeStart\"\n [name]=\"propertyKey.toString() + 'start'\"\n #startModel=\"ngModel\"\n [required]=\"metadata.required\"\n [min]=\"metadataDateRangeDate.minStart ? metadataDateRangeDate.minStart(dateRange.start) : undefined\"\n [max]=\"metadataDateRangeDate.maxStart ? metadataDateRangeDate.maxStart(dateRange.start) : undefined\"\n [placeholder]=\"metadataDateRangeDate.placeholderStart ? metadataDateRangeDate.placeholderStart : 'Start'\"\n (ngModelChange)=\"setDateRangeValues()\"\n >\n <input matEndDate\n [(ngModel)]=\"dateRangeEnd\"\n [name]=\"propertyKey.toString() + 'end'\"\n #endModel=\"ngModel\"\n [required]=\"metadata.required\"\n [min]=\"metadataDateRangeDate.minEnd ? metadataDateRangeDate.minEnd(dateRange.end) : undefined\"\n [max]=\"metadataDateRangeDate.maxEnd ? metadataDateRangeDate.maxEnd(dateRange.end) : undefined\"\n [placeholder]=\"metadataDateRangeDate.placeholderEnd ? metadataDateRangeDate.placeholderEnd : 'End'\"\n (ngModelChange)=\"setDateRangeValues()\"\n >\n </mat-date-range-input>\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-date-range-picker #picker></mat-date-range-picker>\n\n <mat-error *ngIf=\"startModel.errors\">{{getValidationErrorMessage(startModel)}}</mat-error>\n <mat-error *ngIf=\"!startModel.errors && endModel.errors\">{{getValidationErrorMessage(endModel)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.DATE_TIME\" class=\"date-time\">\n <mat-form-field appearance=\"standard\" class=\"datepicker\">\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n [(ngModel)]=\"dateTime\"\n [name]=\"propertyKey.toString()\"\n #model=\"ngModel\"\n [matDatepicker]=\"picker\"\n [required]=\"metadata.required\"\n [min]=\"metadataDateTimeDate.minDate ? metadataDateTimeDate.minDate(dateTime) : undefined\"\n [max]=\"metadataDateTimeDate.maxDate ? metadataDateTimeDate.maxDate(dateTime) : undefined\"\n [matDatepickerFilter]=\"metadataDateTimeDate.filterDate ? metadataDateTimeDate.filterDate : defaultDateFilter\"\n (dateInput)=\"setTime()\"\n >\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-datepicker #picker></mat-datepicker>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n <mat-form-field class=\"timepicker\">\n <mat-label>{{metadataDateTimeDate.timeDisplayName}}</mat-label>\n <mat-select\n [(ngModel)]=\"time\"\n [name]=\"propertyKey.toString() + 'time'\"\n #timeModel=\"ngModel\"\n [required]=\"metadata.required\"\n [compareWith]=\"compareTimes\"\n (ngModelChange)=\"setTime()\"\n >\n <mat-option *ngFor=\"let validTime of DateUtilities.getValidTimesForDropdown(\n DateUtilities.asDate(entity[propertyKey]),\n metadataDateTimeDate.times,\n metadataDateTimeDate.minTime,\n metadataDateTimeDate.maxTime,\n metadataDateTimeDate.filterTime\n )\"\n [value]=\"validTime.value\"\n >\n {{validTime.displayName}}\n </mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(timeModel)}}</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-{{EntityUtilities.getWidth(dialogData.entity, key, 'lg')}} col-md-{{EntityUtilities.getWidth(dialogData.entity, key, 'md')}} col-sm-{{EntityUtilities.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}.date-time{display:flex;align-items:baseline}.date-time .timepicker{margin-left:10px}\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"] }, { type: i11.MatDatepickerToggle, selector: "mat-datepicker-toggle", inputs: ["for", "tabIndex", "aria-label", "disabled", "disableRipple"], exportAs: ["matDatepickerToggle"] }, { type: i11.MatDatepicker, selector: "mat-datepicker", exportAs: ["matDatepicker"] }, { type: i11.MatDateRangeInput, selector: "mat-date-range-input", inputs: ["rangePicker", "required", "dateFilter", "min", "max", "disabled", "separator", "comparisonStart", "comparisonEnd"], exportAs: ["matDateRangeInput"] }, { type: i11.MatDateRangePicker, selector: "mat-date-range-picker", exportAs: ["matDateRangePicker"] }], directives: [{ type: i12.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i12.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i12.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i2.MatLabel, selector: "mat-label" }, { type: i13.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: i14.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: i14.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i14.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i14.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i14.PatternValidator, selector: "[pattern][formControlName],[pattern][formControl],[pattern][ngModel]", inputs: ["pattern"] }, { type: i14.MinLengthValidator, selector: "[minlength][formControlName],[minlength][formControl],[minlength][ngModel]", inputs: ["minlength"] }, { type: i14.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { type: i2.MatError, selector: "mat-error", inputs: ["id"] }, { type: i15.CdkTextareaAutosize, selector: "textarea[cdkTextareaAutosize]", inputs: ["cdkAutosizeMinRows", "cdkAutosizeMaxRows", "cdkTextareaAutosize", "placeholder"], exportAs: ["cdkTextareaAutosize"] }, { type: i3$1.MatAutocompleteTrigger, selector: "input[matAutocomplete], textarea[matAutocomplete]", exportAs: ["matAutocompleteTrigger"] }, { type: i12.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i14.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { type: i14.MinValidator, selector: "input[type=number][min][formControlName],input[type=number][min][formControl],input[type=number][min][ngModel]", inputs: ["min"] }, { type: i14.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.MatDatepickerInput, selector: "input[matDatepicker]", inputs: ["matDatepicker", "min", "max", "matDatepickerFilter"], exportAs: ["matDatepickerInput"] }, { type: i2.MatSuffix, selector: "[matSuffix]" }, { type: i11.MatStartDate, selector: "input[matStartDate]", inputs: ["errorStateMatcher"], outputs: ["dateChange", "dateInput"] }, { type: i11.MatEndDate, selector: "input[matEndDate]", inputs: ["errorStateMatcher"], outputs: ["dateChange", "dateInput"] }, { type: i12.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: i14.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i14.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i14.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]" }] });
|
|
3147
|
+
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" }, outputs: { inputChangeEvent: "inputChangeEvent" }, 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 <string-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></string-input>\n </div>\n <div *ngSwitchCase=\"DecoratorTypes.STRING_TEXTBOX\">\n <string-textbox-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></string-textbox-input>\n </div>\n <div *ngSwitchCase=\"DecoratorTypes.STRING_AUTOCOMPLETE\">\n <string-autocomplete-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></string-autocomplete-input>\n </div>\n <div *ngSwitchCase=\"DecoratorTypes.STRING_DROPDOWN\">\n <string-dropdown-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></string-dropdown-input>\n </div>\n\n <!-------------------------------------------->\n <!-----------------Booleans------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.BOOLEAN_CHECKBOX\">\n <boolean-checkbox-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></boolean-checkbox-input>\n </div>\n <div *ngSwitchCase=\"DecoratorTypes.BOOLEAN_TOGGLE\">\n <boolean-toggle-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></boolean-toggle-input>\n </div>\n <div *ngSwitchCase=\"DecoratorTypes.BOOLEAN_DROPDOWN\">\n <boolean-dropdown-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></boolean-dropdown-input>\n </div>\n\n <!-------------------------------------------->\n <!------------------Numbers------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.NUMBER\">\n <number-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></number-input>\n </div>\n <div *ngSwitchCase=\"DecoratorTypes.NUMBER_DROPDOWN\">\n <number-dropdown-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></number-dropdown-input>\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\" *ngFor=\"let row of objectPropertyRows\">\n <ngx-mat-entity-input *ngFor=\"let key of row.keys; let i = index; trackBy: trackByFn\"\n [entity]=\"objectProperty\"\n [propertyKey]=\"key\"\n [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"\n [hideOmitForCreate]=\"hideOmitForCreate\"\n [hideOmitForEdit]=\"hideOmitForEdit\"\n class=\"col-lg-{{EntityUtilities.getWidth(objectProperty, key, 'lg')}} col-md-{{EntityUtilities.getWidth(objectProperty, key, 'md')}} col-sm-{{EntityUtilities.getWidth(objectProperty, key, 'sm')}}\"\n (inputChangeEvent)=\"emitChange()\"\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 <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]=\"internalGetValidationErrorMessage\"\n class=\"col-lg-{{EntityUtilities.getWidth(arrayItem, key, 'lg')}} col-md-{{EntityUtilities.getWidth(arrayItem, key, 'md')}} col-sm-{{EntityUtilities.getWidth(arrayItem, key, 'sm')}}\"\n (inputChangeEvent)=\"checkIsArrayItemValid()\"\n >\n </ngx-mat-entity-input>\n </div>\n </div>\n \n <div class=\"buttons\">\n <button mat-raised-button\n [disabled]=\"metadataEntityArray.createInline && !isArrayItemValid\"\n (click)=\"addEntity()\">\n {{metadataEntityArray.addButtonLabel}}\n </button>\n <button mat-raised-button\n [disabled]=\"!selection.selected.length\"\n (click)=\"remove(selection, entityArrayValues, dataSource)\">\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(selection, dataSource) : null\" [checked]=\"selection.hasValue() && isAllSelected(selection, dataSource)\" [indeterminate]=\"selection.hasValue() && !isAllSelected(selection, dataSource)\"></mat-checkbox>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let 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_DATE\">\n <array-date-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></array-date-input>\n </div>\n <div *ngSwitchCase=\"DecoratorTypes.ARRAY_DATE_TIME\">\n <array-date-time-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></array-date-time-input>\n </div>\n <div *ngSwitchCase=\"DecoratorTypes.ARRAY_DATE_RANGE\">\n <array-date-range-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></array-date-range-input>\n </div>\n <div *ngSwitchCase=\"DecoratorTypes.ARRAY_STRING_CHIPS\">\n <array-string-chips-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></array-string-chips-input>\n </div>\n <div *ngSwitchCase=\"DecoratorTypes.ARRAY_STRING_AUTOCOMPLETE_CHIPS\">\n <array-string-autocomplete-chips (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></array-string-autocomplete-chips>\n </div>\n\n <!-------------------------------------------->\n <!-------------------Dates-------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.DATE\">\n <date-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></date-input>\n </div>\n <div *ngSwitchCase=\"DecoratorTypes.DATE_RANGE\">\n <date-range-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></date-range-input>\n </div>\n <div *ngSwitchCase=\"DecoratorTypes.DATE_TIME\">\n <date-time-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></date-time-input>\n </div>\n\n <!-------------------------------------------->\n <!-------------------Files-------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.FILE_DEFAULT\">\n <file-default-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></file-default-input>\n </div>\n <div *ngSwitchCase=\"DecoratorTypes.FILE_IMAGE\">\n <file-image-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></file-image-input>\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-{{EntityUtilities.getWidth(dialogData.entity, key, 'lg')}} col-md-{{EntityUtilities.getWidth(dialogData.entity, key, 'md')}} col-sm-{{EntityUtilities.getWidth(dialogData.entity, key, 'sm')}}\"\n (inputChangeEvent)=\"checkIsDialogArrayItemValid()\"\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]=\"!isDialogArrayItemValid\">\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%}.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: StringInputComponent, selector: "string-input", inputs: ["entity", "key", "getValidationErrorMessage"], outputs: ["inputChangeEvent"] }, { type: StringTextboxInputComponent, selector: "string-textbox-input", inputs: ["entity", "key", "getValidationErrorMessage"], outputs: ["inputChangeEvent"] }, { type: StringAutocompleteInputComponent, selector: "string-autocomplete-input", inputs: ["entity", "key", "getValidationErrorMessage"], outputs: ["inputChangeEvent"] }, { type: StringDropdownInputComponent, selector: "string-dropdown-input", inputs: ["entity", "key", "getValidationErrorMessage"], outputs: ["inputChangeEvent"] }, { type: BooleanCheckboxInputComponent, selector: "boolean-checkbox-input", inputs: ["entity", "key", "getValidationErrorMessage"], outputs: ["inputChangeEvent"] }, { type: BooleanToggleInputComponent, selector: "boolean-toggle-input", inputs: ["entity", "key", "getValidationErrorMessage"], outputs: ["inputChangeEvent"] }, { type: BooleanDropdownInputComponent, selector: "boolean-dropdown-input", inputs: ["entity", "key", "getValidationErrorMessage"], outputs: ["inputChangeEvent"] }, { type: NumberInputComponent, selector: "number-input", inputs: ["entity", "key", "getValidationErrorMessage"], outputs: ["inputChangeEvent"] }, { type: NumberDropdownInputComponent, selector: "number-dropdown-input", inputs: ["entity", "key", "getValidationErrorMessage"], outputs: ["inputChangeEvent"] }, { type: NgxMatEntityInputComponent, selector: "ngx-mat-entity-input", inputs: ["entity", "propertyKey", "getValidationErrorMessage", "hideOmitForCreate", "hideOmitForEdit"], outputs: ["inputChangeEvent"] }, { type: i4.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: i5.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: i5.MatHeaderRow, selector: "mat-header-row, tr[mat-header-row]", exportAs: ["matHeaderRow"] }, { type: i5.MatRow, selector: "mat-row, tr[mat-row]", exportAs: ["matRow"] }, { type: ArrayDateInputComponent, selector: "array-date-input", inputs: ["entity", "key", "getValidationErrorMessage"], outputs: ["inputChangeEvent"] }, { type: ArrayDateTimeInputComponent, selector: "array-date-time-input", inputs: ["entity", "key", "getValidationErrorMessage"], outputs: ["inputChangeEvent"] }, { type: ArrayDateRangeInputComponent, selector: "array-date-range-input", inputs: ["entity", "key", "metadata", "getValidationErrorMessage"], outputs: ["inputChangeEvent"] }, { type: ArrayStringChipsInputComponent, selector: "array-string-chips-input", inputs: ["entity", "key", "getValidationErrorMessage"], outputs: ["inputChangeEvent"] }, { type: ArrayStringAutocompleteChipsComponent, selector: "array-string-autocomplete-chips", inputs: ["entity", "key", "getValidationErrorMessage"], outputs: ["inputChangeEvent"] }, { type: DateInputComponent, selector: "date-input", inputs: ["entity", "key", "getValidationErrorMessage"], outputs: ["inputChangeEvent"] }, { type: DateRangeInputComponent, selector: "date-range-input", inputs: ["entity", "key", "getValidationErrorMessage"], outputs: ["inputChangeEvent"] }, { type: DateTimeInputComponent, selector: "date-time-input", inputs: ["entity", "key", "getValidationErrorMessage"], outputs: ["inputChangeEvent"] }, { type: FileDefaultInputComponent, selector: "file-default-input", inputs: ["entity", "key", "getValidationErrorMessage"], outputs: ["inputChangeEvent"] }, { type: FileImageInputComponent, selector: "file-image-input", inputs: ["entity", "key", "getValidationErrorMessage"], outputs: ["inputChangeEvent"] }], directives: [{ type: i4$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4$1.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i4$1.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i4$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5.MatColumnDef, selector: "[matColumnDef]", inputs: ["sticky", "matColumnDef"] }, { type: i5.MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { type: i5.MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { type: i5.MatCellDef, selector: "[matCellDef]" }, { type: i5.MatCell, selector: "mat-cell, td[mat-cell]" }, { type: i5.MatHeaderRowDef, selector: "[matHeaderRowDef]", inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"] }, { type: i5.MatRowDef, selector: "[matRowDef]", inputs: ["matRowDefColumns", "matRowDefWhen"] }, { type: i4$1.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: i3.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i3.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i3.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]" }] });
|
|
1517
3148
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityInputComponent, decorators: [{
|
|
1518
3149
|
type: Component,
|
|
1519
|
-
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-{{EntityUtilities.getWidth(objectProperty, key, 'lg')}} col-md-{{EntityUtilities.getWidth(objectProperty, key, 'md')}} col-sm-{{EntityUtilities.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-{{EntityUtilities.getWidth(arrayItem, key, 'lg')}} col-md-{{EntityUtilities.getWidth(arrayItem, key, 'md')}} col-sm-{{EntityUtilities.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 <!-------------------------------------------->\n <!-------------------Dates-------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.DATE\">\n <mat-form-field appearance=\"standard\">\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n [(ngModel)]=\"entity[propertyKey]\"\n [name]=\"propertyKey.toString()\"\n #model=\"ngModel\"\n [matDatepicker]=\"picker\"\n [required]=\"metadata.required\"\n [min]=\"metadataDefaultDate.min ? metadataDefaultDate.min(DateUtilities.asDate(entity[propertyKey])) : undefined\"\n [max]=\"metadataDefaultDate.max ? metadataDefaultDate.max(DateUtilities.asDate(entity[propertyKey])) : undefined\"\n [matDatepickerFilter]=\"metadataDefaultDate.filter ? metadataDefaultDate.filter : defaultDateFilter\"\n >\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-datepicker #picker></mat-datepicker>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.DATE_RANGE\">\n <mat-form-field appearance=\"standard\">\n <mat-label>{{metadata.displayName}}</mat-label>\n \n <mat-date-range-input [rangePicker]=\"picker\" [required]=\"metadata.required\" [dateFilter]=\"metadataDateRangeDate.filter ? metadataDateRangeDate.filter : defaultDateFilter\">\n <input matStartDate\n [(ngModel)]=\"dateRangeStart\"\n [name]=\"propertyKey.toString() + 'start'\"\n #startModel=\"ngModel\"\n [required]=\"metadata.required\"\n [min]=\"metadataDateRangeDate.minStart ? metadataDateRangeDate.minStart(dateRange.start) : undefined\"\n [max]=\"metadataDateRangeDate.maxStart ? metadataDateRangeDate.maxStart(dateRange.start) : undefined\"\n [placeholder]=\"metadataDateRangeDate.placeholderStart ? metadataDateRangeDate.placeholderStart : 'Start'\"\n (ngModelChange)=\"setDateRangeValues()\"\n >\n <input matEndDate\n [(ngModel)]=\"dateRangeEnd\"\n [name]=\"propertyKey.toString() + 'end'\"\n #endModel=\"ngModel\"\n [required]=\"metadata.required\"\n [min]=\"metadataDateRangeDate.minEnd ? metadataDateRangeDate.minEnd(dateRange.end) : undefined\"\n [max]=\"metadataDateRangeDate.maxEnd ? metadataDateRangeDate.maxEnd(dateRange.end) : undefined\"\n [placeholder]=\"metadataDateRangeDate.placeholderEnd ? metadataDateRangeDate.placeholderEnd : 'End'\"\n (ngModelChange)=\"setDateRangeValues()\"\n >\n </mat-date-range-input>\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-date-range-picker #picker></mat-date-range-picker>\n\n <mat-error *ngIf=\"startModel.errors\">{{getValidationErrorMessage(startModel)}}</mat-error>\n <mat-error *ngIf=\"!startModel.errors && endModel.errors\">{{getValidationErrorMessage(endModel)}}</mat-error>\n </mat-form-field>\n </div>\n\n <div *ngSwitchCase=\"DecoratorTypes.DATE_TIME\" class=\"date-time\">\n <mat-form-field appearance=\"standard\" class=\"datepicker\">\n <mat-label>{{metadata.displayName}}</mat-label>\n <input\n matInput\n [(ngModel)]=\"dateTime\"\n [name]=\"propertyKey.toString()\"\n #model=\"ngModel\"\n [matDatepicker]=\"picker\"\n [required]=\"metadata.required\"\n [min]=\"metadataDateTimeDate.minDate ? metadataDateTimeDate.minDate(dateTime) : undefined\"\n [max]=\"metadataDateTimeDate.maxDate ? metadataDateTimeDate.maxDate(dateTime) : undefined\"\n [matDatepickerFilter]=\"metadataDateTimeDate.filterDate ? metadataDateTimeDate.filterDate : defaultDateFilter\"\n (dateInput)=\"setTime()\"\n >\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-datepicker #picker></mat-datepicker>\n <mat-error>{{getValidationErrorMessage(model)}}</mat-error>\n </mat-form-field>\n <mat-form-field class=\"timepicker\">\n <mat-label>{{metadataDateTimeDate.timeDisplayName}}</mat-label>\n <mat-select\n [(ngModel)]=\"time\"\n [name]=\"propertyKey.toString() + 'time'\"\n #timeModel=\"ngModel\"\n [required]=\"metadata.required\"\n [compareWith]=\"compareTimes\"\n (ngModelChange)=\"setTime()\"\n >\n <mat-option *ngFor=\"let validTime of DateUtilities.getValidTimesForDropdown(\n DateUtilities.asDate(entity[propertyKey]),\n metadataDateTimeDate.times,\n metadataDateTimeDate.minTime,\n metadataDateTimeDate.maxTime,\n metadataDateTimeDate.filterTime\n )\"\n [value]=\"validTime.value\"\n >\n {{validTime.displayName}}\n </mat-option>\n </mat-select>\n <mat-error>{{getValidationErrorMessage(timeModel)}}</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-{{EntityUtilities.getWidth(dialogData.entity, key, 'lg')}} col-md-{{EntityUtilities.getWidth(dialogData.entity, key, 'md')}} col-sm-{{EntityUtilities.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}.date-time{display:flex;align-items:baseline}.date-time .timepicker{margin-left:10px}\n"] }]
|
|
3150
|
+
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 <string-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></string-input>\n </div>\n <div *ngSwitchCase=\"DecoratorTypes.STRING_TEXTBOX\">\n <string-textbox-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></string-textbox-input>\n </div>\n <div *ngSwitchCase=\"DecoratorTypes.STRING_AUTOCOMPLETE\">\n <string-autocomplete-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></string-autocomplete-input>\n </div>\n <div *ngSwitchCase=\"DecoratorTypes.STRING_DROPDOWN\">\n <string-dropdown-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></string-dropdown-input>\n </div>\n\n <!-------------------------------------------->\n <!-----------------Booleans------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.BOOLEAN_CHECKBOX\">\n <boolean-checkbox-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></boolean-checkbox-input>\n </div>\n <div *ngSwitchCase=\"DecoratorTypes.BOOLEAN_TOGGLE\">\n <boolean-toggle-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></boolean-toggle-input>\n </div>\n <div *ngSwitchCase=\"DecoratorTypes.BOOLEAN_DROPDOWN\">\n <boolean-dropdown-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></boolean-dropdown-input>\n </div>\n\n <!-------------------------------------------->\n <!------------------Numbers------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.NUMBER\">\n <number-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></number-input>\n </div>\n <div *ngSwitchCase=\"DecoratorTypes.NUMBER_DROPDOWN\">\n <number-dropdown-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></number-dropdown-input>\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\" *ngFor=\"let row of objectPropertyRows\">\n <ngx-mat-entity-input *ngFor=\"let key of row.keys; let i = index; trackBy: trackByFn\"\n [entity]=\"objectProperty\"\n [propertyKey]=\"key\"\n [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"\n [hideOmitForCreate]=\"hideOmitForCreate\"\n [hideOmitForEdit]=\"hideOmitForEdit\"\n class=\"col-lg-{{EntityUtilities.getWidth(objectProperty, key, 'lg')}} col-md-{{EntityUtilities.getWidth(objectProperty, key, 'md')}} col-sm-{{EntityUtilities.getWidth(objectProperty, key, 'sm')}}\"\n (inputChangeEvent)=\"emitChange()\"\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 <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]=\"internalGetValidationErrorMessage\"\n class=\"col-lg-{{EntityUtilities.getWidth(arrayItem, key, 'lg')}} col-md-{{EntityUtilities.getWidth(arrayItem, key, 'md')}} col-sm-{{EntityUtilities.getWidth(arrayItem, key, 'sm')}}\"\n (inputChangeEvent)=\"checkIsArrayItemValid()\"\n >\n </ngx-mat-entity-input>\n </div>\n </div>\n \n <div class=\"buttons\">\n <button mat-raised-button\n [disabled]=\"metadataEntityArray.createInline && !isArrayItemValid\"\n (click)=\"addEntity()\">\n {{metadataEntityArray.addButtonLabel}}\n </button>\n <button mat-raised-button\n [disabled]=\"!selection.selected.length\"\n (click)=\"remove(selection, entityArrayValues, dataSource)\">\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(selection, dataSource) : null\" [checked]=\"selection.hasValue() && isAllSelected(selection, dataSource)\" [indeterminate]=\"selection.hasValue() && !isAllSelected(selection, dataSource)\"></mat-checkbox>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let 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_DATE\">\n <array-date-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></array-date-input>\n </div>\n <div *ngSwitchCase=\"DecoratorTypes.ARRAY_DATE_TIME\">\n <array-date-time-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></array-date-time-input>\n </div>\n <div *ngSwitchCase=\"DecoratorTypes.ARRAY_DATE_RANGE\">\n <array-date-range-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></array-date-range-input>\n </div>\n <div *ngSwitchCase=\"DecoratorTypes.ARRAY_STRING_CHIPS\">\n <array-string-chips-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></array-string-chips-input>\n </div>\n <div *ngSwitchCase=\"DecoratorTypes.ARRAY_STRING_AUTOCOMPLETE_CHIPS\">\n <array-string-autocomplete-chips (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></array-string-autocomplete-chips>\n </div>\n\n <!-------------------------------------------->\n <!-------------------Dates-------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.DATE\">\n <date-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></date-input>\n </div>\n <div *ngSwitchCase=\"DecoratorTypes.DATE_RANGE\">\n <date-range-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></date-range-input>\n </div>\n <div *ngSwitchCase=\"DecoratorTypes.DATE_TIME\">\n <date-time-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></date-time-input>\n </div>\n\n <!-------------------------------------------->\n <!-------------------Files-------------------->\n <!-------------------------------------------->\n <div *ngSwitchCase=\"DecoratorTypes.FILE_DEFAULT\">\n <file-default-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></file-default-input>\n </div>\n <div *ngSwitchCase=\"DecoratorTypes.FILE_IMAGE\">\n <file-image-input (inputChangeEvent)=\"emitChange()\" [entity]=\"internalEntity\" [key]=\"internalPropertyKey\" [getValidationErrorMessage]=\"internalGetValidationErrorMessage\"></file-image-input>\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-{{EntityUtilities.getWidth(dialogData.entity, key, 'lg')}} col-md-{{EntityUtilities.getWidth(dialogData.entity, key, 'md')}} col-sm-{{EntityUtilities.getWidth(dialogData.entity, key, 'sm')}}\"\n (inputChangeEvent)=\"checkIsDialogArrayItemValid()\"\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]=\"!isDialogArrayItemValid\">\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%}.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"] }]
|
|
1520
3151
|
}], ctorParameters: function () { return [{ type: i1.MatDialog }]; }, propDecorators: { entity: [{
|
|
1521
3152
|
type: Input
|
|
1522
3153
|
}], propertyKey: [{
|
|
@@ -1527,6 +3158,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
|
|
|
1527
3158
|
type: Input
|
|
1528
3159
|
}], hideOmitForEdit: [{
|
|
1529
3160
|
type: Input
|
|
3161
|
+
}], inputChangeEvent: [{
|
|
3162
|
+
type: Output
|
|
1530
3163
|
}], addArrayItemDialog: [{
|
|
1531
3164
|
type: ViewChild,
|
|
1532
3165
|
args: ['addArrayItemDialog']
|
|
@@ -1535,7 +3168,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
|
|
|
1535
3168
|
class NgxMatEntityInputModule {
|
|
1536
3169
|
}
|
|
1537
3170
|
NgxMatEntityInputModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityInputModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1538
|
-
NgxMatEntityInputModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityInputModule, declarations: [
|
|
3171
|
+
NgxMatEntityInputModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityInputModule, declarations: [StringInputComponent,
|
|
3172
|
+
StringTextboxInputComponent,
|
|
3173
|
+
StringAutocompleteInputComponent,
|
|
3174
|
+
StringDropdownInputComponent,
|
|
3175
|
+
BooleanCheckboxInputComponent,
|
|
3176
|
+
BooleanToggleInputComponent,
|
|
3177
|
+
BooleanDropdownInputComponent,
|
|
3178
|
+
NumberInputComponent,
|
|
3179
|
+
NumberDropdownInputComponent,
|
|
3180
|
+
ArrayStringChipsInputComponent,
|
|
3181
|
+
ArrayStringAutocompleteChipsComponent,
|
|
3182
|
+
DateInputComponent,
|
|
3183
|
+
DateRangeInputComponent,
|
|
3184
|
+
DateTimeInputComponent,
|
|
3185
|
+
ArrayDateInputComponent,
|
|
3186
|
+
ArrayDateTimeInputComponent,
|
|
3187
|
+
ArrayDateRangeInputComponent,
|
|
3188
|
+
FileInputComponent,
|
|
3189
|
+
FileImageInputComponent,
|
|
3190
|
+
FileDefaultInputComponent,
|
|
3191
|
+
DragDropDirective,
|
|
3192
|
+
NgxMatEntityInputComponent], imports: [CommonModule,
|
|
1539
3193
|
MatInputModule,
|
|
1540
3194
|
FormsModule,
|
|
1541
3195
|
MatFormFieldModule,
|
|
@@ -1569,7 +3223,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
|
|
|
1569
3223
|
type: NgModule,
|
|
1570
3224
|
args: [{
|
|
1571
3225
|
declarations: [
|
|
1572
|
-
|
|
3226
|
+
StringInputComponent,
|
|
3227
|
+
StringTextboxInputComponent,
|
|
3228
|
+
StringAutocompleteInputComponent,
|
|
3229
|
+
StringDropdownInputComponent,
|
|
3230
|
+
BooleanCheckboxInputComponent,
|
|
3231
|
+
BooleanToggleInputComponent,
|
|
3232
|
+
BooleanDropdownInputComponent,
|
|
3233
|
+
NumberInputComponent,
|
|
3234
|
+
NumberDropdownInputComponent,
|
|
3235
|
+
ArrayStringChipsInputComponent,
|
|
3236
|
+
ArrayStringAutocompleteChipsComponent,
|
|
3237
|
+
DateInputComponent,
|
|
3238
|
+
DateRangeInputComponent,
|
|
3239
|
+
DateTimeInputComponent,
|
|
3240
|
+
ArrayDateInputComponent,
|
|
3241
|
+
ArrayDateTimeInputComponent,
|
|
3242
|
+
ArrayDateRangeInputComponent,
|
|
3243
|
+
FileInputComponent,
|
|
3244
|
+
FileImageInputComponent,
|
|
3245
|
+
FileDefaultInputComponent,
|
|
3246
|
+
DragDropDirective,
|
|
3247
|
+
NgxMatEntityInputComponent
|
|
1573
3248
|
],
|
|
1574
3249
|
imports: [
|
|
1575
3250
|
CommonModule,
|
|
@@ -1628,7 +3303,7 @@ class NgxMatEntityCreateDialogComponent {
|
|
|
1628
3303
|
this.injector = injector;
|
|
1629
3304
|
this.dialog = dialog;
|
|
1630
3305
|
this.EntityUtilities = EntityUtilities;
|
|
1631
|
-
this.
|
|
3306
|
+
this.isEntityValid = false;
|
|
1632
3307
|
}
|
|
1633
3308
|
ngOnInit() {
|
|
1634
3309
|
this.data = new CreateEntityDialogDataBuilder(this.inputData).getResult();
|
|
@@ -1636,16 +3311,22 @@ class NgxMatEntityCreateDialogComponent {
|
|
|
1636
3311
|
this.entityRows = EntityUtilities.getEntityRows(this.data.entity, true);
|
|
1637
3312
|
this.entityService = this.injector.get(this.data.EntityServiceClass);
|
|
1638
3313
|
}
|
|
3314
|
+
/**
|
|
3315
|
+
* Checks if the entity is valid.
|
|
3316
|
+
*/
|
|
3317
|
+
checkIsEntityValid() {
|
|
3318
|
+
this.isEntityValid = EntityUtilities.isEntityValid(this.data.entity, 'create');
|
|
3319
|
+
}
|
|
1639
3320
|
/**
|
|
1640
3321
|
* Tries add the new entity and close the dialog afterwards.
|
|
1641
3322
|
* Also handles the confirmation if required.
|
|
1642
3323
|
*/
|
|
1643
3324
|
create() {
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
return
|
|
3325
|
+
if (!this.data.createDialogData.createRequiresConfirmDialog) {
|
|
3326
|
+
this.confirmCreate();
|
|
3327
|
+
return;
|
|
1647
3328
|
}
|
|
1648
|
-
const dialogData = new ConfirmDialogDataBuilder(
|
|
3329
|
+
const dialogData = new ConfirmDialogDataBuilder(this.data.createDialogData.confirmCreateDialogData)
|
|
1649
3330
|
.withDefault('text', ['Do you really want to create this entity?'])
|
|
1650
3331
|
.withDefault('confirmButtonLabel', 'Create')
|
|
1651
3332
|
.withDefault('title', 'Create')
|
|
@@ -1662,7 +3343,7 @@ class NgxMatEntityCreateDialogComponent {
|
|
|
1662
3343
|
});
|
|
1663
3344
|
}
|
|
1664
3345
|
confirmCreate() {
|
|
1665
|
-
this.entityService.create(this.data.entity).then(() => this.dialogRef.close());
|
|
3346
|
+
void this.entityService.create(this.data.entity).then(() => this.dialogRef.close());
|
|
1666
3347
|
}
|
|
1667
3348
|
/**
|
|
1668
3349
|
* Closes the dialog.
|
|
@@ -1672,10 +3353,10 @@ class NgxMatEntityCreateDialogComponent {
|
|
|
1672
3353
|
}
|
|
1673
3354
|
}
|
|
1674
3355
|
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 });
|
|
1675
|
-
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]=\"!
|
|
3356
|
+
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-{{EntityUtilities.getWidth(data.entity, key, 'lg')}} col-md-{{EntityUtilities.getWidth(data.entity, key, 'md')}} col-sm-{{EntityUtilities.getWidth(data.entity, key, 'sm')}}\"\n (inputChangeEvent)=\"checkIsEntityValid()\"\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]=\"!isEntityValid\">\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"], outputs: ["inputChangeEvent"] }, { type: i4.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: i3.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i3.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i3.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i4$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i1.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]" }] });
|
|
1676
3357
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityCreateDialogComponent, decorators: [{
|
|
1677
3358
|
type: Component,
|
|
1678
|
-
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]=\"!
|
|
3359
|
+
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-{{EntityUtilities.getWidth(data.entity, key, 'lg')}} col-md-{{EntityUtilities.getWidth(data.entity, key, 'md')}} col-sm-{{EntityUtilities.getWidth(data.entity, key, 'sm')}}\"\n (inputChangeEvent)=\"checkIsEntityValid()\"\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]=\"!isEntityValid\">\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"] }]
|
|
1679
3360
|
}], ctorParameters: function () {
|
|
1680
3361
|
return [{ type: undefined, decorators: [{
|
|
1681
3362
|
type: Inject,
|
|
@@ -1707,6 +3388,7 @@ class EditDialogDataBuilder extends BaseBuilder {
|
|
|
1707
3388
|
}
|
|
1708
3389
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
1709
3390
|
generateBaseData(data) {
|
|
3391
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1710
3392
|
const confirmEditDialogData = new ConfirmDialogDataBuilder(data === null || data === void 0 ? void 0 : data.confirmEditDialogData)
|
|
1711
3393
|
.withDefault('confirmButtonLabel', 'Save')
|
|
1712
3394
|
.withDefault('text', ['Do you really want to save all changes?'])
|
|
@@ -1718,7 +3400,7 @@ class EditDialogDataBuilder extends BaseBuilder {
|
|
|
1718
3400
|
.withDefault('text', ['Do you really want to delete this entity?'])
|
|
1719
3401
|
.withDefault('title', 'Delete')
|
|
1720
3402
|
.getResult();
|
|
1721
|
-
return new EditDialogDataInternal((data === null || data === void 0 ? void 0 : data.title) ?
|
|
3403
|
+
return new EditDialogDataInternal((_a = data === null || data === void 0 ? void 0 : data.title) !== null && _a !== void 0 ? _a : (() => 'Edit'), (_b = data === null || data === void 0 ? void 0 : data.confirmButtonLabel) !== null && _b !== void 0 ? _b : 'Save', (_c = data === null || data === void 0 ? void 0 : data.deleteButtonLabel) !== null && _c !== void 0 ? _c : 'Delete', (_d = data === null || data === void 0 ? void 0 : data.cancelButtonLabel) !== null && _d !== void 0 ? _d : 'Cancel', (_e = data === null || data === void 0 ? void 0 : data.deleteRequiresConfirmDialog) !== null && _e !== void 0 ? _e : true, (_f = data === null || data === void 0 ? void 0 : data.editRequiresConfirmDialog) !== null && _f !== void 0 ? _f : false, confirmDeleteDialogData, confirmEditDialogData);
|
|
1722
3404
|
}
|
|
1723
3405
|
}
|
|
1724
3406
|
|
|
@@ -1742,8 +3424,9 @@ class EditEntityDialogDataBuilder extends BaseBuilder {
|
|
|
1742
3424
|
}
|
|
1743
3425
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
1744
3426
|
generateBaseData(data) {
|
|
3427
|
+
var _a;
|
|
1745
3428
|
const editDialogData = new EditDialogDataBuilder(data.editDialogData).getResult();
|
|
1746
|
-
return new EditEntityDialogDataInternal(data.entity, data.EntityServiceClass, editDialogData, data.allowDelete ?
|
|
3429
|
+
return new EditEntityDialogDataInternal(data.entity, data.EntityServiceClass, editDialogData, (_a = data.allowDelete) !== null && _a !== void 0 ? _a : (() => true));
|
|
1747
3430
|
}
|
|
1748
3431
|
}
|
|
1749
3432
|
|
|
@@ -1760,14 +3443,20 @@ class NgxMatEntityEditDialogComponent {
|
|
|
1760
3443
|
this.injector = injector;
|
|
1761
3444
|
this.dialog = dialog;
|
|
1762
3445
|
this.EntityUtilities = EntityUtilities;
|
|
1763
|
-
this.
|
|
3446
|
+
this.isEntityValid = true;
|
|
3447
|
+
this.isEntityDirty = (() => __awaiter(this, void 0, void 0, function* () { return false; })).call(this);
|
|
1764
3448
|
}
|
|
1765
3449
|
ngOnInit() {
|
|
1766
3450
|
this.data = new EditEntityDialogDataBuilder(this.inputData).getResult();
|
|
1767
3451
|
this.dialogRef.disableClose = true;
|
|
1768
3452
|
this.entityRows = EntityUtilities.getEntityRows(this.data.entity, false, true);
|
|
1769
3453
|
this.entityService = this.injector.get(this.data.EntityServiceClass);
|
|
1770
|
-
this.entityPriorChanges = cloneDeep(this.data.entity);
|
|
3454
|
+
this.entityPriorChanges = LodashUtilities.cloneDeep(this.data.entity);
|
|
3455
|
+
}
|
|
3456
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
3457
|
+
checkEntity() {
|
|
3458
|
+
this.isEntityValid = EntityUtilities.isEntityValid(this.data.entity, 'update');
|
|
3459
|
+
this.isEntityDirty = EntityUtilities.dirty(this.data.entity, this.entityPriorChanges);
|
|
1771
3460
|
}
|
|
1772
3461
|
/**
|
|
1773
3462
|
* Tries to save the changes and close the dialog afterwards.
|
|
@@ -1775,7 +3464,8 @@ class NgxMatEntityEditDialogComponent {
|
|
|
1775
3464
|
*/
|
|
1776
3465
|
edit() {
|
|
1777
3466
|
if (!this.data.editDialogData.editRequiresConfirmDialog) {
|
|
1778
|
-
|
|
3467
|
+
this.confirmEdit();
|
|
3468
|
+
return;
|
|
1779
3469
|
}
|
|
1780
3470
|
const dialogData = new ConfirmDialogDataBuilder(this.data.editDialogData.confirmEditDialogData)
|
|
1781
3471
|
.withDefault('text', ['Do you really want to save all changes?'])
|
|
@@ -1794,7 +3484,7 @@ class NgxMatEntityEditDialogComponent {
|
|
|
1794
3484
|
});
|
|
1795
3485
|
}
|
|
1796
3486
|
confirmEdit() {
|
|
1797
|
-
this.entityService.update(this.data.entity, this.entityPriorChanges).then(() => this.dialogRef.close(1));
|
|
3487
|
+
void this.entityService.update(this.data.entity, this.entityPriorChanges).then(() => this.dialogRef.close(1));
|
|
1798
3488
|
}
|
|
1799
3489
|
/**
|
|
1800
3490
|
* Tries to delete the entity and close the dialog afterwards.
|
|
@@ -1802,7 +3492,8 @@ class NgxMatEntityEditDialogComponent {
|
|
|
1802
3492
|
*/
|
|
1803
3493
|
delete() {
|
|
1804
3494
|
if (!this.data.editDialogData.deleteRequiresConfirmDialog) {
|
|
1805
|
-
|
|
3495
|
+
this.confirmDelete();
|
|
3496
|
+
return;
|
|
1806
3497
|
}
|
|
1807
3498
|
const dialogData = new ConfirmDialogDataBuilder(this.data.editDialogData.confirmDeleteDialogData)
|
|
1808
3499
|
.withDefault('text', ['Do you really want to delete this entity?'])
|
|
@@ -1822,7 +3513,7 @@ class NgxMatEntityEditDialogComponent {
|
|
|
1822
3513
|
});
|
|
1823
3514
|
}
|
|
1824
3515
|
confirmDelete() {
|
|
1825
|
-
this.entityService.delete(this.entityPriorChanges).then(() => this.dialogRef.close(2));
|
|
3516
|
+
void this.entityService.delete(this.entityPriorChanges).then(() => this.dialogRef.close(2));
|
|
1826
3517
|
}
|
|
1827
3518
|
/**
|
|
1828
3519
|
* Reverts all changes made and closes the dialog.
|
|
@@ -1833,10 +3524,10 @@ class NgxMatEntityEditDialogComponent {
|
|
|
1833
3524
|
}
|
|
1834
3525
|
}
|
|
1835
3526
|
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 });
|
|
1836
|
-
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]=\"!
|
|
3527
|
+
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-{{EntityUtilities.getWidth(data.entity, key, 'lg')}} col-md-{{EntityUtilities.getWidth(data.entity, key, 'md')}} col-sm-{{EntityUtilities.getWidth(data.entity, key, 'sm')}}\"\n (inputChangeEvent)=\"checkEntity()\"\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]=\"!isEntityValid || (isEntityDirty | async) === false\">\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: i4.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"], outputs: ["inputChangeEvent"] }], directives: [{ type: i1.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { type: i4$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { type: i3.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i3.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i3.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i4$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i1.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]" }], pipes: { "async": i4$1.AsyncPipe } });
|
|
1837
3528
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityEditDialogComponent, decorators: [{
|
|
1838
3529
|
type: Component,
|
|
1839
|
-
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]=\"!
|
|
3530
|
+
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-{{EntityUtilities.getWidth(data.entity, key, 'lg')}} col-md-{{EntityUtilities.getWidth(data.entity, key, 'md')}} col-sm-{{EntityUtilities.getWidth(data.entity, key, 'sm')}}\"\n (inputChangeEvent)=\"checkEntity()\"\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]=\"!isEntityValid || (isEntityDirty | async) === false\">\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"] }]
|
|
1840
3531
|
}], ctorParameters: function () {
|
|
1841
3532
|
return [{ type: undefined, decorators: [{
|
|
1842
3533
|
type: Inject,
|
|
@@ -1863,7 +3554,8 @@ class BaseDataBuilder extends BaseBuilder {
|
|
|
1863
3554
|
}
|
|
1864
3555
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
1865
3556
|
generateBaseData(data) {
|
|
1866
|
-
|
|
3557
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3558
|
+
return new BaseDataInternal(data.title, data.displayColumns, data.EntityServiceClass, (_a = data.searchLabel) !== null && _a !== void 0 ? _a : 'Search', (_b = data.createButtonLabel) !== null && _b !== void 0 ? _b : 'Create', (_c = data.searchString) !== null && _c !== void 0 ? _c : defaultSearchFunction, (_d = data.allowCreate) !== null && _d !== void 0 ? _d : true, (_e = data.allowEdit) !== null && _e !== void 0 ? _e : (() => true), (_f = data.allowDelete) !== null && _f !== void 0 ? _f : (() => true), (_g = data.multiSelectActions) !== null && _g !== void 0 ? _g : [], (_h = data.multiSelectLabel) !== null && _h !== void 0 ? _h : 'Actions', data.EntityClass, data.edit, data.create);
|
|
1867
3559
|
}
|
|
1868
3560
|
}
|
|
1869
3561
|
/**
|
|
@@ -1910,7 +3602,7 @@ class TableDataBuilder extends BaseBuilder {
|
|
|
1910
3602
|
}
|
|
1911
3603
|
if ((data.baseData.allowEdit && data.baseData.allowEdit !== (() => false)
|
|
1912
3604
|
|| data.baseData.allowDelete && data.baseData.allowDelete !== (() => false)
|
|
1913
|
-
|| data.baseData.allowCreate)
|
|
3605
|
+
|| data.baseData.allowCreate === true)
|
|
1914
3606
|
&& !data.baseData.EntityClass) {
|
|
1915
3607
|
throw new Error(`
|
|
1916
3608
|
Missing required Input data "EntityClass".
|
|
@@ -1979,21 +3671,19 @@ class NgxMatEntityTableComponent {
|
|
|
1979
3671
|
return (_a = this.data.baseData.displayColumns.find((dp) => dp.displayName === header)) === null || _a === void 0 ? void 0 : _a.value(entity);
|
|
1980
3672
|
};
|
|
1981
3673
|
this.dataSource.sort = this.sort;
|
|
1982
|
-
|
|
1983
|
-
this.
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
};
|
|
1989
|
-
}
|
|
3674
|
+
this.dataSource.filterPredicate = (entity, filter) => {
|
|
3675
|
+
const searchStr = this.data.baseData.searchString(entity);
|
|
3676
|
+
const formattedSearchString = searchStr.toLowerCase();
|
|
3677
|
+
const formattedFilterString = filter.toLowerCase();
|
|
3678
|
+
return formattedSearchString.includes(formattedFilterString);
|
|
3679
|
+
};
|
|
1990
3680
|
this.dataSource.filter = this.filter;
|
|
1991
3681
|
this.dataSource.paginator = this.paginator;
|
|
1992
3682
|
this.entityService.entitiesSubject.pipe(takeUntil(this.onDestroy)).subscribe((entities) => {
|
|
1993
3683
|
this.dataSource.data = entities;
|
|
1994
3684
|
this.selection.clear();
|
|
1995
3685
|
});
|
|
1996
|
-
this.entityService.read();
|
|
3686
|
+
void this.entityService.read();
|
|
1997
3687
|
}
|
|
1998
3688
|
/**
|
|
1999
3689
|
* Edits an entity. This either calls the edit-Method provided by the user or uses a default edit-dialog.
|
|
@@ -2010,24 +3700,25 @@ class NgxMatEntityTableComponent {
|
|
|
2010
3700
|
this.data.baseData.edit(new this.data.baseData.EntityClass(entity));
|
|
2011
3701
|
}
|
|
2012
3702
|
else {
|
|
2013
|
-
this.editDefault(new this.data.baseData.EntityClass(entity));
|
|
3703
|
+
void this.editDefault(new this.data.baseData.EntityClass(entity));
|
|
2014
3704
|
}
|
|
2015
3705
|
}
|
|
2016
3706
|
}
|
|
2017
3707
|
editDefault(entity) {
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
3708
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3709
|
+
const inputDialogData = {
|
|
3710
|
+
entity: entity,
|
|
3711
|
+
EntityServiceClass: this.data.baseData.EntityServiceClass,
|
|
3712
|
+
allowDelete: this.data.baseData.allowDelete,
|
|
3713
|
+
editDialogData: this.data.editDialogData
|
|
3714
|
+
};
|
|
3715
|
+
const dialogData = new EditEntityDialogDataBuilder(inputDialogData).getResult();
|
|
3716
|
+
const res = yield firstValueFrom(this.dialog.open(NgxMatEntityEditDialogComponent, {
|
|
3717
|
+
data: dialogData,
|
|
3718
|
+
minWidth: '60%',
|
|
3719
|
+
autoFocus: false,
|
|
3720
|
+
restoreFocus: false
|
|
3721
|
+
}).afterClosed());
|
|
2031
3722
|
if (res === 0) {
|
|
2032
3723
|
const data = this.dataSource.data;
|
|
2033
3724
|
data[this.dataSource.data.findIndex((e) => e[this.entityService.idKey] === entity[this.entityService.idKey])] = entity;
|
|
@@ -2075,7 +3766,8 @@ class NgxMatEntityTableComponent {
|
|
|
2075
3766
|
*/
|
|
2076
3767
|
runMultiAction(action) {
|
|
2077
3768
|
if (!action.requireConfirmDialog || !action.requireConfirmDialog(this.selection.selected)) {
|
|
2078
|
-
|
|
3769
|
+
this.confirmRunMultiAction(action);
|
|
3770
|
+
return;
|
|
2079
3771
|
}
|
|
2080
3772
|
const dialogData = new ConfirmDialogDataBuilder(action.confirmDialogData)
|
|
2081
3773
|
.withDefault('text', [`Do you really want to run this action on ${this.selection.selected.length} entries?`])
|
|
@@ -2119,7 +3811,7 @@ class NgxMatEntityTableComponent {
|
|
|
2119
3811
|
this.selection.clear();
|
|
2120
3812
|
}
|
|
2121
3813
|
else {
|
|
2122
|
-
this.dataSource.data.forEach(
|
|
3814
|
+
this.dataSource.data.forEach(row => this.selection.select(row));
|
|
2123
3815
|
}
|
|
2124
3816
|
}
|
|
2125
3817
|
/**
|
|
@@ -2148,7 +3840,7 @@ class NgxMatEntityTableComponent {
|
|
|
2148
3840
|
}
|
|
2149
3841
|
}
|
|
2150
3842
|
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 });
|
|
2151
|
-
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:
|
|
3843
|
+
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: i1$1.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i4.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$3.MatMenu, selector: "mat-menu", exportAs: ["matMenu"] }, { type: i4$3.MatMenuItem, selector: "[mat-menu-item]", inputs: ["disabled", "disableRipple", "role"], exportAs: ["matMenuItem"] }, { type: i5.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: i5.MatHeaderRow, selector: "mat-header-row, tr[mat-header-row]", exportAs: ["matHeaderRow"] }, { type: i5.MatRow, selector: "mat-row, tr[mat-row]", exportAs: ["matRow"] }, { type: i7.MatPaginator, selector: "mat-paginator", inputs: ["disabled"], exportAs: ["matPaginator"] }], directives: [{ type: i1$1.MatLabel, selector: "mat-label" }, { type: i4$2.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: i4$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4$3.MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", exportAs: ["matMenuTrigger"] }, { type: i4$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5.MatColumnDef, selector: "[matColumnDef]", inputs: ["sticky", "matColumnDef"] }, { type: i5.MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { type: i5.MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { type: i5.MatCellDef, selector: "[matCellDef]" }, { type: i5.MatCell, selector: "mat-cell, td[mat-cell]" }, { type: i5.MatHeaderRowDef, selector: "[matHeaderRowDef]", inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"] }, { type: i5.MatRowDef, selector: "[matRowDef]", inputs: ["matRowDefColumns", "matRowDefWhen"] }] });
|
|
2152
3844
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NgxMatEntityTableComponent, decorators: [{
|
|
2153
3845
|
type: Component,
|
|
2154
3846
|
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"] }]
|
|
@@ -2284,17 +3976,88 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
|
|
|
2284
3976
|
*/
|
|
2285
3977
|
class EntityArrayDecoratorConfigInternal extends PropertyDecoratorConfigInternal {
|
|
2286
3978
|
constructor(data) {
|
|
3979
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
2287
3980
|
super(data);
|
|
2288
|
-
this.createInline = data.createInline
|
|
2289
|
-
this.displayStyle = data.displayStyle;
|
|
3981
|
+
this.createInline = (_a = data.createInline) !== null && _a !== void 0 ? _a : true;
|
|
2290
3982
|
this.itemType = data.itemType;
|
|
3983
|
+
this.allowDuplicates = (_b = data.allowDuplicates) !== null && _b !== void 0 ? _b : false;
|
|
3984
|
+
this.duplicatesErrorDialog = getDefaultDuplicateErrorDialogData(data);
|
|
2291
3985
|
this.EntityClass = data.EntityClass;
|
|
2292
3986
|
this.displayColumns = data.displayColumns;
|
|
2293
|
-
this.createInline = data.createInline
|
|
2294
|
-
this.missingErrorMessage = data.missingErrorMessage ?
|
|
2295
|
-
this.defaultWidths = data.defaultWidths ?
|
|
2296
|
-
this.addButtonLabel = data.addButtonLabel ?
|
|
2297
|
-
this.removeButtonLabel = data.removeButtonLabel ?
|
|
3987
|
+
this.createInline = (_c = data.createInline) !== null && _c !== void 0 ? _c : true;
|
|
3988
|
+
this.missingErrorMessage = (_d = data.missingErrorMessage) !== null && _d !== void 0 ? _d : 'Needs to contain at least one value';
|
|
3989
|
+
this.defaultWidths = (_e = data.defaultWidths) !== null && _e !== void 0 ? _e : [12, 12, 12];
|
|
3990
|
+
this.addButtonLabel = (_f = data.addButtonLabel) !== null && _f !== void 0 ? _f : 'Add';
|
|
3991
|
+
this.removeButtonLabel = (_g = data.removeButtonLabel) !== null && _g !== void 0 ? _g : 'Remove';
|
|
3992
|
+
}
|
|
3993
|
+
}
|
|
3994
|
+
/**
|
|
3995
|
+
* The internal DateArrayDecoratorConfig. Sets default values.
|
|
3996
|
+
*/
|
|
3997
|
+
class DateArrayDecoratorConfigInternal extends PropertyDecoratorConfigInternal {
|
|
3998
|
+
constructor(data) {
|
|
3999
|
+
var _a, _b, _c, _d, _e;
|
|
4000
|
+
super(data);
|
|
4001
|
+
this.itemType = data.itemType;
|
|
4002
|
+
this.allowDuplicates = (_a = data.allowDuplicates) !== null && _a !== void 0 ? _a : false;
|
|
4003
|
+
this.duplicatesErrorDialog = getDefaultDuplicateErrorDialogData(data);
|
|
4004
|
+
this.displayColumns = data.displayColumns;
|
|
4005
|
+
this.defaultWidths = (_b = data.defaultWidths) !== null && _b !== void 0 ? _b : [12, 12, 12];
|
|
4006
|
+
this.addButtonLabel = (_c = data.addButtonLabel) !== null && _c !== void 0 ? _c : 'Add';
|
|
4007
|
+
this.removeButtonLabel = (_d = data.removeButtonLabel) !== null && _d !== void 0 ? _d : 'Remove';
|
|
4008
|
+
this.missingErrorMessage = (_e = data.missingErrorMessage) !== null && _e !== void 0 ? _e : 'Needs to contain at least one value';
|
|
4009
|
+
this.min = data.min;
|
|
4010
|
+
this.max = data.max;
|
|
4011
|
+
this.filter = data.filter;
|
|
4012
|
+
}
|
|
4013
|
+
}
|
|
4014
|
+
/**
|
|
4015
|
+
* The internal DateTimeArrayDecoratorConfig. Sets default values.
|
|
4016
|
+
*/
|
|
4017
|
+
class DateTimeArrayDecoratorConfigInternal extends PropertyDecoratorConfigInternal {
|
|
4018
|
+
constructor(data) {
|
|
4019
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
4020
|
+
super(data);
|
|
4021
|
+
this.itemType = data.itemType;
|
|
4022
|
+
this.allowDuplicates = (_a = data.allowDuplicates) !== null && _a !== void 0 ? _a : false;
|
|
4023
|
+
this.duplicatesErrorDialog = getDefaultDuplicateErrorDialogData(data);
|
|
4024
|
+
this.displayColumns = data.displayColumns;
|
|
4025
|
+
this.defaultWidths = (_b = data.defaultWidths) !== null && _b !== void 0 ? _b : [12, 12, 12];
|
|
4026
|
+
this.addButtonLabel = (_c = data.addButtonLabel) !== null && _c !== void 0 ? _c : 'Add';
|
|
4027
|
+
this.removeButtonLabel = (_d = data.removeButtonLabel) !== null && _d !== void 0 ? _d : 'Remove';
|
|
4028
|
+
this.missingErrorMessage = (_e = data.missingErrorMessage) !== null && _e !== void 0 ? _e : 'Needs to contain at least one value';
|
|
4029
|
+
this.times = (_f = data.times) !== null && _f !== void 0 ? _f : DateUtilities.getDefaultTimes();
|
|
4030
|
+
this.timeDisplayName = (_g = data.timeDisplayName) !== null && _g !== void 0 ? _g : 'Time';
|
|
4031
|
+
this.minDate = data.minDate;
|
|
4032
|
+
this.maxDate = data.maxDate;
|
|
4033
|
+
this.filterDate = data.filterDate;
|
|
4034
|
+
this.minTime = data.minTime;
|
|
4035
|
+
this.maxTime = data.maxTime;
|
|
4036
|
+
this.filterTime = data.filterTime;
|
|
4037
|
+
}
|
|
4038
|
+
}
|
|
4039
|
+
/**
|
|
4040
|
+
* The internal DateRangeArrayDecoratorConfig. Sets default values.
|
|
4041
|
+
*/
|
|
4042
|
+
class DateRangeArrayDecoratorConfigInternal extends PropertyDecoratorConfigInternal {
|
|
4043
|
+
constructor(data) {
|
|
4044
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
4045
|
+
super(data);
|
|
4046
|
+
this.itemType = data.itemType;
|
|
4047
|
+
this.allowDuplicates = (_a = data.allowDuplicates) !== null && _a !== void 0 ? _a : false;
|
|
4048
|
+
this.duplicatesErrorDialog = getDefaultDuplicateErrorDialogData(data);
|
|
4049
|
+
this.displayColumns = data.displayColumns;
|
|
4050
|
+
this.defaultWidths = (_b = data.defaultWidths) !== null && _b !== void 0 ? _b : [12, 12, 12];
|
|
4051
|
+
this.addButtonLabel = (_c = data.addButtonLabel) !== null && _c !== void 0 ? _c : 'Add';
|
|
4052
|
+
this.removeButtonLabel = (_d = data.removeButtonLabel) !== null && _d !== void 0 ? _d : 'Remove';
|
|
4053
|
+
this.missingErrorMessage = (_e = data.missingErrorMessage) !== null && _e !== void 0 ? _e : 'Needs to contain at least one value';
|
|
4054
|
+
this.placeholderStart = (_f = data.placeholderStart) !== null && _f !== void 0 ? _f : 'Start';
|
|
4055
|
+
this.placeholderEnd = (_g = data.placeholderEnd) !== null && _g !== void 0 ? _g : 'End';
|
|
4056
|
+
this.minStart = data.minStart;
|
|
4057
|
+
this.maxStart = data.maxStart;
|
|
4058
|
+
this.minEnd = data.minEnd;
|
|
4059
|
+
this.maxEnd = data.maxEnd;
|
|
4060
|
+
this.filter = data.filter;
|
|
2298
4061
|
}
|
|
2299
4062
|
}
|
|
2300
4063
|
/**
|
|
@@ -2302,14 +4065,16 @@ class EntityArrayDecoratorConfigInternal extends PropertyDecoratorConfigInternal
|
|
|
2302
4065
|
*/
|
|
2303
4066
|
class StringChipsArrayDecoratorConfigInternal extends PropertyDecoratorConfigInternal {
|
|
2304
4067
|
constructor(data) {
|
|
4068
|
+
var _a, _b, _c;
|
|
2305
4069
|
super(data);
|
|
2306
|
-
this.deleteIcon = data.deleteIcon ?
|
|
2307
|
-
this.displayStyle = data.displayStyle;
|
|
4070
|
+
this.deleteIcon = (_a = data.deleteIcon) !== null && _a !== void 0 ? _a : 'fas fa-circle-minus';
|
|
2308
4071
|
this.itemType = data.itemType;
|
|
4072
|
+
this.allowDuplicates = (_b = data.allowDuplicates) !== null && _b !== void 0 ? _b : false;
|
|
4073
|
+
this.duplicatesErrorDialog = getDefaultDuplicateErrorDialogData(data);
|
|
2309
4074
|
this.maxLength = data.maxLength;
|
|
2310
4075
|
this.minLength = data.minLength;
|
|
2311
4076
|
this.regex = data.regex;
|
|
2312
|
-
this.defaultWidths = data.defaultWidths ?
|
|
4077
|
+
this.defaultWidths = (_c = data.defaultWidths) !== null && _c !== void 0 ? _c : [6, 12, 12];
|
|
2313
4078
|
}
|
|
2314
4079
|
}
|
|
2315
4080
|
/**
|
|
@@ -2317,17 +4082,38 @@ class StringChipsArrayDecoratorConfigInternal extends PropertyDecoratorConfigInt
|
|
|
2317
4082
|
*/
|
|
2318
4083
|
class AutocompleteStringChipsArrayDecoratorConfigInternal extends PropertyDecoratorConfigInternal {
|
|
2319
4084
|
constructor(data) {
|
|
4085
|
+
var _a, _b, _c;
|
|
2320
4086
|
super(data);
|
|
2321
4087
|
this.autocompleteValues = data.autocompleteValues;
|
|
2322
|
-
this.deleteIcon = data.deleteIcon ?
|
|
2323
|
-
this.displayStyle = data.displayStyle;
|
|
4088
|
+
this.deleteIcon = (_a = data.deleteIcon) !== null && _a !== void 0 ? _a : 'fas fa-circle-minus';
|
|
2324
4089
|
this.itemType = data.itemType;
|
|
4090
|
+
this.allowDuplicates = (_b = data.allowDuplicates) !== null && _b !== void 0 ? _b : false;
|
|
4091
|
+
this.duplicatesErrorDialog = getDefaultDuplicateErrorDialogData(data);
|
|
2325
4092
|
this.maxLength = data.maxLength;
|
|
2326
4093
|
this.minLength = data.minLength;
|
|
2327
4094
|
this.regex = data.regex;
|
|
2328
|
-
this.defaultWidths = data.defaultWidths ?
|
|
4095
|
+
this.defaultWidths = (_c = data.defaultWidths) !== null && _c !== void 0 ? _c : [6, 12, 12];
|
|
2329
4096
|
}
|
|
2330
4097
|
}
|
|
4098
|
+
/**
|
|
4099
|
+
* Gets the default dialog data for the error dialog to display when the user tries to add a duplicate value.
|
|
4100
|
+
*
|
|
4101
|
+
* @param data - The Array Decorator data.
|
|
4102
|
+
* @returns The dialog data with set default values.
|
|
4103
|
+
*/
|
|
4104
|
+
function getDefaultDuplicateErrorDialogData(data) {
|
|
4105
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
4106
|
+
return {
|
|
4107
|
+
type: (_b = (_a = data.duplicatesErrorDialog) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : 'info-only',
|
|
4108
|
+
// eslint-disable-next-line max-len
|
|
4109
|
+
text: (_d = (_c = data.duplicatesErrorDialog) === null || _c === void 0 ? void 0 : _c.text) !== null && _d !== void 0 ? _d : ['Adding duplicate entries to the array is not allowed.'],
|
|
4110
|
+
title: (_f = (_e = data.duplicatesErrorDialog) === null || _e === void 0 ? void 0 : _e.title) !== null && _f !== void 0 ? _f : 'Error adding duplicate item',
|
|
4111
|
+
confirmButtonLabel: (_g = data.duplicatesErrorDialog) === null || _g === void 0 ? void 0 : _g.confirmButtonLabel,
|
|
4112
|
+
cancelButtonLabel: (_h = data.duplicatesErrorDialog) === null || _h === void 0 ? void 0 : _h.cancelButtonLabel,
|
|
4113
|
+
requireConfirmation: (_j = data.duplicatesErrorDialog) === null || _j === void 0 ? void 0 : _j.requireConfirmation,
|
|
4114
|
+
confirmationText: (_k = data.duplicatesErrorDialog) === null || _k === void 0 ? void 0 : _k.confirmationText
|
|
4115
|
+
};
|
|
4116
|
+
}
|
|
2331
4117
|
|
|
2332
4118
|
/**
|
|
2333
4119
|
* Decorator for setting and getting array property metadata.
|
|
@@ -2340,6 +4126,12 @@ function array(metadata) {
|
|
|
2340
4126
|
switch (metadata.itemType) {
|
|
2341
4127
|
case DecoratorTypes.OBJECT:
|
|
2342
4128
|
return baseProperty(new EntityArrayDecoratorConfigInternal(metadata), DecoratorTypes.ARRAY);
|
|
4129
|
+
case DecoratorTypes.DATE:
|
|
4130
|
+
return baseProperty(new DateArrayDecoratorConfigInternal(metadata), DecoratorTypes.ARRAY_DATE);
|
|
4131
|
+
case DecoratorTypes.DATE_TIME:
|
|
4132
|
+
return baseProperty(new DateTimeArrayDecoratorConfigInternal(metadata), DecoratorTypes.ARRAY_DATE_TIME);
|
|
4133
|
+
case DecoratorTypes.DATE_RANGE:
|
|
4134
|
+
return baseProperty(new DateRangeArrayDecoratorConfigInternal(metadata), DecoratorTypes.ARRAY_DATE_RANGE);
|
|
2343
4135
|
case DecoratorTypes.STRING:
|
|
2344
4136
|
return baseProperty(new StringChipsArrayDecoratorConfigInternal(metadata), DecoratorTypes.ARRAY_STRING_CHIPS);
|
|
2345
4137
|
case DecoratorTypes.STRING_AUTOCOMPLETE:
|
|
@@ -2378,9 +4170,10 @@ class DropdownBooleanDecoratorConfigInternal extends PropertyDecoratorConfigInte
|
|
|
2378
4170
|
*/
|
|
2379
4171
|
class CheckboxBooleanDecoratorConfigInternal extends PropertyDecoratorConfigInternal {
|
|
2380
4172
|
constructor(data) {
|
|
4173
|
+
var _a;
|
|
2381
4174
|
super(data);
|
|
2382
4175
|
this.displayStyle = data.displayStyle;
|
|
2383
|
-
this.required = data.required
|
|
4176
|
+
this.required = (_a = data.required) !== null && _a !== void 0 ? _a : false;
|
|
2384
4177
|
}
|
|
2385
4178
|
}
|
|
2386
4179
|
/**
|
|
@@ -2388,9 +4181,10 @@ class CheckboxBooleanDecoratorConfigInternal extends PropertyDecoratorConfigInte
|
|
|
2388
4181
|
*/
|
|
2389
4182
|
class ToggleBooleanDecoratorConfigInternal extends PropertyDecoratorConfigInternal {
|
|
2390
4183
|
constructor(data) {
|
|
4184
|
+
var _a;
|
|
2391
4185
|
super(data);
|
|
2392
4186
|
this.displayStyle = data.displayStyle;
|
|
2393
|
-
this.required = data.required
|
|
4187
|
+
this.required = (_a = data.required) !== null && _a !== void 0 ? _a : false;
|
|
2394
4188
|
}
|
|
2395
4189
|
}
|
|
2396
4190
|
|
|
@@ -2418,6 +4212,78 @@ function boolean(metadata) {
|
|
|
2418
4212
|
class BooleanDecoratorConfig extends PropertyDecoratorConfig {
|
|
2419
4213
|
}
|
|
2420
4214
|
|
|
4215
|
+
/**
|
|
4216
|
+
* The internal DefaultDateDecoratorConfig. Sets default values.
|
|
4217
|
+
*/
|
|
4218
|
+
class DefaultDateDecoratorConfigInternal extends PropertyDecoratorConfigInternal {
|
|
4219
|
+
constructor(data) {
|
|
4220
|
+
super(data);
|
|
4221
|
+
this.displayStyle = data.displayStyle;
|
|
4222
|
+
this.max = data.max;
|
|
4223
|
+
this.min = data.min;
|
|
4224
|
+
this.filter = data.filter;
|
|
4225
|
+
}
|
|
4226
|
+
}
|
|
4227
|
+
/**
|
|
4228
|
+
* The internal DateRangeDateDecoratorConfig. Sets default values.
|
|
4229
|
+
*/
|
|
4230
|
+
class DateRangeDateDecoratorConfigInternal extends PropertyDecoratorConfigInternal {
|
|
4231
|
+
constructor(data) {
|
|
4232
|
+
var _a, _b;
|
|
4233
|
+
super(data);
|
|
4234
|
+
this.displayStyle = data.displayStyle;
|
|
4235
|
+
this.minStart = data.minStart;
|
|
4236
|
+
this.maxStart = data.maxStart;
|
|
4237
|
+
this.minEnd = data.minEnd;
|
|
4238
|
+
this.maxEnd = data.maxEnd;
|
|
4239
|
+
this.filter = data.filter;
|
|
4240
|
+
this.placeholderStart = (_a = data.placeholderStart) !== null && _a !== void 0 ? _a : 'Start';
|
|
4241
|
+
this.placeholderEnd = (_b = data.placeholderEnd) !== null && _b !== void 0 ? _b : 'End';
|
|
4242
|
+
}
|
|
4243
|
+
}
|
|
4244
|
+
/**
|
|
4245
|
+
* The internal DateTimeDateDecoratorConfig. Sets default values.
|
|
4246
|
+
*/
|
|
4247
|
+
class DateTimeDateDecoratorConfigInternal extends PropertyDecoratorConfigInternal {
|
|
4248
|
+
constructor(data) {
|
|
4249
|
+
var _a, _b;
|
|
4250
|
+
super(data);
|
|
4251
|
+
this.displayStyle = data.displayStyle;
|
|
4252
|
+
this.times = (_a = data.times) !== null && _a !== void 0 ? _a : DateUtilities.getDefaultTimes();
|
|
4253
|
+
this.timeDisplayName = (_b = data.timeDisplayName) !== null && _b !== void 0 ? _b : 'Time';
|
|
4254
|
+
this.minDate = data.minDate;
|
|
4255
|
+
this.maxDate = data.maxDate;
|
|
4256
|
+
this.filterDate = data.filterDate;
|
|
4257
|
+
this.minTime = data.minTime;
|
|
4258
|
+
this.maxTime = data.maxTime;
|
|
4259
|
+
this.filterTime = data.filterTime;
|
|
4260
|
+
}
|
|
4261
|
+
}
|
|
4262
|
+
|
|
4263
|
+
/**
|
|
4264
|
+
* Decorator for setting and getting date property metadata.
|
|
4265
|
+
*
|
|
4266
|
+
* @param metadata - The metadata of the date property.
|
|
4267
|
+
* @returns The method that defines the metadata.
|
|
4268
|
+
*/
|
|
4269
|
+
function date(metadata) {
|
|
4270
|
+
if (metadata.displayStyle === 'date') {
|
|
4271
|
+
return baseProperty(new DefaultDateDecoratorConfigInternal(metadata), DecoratorTypes.DATE);
|
|
4272
|
+
}
|
|
4273
|
+
else if (metadata.displayStyle === 'datetime') {
|
|
4274
|
+
return baseProperty(new DateTimeDateDecoratorConfigInternal(metadata), DecoratorTypes.DATE_TIME);
|
|
4275
|
+
}
|
|
4276
|
+
else {
|
|
4277
|
+
return baseProperty(new DateRangeDateDecoratorConfigInternal(metadata), DecoratorTypes.DATE_RANGE);
|
|
4278
|
+
}
|
|
4279
|
+
}
|
|
4280
|
+
|
|
4281
|
+
/**
|
|
4282
|
+
* Definition for the @date metadata.
|
|
4283
|
+
*/
|
|
4284
|
+
class DateDecoratorConfig extends PropertyDecoratorConfig {
|
|
4285
|
+
}
|
|
4286
|
+
|
|
2421
4287
|
/**
|
|
2422
4288
|
* The internal DefaultNumberDecoratorConfig. Sets default values.
|
|
2423
4289
|
*/
|
|
@@ -2494,6 +4360,133 @@ class ObjectDecoratorConfig extends PropertyDecoratorConfig {
|
|
|
2494
4360
|
class StringDecoratorConfig extends PropertyDecoratorConfig {
|
|
2495
4361
|
}
|
|
2496
4362
|
|
|
4363
|
+
/**
|
|
4364
|
+
* The internal DefaultFileDecoratorConfig. Sets default values.
|
|
4365
|
+
*/
|
|
4366
|
+
class DefaultFileDecoratorConfigInternal extends PropertyDecoratorConfigInternal {
|
|
4367
|
+
constructor(data) {
|
|
4368
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4369
|
+
super(data);
|
|
4370
|
+
this.type = data.type;
|
|
4371
|
+
this.preview = false;
|
|
4372
|
+
this.multiple = data.multiple;
|
|
4373
|
+
this.deleteIcon = (_a = data.deleteIcon) !== null && _a !== void 0 ? _a : 'fas fa-circle-minus';
|
|
4374
|
+
this.allowedMimeTypes = (_b = data.allowedMimeTypes) !== null && _b !== void 0 ? _b : ['*'];
|
|
4375
|
+
this.maxSize = (_c = data.maxSize) !== null && _c !== void 0 ? _c : 10;
|
|
4376
|
+
this.maxSizeTotal = (_d = data.maxSizeTotal) !== null && _d !== void 0 ? _d : 100;
|
|
4377
|
+
this.mimeTypeErrorDialog = (_e = data.mimeTypeErrorDialog) !== null && _e !== void 0 ? _e : getDefaultMimeTypeErrorDialogData(data);
|
|
4378
|
+
this.maxSizeErrorDialog = (_f = data.maxSizeErrorDialog) !== null && _f !== void 0 ? _f : getDefaultMaxSizeErrorDialogData(data);
|
|
4379
|
+
this.maxSizeTotalErrorDialog = (_g = data.maxSizeTotalErrorDialog) !== null && _g !== void 0 ? _g : getDefaultMaxSizeTotalErrorDialogData(data);
|
|
4380
|
+
this.dragAndDrop = (_h = data.dragAndDrop) !== null && _h !== void 0 ? _h : data.multiple;
|
|
4381
|
+
}
|
|
4382
|
+
}
|
|
4383
|
+
/**
|
|
4384
|
+
* The internal ImageFileDecoratorConfig. Sets default values.
|
|
4385
|
+
*/
|
|
4386
|
+
class ImageFileDecoratorConfigInternal extends PropertyDecoratorConfigInternal {
|
|
4387
|
+
constructor(data) {
|
|
4388
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
4389
|
+
super(data);
|
|
4390
|
+
this.type = data.type;
|
|
4391
|
+
this.allowedMimeTypes = (_a = data.allowedMimeTypes) !== null && _a !== void 0 ? _a : ['image/*'];
|
|
4392
|
+
this.multiple = data.multiple;
|
|
4393
|
+
this.preview = (_b = data.preview) !== null && _b !== void 0 ? _b : true;
|
|
4394
|
+
this.deleteIcon = (_c = data.deleteIcon) !== null && _c !== void 0 ? _c : 'fas fa-circle-minus';
|
|
4395
|
+
this.maxSize = (_d = data.maxSize) !== null && _d !== void 0 ? _d : 10;
|
|
4396
|
+
this.maxSizeTotal = (_e = data.maxSizeTotal) !== null && _e !== void 0 ? _e : 100;
|
|
4397
|
+
this.mimeTypeErrorDialog = (_f = data.mimeTypeErrorDialog) !== null && _f !== void 0 ? _f : getDefaultMimeTypeErrorDialogData(data);
|
|
4398
|
+
this.maxSizeErrorDialog = (_g = data.maxSizeErrorDialog) !== null && _g !== void 0 ? _g : getDefaultMaxSizeErrorDialogData(data);
|
|
4399
|
+
this.maxSizeTotalErrorDialog = (_h = data.maxSizeTotalErrorDialog) !== null && _h !== void 0 ? _h : getDefaultMaxSizeTotalErrorDialogData(data);
|
|
4400
|
+
this.previewPlaceholderUrl = data.previewPlaceholderUrl;
|
|
4401
|
+
this.dragAndDrop = (_j = data.dragAndDrop) !== null && _j !== void 0 ? _j : data.multiple;
|
|
4402
|
+
}
|
|
4403
|
+
}
|
|
4404
|
+
/**
|
|
4405
|
+
* Gets the default dialog data for the error dialog to display
|
|
4406
|
+
* when the user tries to add a file with a wrong type.
|
|
4407
|
+
*
|
|
4408
|
+
* @param data - The File Decorator data.
|
|
4409
|
+
* @returns The dialog data with set default values.
|
|
4410
|
+
*/
|
|
4411
|
+
function getDefaultMimeTypeErrorDialogData(data) {
|
|
4412
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
4413
|
+
return {
|
|
4414
|
+
type: (_b = (_a = data.mimeTypeErrorDialog) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : 'info-only',
|
|
4415
|
+
// eslint-disable-next-line max-len
|
|
4416
|
+
text: (_d = (_c = data.mimeTypeErrorDialog) === null || _c === void 0 ? void 0 : _c.text) !== null && _d !== void 0 ? _d : (data.multiple ? ['One of the uploaded files has the wrong type.'] : ['The uploaded file has the wrong type.']),
|
|
4417
|
+
title: (_f = (_e = data.mimeTypeErrorDialog) === null || _e === void 0 ? void 0 : _e.title) !== null && _f !== void 0 ? _f : (data.multiple ? 'Error adding files' : 'Error adding file'),
|
|
4418
|
+
confirmButtonLabel: (_g = data.mimeTypeErrorDialog) === null || _g === void 0 ? void 0 : _g.confirmButtonLabel,
|
|
4419
|
+
cancelButtonLabel: (_h = data.mimeTypeErrorDialog) === null || _h === void 0 ? void 0 : _h.cancelButtonLabel,
|
|
4420
|
+
requireConfirmation: (_j = data.mimeTypeErrorDialog) === null || _j === void 0 ? void 0 : _j.requireConfirmation,
|
|
4421
|
+
confirmationText: (_k = data.mimeTypeErrorDialog) === null || _k === void 0 ? void 0 : _k.confirmationText
|
|
4422
|
+
};
|
|
4423
|
+
}
|
|
4424
|
+
/**
|
|
4425
|
+
* Gets the default dialog data for the error dialog to display
|
|
4426
|
+
* when the user tries to add a single file that is bigger than the allowed maxSize.
|
|
4427
|
+
*
|
|
4428
|
+
* @param data - The File Decorator data.
|
|
4429
|
+
* @returns The dialog data with set default values.
|
|
4430
|
+
*/
|
|
4431
|
+
function getDefaultMaxSizeErrorDialogData(data) {
|
|
4432
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
4433
|
+
return {
|
|
4434
|
+
type: (_b = (_a = data.mimeTypeErrorDialog) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : 'info-only',
|
|
4435
|
+
// eslint-disable-next-line max-len
|
|
4436
|
+
text: (_d = (_c = data.mimeTypeErrorDialog) === null || _c === void 0 ? void 0 : _c.text) !== null && _d !== void 0 ? _d : (data.multiple ? ['One of the uploaded files is too big'] : ['The uploaded files is too big']),
|
|
4437
|
+
title: (_f = (_e = data.mimeTypeErrorDialog) === null || _e === void 0 ? void 0 : _e.title) !== null && _f !== void 0 ? _f : (data.multiple ? 'Error adding files' : 'Error adding file'),
|
|
4438
|
+
confirmButtonLabel: (_g = data.mimeTypeErrorDialog) === null || _g === void 0 ? void 0 : _g.confirmButtonLabel,
|
|
4439
|
+
cancelButtonLabel: (_h = data.mimeTypeErrorDialog) === null || _h === void 0 ? void 0 : _h.cancelButtonLabel,
|
|
4440
|
+
requireConfirmation: (_j = data.mimeTypeErrorDialog) === null || _j === void 0 ? void 0 : _j.requireConfirmation,
|
|
4441
|
+
confirmationText: (_k = data.mimeTypeErrorDialog) === null || _k === void 0 ? void 0 : _k.confirmationText
|
|
4442
|
+
};
|
|
4443
|
+
}
|
|
4444
|
+
/**
|
|
4445
|
+
* Gets the default dialog data for the error dialog to display
|
|
4446
|
+
* when the user tries to add a single file that is bigger than the allowed maxSize.
|
|
4447
|
+
*
|
|
4448
|
+
* @param data - The File Decorator data.
|
|
4449
|
+
* @returns The dialog data with set default values.
|
|
4450
|
+
*/
|
|
4451
|
+
function getDefaultMaxSizeTotalErrorDialogData(data) {
|
|
4452
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
4453
|
+
return {
|
|
4454
|
+
type: (_b = (_a = data.mimeTypeErrorDialog) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : 'info-only',
|
|
4455
|
+
// eslint-disable-next-line max-len
|
|
4456
|
+
text: (_d = (_c = data.mimeTypeErrorDialog) === null || _c === void 0 ? void 0 : _c.text) !== null && _d !== void 0 ? _d : ['The size of all files combined is too big'],
|
|
4457
|
+
title: (_f = (_e = data.mimeTypeErrorDialog) === null || _e === void 0 ? void 0 : _e.title) !== null && _f !== void 0 ? _f : (data.multiple ? 'Error adding files' : 'Error adding file'),
|
|
4458
|
+
confirmButtonLabel: (_g = data.mimeTypeErrorDialog) === null || _g === void 0 ? void 0 : _g.confirmButtonLabel,
|
|
4459
|
+
cancelButtonLabel: (_h = data.mimeTypeErrorDialog) === null || _h === void 0 ? void 0 : _h.cancelButtonLabel,
|
|
4460
|
+
requireConfirmation: (_j = data.mimeTypeErrorDialog) === null || _j === void 0 ? void 0 : _j.requireConfirmation,
|
|
4461
|
+
confirmationText: (_k = data.mimeTypeErrorDialog) === null || _k === void 0 ? void 0 : _k.confirmationText
|
|
4462
|
+
};
|
|
4463
|
+
}
|
|
4464
|
+
|
|
4465
|
+
/**
|
|
4466
|
+
* Decorator for setting and getting file property metadata.
|
|
4467
|
+
*
|
|
4468
|
+
* @param metadata - The metadata of the file property.
|
|
4469
|
+
* @returns The method that defines the metadata.
|
|
4470
|
+
* @throws When an unknown metadata type was provided.
|
|
4471
|
+
*/
|
|
4472
|
+
function file(metadata) {
|
|
4473
|
+
switch (metadata.type) {
|
|
4474
|
+
case 'other':
|
|
4475
|
+
return baseProperty(new DefaultFileDecoratorConfigInternal(metadata), DecoratorTypes.FILE_DEFAULT);
|
|
4476
|
+
case 'image':
|
|
4477
|
+
return baseProperty(new ImageFileDecoratorConfigInternal(metadata), DecoratorTypes.FILE_IMAGE);
|
|
4478
|
+
default:
|
|
4479
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
|
|
4480
|
+
throw new Error(`Unknown metadata type ${metadata.type}`);
|
|
4481
|
+
}
|
|
4482
|
+
}
|
|
4483
|
+
|
|
4484
|
+
/**
|
|
4485
|
+
* Definition for the @file metadata.
|
|
4486
|
+
*/
|
|
4487
|
+
class FileDecoratorConfig extends PropertyDecoratorConfig {
|
|
4488
|
+
}
|
|
4489
|
+
|
|
2497
4490
|
/**
|
|
2498
4491
|
* Public API Surface of ngx-material-entity.
|
|
2499
4492
|
*/
|
|
@@ -2502,5 +4495,5 @@ class StringDecoratorConfig extends PropertyDecoratorConfig {
|
|
|
2502
4495
|
* Generated bundle index. Do not edit.
|
|
2503
4496
|
*/
|
|
2504
4497
|
|
|
2505
|
-
export { DateUtilities, DecoratorTypes, Entity, EntityService, EntityUtilities, NgxMatEntityConfirmDialogComponent, NgxMatEntityConfirmDialogModule, NgxMatEntityCreateDialogComponent, NgxMatEntityCreateDialogModule, NgxMatEntityEditDialogComponent, NgxMatEntityEditDialogModule, NgxMatEntityInputComponent, NgxMatEntityInputModule, NgxMatEntityTableComponent, NgxMatEntityTableModule, array, boolean, getValidationErrorMessage, number, object, string };
|
|
4498
|
+
export { ArrayDecoratorConfig, DateUtilities, DecoratorTypes, Entity, EntityService, EntityUtilities, FileUtilities, NgxMatEntityConfirmDialogComponent, NgxMatEntityConfirmDialogModule, NgxMatEntityCreateDialogComponent, NgxMatEntityCreateDialogModule, NgxMatEntityEditDialogComponent, NgxMatEntityEditDialogModule, NgxMatEntityInputComponent, NgxMatEntityInputModule, NgxMatEntityTableComponent, NgxMatEntityTableModule, array, boolean, date, file, getValidationErrorMessage, number, object, string };
|
|
2506
4499
|
//# sourceMappingURL=ngx-material-entity.mjs.map
|